diff --git a/source/fluid/code_input.d b/source/fluid/code_input.d index 09653c6..72ecd77 100644 --- a/source/fluid/code_input.d +++ b/source/fluid/code_input.d @@ -2065,9 +2065,9 @@ unittest { else return 1; - }; + } - }; + } // Every new line indents. If "end" is found in the text, every new line *outdents*, effectively making the text // flat. diff --git a/source/fluid/input.d b/source/fluid/input.d index 7eab4c1..3afc31f 100644 --- a/source/fluid/input.d +++ b/source/fluid/input.d @@ -764,18 +764,24 @@ interface FluidHoverable { /// Returns: /// * `true` if the handler took care of the action; processing of the action will finish. /// * `false` if the action should be handled by the default input action handler. - bool inputActionImpl(InputActionID id, bool active); + bool inputActionImpl(immutable InputActionID id, bool active); /// Run input actions. /// /// Use `mixin enableInputActions` to implement. /// /// Manual implementation is discouraged; override `inputActionImpl` instead. - bool runInputAction(InputActionID action, bool active = true); + bool runInputActionImpl(immutable InputActionID action, bool active = true); + + final bool runInputAction(immutable InputActionID action, bool active = true) { + + return runInputActionImpl(action, active); + + } final bool runInputAction(alias action)(bool active = true) { - return runInputAction(InputActionID.from!action, active); + return runInputActionImpl(InputActionID.from!action, active); } @@ -814,22 +820,15 @@ interface FluidHoverable { static assert(is(typeof(this) : Node), format!"%s : FluidHoverable must inherit from Node"(typeid(this))); - // For some reason, a simple alias to FluidHoverable.runInputAction doesn't work - final bool runInputAction(alias action)(bool active = true) { - - return runInputAction(InputActionID.from!action, active); - - } - // Provide a default implementation of inputActionImpl static if (!is(typeof(super) : FluidHoverable)) - bool inputActionImpl(InputActionID id, bool active) { + bool inputActionImpl(immutable InputActionID id, bool active) { return false; } - override bool runInputAction(InputActionID action, bool active = true) { + override bool runInputActionImpl(immutable InputActionID action, bool active) { import std.meta : Filter; diff --git a/source/fluid/map_frame.d b/source/fluid/map_frame.d index 7c2f6b8..def2304 100644 --- a/source/fluid/map_frame.d +++ b/source/fluid/map_frame.d @@ -496,7 +496,7 @@ class MapFrame : Frame { const position = MapPosition(rectangle.start); // Already a child - if (children.canFind(node)) { + if (children.canFind!"a is b"(node)) { positions[node] = position; diff --git a/source/fluid/node.d b/source/fluid/node.d index f47b4ee..b3e1f0c 100644 --- a/source/fluid/node.d +++ b/source/fluid/node.d @@ -230,6 +230,12 @@ abstract class Node { /// Direct changes are discouraged, and are likely to be discarded when reloading themes. Use themes instead. ref inout(Style) style() inout { return _style; } + override bool opEquals(Object other) const { + + return this is other; + + } + bool opEquals(const Node otherNode) const { return this is otherNode; @@ -538,7 +544,7 @@ abstract class Node { root.draw(); - assert(visitedNodes == allNodes[1..3]); + assert(visitedNodes[] == allNodes[1..3]); } diff --git a/source/fluid/structs.d b/source/fluid/structs.d index 18758a2..deb205b 100644 --- a/source/fluid/structs.d +++ b/source/fluid/structs.d @@ -183,7 +183,7 @@ struct Layout { /// Tags are optional "marks" left on nodes that are used to apply matching styles. Tags closely resemble /// [HTML classes](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class). /// -/// Tags have to be explicitly defined before usage, by creating an enum and marking it with the `@NodeTag` attribute. +/// Tags have to be explicitly defined before usage by creating an enum and marking it with the `@NodeTag` attribute. /// Such tags can then be applied by passing them to the constructor. enum NodeTag; @@ -197,6 +197,8 @@ unittest { myTag, } + static assert(isNodeTag!(Tags.myTag)); + auto myLabel = label( .tags!(Tags.myTag), "Hello, World!" @@ -207,16 +209,34 @@ unittest { } /// Check if the given item is a node tag. -enum isNodeTag(alias tag) +template isNodeTag(alias tag) { + // @NodeTag enum Tag; // enum Tag { @NodeTag tag } - = (isSomeEnum!tag - && hasUDA!(tag, NodeTag)) + enum isDirectTag + = isSomeEnum!tag + && hasUDA!(tag, NodeTag); + + // Get the parent symbol + alias parent = __traits(parent, tag); // @NodeTag enum Enum { tag } - || (!isType!tag - && is(__traits(parent, tag) == enum) - && hasUDA!(typeof(tag), NodeTag)); + enum isTagMember + = !isType!tag + && is(parent == enum) + && hasUDA!(typeof(tag), NodeTag); + + pragma(msg, tag, " ", isDirectTag, " ", isTagMember); + pragma(msg, " isDirectTag: ", isSomeEnum!tag, + ", ", hasUDA!(tag, NodeTag)); + pragma(msg, " parent: ", parent); + pragma(msg, " isTagMember: ", !isType!tag, + ", ", is(__traits(parent, tag) == enum), + ", ", hasUDA!(typeof(tag), NodeTag)); + + enum isNodeTag = isDirectTag || isTagMember; + +} /// Test if the given symbol is an enum, or an enum member. enum isSomeEnum(alias tag) diff --git a/source/fluid/theme.d b/source/fluid/theme.d index 0133448..de41d83 100644 --- a/source/fluid/theme.d +++ b/source/fluid/theme.d @@ -10,6 +10,7 @@ import std.traits; import std.exception; import fluid.node; +import fluid.utils; import fluid.style; import fluid.backend; import fluid.structs; @@ -1535,9 +1536,9 @@ private struct FieldValueStaticArray(E, size_t n) { isSet = true; // Assign each field - foreach (i, ref field; this.value.tupleof) { + foreach (i, ref field; this.value[]) { - field = value.tupleof[i]; + field = value[i]; } @@ -1599,8 +1600,8 @@ private struct FieldValueStaticArray(E, size_t n) { if (!isSet) return; - foreach (i, field; this.value.tupleof) { - field.apply(value.tupleof[i]); + foreach (i, field; this.value[]) { + field.apply(value[i]); } } @@ -1612,7 +1613,7 @@ private struct FieldValueStaticArray(E, size_t n) { value.isSet = true; - foreach (i, field; this.value.tupleof) { + foreach (i, field; this.value[]) { field.apply(value.value[i]); }