From db8f16c17e7772390ff9018ac178368bac417e71 Mon Sep 17 00:00:00 2001 From: osch Date: Thu, 4 Jan 2024 20:07:08 +0100 Subject: [PATCH] new Methods removeChild, discard and minor improvments --- doc/gen/lwtk/Animations.md | 8 +- doc/gen/lwtk/Box.md | 6 +- doc/gen/lwtk/Button.md | 6 +- doc/gen/lwtk/Column.md | 6 +- doc/gen/lwtk/Component.md | 2 + doc/gen/lwtk/Compound.md | 1 + doc/gen/lwtk/FocusGroup.md | 9 +- doc/gen/lwtk/FocusHandler.md | 8 ++ doc/gen/lwtk/Group.md | 16 ++- doc/gen/lwtk/InnerCompound.md | 4 +- doc/gen/lwtk/Matrix.md | 6 +- doc/gen/lwtk/PushButton.md | 6 +- doc/gen/lwtk/Row.md | 6 +- doc/gen/lwtk/Space.md | 10 +- doc/gen/lwtk/Square.md | 10 +- doc/gen/lwtk/TextCursor.md | 2 + doc/gen/lwtk/TextFragment.md | 2 + doc/gen/lwtk/TextInput.md | 4 +- doc/gen/lwtk/TextLabel.md | 6 +- doc/gen/lwtk/TitleText.md | 6 +- doc/gen/lwtk/ViewSwitcher.md | 10 +- doc/gen/lwtk/WeakKeysTable.md | 9 ++ doc/gen/lwtk/Widget.md | 5 +- doc/gen/lwtk/Window.md | 6 +- doc/gen/lwtk/discard.md | 7 ++ doc/gen/lwtk/love/Application.md | 4 +- doc/gen/lwtk/undef.md | 5 - doc/gen/lwtk/util.md | 3 + doc/gen/modules.md | 5 +- lwtk-scm-0.rockspec | 3 +- src/Makefile | 11 +- src/activate.sh | 105 ++++++++++++++++ src/lwtk/Animatable.lua | 18 ++- src/lwtk/Animations.lua | 20 ++- src/lwtk/Application.lua | 4 +- src/lwtk/ChildLookup.lua | 3 +- src/lwtk/Class.lua | 16 +++ src/lwtk/Color.lua | 4 +- src/lwtk/Component.lua | 80 ++++++++---- src/lwtk/Compound.lua | 77 +++++++++++- src/lwtk/Drawable.lua | 1 - src/lwtk/FocusGroup.lua | 18 +-- src/lwtk/FocusHandler.lua | 47 ++++++- src/lwtk/Group.lua | 17 ++- src/lwtk/HotkeyListener.lua | 16 ++- src/lwtk/KeyHandler.lua | 2 +- src/lwtk/LayoutFrame.lua | 8 +- src/lwtk/Meta.lua | 21 +--- src/lwtk/MouseDispatcher.lua | 14 +++ src/lwtk/Node.lua | 28 ++++- src/lwtk/Space.lua | 4 +- src/lwtk/Square.lua | 4 +- src/lwtk/Style.lua | 4 +- src/lwtk/Styleable.lua | 2 +- src/lwtk/ViewSwitcher.lua | 4 +- src/lwtk/WeakKeysTable.lua | 26 ++++ src/lwtk/Widget.lua | 2 +- src/lwtk/Window.lua | 2 +- src/lwtk/discard.lua | 37 ++++++ src/lwtk/get.lua | 38 +++--- src/lwtk/internal/ColumnImpl.lua | 4 +- src/lwtk/layout.lua | 4 +- src/lwtk/newMixin.lua | 4 +- src/lwtk/undef.lua | 24 ---- src/lwtk/util.lua | 29 +++++ src/tests/test01.lua | 208 ++++++++++++++++++++++++++++--- 66 files changed, 877 insertions(+), 210 deletions(-) create mode 100644 doc/gen/lwtk/discard.md delete mode 100644 doc/gen/lwtk/undef.md create mode 100644 doc/gen/lwtk/util.md create mode 100644 src/activate.sh create mode 100644 src/lwtk/discard.lua delete mode 100644 src/lwtk/undef.lua create mode 100644 src/lwtk/util.lua diff --git a/doc/gen/lwtk/Animations.md b/doc/gen/lwtk/Animations.md index 596c335..b98eec7 100644 --- a/doc/gen/lwtk/Animations.md +++ b/doc/gen/lwtk/Animations.md @@ -6,8 +6,9 @@ * [Inheritance](#inheritance) * [Constructor](#constructor) * [Methods](#methods) - * [add()](#.add) + * [addAnimation()](#.addAnimation) * [hasActive()](#.hasActive) + * [removeAnimation()](#.removeAnimation) * [Inherited Methods](#inherited-methods) @@ -20,12 +21,15 @@ ## Methods - * **`Animations:add(animatable)`** + * **`Animations:addAnimation(animatable)`** * **`Animations:hasActive()`** + * **`Animations:removeAnimation(animatable)`** + + ## Inherited Methods * **[Object](../lwtk/Object.md)**: diff --git a/doc/gen/lwtk/Box.md b/doc/gen/lwtk/Box.md index 49045a5..4e46029 100644 --- a/doc/gen/lwtk/Box.md +++ b/doc/gen/lwtk/Box.md @@ -32,11 +32,11 @@ * [LayoutFrame](../lwtk/LayoutFrame.md): * [addChild()](../lwtk/LayoutFrame.md#.addChild), [onDraw()](../lwtk/LayoutFrame.md#.onDraw), [onLayout()](../lwtk/LayoutFrame.md#.onLayout) * **[Group](../lwtk/Group.md)**: - * [childById()](../lwtk/Group.md#.childById), [_clearChildLookup()](../lwtk/Group.md#._clearChildLookup) + * [childById()](../lwtk/Group.md#.childById), [removeChild()](../lwtk/Group.md#.removeChild), [_clearChildLookup()](../lwtk/Group.md#._clearChildLookup) * [MouseDispatcher](../lwtk/MouseDispatcher.md): * [_processMouseDown()](../lwtk/MouseDispatcher.md#._processMouseDown), [_processMouseEnter()](../lwtk/MouseDispatcher.md#._processMouseEnter), [_processMouseLeave()](../lwtk/MouseDispatcher.md#._processMouseLeave), [_processMouseMove()](../lwtk/MouseDispatcher.md#._processMouseMove), [_processMouseScroll()](../lwtk/MouseDispatcher.md#._processMouseScroll), [_processMouseUp()](../lwtk/MouseDispatcher.md#._processMouseUp) * [Compound](../lwtk/Compound.md): - * [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) + * [discardChild()](../lwtk/Compound.md#.discardChild), [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) * **[Widget](../lwtk/Widget.md)**: * [notifyInputChanged()](../lwtk/Widget.md#.notifyInputChanged), [setOnInputChanged()](../lwtk/Widget.md#.setOnInputChanged), [setOnRealize()](../lwtk/Widget.md#.setOnRealize), [_setApp()](../lwtk/Widget.md#._setApp), [_setParent()](../lwtk/Widget.md#._setParent) * [Animatable](../lwtk/Animatable.md): @@ -47,6 +47,8 @@ * [byId()](../lwtk/Component.md#.byId), [getCurrentTime()](../lwtk/Component.md#.getCurrentTime), [getFocusHandler()](../lwtk/Component.md#.getFocusHandler), [getFontInfo()](../lwtk/Component.md#.getFontInfo), [getFrame()](../lwtk/Component.md#.getFrame), [getLayoutContext()](../lwtk/Component.md#.getLayoutContext), [getParent()](../lwtk/Component.md#.getParent), [getRoot()](../lwtk/Component.md#.getRoot), [getSize()](../lwtk/Component.md#.getSize), [handleRemainingInitParams()](../lwtk/Component.md#.handleRemainingInitParams), [parentById()](../lwtk/Component.md#.parentById), [setFrame()](../lwtk/Component.md#.setFrame), [setInitParams()](../lwtk/Component.md#.setInitParams), [setTimer()](../lwtk/Component.md#.setTimer), [transformXY()](../lwtk/Component.md#.transformXY), [triggerLayout()](../lwtk/Component.md#.triggerLayout), [triggerRedraw()](../lwtk/Component.md#.triggerRedraw), [updateFrameTransition()](../lwtk/Component.md#.updateFrameTransition), [_setFrame()](../lwtk/Component.md#._setFrame) * [Drawable](../lwtk/Drawable.md): * [getMandatoryStyleParam()](../lwtk/Drawable.md#.getMandatoryStyleParam) + * [Node](../lwtk/Node.md): + * [discard()](../lwtk/Node.md#.discard) * [Actionable](../lwtk/Actionable.md): * [hasActionMethod()](../lwtk/Actionable.md#.hasActionMethod), [invokeActionMethod()](../lwtk/Actionable.md#.invokeActionMethod) * **[Object](../lwtk/Object.md)**: diff --git a/doc/gen/lwtk/Button.md b/doc/gen/lwtk/Button.md index 84e0229..498681c 100644 --- a/doc/gen/lwtk/Button.md +++ b/doc/gen/lwtk/Button.md @@ -20,11 +20,11 @@ ## Inherited Methods * [HotkeyListener](../lwtk/HotkeyListener.md): - * [isHotkeyEnabled()](../lwtk/HotkeyListener.md#.isHotkeyEnabled), [onDisabled()](../lwtk/HotkeyListener.md#.onDisabled), [onEffectiveVisibilityChanged()](../lwtk/HotkeyListener.md#.onEffectiveVisibilityChanged), [onHotkeyDisabled()](../lwtk/HotkeyListener.md#.onHotkeyDisabled), [onHotkeyEnabled()](../lwtk/HotkeyListener.md#.onHotkeyEnabled), [setHotkey()](../lwtk/HotkeyListener.md#.setHotkey), [_handleHasFocusHandler()](../lwtk/HotkeyListener.md#._handleHasFocusHandler) + * [isHotkeyEnabled()](../lwtk/HotkeyListener.md#.isHotkeyEnabled), [onDisabled()](../lwtk/HotkeyListener.md#.onDisabled), [onEffectiveVisibilityChanged()](../lwtk/HotkeyListener.md#.onEffectiveVisibilityChanged), [onHotkeyDisabled()](../lwtk/HotkeyListener.md#.onHotkeyDisabled), [onHotkeyEnabled()](../lwtk/HotkeyListener.md#.onHotkeyEnabled), [setHotkey()](../lwtk/HotkeyListener.md#.setHotkey), [_handleHasFocusHandler()](../lwtk/HotkeyListener.md#._handleHasFocusHandler), [_handleRemovedFocusHandler()](../lwtk/HotkeyListener.md#._handleRemovedFocusHandler) * [LayoutFrame](../lwtk/LayoutFrame.md): * [addChild()](../lwtk/LayoutFrame.md#.addChild), [onDraw()](../lwtk/LayoutFrame.md#.onDraw), [onLayout()](../lwtk/LayoutFrame.md#.onLayout) * [Compound](../lwtk/Compound.md): - * [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) + * [discardChild()](../lwtk/Compound.md#.discardChild), [removeChild()](../lwtk/Compound.md#.removeChild), [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) * **[Widget](../lwtk/Widget.md)**: * [notifyInputChanged()](../lwtk/Widget.md#.notifyInputChanged), [setOnInputChanged()](../lwtk/Widget.md#.setOnInputChanged), [setOnRealize()](../lwtk/Widget.md#.setOnRealize), [_setApp()](../lwtk/Widget.md#._setApp), [_setParent()](../lwtk/Widget.md#._setParent) * [Animatable](../lwtk/Animatable.md): @@ -35,6 +35,8 @@ * [byId()](../lwtk/Component.md#.byId), [getCurrentTime()](../lwtk/Component.md#.getCurrentTime), [getFocusHandler()](../lwtk/Component.md#.getFocusHandler), [getFontInfo()](../lwtk/Component.md#.getFontInfo), [getFrame()](../lwtk/Component.md#.getFrame), [getLayoutContext()](../lwtk/Component.md#.getLayoutContext), [getParent()](../lwtk/Component.md#.getParent), [getRoot()](../lwtk/Component.md#.getRoot), [getSize()](../lwtk/Component.md#.getSize), [handleRemainingInitParams()](../lwtk/Component.md#.handleRemainingInitParams), [parentById()](../lwtk/Component.md#.parentById), [setFrame()](../lwtk/Component.md#.setFrame), [setInitParams()](../lwtk/Component.md#.setInitParams), [setTimer()](../lwtk/Component.md#.setTimer), [transformXY()](../lwtk/Component.md#.transformXY), [triggerLayout()](../lwtk/Component.md#.triggerLayout), [triggerRedraw()](../lwtk/Component.md#.triggerRedraw), [updateFrameTransition()](../lwtk/Component.md#.updateFrameTransition), [_setFrame()](../lwtk/Component.md#._setFrame) * [Drawable](../lwtk/Drawable.md): * [getMandatoryStyleParam()](../lwtk/Drawable.md#.getMandatoryStyleParam), [_processMouseDown()](../lwtk/Drawable.md#._processMouseDown), [_processMouseEnter()](../lwtk/Drawable.md#._processMouseEnter), [_processMouseLeave()](../lwtk/Drawable.md#._processMouseLeave), [_processMouseMove()](../lwtk/Drawable.md#._processMouseMove), [_processMouseScroll()](../lwtk/Drawable.md#._processMouseScroll), [_processMouseUp()](../lwtk/Drawable.md#._processMouseUp) + * [Node](../lwtk/Node.md): + * [discard()](../lwtk/Node.md#.discard) * [Actionable](../lwtk/Actionable.md): * [hasActionMethod()](../lwtk/Actionable.md#.hasActionMethod), [invokeActionMethod()](../lwtk/Actionable.md#.invokeActionMethod) * **[Object](../lwtk/Object.md)**: diff --git a/doc/gen/lwtk/Column.md b/doc/gen/lwtk/Column.md index e45bd3a..fb71b01 100644 --- a/doc/gen/lwtk/Column.md +++ b/doc/gen/lwtk/Column.md @@ -34,11 +34,11 @@ ## Inherited Methods * **[Group](../lwtk/Group.md)**: - * [addChild()](../lwtk/Group.md#.addChild), [childById()](../lwtk/Group.md#.childById), [_clearChildLookup()](../lwtk/Group.md#._clearChildLookup) + * [addChild()](../lwtk/Group.md#.addChild), [childById()](../lwtk/Group.md#.childById), [removeChild()](../lwtk/Group.md#.removeChild), [_clearChildLookup()](../lwtk/Group.md#._clearChildLookup) * [MouseDispatcher](../lwtk/MouseDispatcher.md): * [_processMouseDown()](../lwtk/MouseDispatcher.md#._processMouseDown), [_processMouseEnter()](../lwtk/MouseDispatcher.md#._processMouseEnter), [_processMouseLeave()](../lwtk/MouseDispatcher.md#._processMouseLeave), [_processMouseMove()](../lwtk/MouseDispatcher.md#._processMouseMove), [_processMouseScroll()](../lwtk/MouseDispatcher.md#._processMouseScroll), [_processMouseUp()](../lwtk/MouseDispatcher.md#._processMouseUp) * [Compound](../lwtk/Compound.md): - * [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) + * [discardChild()](../lwtk/Compound.md#.discardChild), [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) * **[Widget](../lwtk/Widget.md)**: * [notifyInputChanged()](../lwtk/Widget.md#.notifyInputChanged), [setOnInputChanged()](../lwtk/Widget.md#.setOnInputChanged), [setOnRealize()](../lwtk/Widget.md#.setOnRealize), [_setApp()](../lwtk/Widget.md#._setApp), [_setParent()](../lwtk/Widget.md#._setParent) * [Animatable](../lwtk/Animatable.md): @@ -49,6 +49,8 @@ * [byId()](../lwtk/Component.md#.byId), [getCurrentTime()](../lwtk/Component.md#.getCurrentTime), [getFocusHandler()](../lwtk/Component.md#.getFocusHandler), [getFontInfo()](../lwtk/Component.md#.getFontInfo), [getFrame()](../lwtk/Component.md#.getFrame), [getLayoutContext()](../lwtk/Component.md#.getLayoutContext), [getParent()](../lwtk/Component.md#.getParent), [getRoot()](../lwtk/Component.md#.getRoot), [getSize()](../lwtk/Component.md#.getSize), [handleRemainingInitParams()](../lwtk/Component.md#.handleRemainingInitParams), [parentById()](../lwtk/Component.md#.parentById), [setFrame()](../lwtk/Component.md#.setFrame), [setInitParams()](../lwtk/Component.md#.setInitParams), [setTimer()](../lwtk/Component.md#.setTimer), [transformXY()](../lwtk/Component.md#.transformXY), [triggerLayout()](../lwtk/Component.md#.triggerLayout), [triggerRedraw()](../lwtk/Component.md#.triggerRedraw), [updateFrameTransition()](../lwtk/Component.md#.updateFrameTransition), [_setFrame()](../lwtk/Component.md#._setFrame) * [Drawable](../lwtk/Drawable.md): * [getMandatoryStyleParam()](../lwtk/Drawable.md#.getMandatoryStyleParam) + * [Node](../lwtk/Node.md): + * [discard()](../lwtk/Node.md#.discard) * [Actionable](../lwtk/Actionable.md): * [hasActionMethod()](../lwtk/Actionable.md#.hasActionMethod), [invokeActionMethod()](../lwtk/Actionable.md#.invokeActionMethod) * **[Object](../lwtk/Object.md)**: diff --git a/doc/gen/lwtk/Component.md b/doc/gen/lwtk/Component.md index f8764aa..1d48479 100644 --- a/doc/gen/lwtk/Component.md +++ b/doc/gen/lwtk/Component.md @@ -129,6 +129,8 @@ ## Inherited Methods * [Drawable](../lwtk/Drawable.md): * [getMandatoryStyleParam()](../lwtk/Drawable.md#.getMandatoryStyleParam), [getStyleParam()](../lwtk/Drawable.md#.getStyleParam), [_processMouseDown()](../lwtk/Drawable.md#._processMouseDown), [_processMouseEnter()](../lwtk/Drawable.md#._processMouseEnter), [_processMouseLeave()](../lwtk/Drawable.md#._processMouseLeave), [_processMouseMove()](../lwtk/Drawable.md#._processMouseMove), [_processMouseScroll()](../lwtk/Drawable.md#._processMouseScroll), [_processMouseUp()](../lwtk/Drawable.md#._processMouseUp) + * [Node](../lwtk/Node.md): + * [discard()](../lwtk/Node.md#.discard) * [Actionable](../lwtk/Actionable.md): * [hasActionMethod()](../lwtk/Actionable.md#.hasActionMethod), [invokeActionMethod()](../lwtk/Actionable.md#.invokeActionMethod) * **[Object](../lwtk/Object.md)**: diff --git a/doc/gen/lwtk/Compound.md b/doc/gen/lwtk/Compound.md index 741fb20..8450833 100644 --- a/doc/gen/lwtk/Compound.md +++ b/doc/gen/lwtk/Compound.md @@ -1,5 +1,6 @@ # Mixin lwtk.Compound +Base for components that can have children. ## Contents diff --git a/doc/gen/lwtk/FocusGroup.md b/doc/gen/lwtk/FocusGroup.md index 9c9e449..3f6e5a4 100644 --- a/doc/gen/lwtk/FocusGroup.md +++ b/doc/gen/lwtk/FocusGroup.md @@ -89,7 +89,8 @@ * **`FocusGroup:_setApp(app)`** * Overrides: [Widget:_setApp()](../lwtk/Widget.md#._setApp) - * Overrides: [Component:_setApp()](../lwtk/Component.md#._setApp) + * Overrides: [Animatable:_setApp()](../lwtk/Animatable.md#._setApp) + * Overrides: [Component:_setApp()](../lwtk/Component.md#._setApp) @@ -101,11 +102,11 @@ * [LayoutFrame](../lwtk/LayoutFrame.md): * [addChild()](../lwtk/LayoutFrame.md#.addChild), [onDraw()](../lwtk/LayoutFrame.md#.onDraw), [onLayout()](../lwtk/LayoutFrame.md#.onLayout) * **[Group](../lwtk/Group.md)**: - * [childById()](../lwtk/Group.md#.childById), [_clearChildLookup()](../lwtk/Group.md#._clearChildLookup) + * [childById()](../lwtk/Group.md#.childById), [removeChild()](../lwtk/Group.md#.removeChild), [_clearChildLookup()](../lwtk/Group.md#._clearChildLookup) * [MouseDispatcher](../lwtk/MouseDispatcher.md): * [_processMouseEnter()](../lwtk/MouseDispatcher.md#._processMouseEnter), [_processMouseLeave()](../lwtk/MouseDispatcher.md#._processMouseLeave), [_processMouseMove()](../lwtk/MouseDispatcher.md#._processMouseMove), [_processMouseScroll()](../lwtk/MouseDispatcher.md#._processMouseScroll), [_processMouseUp()](../lwtk/MouseDispatcher.md#._processMouseUp) * [Compound](../lwtk/Compound.md): - * [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) + * [discardChild()](../lwtk/Compound.md#.discardChild), [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) * **[Widget](../lwtk/Widget.md)**: * [notifyInputChanged()](../lwtk/Widget.md#.notifyInputChanged), [setOnInputChanged()](../lwtk/Widget.md#.setOnInputChanged), [setOnRealize()](../lwtk/Widget.md#.setOnRealize), [_setParent()](../lwtk/Widget.md#._setParent) * [Animatable](../lwtk/Animatable.md): @@ -116,6 +117,8 @@ * [byId()](../lwtk/Component.md#.byId), [getCurrentTime()](../lwtk/Component.md#.getCurrentTime), [getFocusHandler()](../lwtk/Component.md#.getFocusHandler), [getFontInfo()](../lwtk/Component.md#.getFontInfo), [getFrame()](../lwtk/Component.md#.getFrame), [getLayoutContext()](../lwtk/Component.md#.getLayoutContext), [getParent()](../lwtk/Component.md#.getParent), [getRoot()](../lwtk/Component.md#.getRoot), [getSize()](../lwtk/Component.md#.getSize), [handleRemainingInitParams()](../lwtk/Component.md#.handleRemainingInitParams), [parentById()](../lwtk/Component.md#.parentById), [setFrame()](../lwtk/Component.md#.setFrame), [setInitParams()](../lwtk/Component.md#.setInitParams), [setTimer()](../lwtk/Component.md#.setTimer), [transformXY()](../lwtk/Component.md#.transformXY), [triggerLayout()](../lwtk/Component.md#.triggerLayout), [triggerRedraw()](../lwtk/Component.md#.triggerRedraw), [updateFrameTransition()](../lwtk/Component.md#.updateFrameTransition), [_setFrame()](../lwtk/Component.md#._setFrame) * [Drawable](../lwtk/Drawable.md): * [getMandatoryStyleParam()](../lwtk/Drawable.md#.getMandatoryStyleParam) + * [Node](../lwtk/Node.md): + * [discard()](../lwtk/Node.md#.discard) * [Actionable](../lwtk/Actionable.md): * [hasActionMethod()](../lwtk/Actionable.md#.hasActionMethod) * **[Object](../lwtk/Object.md)**: diff --git a/doc/gen/lwtk/FocusHandler.md b/doc/gen/lwtk/FocusHandler.md index 92bed50..a2036fa 100644 --- a/doc/gen/lwtk/FocusHandler.md +++ b/doc/gen/lwtk/FocusHandler.md @@ -30,8 +30,10 @@ * [setFocusTo()](#.setFocusTo) * [setFocusToNextInput()](#.setFocusToNextInput) * [setFocusToPrevInput()](#.setFocusToPrevInput) + * [_addFocusableChild()](#._addFocusableChild) * [_handleFocusIn()](#._handleFocusIn) * [_handleFocusOut()](#._handleFocusOut) + * [_removeFocusableChildren()](#._removeFocusableChildren) * [_setParentFocusHandler()](#._setParentFocusHandler) * [Inherited Methods](#inherited-methods) @@ -123,12 +125,18 @@ * **`FocusHandler:setFocusToPrevInput(child)`** + * **`FocusHandler:_addFocusableChild(child)`** + + * **`FocusHandler:_handleFocusIn()`** * **`FocusHandler:_handleFocusOut()`** + * **`FocusHandler:_removeFocusableChildren(child)`** + + * **`FocusHandler:_setParentFocusHandler(parentFocusHandler)`** diff --git a/doc/gen/lwtk/Group.md b/doc/gen/lwtk/Group.md index e48630b..434531c 100644 --- a/doc/gen/lwtk/Group.md +++ b/doc/gen/lwtk/Group.md @@ -8,6 +8,7 @@ * [Methods](#methods) * [addChild()](#.addChild) * [childById()](#.childById) + * [removeChild()](#.removeChild) * [_clearChildLookup()](#._clearChildLookup) * [Inherited Methods](#inherited-methods) * [Subclasses](#subclasses) @@ -29,15 +30,22 @@ ## Methods - * **`Group:addChild(child)`** + * **`Group:addChild(child, index)`** * Overrides: [Compound:addChild()](../lwtk/Compound.md#.addChild) - * Implements: [Drawable:addChild()](../lwtk/Drawable.md#.addChild) + * Implements: [Node:addChild()](../lwtk/Node.md#.addChild) * **`Group:childById(id)`** + * **`Group:removeChild(child)`** + + * Overrides: [MouseDispatcher:removeChild()](../lwtk/MouseDispatcher.md#.removeChild) + * Overrides: [Compound:removeChild()](../lwtk/Compound.md#.removeChild) + * Implements: [Node:removeChild()](../lwtk/Node.md#.removeChild) + + * **`Group:_clearChildLookup()`** @@ -46,7 +54,7 @@ * [MouseDispatcher](../lwtk/MouseDispatcher.md): * [_processMouseDown()](../lwtk/MouseDispatcher.md#._processMouseDown), [_processMouseEnter()](../lwtk/MouseDispatcher.md#._processMouseEnter), [_processMouseLeave()](../lwtk/MouseDispatcher.md#._processMouseLeave), [_processMouseMove()](../lwtk/MouseDispatcher.md#._processMouseMove), [_processMouseScroll()](../lwtk/MouseDispatcher.md#._processMouseScroll), [_processMouseUp()](../lwtk/MouseDispatcher.md#._processMouseUp) * [Compound](../lwtk/Compound.md): - * [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) + * [discardChild()](../lwtk/Compound.md#.discardChild), [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) * **[Widget](../lwtk/Widget.md)**: * [notifyInputChanged()](../lwtk/Widget.md#.notifyInputChanged), [setOnInputChanged()](../lwtk/Widget.md#.setOnInputChanged), [setOnRealize()](../lwtk/Widget.md#.setOnRealize), [_setApp()](../lwtk/Widget.md#._setApp), [_setParent()](../lwtk/Widget.md#._setParent) * [Animatable](../lwtk/Animatable.md): @@ -57,6 +65,8 @@ * [byId()](../lwtk/Component.md#.byId), [getCurrentTime()](../lwtk/Component.md#.getCurrentTime), [getFocusHandler()](../lwtk/Component.md#.getFocusHandler), [getFontInfo()](../lwtk/Component.md#.getFontInfo), [getFrame()](../lwtk/Component.md#.getFrame), [getLayoutContext()](../lwtk/Component.md#.getLayoutContext), [getParent()](../lwtk/Component.md#.getParent), [getRoot()](../lwtk/Component.md#.getRoot), [getSize()](../lwtk/Component.md#.getSize), [handleRemainingInitParams()](../lwtk/Component.md#.handleRemainingInitParams), [parentById()](../lwtk/Component.md#.parentById), [setFrame()](../lwtk/Component.md#.setFrame), [setInitParams()](../lwtk/Component.md#.setInitParams), [setTimer()](../lwtk/Component.md#.setTimer), [transformXY()](../lwtk/Component.md#.transformXY), [triggerLayout()](../lwtk/Component.md#.triggerLayout), [triggerRedraw()](../lwtk/Component.md#.triggerRedraw), [updateFrameTransition()](../lwtk/Component.md#.updateFrameTransition), [_setFrame()](../lwtk/Component.md#._setFrame) * [Drawable](../lwtk/Drawable.md): * [getMandatoryStyleParam()](../lwtk/Drawable.md#.getMandatoryStyleParam) + * [Node](../lwtk/Node.md): + * [discard()](../lwtk/Node.md#.discard) * [Actionable](../lwtk/Actionable.md): * [hasActionMethod()](../lwtk/Actionable.md#.hasActionMethod), [invokeActionMethod()](../lwtk/Actionable.md#.invokeActionMethod) * **[Object](../lwtk/Object.md)**: diff --git a/doc/gen/lwtk/InnerCompound.md b/doc/gen/lwtk/InnerCompound.md index e1ae0e1..d144e9d 100644 --- a/doc/gen/lwtk/InnerCompound.md +++ b/doc/gen/lwtk/InnerCompound.md @@ -19,11 +19,13 @@ ## Inherited Methods * [Compound](../lwtk/Compound.md): - * [addChild()](../lwtk/Compound.md#.addChild), [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) + * [addChild()](../lwtk/Compound.md#.addChild), [discardChild()](../lwtk/Compound.md#.discardChild), [removeChild()](../lwtk/Compound.md#.removeChild), [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) * **[Component](../lwtk/Component.md)**: * [animateFrame()](../lwtk/Component.md#.animateFrame), [byId()](../lwtk/Component.md#.byId), [getCurrentTime()](../lwtk/Component.md#.getCurrentTime), [getFocusHandler()](../lwtk/Component.md#.getFocusHandler), [getFontInfo()](../lwtk/Component.md#.getFontInfo), [getFrame()](../lwtk/Component.md#.getFrame), [getLayoutContext()](../lwtk/Component.md#.getLayoutContext), [getParent()](../lwtk/Component.md#.getParent), [getRoot()](../lwtk/Component.md#.getRoot), [getSize()](../lwtk/Component.md#.getSize), [handleRemainingInitParams()](../lwtk/Component.md#.handleRemainingInitParams), [parentById()](../lwtk/Component.md#.parentById), [setFrame()](../lwtk/Component.md#.setFrame), [setInitParams()](../lwtk/Component.md#.setInitParams), [setTimer()](../lwtk/Component.md#.setTimer), [transformXY()](../lwtk/Component.md#.transformXY), [triggerLayout()](../lwtk/Component.md#.triggerLayout), [triggerRedraw()](../lwtk/Component.md#.triggerRedraw), [updateAnimation()](../lwtk/Component.md#.updateAnimation), [updateFrameTransition()](../lwtk/Component.md#.updateFrameTransition), [_setApp()](../lwtk/Component.md#._setApp), [_setFrame()](../lwtk/Component.md#._setFrame), [_setParent()](../lwtk/Component.md#._setParent) * [Drawable](../lwtk/Drawable.md): * [getMandatoryStyleParam()](../lwtk/Drawable.md#.getMandatoryStyleParam), [getStyleParam()](../lwtk/Drawable.md#.getStyleParam), [_processMouseDown()](../lwtk/Drawable.md#._processMouseDown), [_processMouseEnter()](../lwtk/Drawable.md#._processMouseEnter), [_processMouseLeave()](../lwtk/Drawable.md#._processMouseLeave), [_processMouseMove()](../lwtk/Drawable.md#._processMouseMove), [_processMouseScroll()](../lwtk/Drawable.md#._processMouseScroll), [_processMouseUp()](../lwtk/Drawable.md#._processMouseUp) + * [Node](../lwtk/Node.md): + * [discard()](../lwtk/Node.md#.discard) * [Actionable](../lwtk/Actionable.md): * [hasActionMethod()](../lwtk/Actionable.md#.hasActionMethod), [invokeActionMethod()](../lwtk/Actionable.md#.invokeActionMethod) * **[Object](../lwtk/Object.md)**: diff --git a/doc/gen/lwtk/Matrix.md b/doc/gen/lwtk/Matrix.md index d436f0f..26ec52b 100644 --- a/doc/gen/lwtk/Matrix.md +++ b/doc/gen/lwtk/Matrix.md @@ -41,11 +41,11 @@ ## Inherited Methods * **[Group](../lwtk/Group.md)**: - * [addChild()](../lwtk/Group.md#.addChild), [childById()](../lwtk/Group.md#.childById), [_clearChildLookup()](../lwtk/Group.md#._clearChildLookup) + * [addChild()](../lwtk/Group.md#.addChild), [childById()](../lwtk/Group.md#.childById), [removeChild()](../lwtk/Group.md#.removeChild), [_clearChildLookup()](../lwtk/Group.md#._clearChildLookup) * [MouseDispatcher](../lwtk/MouseDispatcher.md): * [_processMouseDown()](../lwtk/MouseDispatcher.md#._processMouseDown), [_processMouseEnter()](../lwtk/MouseDispatcher.md#._processMouseEnter), [_processMouseLeave()](../lwtk/MouseDispatcher.md#._processMouseLeave), [_processMouseMove()](../lwtk/MouseDispatcher.md#._processMouseMove), [_processMouseScroll()](../lwtk/MouseDispatcher.md#._processMouseScroll), [_processMouseUp()](../lwtk/MouseDispatcher.md#._processMouseUp) * [Compound](../lwtk/Compound.md): - * [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) + * [discardChild()](../lwtk/Compound.md#.discardChild), [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) * **[Widget](../lwtk/Widget.md)**: * [notifyInputChanged()](../lwtk/Widget.md#.notifyInputChanged), [setOnInputChanged()](../lwtk/Widget.md#.setOnInputChanged), [setOnRealize()](../lwtk/Widget.md#.setOnRealize), [_setApp()](../lwtk/Widget.md#._setApp), [_setParent()](../lwtk/Widget.md#._setParent) * [Animatable](../lwtk/Animatable.md): @@ -56,6 +56,8 @@ * [byId()](../lwtk/Component.md#.byId), [getCurrentTime()](../lwtk/Component.md#.getCurrentTime), [getFocusHandler()](../lwtk/Component.md#.getFocusHandler), [getFontInfo()](../lwtk/Component.md#.getFontInfo), [getFrame()](../lwtk/Component.md#.getFrame), [getLayoutContext()](../lwtk/Component.md#.getLayoutContext), [getParent()](../lwtk/Component.md#.getParent), [getRoot()](../lwtk/Component.md#.getRoot), [getSize()](../lwtk/Component.md#.getSize), [handleRemainingInitParams()](../lwtk/Component.md#.handleRemainingInitParams), [parentById()](../lwtk/Component.md#.parentById), [setFrame()](../lwtk/Component.md#.setFrame), [setInitParams()](../lwtk/Component.md#.setInitParams), [setTimer()](../lwtk/Component.md#.setTimer), [transformXY()](../lwtk/Component.md#.transformXY), [triggerLayout()](../lwtk/Component.md#.triggerLayout), [triggerRedraw()](../lwtk/Component.md#.triggerRedraw), [updateFrameTransition()](../lwtk/Component.md#.updateFrameTransition), [_setFrame()](../lwtk/Component.md#._setFrame) * [Drawable](../lwtk/Drawable.md): * [getMandatoryStyleParam()](../lwtk/Drawable.md#.getMandatoryStyleParam) + * [Node](../lwtk/Node.md): + * [discard()](../lwtk/Node.md#.discard) * [Actionable](../lwtk/Actionable.md): * [hasActionMethod()](../lwtk/Actionable.md#.hasActionMethod), [invokeActionMethod()](../lwtk/Actionable.md#.invokeActionMethod) * **[Object](../lwtk/Object.md)**: diff --git a/doc/gen/lwtk/PushButton.md b/doc/gen/lwtk/PushButton.md index 9ce80eb..31d75ad 100644 --- a/doc/gen/lwtk/PushButton.md +++ b/doc/gen/lwtk/PushButton.md @@ -111,11 +111,11 @@ * [Focusable](../lwtk/Focusable.md): * [onDisabled()](../lwtk/Focusable.md#.onDisabled), [onEffectiveVisibilityChanged()](../lwtk/Focusable.md#.onEffectiveVisibilityChanged), [setFocus()](../lwtk/Focusable.md#.setFocus), [_handleFocusIn()](../lwtk/Focusable.md#._handleFocusIn), [_handleFocusOut()](../lwtk/Focusable.md#._handleFocusOut), [_handleHasFocusHandler()](../lwtk/Focusable.md#._handleHasFocusHandler) * [HotkeyListener](../lwtk/HotkeyListener.md): - * [isHotkeyEnabled()](../lwtk/HotkeyListener.md#.isHotkeyEnabled), [setHotkey()](../lwtk/HotkeyListener.md#.setHotkey) + * [isHotkeyEnabled()](../lwtk/HotkeyListener.md#.isHotkeyEnabled), [setHotkey()](../lwtk/HotkeyListener.md#.setHotkey), [_handleRemovedFocusHandler()](../lwtk/HotkeyListener.md#._handleRemovedFocusHandler) * [LayoutFrame](../lwtk/LayoutFrame.md): * [addChild()](../lwtk/LayoutFrame.md#.addChild), [onDraw()](../lwtk/LayoutFrame.md#.onDraw) * [Compound](../lwtk/Compound.md): - * [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) + * [discardChild()](../lwtk/Compound.md#.discardChild), [removeChild()](../lwtk/Compound.md#.removeChild), [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) * **[Widget](../lwtk/Widget.md)**: * [notifyInputChanged()](../lwtk/Widget.md#.notifyInputChanged), [setOnInputChanged()](../lwtk/Widget.md#.setOnInputChanged), [setOnRealize()](../lwtk/Widget.md#.setOnRealize), [_setApp()](../lwtk/Widget.md#._setApp), [_setParent()](../lwtk/Widget.md#._setParent) * [Animatable](../lwtk/Animatable.md): @@ -126,6 +126,8 @@ * [byId()](../lwtk/Component.md#.byId), [getCurrentTime()](../lwtk/Component.md#.getCurrentTime), [getFocusHandler()](../lwtk/Component.md#.getFocusHandler), [getFontInfo()](../lwtk/Component.md#.getFontInfo), [getFrame()](../lwtk/Component.md#.getFrame), [getLayoutContext()](../lwtk/Component.md#.getLayoutContext), [getParent()](../lwtk/Component.md#.getParent), [getRoot()](../lwtk/Component.md#.getRoot), [getSize()](../lwtk/Component.md#.getSize), [handleRemainingInitParams()](../lwtk/Component.md#.handleRemainingInitParams), [parentById()](../lwtk/Component.md#.parentById), [setFrame()](../lwtk/Component.md#.setFrame), [setInitParams()](../lwtk/Component.md#.setInitParams), [setTimer()](../lwtk/Component.md#.setTimer), [transformXY()](../lwtk/Component.md#.transformXY), [triggerLayout()](../lwtk/Component.md#.triggerLayout), [triggerRedraw()](../lwtk/Component.md#.triggerRedraw), [updateFrameTransition()](../lwtk/Component.md#.updateFrameTransition), [_setFrame()](../lwtk/Component.md#._setFrame) * [Drawable](../lwtk/Drawable.md): * [getMandatoryStyleParam()](../lwtk/Drawable.md#.getMandatoryStyleParam), [_processMouseDown()](../lwtk/Drawable.md#._processMouseDown), [_processMouseEnter()](../lwtk/Drawable.md#._processMouseEnter), [_processMouseLeave()](../lwtk/Drawable.md#._processMouseLeave), [_processMouseMove()](../lwtk/Drawable.md#._processMouseMove), [_processMouseScroll()](../lwtk/Drawable.md#._processMouseScroll), [_processMouseUp()](../lwtk/Drawable.md#._processMouseUp) + * [Node](../lwtk/Node.md): + * [discard()](../lwtk/Node.md#.discard) * [Actionable](../lwtk/Actionable.md): * [hasActionMethod()](../lwtk/Actionable.md#.hasActionMethod), [invokeActionMethod()](../lwtk/Actionable.md#.invokeActionMethod) * **[Object](../lwtk/Object.md)**: diff --git a/doc/gen/lwtk/Row.md b/doc/gen/lwtk/Row.md index 14d4ab6..6a5e258 100644 --- a/doc/gen/lwtk/Row.md +++ b/doc/gen/lwtk/Row.md @@ -34,11 +34,11 @@ ## Inherited Methods * **[Group](../lwtk/Group.md)**: - * [addChild()](../lwtk/Group.md#.addChild), [childById()](../lwtk/Group.md#.childById), [_clearChildLookup()](../lwtk/Group.md#._clearChildLookup) + * [addChild()](../lwtk/Group.md#.addChild), [childById()](../lwtk/Group.md#.childById), [removeChild()](../lwtk/Group.md#.removeChild), [_clearChildLookup()](../lwtk/Group.md#._clearChildLookup) * [MouseDispatcher](../lwtk/MouseDispatcher.md): * [_processMouseDown()](../lwtk/MouseDispatcher.md#._processMouseDown), [_processMouseEnter()](../lwtk/MouseDispatcher.md#._processMouseEnter), [_processMouseLeave()](../lwtk/MouseDispatcher.md#._processMouseLeave), [_processMouseMove()](../lwtk/MouseDispatcher.md#._processMouseMove), [_processMouseScroll()](../lwtk/MouseDispatcher.md#._processMouseScroll), [_processMouseUp()](../lwtk/MouseDispatcher.md#._processMouseUp) * [Compound](../lwtk/Compound.md): - * [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) + * [discardChild()](../lwtk/Compound.md#.discardChild), [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) * **[Widget](../lwtk/Widget.md)**: * [notifyInputChanged()](../lwtk/Widget.md#.notifyInputChanged), [setOnInputChanged()](../lwtk/Widget.md#.setOnInputChanged), [setOnRealize()](../lwtk/Widget.md#.setOnRealize), [_setApp()](../lwtk/Widget.md#._setApp), [_setParent()](../lwtk/Widget.md#._setParent) * [Animatable](../lwtk/Animatable.md): @@ -49,6 +49,8 @@ * [byId()](../lwtk/Component.md#.byId), [getCurrentTime()](../lwtk/Component.md#.getCurrentTime), [getFocusHandler()](../lwtk/Component.md#.getFocusHandler), [getFontInfo()](../lwtk/Component.md#.getFontInfo), [getFrame()](../lwtk/Component.md#.getFrame), [getLayoutContext()](../lwtk/Component.md#.getLayoutContext), [getParent()](../lwtk/Component.md#.getParent), [getRoot()](../lwtk/Component.md#.getRoot), [getSize()](../lwtk/Component.md#.getSize), [handleRemainingInitParams()](../lwtk/Component.md#.handleRemainingInitParams), [parentById()](../lwtk/Component.md#.parentById), [setFrame()](../lwtk/Component.md#.setFrame), [setInitParams()](../lwtk/Component.md#.setInitParams), [setTimer()](../lwtk/Component.md#.setTimer), [transformXY()](../lwtk/Component.md#.transformXY), [triggerLayout()](../lwtk/Component.md#.triggerLayout), [triggerRedraw()](../lwtk/Component.md#.triggerRedraw), [updateFrameTransition()](../lwtk/Component.md#.updateFrameTransition), [_setFrame()](../lwtk/Component.md#._setFrame) * [Drawable](../lwtk/Drawable.md): * [getMandatoryStyleParam()](../lwtk/Drawable.md#.getMandatoryStyleParam) + * [Node](../lwtk/Node.md): + * [discard()](../lwtk/Node.md#.discard) * [Actionable](../lwtk/Actionable.md): * [hasActionMethod()](../lwtk/Actionable.md#.hasActionMethod), [invokeActionMethod()](../lwtk/Actionable.md#.invokeActionMethod) * **[Object](../lwtk/Object.md)**: diff --git a/doc/gen/lwtk/Space.md b/doc/gen/lwtk/Space.md index bc44710..fc05f1b 100644 --- a/doc/gen/lwtk/Space.md +++ b/doc/gen/lwtk/Space.md @@ -23,11 +23,11 @@ ## Methods - * **`Space:addChild(child)`** + * **`Space:addChild(child, index)`** * Overrides: [Group:addChild()](../lwtk/Group.md#.addChild) * Overrides: [Compound:addChild()](../lwtk/Compound.md#.addChild) - * Implements: [Drawable:addChild()](../lwtk/Drawable.md#.addChild) + * Implements: [Node:addChild()](../lwtk/Node.md#.addChild) * **`Space:getMeasures()`** @@ -46,11 +46,11 @@ ## Inherited Methods * **[Group](../lwtk/Group.md)**: - * [childById()](../lwtk/Group.md#.childById), [_clearChildLookup()](../lwtk/Group.md#._clearChildLookup) + * [childById()](../lwtk/Group.md#.childById), [removeChild()](../lwtk/Group.md#.removeChild), [_clearChildLookup()](../lwtk/Group.md#._clearChildLookup) * [MouseDispatcher](../lwtk/MouseDispatcher.md): * [_processMouseDown()](../lwtk/MouseDispatcher.md#._processMouseDown), [_processMouseEnter()](../lwtk/MouseDispatcher.md#._processMouseEnter), [_processMouseLeave()](../lwtk/MouseDispatcher.md#._processMouseLeave), [_processMouseMove()](../lwtk/MouseDispatcher.md#._processMouseMove), [_processMouseScroll()](../lwtk/MouseDispatcher.md#._processMouseScroll), [_processMouseUp()](../lwtk/MouseDispatcher.md#._processMouseUp) * [Compound](../lwtk/Compound.md): - * [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) + * [discardChild()](../lwtk/Compound.md#.discardChild), [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) * **[Widget](../lwtk/Widget.md)**: * [notifyInputChanged()](../lwtk/Widget.md#.notifyInputChanged), [setOnInputChanged()](../lwtk/Widget.md#.setOnInputChanged), [setOnRealize()](../lwtk/Widget.md#.setOnRealize), [_setApp()](../lwtk/Widget.md#._setApp), [_setParent()](../lwtk/Widget.md#._setParent) * [Animatable](../lwtk/Animatable.md): @@ -61,6 +61,8 @@ * [byId()](../lwtk/Component.md#.byId), [getCurrentTime()](../lwtk/Component.md#.getCurrentTime), [getFocusHandler()](../lwtk/Component.md#.getFocusHandler), [getFontInfo()](../lwtk/Component.md#.getFontInfo), [getFrame()](../lwtk/Component.md#.getFrame), [getLayoutContext()](../lwtk/Component.md#.getLayoutContext), [getParent()](../lwtk/Component.md#.getParent), [getRoot()](../lwtk/Component.md#.getRoot), [getSize()](../lwtk/Component.md#.getSize), [handleRemainingInitParams()](../lwtk/Component.md#.handleRemainingInitParams), [parentById()](../lwtk/Component.md#.parentById), [setFrame()](../lwtk/Component.md#.setFrame), [setInitParams()](../lwtk/Component.md#.setInitParams), [setTimer()](../lwtk/Component.md#.setTimer), [transformXY()](../lwtk/Component.md#.transformXY), [triggerLayout()](../lwtk/Component.md#.triggerLayout), [triggerRedraw()](../lwtk/Component.md#.triggerRedraw), [updateFrameTransition()](../lwtk/Component.md#.updateFrameTransition), [_setFrame()](../lwtk/Component.md#._setFrame) * [Drawable](../lwtk/Drawable.md): * [getMandatoryStyleParam()](../lwtk/Drawable.md#.getMandatoryStyleParam) + * [Node](../lwtk/Node.md): + * [discard()](../lwtk/Node.md#.discard) * [Actionable](../lwtk/Actionable.md): * [hasActionMethod()](../lwtk/Actionable.md#.hasActionMethod), [invokeActionMethod()](../lwtk/Actionable.md#.invokeActionMethod) * **[Object](../lwtk/Object.md)**: diff --git a/doc/gen/lwtk/Square.md b/doc/gen/lwtk/Square.md index 587c57a..f1e5aaa 100644 --- a/doc/gen/lwtk/Square.md +++ b/doc/gen/lwtk/Square.md @@ -22,11 +22,11 @@ ## Methods - * **`Square:addChild(child)`** + * **`Square:addChild(child, index)`** * Overrides: [Group:addChild()](../lwtk/Group.md#.addChild) * Overrides: [Compound:addChild()](../lwtk/Compound.md#.addChild) - * Implements: [Drawable:addChild()](../lwtk/Drawable.md#.addChild) + * Implements: [Node:addChild()](../lwtk/Node.md#.addChild) * **`Square:getMeasures()`** @@ -42,11 +42,11 @@ ## Inherited Methods * **[Group](../lwtk/Group.md)**: - * [childById()](../lwtk/Group.md#.childById), [_clearChildLookup()](../lwtk/Group.md#._clearChildLookup) + * [childById()](../lwtk/Group.md#.childById), [removeChild()](../lwtk/Group.md#.removeChild), [_clearChildLookup()](../lwtk/Group.md#._clearChildLookup) * [MouseDispatcher](../lwtk/MouseDispatcher.md): * [_processMouseDown()](../lwtk/MouseDispatcher.md#._processMouseDown), [_processMouseEnter()](../lwtk/MouseDispatcher.md#._processMouseEnter), [_processMouseLeave()](../lwtk/MouseDispatcher.md#._processMouseLeave), [_processMouseMove()](../lwtk/MouseDispatcher.md#._processMouseMove), [_processMouseScroll()](../lwtk/MouseDispatcher.md#._processMouseScroll), [_processMouseUp()](../lwtk/MouseDispatcher.md#._processMouseUp) * [Compound](../lwtk/Compound.md): - * [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) + * [discardChild()](../lwtk/Compound.md#.discardChild), [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) * **[Widget](../lwtk/Widget.md)**: * [notifyInputChanged()](../lwtk/Widget.md#.notifyInputChanged), [setOnInputChanged()](../lwtk/Widget.md#.setOnInputChanged), [setOnRealize()](../lwtk/Widget.md#.setOnRealize), [_setApp()](../lwtk/Widget.md#._setApp), [_setParent()](../lwtk/Widget.md#._setParent) * [Animatable](../lwtk/Animatable.md): @@ -57,6 +57,8 @@ * [byId()](../lwtk/Component.md#.byId), [getCurrentTime()](../lwtk/Component.md#.getCurrentTime), [getFocusHandler()](../lwtk/Component.md#.getFocusHandler), [getFontInfo()](../lwtk/Component.md#.getFontInfo), [getFrame()](../lwtk/Component.md#.getFrame), [getLayoutContext()](../lwtk/Component.md#.getLayoutContext), [getParent()](../lwtk/Component.md#.getParent), [getRoot()](../lwtk/Component.md#.getRoot), [getSize()](../lwtk/Component.md#.getSize), [handleRemainingInitParams()](../lwtk/Component.md#.handleRemainingInitParams), [parentById()](../lwtk/Component.md#.parentById), [setFrame()](../lwtk/Component.md#.setFrame), [setInitParams()](../lwtk/Component.md#.setInitParams), [setTimer()](../lwtk/Component.md#.setTimer), [transformXY()](../lwtk/Component.md#.transformXY), [triggerLayout()](../lwtk/Component.md#.triggerLayout), [triggerRedraw()](../lwtk/Component.md#.triggerRedraw), [updateFrameTransition()](../lwtk/Component.md#.updateFrameTransition), [_setFrame()](../lwtk/Component.md#._setFrame) * [Drawable](../lwtk/Drawable.md): * [getMandatoryStyleParam()](../lwtk/Drawable.md#.getMandatoryStyleParam) + * [Node](../lwtk/Node.md): + * [discard()](../lwtk/Node.md#.discard) * [Actionable](../lwtk/Actionable.md): * [hasActionMethod()](../lwtk/Actionable.md#.hasActionMethod), [invokeActionMethod()](../lwtk/Actionable.md#.invokeActionMethod) * **[Object](../lwtk/Object.md)**: diff --git a/doc/gen/lwtk/TextCursor.md b/doc/gen/lwtk/TextCursor.md index 925f11d..3ec7d73 100644 --- a/doc/gen/lwtk/TextCursor.md +++ b/doc/gen/lwtk/TextCursor.md @@ -31,6 +31,8 @@ * [animateFrame()](../lwtk/Component.md#.animateFrame), [byId()](../lwtk/Component.md#.byId), [getCurrentTime()](../lwtk/Component.md#.getCurrentTime), [getFocusHandler()](../lwtk/Component.md#.getFocusHandler), [getFontInfo()](../lwtk/Component.md#.getFontInfo), [getFrame()](../lwtk/Component.md#.getFrame), [getLayoutContext()](../lwtk/Component.md#.getLayoutContext), [getParent()](../lwtk/Component.md#.getParent), [getRoot()](../lwtk/Component.md#.getRoot), [getSize()](../lwtk/Component.md#.getSize), [handleRemainingInitParams()](../lwtk/Component.md#.handleRemainingInitParams), [parentById()](../lwtk/Component.md#.parentById), [setFrame()](../lwtk/Component.md#.setFrame), [setInitParams()](../lwtk/Component.md#.setInitParams), [setTimer()](../lwtk/Component.md#.setTimer), [transformXY()](../lwtk/Component.md#.transformXY), [triggerLayout()](../lwtk/Component.md#.triggerLayout), [triggerRedraw()](../lwtk/Component.md#.triggerRedraw), [updateAnimation()](../lwtk/Component.md#.updateAnimation), [updateFrameTransition()](../lwtk/Component.md#.updateFrameTransition), [_processChanges()](../lwtk/Component.md#._processChanges), [_processDraw()](../lwtk/Component.md#._processDraw), [_setApp()](../lwtk/Component.md#._setApp), [_setFrame()](../lwtk/Component.md#._setFrame), [_setParent()](../lwtk/Component.md#._setParent) * [Drawable](../lwtk/Drawable.md): * [getMandatoryStyleParam()](../lwtk/Drawable.md#.getMandatoryStyleParam), [getStyleParam()](../lwtk/Drawable.md#.getStyleParam), [_processMouseDown()](../lwtk/Drawable.md#._processMouseDown), [_processMouseEnter()](../lwtk/Drawable.md#._processMouseEnter), [_processMouseLeave()](../lwtk/Drawable.md#._processMouseLeave), [_processMouseMove()](../lwtk/Drawable.md#._processMouseMove), [_processMouseScroll()](../lwtk/Drawable.md#._processMouseScroll), [_processMouseUp()](../lwtk/Drawable.md#._processMouseUp) + * [Node](../lwtk/Node.md): + * [discard()](../lwtk/Node.md#.discard) * [Actionable](../lwtk/Actionable.md): * [hasActionMethod()](../lwtk/Actionable.md#.hasActionMethod), [invokeActionMethod()](../lwtk/Actionable.md#.invokeActionMethod) * **[Object](../lwtk/Object.md)**: diff --git a/doc/gen/lwtk/TextFragment.md b/doc/gen/lwtk/TextFragment.md index 69ae57c..499b147 100644 --- a/doc/gen/lwtk/TextFragment.md +++ b/doc/gen/lwtk/TextFragment.md @@ -59,6 +59,8 @@ * [animateFrame()](../lwtk/Component.md#.animateFrame), [byId()](../lwtk/Component.md#.byId), [getCurrentTime()](../lwtk/Component.md#.getCurrentTime), [getFocusHandler()](../lwtk/Component.md#.getFocusHandler), [getFrame()](../lwtk/Component.md#.getFrame), [getLayoutContext()](../lwtk/Component.md#.getLayoutContext), [getParent()](../lwtk/Component.md#.getParent), [getRoot()](../lwtk/Component.md#.getRoot), [getSize()](../lwtk/Component.md#.getSize), [handleRemainingInitParams()](../lwtk/Component.md#.handleRemainingInitParams), [parentById()](../lwtk/Component.md#.parentById), [setFrame()](../lwtk/Component.md#.setFrame), [setInitParams()](../lwtk/Component.md#.setInitParams), [setTimer()](../lwtk/Component.md#.setTimer), [transformXY()](../lwtk/Component.md#.transformXY), [triggerLayout()](../lwtk/Component.md#.triggerLayout), [triggerRedraw()](../lwtk/Component.md#.triggerRedraw), [updateAnimation()](../lwtk/Component.md#.updateAnimation), [updateFrameTransition()](../lwtk/Component.md#.updateFrameTransition), [_processChanges()](../lwtk/Component.md#._processChanges), [_processDraw()](../lwtk/Component.md#._processDraw), [_setApp()](../lwtk/Component.md#._setApp), [_setFrame()](../lwtk/Component.md#._setFrame), [_setParent()](../lwtk/Component.md#._setParent) * [Drawable](../lwtk/Drawable.md): * [getMandatoryStyleParam()](../lwtk/Drawable.md#.getMandatoryStyleParam), [getStyleParam()](../lwtk/Drawable.md#.getStyleParam), [_processMouseDown()](../lwtk/Drawable.md#._processMouseDown), [_processMouseEnter()](../lwtk/Drawable.md#._processMouseEnter), [_processMouseLeave()](../lwtk/Drawable.md#._processMouseLeave), [_processMouseMove()](../lwtk/Drawable.md#._processMouseMove), [_processMouseScroll()](../lwtk/Drawable.md#._processMouseScroll), [_processMouseUp()](../lwtk/Drawable.md#._processMouseUp) + * [Node](../lwtk/Node.md): + * [discard()](../lwtk/Node.md#.discard) * [Actionable](../lwtk/Actionable.md): * [hasActionMethod()](../lwtk/Actionable.md#.hasActionMethod), [invokeActionMethod()](../lwtk/Actionable.md#.invokeActionMethod) * **[Object](../lwtk/Object.md)**: diff --git a/doc/gen/lwtk/TextInput.md b/doc/gen/lwtk/TextInput.md index be44082..876f892 100644 --- a/doc/gen/lwtk/TextInput.md +++ b/doc/gen/lwtk/TextInput.md @@ -119,7 +119,7 @@ * [LayoutFrame](../lwtk/LayoutFrame.md): * [addChild()](../lwtk/LayoutFrame.md#.addChild), [onDraw()](../lwtk/LayoutFrame.md#.onDraw) * [Compound](../lwtk/Compound.md): - * [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) + * [discardChild()](../lwtk/Compound.md#.discardChild), [removeChild()](../lwtk/Compound.md#.removeChild), [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) * **[Widget](../lwtk/Widget.md)**: * [notifyInputChanged()](../lwtk/Widget.md#.notifyInputChanged), [setOnInputChanged()](../lwtk/Widget.md#.setOnInputChanged), [setOnRealize()](../lwtk/Widget.md#.setOnRealize), [_setApp()](../lwtk/Widget.md#._setApp), [_setParent()](../lwtk/Widget.md#._setParent) * [Animatable](../lwtk/Animatable.md): @@ -130,6 +130,8 @@ * [byId()](../lwtk/Component.md#.byId), [getCurrentTime()](../lwtk/Component.md#.getCurrentTime), [getFocusHandler()](../lwtk/Component.md#.getFocusHandler), [getFontInfo()](../lwtk/Component.md#.getFontInfo), [getFrame()](../lwtk/Component.md#.getFrame), [getLayoutContext()](../lwtk/Component.md#.getLayoutContext), [getParent()](../lwtk/Component.md#.getParent), [getRoot()](../lwtk/Component.md#.getRoot), [getSize()](../lwtk/Component.md#.getSize), [handleRemainingInitParams()](../lwtk/Component.md#.handleRemainingInitParams), [parentById()](../lwtk/Component.md#.parentById), [setFrame()](../lwtk/Component.md#.setFrame), [setInitParams()](../lwtk/Component.md#.setInitParams), [setTimer()](../lwtk/Component.md#.setTimer), [transformXY()](../lwtk/Component.md#.transformXY), [triggerLayout()](../lwtk/Component.md#.triggerLayout), [triggerRedraw()](../lwtk/Component.md#.triggerRedraw), [updateFrameTransition()](../lwtk/Component.md#.updateFrameTransition), [_setFrame()](../lwtk/Component.md#._setFrame) * [Drawable](../lwtk/Drawable.md): * [getMandatoryStyleParam()](../lwtk/Drawable.md#.getMandatoryStyleParam), [_processMouseDown()](../lwtk/Drawable.md#._processMouseDown), [_processMouseEnter()](../lwtk/Drawable.md#._processMouseEnter), [_processMouseLeave()](../lwtk/Drawable.md#._processMouseLeave), [_processMouseMove()](../lwtk/Drawable.md#._processMouseMove), [_processMouseScroll()](../lwtk/Drawable.md#._processMouseScroll), [_processMouseUp()](../lwtk/Drawable.md#._processMouseUp) + * [Node](../lwtk/Node.md): + * [discard()](../lwtk/Node.md#.discard) * [Actionable](../lwtk/Actionable.md): * [hasActionMethod()](../lwtk/Actionable.md#.hasActionMethod), [invokeActionMethod()](../lwtk/Actionable.md#.invokeActionMethod) * **[Object](../lwtk/Object.md)**: diff --git a/doc/gen/lwtk/TextLabel.md b/doc/gen/lwtk/TextLabel.md index a78c724..923fe3e 100644 --- a/doc/gen/lwtk/TextLabel.md +++ b/doc/gen/lwtk/TextLabel.md @@ -72,11 +72,11 @@ ## Inherited Methods * [HotkeyListener](../lwtk/HotkeyListener.md): - * [isHotkeyEnabled()](../lwtk/HotkeyListener.md#.isHotkeyEnabled), [onDisabled()](../lwtk/HotkeyListener.md#.onDisabled), [onEffectiveVisibilityChanged()](../lwtk/HotkeyListener.md#.onEffectiveVisibilityChanged), [setHotkey()](../lwtk/HotkeyListener.md#.setHotkey), [_handleHasFocusHandler()](../lwtk/HotkeyListener.md#._handleHasFocusHandler) + * [isHotkeyEnabled()](../lwtk/HotkeyListener.md#.isHotkeyEnabled), [onDisabled()](../lwtk/HotkeyListener.md#.onDisabled), [onEffectiveVisibilityChanged()](../lwtk/HotkeyListener.md#.onEffectiveVisibilityChanged), [setHotkey()](../lwtk/HotkeyListener.md#.setHotkey), [_handleHasFocusHandler()](../lwtk/HotkeyListener.md#._handleHasFocusHandler), [_handleRemovedFocusHandler()](../lwtk/HotkeyListener.md#._handleRemovedFocusHandler) * [LayoutFrame](../lwtk/LayoutFrame.md): * [addChild()](../lwtk/LayoutFrame.md#.addChild), [onDraw()](../lwtk/LayoutFrame.md#.onDraw) * [Compound](../lwtk/Compound.md): - * [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) + * [discardChild()](../lwtk/Compound.md#.discardChild), [removeChild()](../lwtk/Compound.md#.removeChild), [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) * **[Widget](../lwtk/Widget.md)**: * [notifyInputChanged()](../lwtk/Widget.md#.notifyInputChanged), [setOnInputChanged()](../lwtk/Widget.md#.setOnInputChanged), [setOnRealize()](../lwtk/Widget.md#.setOnRealize), [_setApp()](../lwtk/Widget.md#._setApp), [_setParent()](../lwtk/Widget.md#._setParent) * [Animatable](../lwtk/Animatable.md): @@ -87,6 +87,8 @@ * [byId()](../lwtk/Component.md#.byId), [getCurrentTime()](../lwtk/Component.md#.getCurrentTime), [getFocusHandler()](../lwtk/Component.md#.getFocusHandler), [getFontInfo()](../lwtk/Component.md#.getFontInfo), [getFrame()](../lwtk/Component.md#.getFrame), [getLayoutContext()](../lwtk/Component.md#.getLayoutContext), [getParent()](../lwtk/Component.md#.getParent), [getRoot()](../lwtk/Component.md#.getRoot), [getSize()](../lwtk/Component.md#.getSize), [handleRemainingInitParams()](../lwtk/Component.md#.handleRemainingInitParams), [parentById()](../lwtk/Component.md#.parentById), [setFrame()](../lwtk/Component.md#.setFrame), [setInitParams()](../lwtk/Component.md#.setInitParams), [setTimer()](../lwtk/Component.md#.setTimer), [transformXY()](../lwtk/Component.md#.transformXY), [triggerLayout()](../lwtk/Component.md#.triggerLayout), [triggerRedraw()](../lwtk/Component.md#.triggerRedraw), [updateFrameTransition()](../lwtk/Component.md#.updateFrameTransition), [_setFrame()](../lwtk/Component.md#._setFrame) * [Drawable](../lwtk/Drawable.md): * [getMandatoryStyleParam()](../lwtk/Drawable.md#.getMandatoryStyleParam), [_processMouseDown()](../lwtk/Drawable.md#._processMouseDown), [_processMouseEnter()](../lwtk/Drawable.md#._processMouseEnter), [_processMouseLeave()](../lwtk/Drawable.md#._processMouseLeave), [_processMouseMove()](../lwtk/Drawable.md#._processMouseMove), [_processMouseScroll()](../lwtk/Drawable.md#._processMouseScroll), [_processMouseUp()](../lwtk/Drawable.md#._processMouseUp) + * [Node](../lwtk/Node.md): + * [discard()](../lwtk/Node.md#.discard) * [Actionable](../lwtk/Actionable.md): * [hasActionMethod()](../lwtk/Actionable.md#.hasActionMethod), [invokeActionMethod()](../lwtk/Actionable.md#.invokeActionMethod) * **[Object](../lwtk/Object.md)**: diff --git a/doc/gen/lwtk/TitleText.md b/doc/gen/lwtk/TitleText.md index 45bc98a..360f386 100644 --- a/doc/gen/lwtk/TitleText.md +++ b/doc/gen/lwtk/TitleText.md @@ -21,11 +21,11 @@ * **[TextLabel](../lwtk/TextLabel.md)**: * [getMeasures()](../lwtk/TextLabel.md#.getMeasures), [onHotkeyDisabled()](../lwtk/TextLabel.md#.onHotkeyDisabled), [onHotkeyDown()](../lwtk/TextLabel.md#.onHotkeyDown), [onHotkeyEnabled()](../lwtk/TextLabel.md#.onHotkeyEnabled), [onLayout()](../lwtk/TextLabel.md#.onLayout), [onMouseDown()](../lwtk/TextLabel.md#.onMouseDown), [setInput()](../lwtk/TextLabel.md#.setInput), [setText()](../lwtk/TextLabel.md#.setText) * [HotkeyListener](../lwtk/HotkeyListener.md): - * [isHotkeyEnabled()](../lwtk/HotkeyListener.md#.isHotkeyEnabled), [onDisabled()](../lwtk/HotkeyListener.md#.onDisabled), [onEffectiveVisibilityChanged()](../lwtk/HotkeyListener.md#.onEffectiveVisibilityChanged), [setHotkey()](../lwtk/HotkeyListener.md#.setHotkey), [_handleHasFocusHandler()](../lwtk/HotkeyListener.md#._handleHasFocusHandler) + * [isHotkeyEnabled()](../lwtk/HotkeyListener.md#.isHotkeyEnabled), [onDisabled()](../lwtk/HotkeyListener.md#.onDisabled), [onEffectiveVisibilityChanged()](../lwtk/HotkeyListener.md#.onEffectiveVisibilityChanged), [setHotkey()](../lwtk/HotkeyListener.md#.setHotkey), [_handleHasFocusHandler()](../lwtk/HotkeyListener.md#._handleHasFocusHandler), [_handleRemovedFocusHandler()](../lwtk/HotkeyListener.md#._handleRemovedFocusHandler) * [LayoutFrame](../lwtk/LayoutFrame.md): * [addChild()](../lwtk/LayoutFrame.md#.addChild), [onDraw()](../lwtk/LayoutFrame.md#.onDraw) * [Compound](../lwtk/Compound.md): - * [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) + * [discardChild()](../lwtk/Compound.md#.discardChild), [removeChild()](../lwtk/Compound.md#.removeChild), [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) * **[Widget](../lwtk/Widget.md)**: * [notifyInputChanged()](../lwtk/Widget.md#.notifyInputChanged), [setOnInputChanged()](../lwtk/Widget.md#.setOnInputChanged), [setOnRealize()](../lwtk/Widget.md#.setOnRealize), [_setApp()](../lwtk/Widget.md#._setApp), [_setParent()](../lwtk/Widget.md#._setParent) * [Animatable](../lwtk/Animatable.md): @@ -36,6 +36,8 @@ * [byId()](../lwtk/Component.md#.byId), [getCurrentTime()](../lwtk/Component.md#.getCurrentTime), [getFocusHandler()](../lwtk/Component.md#.getFocusHandler), [getFontInfo()](../lwtk/Component.md#.getFontInfo), [getFrame()](../lwtk/Component.md#.getFrame), [getLayoutContext()](../lwtk/Component.md#.getLayoutContext), [getParent()](../lwtk/Component.md#.getParent), [getRoot()](../lwtk/Component.md#.getRoot), [getSize()](../lwtk/Component.md#.getSize), [handleRemainingInitParams()](../lwtk/Component.md#.handleRemainingInitParams), [parentById()](../lwtk/Component.md#.parentById), [setFrame()](../lwtk/Component.md#.setFrame), [setInitParams()](../lwtk/Component.md#.setInitParams), [setTimer()](../lwtk/Component.md#.setTimer), [transformXY()](../lwtk/Component.md#.transformXY), [triggerLayout()](../lwtk/Component.md#.triggerLayout), [triggerRedraw()](../lwtk/Component.md#.triggerRedraw), [updateFrameTransition()](../lwtk/Component.md#.updateFrameTransition), [_setFrame()](../lwtk/Component.md#._setFrame) * [Drawable](../lwtk/Drawable.md): * [getMandatoryStyleParam()](../lwtk/Drawable.md#.getMandatoryStyleParam), [_processMouseDown()](../lwtk/Drawable.md#._processMouseDown), [_processMouseEnter()](../lwtk/Drawable.md#._processMouseEnter), [_processMouseLeave()](../lwtk/Drawable.md#._processMouseLeave), [_processMouseMove()](../lwtk/Drawable.md#._processMouseMove), [_processMouseScroll()](../lwtk/Drawable.md#._processMouseScroll), [_processMouseUp()](../lwtk/Drawable.md#._processMouseUp) + * [Node](../lwtk/Node.md): + * [discard()](../lwtk/Node.md#.discard) * [Actionable](../lwtk/Actionable.md): * [hasActionMethod()](../lwtk/Actionable.md#.hasActionMethod), [invokeActionMethod()](../lwtk/Actionable.md#.invokeActionMethod) * **[Object](../lwtk/Object.md)**: diff --git a/doc/gen/lwtk/ViewSwitcher.md b/doc/gen/lwtk/ViewSwitcher.md index 17960e0..f14bfd5 100644 --- a/doc/gen/lwtk/ViewSwitcher.md +++ b/doc/gen/lwtk/ViewSwitcher.md @@ -23,11 +23,11 @@ ## Methods - * **`ViewSwitcher:addChild(child)`** + * **`ViewSwitcher:addChild(child, index)`** * Overrides: [Group:addChild()](../lwtk/Group.md#.addChild) * Overrides: [Compound:addChild()](../lwtk/Compound.md#.addChild) - * Implements: [Drawable:addChild()](../lwtk/Drawable.md#.addChild) + * Implements: [Node:addChild()](../lwtk/Node.md#.addChild) * **`ViewSwitcher:getMeasures()`** @@ -48,11 +48,11 @@ * [Colored](../lwtk/Colored.md): * [onDraw()](../lwtk/Colored.md#.onDraw) * **[Group](../lwtk/Group.md)**: - * [childById()](../lwtk/Group.md#.childById), [_clearChildLookup()](../lwtk/Group.md#._clearChildLookup) + * [childById()](../lwtk/Group.md#.childById), [removeChild()](../lwtk/Group.md#.removeChild), [_clearChildLookup()](../lwtk/Group.md#._clearChildLookup) * [MouseDispatcher](../lwtk/MouseDispatcher.md): * [_processMouseDown()](../lwtk/MouseDispatcher.md#._processMouseDown), [_processMouseEnter()](../lwtk/MouseDispatcher.md#._processMouseEnter), [_processMouseLeave()](../lwtk/MouseDispatcher.md#._processMouseLeave), [_processMouseMove()](../lwtk/MouseDispatcher.md#._processMouseMove), [_processMouseScroll()](../lwtk/MouseDispatcher.md#._processMouseScroll), [_processMouseUp()](../lwtk/MouseDispatcher.md#._processMouseUp) * [Compound](../lwtk/Compound.md): - * [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) + * [discardChild()](../lwtk/Compound.md#.discardChild), [_processChanges()](../lwtk/Compound.md#._processChanges), [_processDraw()](../lwtk/Compound.md#._processDraw) * **[Widget](../lwtk/Widget.md)**: * [notifyInputChanged()](../lwtk/Widget.md#.notifyInputChanged), [setOnInputChanged()](../lwtk/Widget.md#.setOnInputChanged), [setOnRealize()](../lwtk/Widget.md#.setOnRealize), [_setApp()](../lwtk/Widget.md#._setApp), [_setParent()](../lwtk/Widget.md#._setParent) * [Animatable](../lwtk/Animatable.md): @@ -63,6 +63,8 @@ * [byId()](../lwtk/Component.md#.byId), [getCurrentTime()](../lwtk/Component.md#.getCurrentTime), [getFocusHandler()](../lwtk/Component.md#.getFocusHandler), [getFontInfo()](../lwtk/Component.md#.getFontInfo), [getFrame()](../lwtk/Component.md#.getFrame), [getLayoutContext()](../lwtk/Component.md#.getLayoutContext), [getParent()](../lwtk/Component.md#.getParent), [getRoot()](../lwtk/Component.md#.getRoot), [getSize()](../lwtk/Component.md#.getSize), [handleRemainingInitParams()](../lwtk/Component.md#.handleRemainingInitParams), [parentById()](../lwtk/Component.md#.parentById), [setFrame()](../lwtk/Component.md#.setFrame), [setInitParams()](../lwtk/Component.md#.setInitParams), [setTimer()](../lwtk/Component.md#.setTimer), [transformXY()](../lwtk/Component.md#.transformXY), [triggerLayout()](../lwtk/Component.md#.triggerLayout), [triggerRedraw()](../lwtk/Component.md#.triggerRedraw), [updateFrameTransition()](../lwtk/Component.md#.updateFrameTransition), [_setFrame()](../lwtk/Component.md#._setFrame) * [Drawable](../lwtk/Drawable.md): * [getMandatoryStyleParam()](../lwtk/Drawable.md#.getMandatoryStyleParam) + * [Node](../lwtk/Node.md): + * [discard()](../lwtk/Node.md#.discard) * [Actionable](../lwtk/Actionable.md): * [hasActionMethod()](../lwtk/Actionable.md#.hasActionMethod), [invokeActionMethod()](../lwtk/Actionable.md#.invokeActionMethod) * **[Object](../lwtk/Object.md)**: diff --git a/doc/gen/lwtk/WeakKeysTable.md b/doc/gen/lwtk/WeakKeysTable.md index 8579c30..b3974e6 100644 --- a/doc/gen/lwtk/WeakKeysTable.md +++ b/doc/gen/lwtk/WeakKeysTable.md @@ -1,3 +1,12 @@ # Meta lwtk.WeakKeysTable +## Contents + + * [Constructor](#constructor) + + +## Constructor + * **`WeakKeysTable(name)`** + + diff --git a/doc/gen/lwtk/Widget.md b/doc/gen/lwtk/Widget.md index bd284df..848627f 100644 --- a/doc/gen/lwtk/Widget.md +++ b/doc/gen/lwtk/Widget.md @@ -40,7 +40,8 @@ * **`Widget:_setApp(app)`** - * Overrides: [Component:_setApp()](../lwtk/Component.md#._setApp) + * Overrides: [Animatable:_setApp()](../lwtk/Animatable.md#._setApp) + * Overrides: [Component:_setApp()](../lwtk/Component.md#._setApp) * **`Widget:_setParent(parent)`** @@ -58,6 +59,8 @@ * [byId()](../lwtk/Component.md#.byId), [getCurrentTime()](../lwtk/Component.md#.getCurrentTime), [getFocusHandler()](../lwtk/Component.md#.getFocusHandler), [getFontInfo()](../lwtk/Component.md#.getFontInfo), [getFrame()](../lwtk/Component.md#.getFrame), [getLayoutContext()](../lwtk/Component.md#.getLayoutContext), [getParent()](../lwtk/Component.md#.getParent), [getRoot()](../lwtk/Component.md#.getRoot), [getSize()](../lwtk/Component.md#.getSize), [handleRemainingInitParams()](../lwtk/Component.md#.handleRemainingInitParams), [parentById()](../lwtk/Component.md#.parentById), [setFrame()](../lwtk/Component.md#.setFrame), [setInitParams()](../lwtk/Component.md#.setInitParams), [setTimer()](../lwtk/Component.md#.setTimer), [transformXY()](../lwtk/Component.md#.transformXY), [triggerLayout()](../lwtk/Component.md#.triggerLayout), [triggerRedraw()](../lwtk/Component.md#.triggerRedraw), [updateFrameTransition()](../lwtk/Component.md#.updateFrameTransition), [_processChanges()](../lwtk/Component.md#._processChanges), [_processDraw()](../lwtk/Component.md#._processDraw), [_setFrame()](../lwtk/Component.md#._setFrame) * [Drawable](../lwtk/Drawable.md): * [getMandatoryStyleParam()](../lwtk/Drawable.md#.getMandatoryStyleParam), [_processMouseDown()](../lwtk/Drawable.md#._processMouseDown), [_processMouseEnter()](../lwtk/Drawable.md#._processMouseEnter), [_processMouseLeave()](../lwtk/Drawable.md#._processMouseLeave), [_processMouseMove()](../lwtk/Drawable.md#._processMouseMove), [_processMouseScroll()](../lwtk/Drawable.md#._processMouseScroll), [_processMouseUp()](../lwtk/Drawable.md#._processMouseUp) + * [Node](../lwtk/Node.md): + * [discard()](../lwtk/Node.md#.discard) * [Actionable](../lwtk/Actionable.md): * [hasActionMethod()](../lwtk/Actionable.md#.hasActionMethod), [invokeActionMethod()](../lwtk/Actionable.md#.invokeActionMethod) * **[Object](../lwtk/Object.md)**: diff --git a/doc/gen/lwtk/Window.md b/doc/gen/lwtk/Window.md index bb5e039..949dd06 100644 --- a/doc/gen/lwtk/Window.md +++ b/doc/gen/lwtk/Window.md @@ -68,7 +68,7 @@ ## Methods * **`Window:addChild(child)`** - * Implements: [Drawable:addChild()](../lwtk/Drawable.md#.addChild) + * Implements: [Node:addChild()](../lwtk/Node.md#.addChild) * **`Window:byId(id)`** @@ -204,13 +204,15 @@ ## Inherited Methods * [MouseDispatcher](../lwtk/MouseDispatcher.md): - * [_processMouseDown()](../lwtk/MouseDispatcher.md#._processMouseDown), [_processMouseEnter()](../lwtk/MouseDispatcher.md#._processMouseEnter), [_processMouseLeave()](../lwtk/MouseDispatcher.md#._processMouseLeave), [_processMouseMove()](../lwtk/MouseDispatcher.md#._processMouseMove), [_processMouseScroll()](../lwtk/MouseDispatcher.md#._processMouseScroll), [_processMouseUp()](../lwtk/MouseDispatcher.md#._processMouseUp) + * [removeChild()](../lwtk/MouseDispatcher.md#.removeChild), [_processMouseDown()](../lwtk/MouseDispatcher.md#._processMouseDown), [_processMouseEnter()](../lwtk/MouseDispatcher.md#._processMouseEnter), [_processMouseLeave()](../lwtk/MouseDispatcher.md#._processMouseLeave), [_processMouseMove()](../lwtk/MouseDispatcher.md#._processMouseMove), [_processMouseScroll()](../lwtk/MouseDispatcher.md#._processMouseScroll), [_processMouseUp()](../lwtk/MouseDispatcher.md#._processMouseUp) * [KeyHandler](../lwtk/KeyHandler.md): * [resetKeyHandling()](../lwtk/KeyHandler.md#.resetKeyHandling), [_handleKeyDown()](../lwtk/KeyHandler.md#._handleKeyDown), [_handleKeyUp()](../lwtk/KeyHandler.md#._handleKeyUp) * [Styleable](../lwtk/Styleable.md): * [clearStyleCache()](../lwtk/Styleable.md#.clearStyleCache), [getStateString()](../lwtk/Styleable.md#.getStateString), [getStyle()](../lwtk/Styleable.md#.getStyle), [getStyleParam()](../lwtk/Styleable.md#.getStyleParam), [setState()](../lwtk/Styleable.md#.setState), [setStyle()](../lwtk/Styleable.md#.setStyle), [_getStyleParam()](../lwtk/Styleable.md#._getStyleParam), [_setStyleFromParent()](../lwtk/Styleable.md#._setStyleFromParent) * [Drawable](../lwtk/Drawable.md): * [getMandatoryStyleParam()](../lwtk/Drawable.md#.getMandatoryStyleParam) + * [Node](../lwtk/Node.md): + * [discard()](../lwtk/Node.md#.discard) * [Actionable](../lwtk/Actionable.md): * [handleRemainingInitParams()](../lwtk/Actionable.md#.handleRemainingInitParams), [hasActionMethod()](../lwtk/Actionable.md#.hasActionMethod), [invokeActionMethod()](../lwtk/Actionable.md#.invokeActionMethod), [setInitParams()](../lwtk/Actionable.md#.setInitParams) * **[Object](../lwtk/Object.md)**: diff --git a/doc/gen/lwtk/discard.md b/doc/gen/lwtk/discard.md new file mode 100644 index 0000000..6672c08 --- /dev/null +++ b/doc/gen/lwtk/discard.md @@ -0,0 +1,7 @@ +# Function lwtk.discard + + * **`discard(arg)`** + + Discard object that should no longer be used. + + This function could be useful under Lua 5.1 which does not have ephemeron tables. diff --git a/doc/gen/lwtk/love/Application.md b/doc/gen/lwtk/love/Application.md index 97fdbeb..f4f305f 100644 --- a/doc/gen/lwtk/love/Application.md +++ b/doc/gen/lwtk/love/Application.md @@ -73,7 +73,9 @@ Use [lwtk.Application](../../lwtk/Application.md) for runing standalone desktop ## Inherited Methods * [MouseDispatcher](../../lwtk/MouseDispatcher.md): - * [_processMouseDown()](../../lwtk/MouseDispatcher.md#._processMouseDown), [_processMouseEnter()](../../lwtk/MouseDispatcher.md#._processMouseEnter), [_processMouseLeave()](../../lwtk/MouseDispatcher.md#._processMouseLeave), [_processMouseMove()](../../lwtk/MouseDispatcher.md#._processMouseMove), [_processMouseScroll()](../../lwtk/MouseDispatcher.md#._processMouseScroll), [_processMouseUp()](../../lwtk/MouseDispatcher.md#._processMouseUp) + * [removeChild()](../../lwtk/MouseDispatcher.md#.removeChild), [_processMouseDown()](../../lwtk/MouseDispatcher.md#._processMouseDown), [_processMouseEnter()](../../lwtk/MouseDispatcher.md#._processMouseEnter), [_processMouseLeave()](../../lwtk/MouseDispatcher.md#._processMouseLeave), [_processMouseMove()](../../lwtk/MouseDispatcher.md#._processMouseMove), [_processMouseScroll()](../../lwtk/MouseDispatcher.md#._processMouseScroll), [_processMouseUp()](../../lwtk/MouseDispatcher.md#._processMouseUp) + * [Node](../../lwtk/Node.md): + * [discard()](../../lwtk/Node.md#.discard) * **[Application](../../lwtk/Application.md)**: * [addStyle()](../../lwtk/Application.md#.addStyle), [close()](../../lwtk/Application.md#.close), [deferChanges()](../../lwtk/Application.md#.deferChanges), [getCurrentTime()](../../lwtk/Application.md#.getCurrentTime), [getFontInfo()](../../lwtk/Application.md#.getFontInfo), [getLayoutContext()](../../lwtk/Application.md#.getLayoutContext), [getScreenScale()](../../lwtk/Application.md#.getScreenScale), [hasWindows()](../../lwtk/Application.md#.hasWindows), [newWindow()](../../lwtk/Application.md#.newWindow), [runEventLoop()](../../lwtk/Application.md#.runEventLoop), [setErrorFunc()](../../lwtk/Application.md#.setErrorFunc), [setExtensions()](../../lwtk/Application.md#.setExtensions), [setStyle()](../../lwtk/Application.md#.setStyle), [setTimer()](../../lwtk/Application.md#.setTimer), [_addWindow()](../../lwtk/Application.md#._addWindow), [_processAllChanges()](../../lwtk/Application.md#._processAllChanges), [_removeWindow()](../../lwtk/Application.md#._removeWindow) * **[Object](../../lwtk/Object.md)**: diff --git a/doc/gen/lwtk/undef.md b/doc/gen/lwtk/undef.md deleted file mode 100644 index 9835312..0000000 --- a/doc/gen/lwtk/undef.md +++ /dev/null @@ -1,5 +0,0 @@ -# Function lwtk.undef - - * **`undef(class)`** - - diff --git a/doc/gen/lwtk/util.md b/doc/gen/lwtk/util.md new file mode 100644 index 0000000..16be3e6 --- /dev/null +++ b/doc/gen/lwtk/util.md @@ -0,0 +1,3 @@ +# Table lwtk.util + + diff --git a/doc/gen/modules.md b/doc/gen/modules.md index 7264163..8f3a46e 100644 --- a/doc/gen/modules.md +++ b/doc/gen/modules.md @@ -43,7 +43,7 @@ * [lwtk.Actionable](lwtk/Actionable.md) * [lwtk.Animatable](lwtk/Animatable.md) * [lwtk.Colored](lwtk/Colored.md) - * [lwtk.Compound](lwtk/Compound.md) + * [lwtk.Compound](lwtk/Compound.md) - Base for components that can have children. * [lwtk.Control](lwtk/Control.md) * [lwtk.Drawable](lwtk/Drawable.md) * [lwtk.Focusable](lwtk/Focusable.md) @@ -63,6 +63,7 @@ * [lwtk.DefaultKeyBinding](lwtk/DefaultKeyBinding.md) - Returns new [lwtk.KeyBinding](lwtk/KeyBinding.md) object with default settings. * [lwtk.btest](lwtk/btest.md) - Returns *true* if bitwise AND of its operands is different from zero. * [lwtk.call](lwtk/call.md) + * [lwtk.discard](lwtk/discard.md) - Discard object that should no longer be used. * [lwtk.errorf](lwtk/errorf.md) * [lwtk.extract](lwtk/extract.md) * [lwtk.getSuperClass](lwtk/getSuperClass.md) @@ -72,7 +73,6 @@ * [lwtk.newMixin](lwtk/newMixin.md) - Creates new mixin object. * [lwtk.tryrequire](lwtk/tryrequire.md) * [lwtk.type](lwtk/type.md) - Returns the type name. - * [lwtk.undef](lwtk/undef.md) ### Other * [lwtk.Class](lwtk/Class.md) - Metatable for objects created by [lwtk.newClass](lwtk/newClass.md)(). * [lwtk.Meta](lwtk/Meta.md) - Metatable for objects created by [lwtk.newMeta](lwtk/newMeta.md)(). @@ -83,6 +83,7 @@ * [lwtk.get](lwtk/get.md) * [lwtk.layout](lwtk/layout.md) * [lwtk.utf8](lwtk/utf8.md) + * [lwtk.util](lwtk/util.md) ## lwtk.love diff --git a/lwtk-scm-0.rockspec b/lwtk-scm-0.rockspec index 89fff67..61d2ed5 100644 --- a/lwtk-scm-0.rockspec +++ b/lwtk-scm-0.rockspec @@ -83,6 +83,7 @@ build = { ["lwtk._VERSION"] = "src/lwtk/_VERSION.lua", ["lwtk.btest"] = "src/lwtk/btest.lua", ["lwtk.call"] = "src/lwtk/call.lua", + ["lwtk.discard"] = "src/lwtk/discard.lua", ["lwtk.errorf"] = "src/lwtk/errorf.lua", ["lwtk.extract"] = "src/lwtk/extract.lua", ["lwtk.get"] = "src/lwtk/get.lua", @@ -98,8 +99,8 @@ build = { ["lwtk.newMixin"] = "src/lwtk/newMixin.lua", ["lwtk.tryrequire"] = "src/lwtk/tryrequire.lua", ["lwtk.type"] = "src/lwtk/type.lua", - ["lwtk.undef"] = "src/lwtk/undef.lua", ["lwtk.utf8"] = "src/lwtk/utf8.lua", + ["lwtk.util"] = "src/lwtk/util.lua", -- ["lwtk.internal"] = "src/lwtk/internal/init.lua", ["lwtk.internal.ColumnImpl"] = "src/lwtk/internal/ColumnImpl.lua", diff --git a/src/Makefile b/src/Makefile index 8ef6d0d..b06ee66 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,11 +1,14 @@ -.PHONY: default doc test doctest +.PHONY: default all doc doctest alltests default: doc doctest +all: doc doctest alltests + doc: lua mkdoc/main.lua -test: doctest - doctest: - lua doctest.lua $(sort $(wildcard ../doc/*.md)) + lua doctest.lua + +alltests: + lua alltests.lua diff --git a/src/activate.sh b/src/activate.sh new file mode 100644 index 0000000..4616cc4 --- /dev/null +++ b/src/activate.sh @@ -0,0 +1,105 @@ +# Activations script for add the lwtk module to the lua path when +# building lwtk using the Makefile. +# Source this into interactive shell by invoking ". activates.sh" from this directory +# This is not necessary if lwtk is installed, e.g. via luarocks. + +################################################### +if [ -n "$MSYSTEM" ]; then +################################################### +path_to_unix() +{ + cygpath -up $1 +} + +path_to_dos() +{ + cygpath -wp $1 +} + +so_ext=dll + +################################################### +else +################################################### +path_to_unix() +{ + echo $1|sed 's/;/:/g' +} + +path_to_dos() +{ + echo $1|sed 's/:/;/g' +} + +so_ext=so + +################################################### +fi +################################################### + +this_dir=$(pwd) + +lualwtk_dir=$(cd "$this_dir"/..; pwd) + +if [ ! -e "$lualwtk_dir/src/activate.sh" -o ! -e "$lualwtk_dir/src/lwtk/init.lua" ]; then + + echo '**** ERROR: ". activate.sh" must be invoked from "src" directory ***' + +else + + echo "Setting lua paths for: $lualwtk_dir" + + add_lua_path="$lualwtk_dir/src/?.lua:$lualwtk_dir/src/?/init.lua" + add_lua_cpath="$lualwtk_dir/src/build" + + # unset LUA_PATH_5_4 LUA_CPATH_5_4 LUA_PATH_5_3 LUA_CPATH_5_3 LUA_PATH_5_2 LUA_CPATH_5_2 LUA_PATH LUA_CPATH + + default_version="" + if which lua > /dev/null 2>&1; then + default_version=$(lua -e 'v=_VERSION:gsub("^Lua ","");print(v)') + fi + + if [ -n "$default_version" ]; then + if [ "$default_version" != "5.1" ]; then + echo "Setting path for lua (version=$default_version)" + lua_path_vers=$(echo $default_version|sed 's/\./_/') + eval "export LUA_PATH_$lua_path_vers=\"$(path_to_dos $add_lua_path:$(path_to_unix $(lua -e 'print(package.path)')))\"" + eval "export LUA_CPATH_$lua_path_vers=\"$(path_to_dos $add_lua_cpath/lua$default_version/?.$so_ext:$(path_to_unix $(lua -e 'print(package.cpath)')))\"" + fi + fi + + for vers in 5.4 5.3 5.2 5.1; do + lua_cmd="" + if which lua$vers > /dev/null 2>&1; then + lua_cmd="lua$vers" + elif which lua-$vers > /dev/null 2>&1; then + lua_cmd="lua-$vers" + fi + if [ -n "$lua_cmd" ]; then + lua_version=$($lua_cmd -e 'v=_VERSION:gsub("^Lua ","");print(v)') + if [ "$lua_version" != "$default_version" ]; then + echo "Setting path for $lua_cmd (version=$lua_version)" + if [ "$lua_version" = "5.1" ]; then + export LUA_PATH=$(path_to_dos "$add_lua_path:$(path_to_unix $($lua_cmd -e 'print(package.path)'))") + export LUA_CPATH=$(path_to_dos "$add_lua_cpath/lua5.1/?.$so_ext:$(path_to_unix $($lua_cmd -e 'print(package.cpath)'))") + else + lua_path_vers=$(echo $lua_version|sed 's/\./_/') + eval "export LUA_PATH_$lua_path_vers=\"$(path_to_dos $add_lua_path:$(path_to_unix $($lua_cmd -e 'print(package.path)')))\"" + eval "export LUA_CPATH_$lua_path_vers=\"$(path_to_dos $add_lua_cpath/lua$lua_version/?.$so_ext:$(path_to_unix $($lua_cmd -e 'print(package.cpath)')))\"" + fi + fi + fi + done + + if [ -n "$default_version" ]; then + if [ "$default_version" = "5.1" ]; then + echo "Setting path for lua (version=$default_version)" + export LUA_PATH="$(path_to_dos $add_lua_path:$(path_to_unix $(lua -e 'print(package.path)')))" + export LUA_CPATH="$(path_to_dos $add_lua_cpath/lua5.1/?.$so_ext:$(path_to_unix $(lua -e 'print(package.cpath)')))" + fi + fi +fi + +unset lua_cmd this_dir lualwtk_dir add_lua_path add_lua_cpath lua_version lua_path_vers vers default_version \ + path_to_unix path_to_dos so_ext + diff --git a/src/lwtk/Animatable.lua b/src/lwtk/Animatable.lua index 2651eb6..2017dd4 100644 --- a/src/lwtk/Animatable.lua +++ b/src/lwtk/Animatable.lua @@ -6,9 +6,9 @@ local getVisibilityChanges = lwtk.get.visibilityChanges local callOnLayout = lwtk.layout.callOnLayout -local getParamTransitions = lwtk.WeakKeysTable() -local getStateTransitions = lwtk.WeakKeysTable() -local getCurrentValues = lwtk.WeakKeysTable() +local getParamTransitions = lwtk.WeakKeysTable("lwtk.Animatable.getParamTransitions") +local getStateTransitions = lwtk.WeakKeysTable("lwtk.Animatable.getStateTransitions") +local getCurrentValues = lwtk.WeakKeysTable("lwtk.Animatable.getCurrentValues") local Styleable = lwtk.Styleable local Animatable = lwtk.newMixin("lwtk.Animatable", Styleable, Styleable.NO_STYLE_SELECTOR, @@ -25,6 +25,16 @@ local Animatable = lwtk.newMixin("lwtk.Animatable", Styleable, Styleable.NO_STYL getCurrentValues[self] = {} Super.new(self, initParams) end + + function Animatable.override:_setApp(app) + if not app then + local app = getApp[self] + if app then + app._animations:removeAnimation(self) + end + end + Super._setApp(self, app) + end end ) @@ -32,7 +42,7 @@ local getStyleParam = Styleable.getStyleParam local function addToAnimations(self) local app = assert(getApp[self], "widget not connected to application") - app._animations:add(self) + app._animations:addAnimation(self) end function Animatable.override:animateFrame(newX, newY, newW, newH, isLayoutTransition) diff --git a/src/lwtk/Animations.lua b/src/lwtk/Animations.lua index 0c6d04b..a832c2b 100644 --- a/src/lwtk/Animations.lua +++ b/src/lwtk/Animations.lua @@ -2,6 +2,9 @@ local lwtk = require("lwtk") local remove = table.remove local rawset = rawset +local rawget = rawget + +local getApp = lwtk.get.app local UPDATE_INTERVAL = 0.015 -- seconds local processAnimations @@ -9,23 +12,30 @@ local processAnimations local Animations = lwtk.newClass("lwtk.Animations") Animations:declare( - "app", "timer" ) function Animations:new(app) - self.app = app + getApp[self] = app self.timer = lwtk.Timer(processAnimations, self) end -function Animations:add(animatable) +function Animations:addAnimation(animatable) rawset(self, #self + 1, animatable) local timer = self.timer if not timer.time then - self.app:setTimer(UPDATE_INTERVAL, timer) + getApp[self]:setTimer(UPDATE_INTERVAL, timer) end end +function Animations:removeAnimation(animatable) + local found = 0 + for i = #self, 1, -1 do + if rawget(self, i) == animatable then + remove(self, i) + end + end +end function Animations:hasActive() return #self > 0 @@ -53,7 +63,7 @@ processAnimations = function(self) if #self > 0 then local timer = self.timer if not timer.time then - self.app:setTimer(UPDATE_INTERVAL, timer) + getApp[self]:setTimer(UPDATE_INTERVAL, timer) end end end diff --git a/src/lwtk/Application.lua b/src/lwtk/Application.lua index 012adbd..c47e8a8 100644 --- a/src/lwtk/Application.lua +++ b/src/lwtk/Application.lua @@ -16,7 +16,7 @@ local getVisibilityChanges = lwtk.get.visibilityChanges local getDeferredChanges = lwtk.get.deferredChanges local isInstanceOf = lwtk.isInstanceOf -local isClosed = lwtk.WeakKeysTable() +local isClosed = lwtk.WeakKeysTable("lwtk.Application.isClosed") --[[ Default application implementation. @@ -90,7 +90,7 @@ function Application:new(arg1, arg2) style = lwtk.DefaultStyle(initParams) end - getVisibilityChanges[self] = lwtk.WeakKeysTable() + getVisibilityChanges[self] = lwtk.WeakKeysTable("lwtk.Application.getVisibilityChanges") getDeferredChanges[self] = {} if getApp[style] then diff --git a/src/lwtk/ChildLookup.lua b/src/lwtk/ChildLookup.lua index b8b5959..632a462 100644 --- a/src/lwtk/ChildLookup.lua +++ b/src/lwtk/ChildLookup.lua @@ -40,12 +40,13 @@ function ChildLookup:__index(id) end function ChildLookup.clear(self) - if self[0] then + if self and self[0] then for k,v in pairs(self) do if type(k) == "string" then self[k] = nil end end + self[0] = false end end diff --git a/src/lwtk/Class.lua b/src/lwtk/Class.lua index 44c2b98..ea09839 100644 --- a/src/lwtk/Class.lua +++ b/src/lwtk/Class.lua @@ -7,6 +7,8 @@ local getObjectMeta = lwtk.get.objectMeta local getSuperClass = lwtk.get.superClass local getClass = lwtk.get.class +local WeakKeysTable = lwtk.WeakKeysTable + local DO_CHECKS = not _G.LWTK_DISABLE_CHECKS --[[ @@ -245,4 +247,18 @@ function implementMeta:__newindex(k, v) end end +function Class.discard(class) + local objectMeta = getObjectMeta[class] + if objectMeta then + WeakKeysTable.discard(objectMeta) + for k, v in next, objectMeta do + objectMeta[k] = nil + end + end + WeakKeysTable.discard(class) + for k, v in next, class do + class[k] = nil + end +end + return Class diff --git a/src/lwtk/Color.lua b/src/lwtk/Color.lua index 7896f19..f39718e 100644 --- a/src/lwtk/Color.lua +++ b/src/lwtk/Color.lua @@ -163,7 +163,9 @@ function Color.__add(color1, color2) end function Color.__eq(color1, color2) - return color1.r and color2.r + return getmetatable(color1) == Color + and getmetatable(color2) == Color + and color1.r and color2.r and color1.g and color2.g and color1.b and color2.b and floor(color1.r * 0xff) == floor(color2.r * 0xff) diff --git a/src/lwtk/Component.lua b/src/lwtk/Component.lua index 9d168b3..b02d8e8 100644 --- a/src/lwtk/Component.lua +++ b/src/lwtk/Component.lua @@ -11,12 +11,12 @@ local Animatable = lwtk.Animatable local intersectRects = Rect.intersectRects local roundRect = Rect.round +local WeakKeysTable = lwtk.WeakKeysTable local extract = lwtk.extract local getApp = lwtk.get.app local getRoot = lwtk.get.root local getParent = lwtk.get.parent local getFocusHandler = lwtk.get.focusHandler -local getFocusableChildren = lwtk.get.focusableChildren local callOnLayout = lwtk.layout.callOnLayout local getFontInfos = lwtk.get.fontInfos local getChildLookup = lwtk.get.childLookup @@ -29,6 +29,7 @@ Component:declare( "_animationTriggered", "_handleFocusIn", "_handleHasFocusHandler", + "_handleRemovedFocusHandler", "_hasChanges", "_isRelayouting", "_needsRedraw", @@ -122,7 +123,9 @@ function Component:getLayoutContext() end function Component:_setApp(app) - assert(not getApp[self], "Component was already added to Application") + if app then + assert(not getApp[self], "Component was already added to Application") + end getApp[self] = app getFontInfos[self] = getFontInfos[app] end @@ -159,20 +162,18 @@ local function setAppAndRoot(self, app, root) oldRoot._positionsChanged = nil end getRoot[self] = root - if app then + if app or getApp[self] then self:_setApp(app) end for i = 1, #self do local child = rawget(self, i) setAppAndRoot(child, app, root) end - if (self._handleFocusIn or self.onHotkeyEnabled) and not getFocusHandler[self] then + if app and (self._handleFocusIn or self.onHotkeyEnabled) and not getFocusHandler[self] then local handler = self:getFocusHandler() if handler then getFocusHandler[self] = handler - local focusableChildren = getFocusableChildren[handler] - focusableChildren[#focusableChildren + 1] = self - call("_handleHasFocusHandler", self, handler) + handler:_addFocusableChild(self) end end local w, h = self.w, self.h @@ -199,26 +200,53 @@ local function setAppAndRoot(self, app, root) end end +local function removeFocusHandler(self, handler) + if getFocusHandler[self] == handler then + getFocusHandler[self] = nil + end + for i = 1, #self do + removeFocusHandler(rawget(self, i), handler) + end +end + function Component:_setParent(parent) - assert(not getParent[self], "Component was already added to parent") - getParent[self] = parent - local app = getApp[parent] - setAppAndRoot(self, app, - getRoot[parent]) - local _needsRelayout = self._needsRelayout - if self._hasChanges then - local w = parent - repeat - if w._hasChanges and w._needsRelayout == _needsRelayout then - break - end - w._hasChanges = true - w._needsRelayout = _needsRelayout - w = getParent[w] - if not w and app then - app._hasChanges = true - end - until not w + if parent then + assert(not getParent[self], "Component was already added to parent") + getParent[self] = parent + local app = getApp[parent] + setAppAndRoot(self, app, + getRoot[parent]) + local _needsRelayout = self._needsRelayout + if self._hasChanges then + local w = parent + repeat + if w._hasChanges and w._needsRelayout == _needsRelayout then + break + end + w._hasChanges = true + w._needsRelayout = _needsRelayout + w = getParent[w] + if not w and app then + app._hasChanges = true + end + until not w + end + else + local oldParent = getParent[self] + if oldParent then + local handler = getFocusHandler[oldParent] + if handler then + handler:_removeFocusableChildren(self) + removeFocusHandler(self, handler) + end + end + getParent[self] = nil + getRoot[self] = nil + self:_setApp(nil) + for i = 1, #self do + local child = rawget(self, i) + setAppAndRoot(child, nil, self) + end end end diff --git a/src/lwtk/Compound.lua b/src/lwtk/Compound.lua index 2a6af0b..4a4f7e2 100644 --- a/src/lwtk/Compound.lua +++ b/src/lwtk/Compound.lua @@ -3,6 +3,9 @@ local lwtk = require"lwtk" local Rect = lwtk.Rect local intersectRects = Rect.intersectRects +--[[ + Base for components that can have children. +]] local Compound = lwtk.newMixin("lwtk.Compound", lwtk.Styleable.NO_STYLE_SELECTOR, function(Compound, Super) @@ -24,12 +27,82 @@ local Compound = lwtk.newMixin("lwtk.Compound", lwtk.Styleable.NO_STYLE_SELECTOR ) -function Compound.implement:addChild(child) - rawset(self, #self + 1, child) +--[[ + Adds child. + + * *child* - child object + * *index* - optional integer + + The *index* denotes the position where the child is inserted in the list. + Negative values are possible, 1 means the last position of the current list. + + If *index* is not given or 0, the child is inserted at the end of the list. + + Returns the removed child object. +]] +function Compound.implement:addChild(child, index) + if index then + if index <= 0 then + index = #self + index + 1 + end + for i = #self, index, -1 do + rawset(self, i + 1, rawget(self, i)) + end + else + index = #self + 1 + end + rawset(self, index, child) child:_setParent(self) return child end +--[[ + Removes child. + + * *child* - child object or child index. + + Returns the removed child object. +]] +function Compound.implement:removeChild(child) + if type(child) == "number" then + local n = child + if n <= 0 then + n = #self + n + 1 + end + child = rawget(self, n) + for i = n, #self do + rawset(self, i, rawget(self, i + 1)) + end + else + local found = false + for i = 1, #self do + if not found and rawget(self, i) == child then + found = i + end + if found then + rawset(self, i, rawget(self, i + 1)) + end + end + end + if child then + child:_setParent(nil) + end + return child +end + +--[[ + Discard child that should no longer be used. + + This function could be useful under Lua 5.1 which does not have ephemeron tables. +]] +function Compound.implement:discardChild(child) + child = self:removeChild(child) + if child then + child:discard() + end + return child +end + function Compound.override:_processDraw(ctx, x0, y0, cx, cy, cw, ch, exposedArea) local opacity = self:getStyleParam("Opacity") or 1 if opacity < 1 then diff --git a/src/lwtk/Drawable.lua b/src/lwtk/Drawable.lua index 1a1c963..9afbf19 100644 --- a/src/lwtk/Drawable.lua +++ b/src/lwtk/Drawable.lua @@ -9,7 +9,6 @@ Drawable:declare( "visible", "x", "y", "w", "h", "id", - "addChild", "_setStyleFromParent" ) diff --git a/src/lwtk/FocusGroup.lua b/src/lwtk/FocusGroup.lua index 7c13ef0..95870a8 100644 --- a/src/lwtk/FocusGroup.lua +++ b/src/lwtk/FocusGroup.lua @@ -4,7 +4,6 @@ local getApp = lwtk.get.app local getParent = lwtk.get.parent local getFocusHandler = lwtk.get.focusHandler local getParentFocusHandler = lwtk.get.parentFocusHandler -local getFocusableChildren = lwtk.get.focusableChildren local FocusHandler = lwtk.FocusHandler local Super = lwtk.Focusable(lwtk.Box) @@ -22,14 +21,15 @@ end function FocusGroup.override:_setApp(app) getApp[getFocusHandler[self]] = app Super._setApp(self, app) - local parentHandler = getParent[self]:getFocusHandler() - getParentFocusHandler[self] = parentHandler - local focusableChildren = getFocusableChildren[parentHandler] - focusableChildren[#focusableChildren + 1] = self - getFocusHandler[self]:_setParentFocusHandler(parentHandler) - if self._wantsFocus then - getParentFocusHandler[self]:setFocusTo(self) - self._wantsFocus = false + if app then + local parentHandler = getParent[self]:getFocusHandler() + getParentFocusHandler[self] = parentHandler + parentHandler:_addFocusableChild(self) + getFocusHandler[self]:_setParentFocusHandler(parentHandler) + if self._wantsFocus then + getParentFocusHandler[self]:setFocusTo(self) + self._wantsFocus = false + end end end diff --git a/src/lwtk/FocusHandler.lua b/src/lwtk/FocusHandler.lua index d50de7e..7f8cc65 100644 --- a/src/lwtk/FocusHandler.lua +++ b/src/lwtk/FocusHandler.lua @@ -10,9 +10,9 @@ local getFocusedChild = lwtk.get.focusedChild local getApp = lwtk.get.app local Callback = lwtk.Callback -local getDefault = lwtk.WeakKeysTable() -local getHotkeys = lwtk.WeakKeysTable() -local registeredWidgets = lwtk.WeakKeysTable() +local getDefault = lwtk.WeakKeysTable("lwtk.FocusHandler.getDefault") +local getHotkeys = lwtk.WeakKeysTable("lwtk.FocusHandler.getHotkeys") +local registeredWidgets = lwtk.WeakKeysTable("lwtk.FocusHandler.registeredWidgets") local Super = lwtk.Actionable() local FocusHandler = lwtk.newClass("lwtk.FocusHandler", Super) @@ -704,4 +704,45 @@ function FocusHandler:onActionCloseWindow() end +function FocusHandler:_addFocusableChild(child) + local focusableChildren = getFocusableChildren[self] + focusableChildren[#focusableChildren + 1] = child + call("_handleHasFocusHandler", child, self) +end + +local function removeChildren2(self, child, focusableChildren) + local found = false + for i = 1, #focusableChildren do + if not found and focusableChildren[i] == child then + found = i + end + if found then + focusableChildren[i] = focusableChildren[i+1] + end + end + if found then + call("_handleRemovedFocusHandler", child, self) + if getFocusedChild[self] == child then + local found = findNextFocusableChild2(self, child, "next", isFocusableChild) + if not found then + found = findNextFocusableChild2(self, child, "prev", isFocusableChild) + end + self:setFocusTo(found) + end + if getDefault[self] == child then + self:setDefault(child, false) + end + end + for i = 1, #child do + local cchild = rawget(child, i) + removeChildren2(self, cchild, focusableChildren) + end +end + +function FocusHandler:_removeFocusableChildren(child) + local focusableChildren = getFocusableChildren[self] + removeChildren2(self, child, focusableChildren) +end + + return FocusHandler diff --git a/src/lwtk/Group.lua b/src/lwtk/Group.lua index 52bb5e0..c15633f 100644 --- a/src/lwtk/Group.lua +++ b/src/lwtk/Group.lua @@ -14,8 +14,6 @@ Group:declare( "_handleChildRequestsFocus" ) -local Super_addChild = Super.addChild - function Group.override:new(initParams) Super.new(self) getChildLookup[self] = ChildLookup(self) @@ -52,8 +50,8 @@ function Group:childById(id) end end -function Group.override:addChild(child) - Super_addChild(self, child) +function Group.override:addChild(child, index) + Super.addChild(self, child, index) self:_clearChildLookup() local style = getStyle[self] if style then @@ -63,6 +61,17 @@ function Group.override:addChild(child) return child end +function Group.override:removeChild(child) + child = Super.removeChild(self, child) + self:_clearChildLookup() + local style = getStyle[self] + if style and child then + call("_setStyleFromParent", child, nil) + end + self:triggerLayout() + return child +end + return Group diff --git a/src/lwtk/HotkeyListener.lua b/src/lwtk/HotkeyListener.lua index 788edb5..a18d1a9 100644 --- a/src/lwtk/HotkeyListener.lua +++ b/src/lwtk/HotkeyListener.lua @@ -1,8 +1,8 @@ local lwtk = require("lwtk") local getFocusHandler = lwtk.get.focusHandler -local getHotkeys = lwtk.WeakKeysTable() -local registeredHotkeys = lwtk.WeakKeysTable() +local getHotkeys = lwtk.WeakKeysTable("lwtk.HotkeyListener.getHotkeys") +local registeredHotkeys = lwtk.WeakKeysTable("lwtk.HotkeyListener.registeredHotkeys") local processHotKeyRegistration @@ -31,6 +31,18 @@ local HotkeyListener = lwtk.newMixin("lwtk.HotkeyListener", lwtk.Styleable.NO_ST end end + function HotkeyListener.implement:_handleRemovedFocusHandler(focusHandler) + local superCall = Super._handleRemovedFocusHandler + if superCall then + superCall(self, focusHandler) + end + local hotkeys = getHotkeys[self] + if hotkeys then + focusHandler:deregisterHotkeys(self, hotkeys) + registeredHotkeys[self] = nil + end + end + local Super_onDisabled = Super.onDisabled function HotkeyListener.implement:onDisabled(disableFlag) diff --git a/src/lwtk/KeyHandler.lua b/src/lwtk/KeyHandler.lua index 8bb702f..ef73593 100644 --- a/src/lwtk/KeyHandler.lua +++ b/src/lwtk/KeyHandler.lua @@ -29,7 +29,7 @@ local isModifier = { Super_R = "Super" } -local getState = lwtk.WeakKeysTable() +local getState = lwtk.WeakKeysTable("lwtk.KeyHandler.getState") local KeyHandler = lwtk.newMixin("lwtk.KeyHandler", diff --git a/src/lwtk/LayoutFrame.lua b/src/lwtk/LayoutFrame.lua index d26cca4..0c9e32a 100644 --- a/src/lwtk/LayoutFrame.lua +++ b/src/lwtk/LayoutFrame.lua @@ -8,13 +8,11 @@ local LayoutFrame = lwtk.newMixin("lwtk.LayoutFrame", lwtk.Styleable.NO_STYLE_SE function(LayoutFrame, Super) - local Super_addChild = Super.addChild - - function LayoutFrame.override:addChild(child) - if rawget(self, 1) then + function LayoutFrame.override:addChild(child, index) + if rawget(self, 1) or index then lwtk.errorf("object of type %s can only have one child", lwtk.type(self)) end - return Super_addChild(self, child) + return Super.addChild(self, child) end end ) diff --git a/src/lwtk/Meta.lua b/src/lwtk/Meta.lua index d21173b..9d3b329 100644 --- a/src/lwtk/Meta.lua +++ b/src/lwtk/Meta.lua @@ -22,21 +22,12 @@ local lua_version = _VERSION:match("[%d%.]*$") local isOldLua = (#lua_version == 3 and lua_version < "5.3") if isOldLua then - if pcall(function() string.format("%p", {}) end) then - - Meta.fallbackToString = function(self) - local mt = getmetatable(self) - return string.format("%s: %p", mt.__name, self) -- luajit - end - else - Meta.fallbackToString = function(self) - local mt = debug.getmetatable(self) - local tmp = rawget(mt, "__tostring") - rawset(mt, "__tostring", nil) - local hash = tostring(self):match("([^ :]*)$") - rawset(mt, "__tostring", tmp) - return string.format("%s: %s", rawget(mt, "__name"), hash) -- lua5.1, lua5.2 - end + local getHashString = lwtk.util.getHashString + local format, getmt, rawget = string.format, debug.getmetatable, rawget + Meta.fallbackToString = function(self) + local mt = getmt(self) + local hash = getHashString(self) + return format("%s: %s", rawget(mt, "__name"), hash) end end diff --git a/src/lwtk/MouseDispatcher.lua b/src/lwtk/MouseDispatcher.lua index d0f6b4b..8a37cd3 100644 --- a/src/lwtk/MouseDispatcher.lua +++ b/src/lwtk/MouseDispatcher.lua @@ -18,6 +18,20 @@ local MouseDispatcher = lwtk.newMixin("lwtk.MouseDispatcher", lwtk.Styleable.NO_ self.mouseChildButtons = {} Super.new(self, initParams) end + + function MouseDispatcher.override:removeChild(child) + if Super.removeChild then + local removedChild = Super.removeChild(self, child) + if self.mouseHoverChild == removedChild then + self.mouseHoverChild = false + end + if self.mouseButtonChild == removedChild then + self.mouseButtonChild = false + end + return removedChild + end + end + end ) diff --git a/src/lwtk/Node.lua b/src/lwtk/Node.lua index d09e59b..858f5b1 100644 --- a/src/lwtk/Node.lua +++ b/src/lwtk/Node.lua @@ -1,5 +1,7 @@ local lwtk = require"lwtk" +local WeakKeysTable = lwtk.WeakKeysTable +local getParent = lwtk.get.parent local Node = lwtk.newMixin("lwtk.Node") @@ -16,8 +18,32 @@ Node:declare( "onMouseDown", "_processMouseUp", "onMouseUp", - "onInputChanged" + "onInputChanged", + + "addChild", + "removeChild", + "discardChild" ) +--[[ + Discard Node that should no longer be used. + + This function could be useful under Lua 5.1 which does not have ephemeron tables. +]] +function Node:discard() + local parent = getParent[self] + if parent then + local removeChild = parent.removeChild + if removeChild then + removeChild(parent, self) + else + getParent[self] = nil + end + end + WeakKeysTable.discard(self) + for i = #self, 1, -1 do + rawget(self, i):discard() + end +end return Node diff --git a/src/lwtk/Space.lua b/src/lwtk/Space.lua index ae40033..e9aea58 100644 --- a/src/lwtk/Space.lua +++ b/src/lwtk/Space.lua @@ -17,8 +17,8 @@ function Space:setUnlimited(unlimited) self.unlimited = unlimited end -function Space.override:addChild(child) - if rawget(self, 1) then +function Space.override:addChild(child, index) + if rawget(self, 1) or index then lwtk.errorf("object of type %s can only have one child", lwtk.type(self)) end return Super.addChild(self, child) diff --git a/src/lwtk/Square.lua b/src/lwtk/Square.lua index 7c8c2f7..84845ff 100644 --- a/src/lwtk/Square.lua +++ b/src/lwtk/Square.lua @@ -6,8 +6,8 @@ local setOuterMargins = lwtk.layout.setOuterMargins local Super = lwtk.Group local Square = lwtk.newClass("lwtk.Square", Super) -function Square.override:addChild(child) - if self[1] then +function Square.override:addChild(child, index) + if self[1] or index then lwtk.errorf("object of type %s can only have one child", lwtk.type(self)) end return Super.addChild(self, child) diff --git a/src/lwtk/Style.lua b/src/lwtk/Style.lua index 11980f6..c6a2f86 100644 --- a/src/lwtk/Style.lua +++ b/src/lwtk/Style.lua @@ -13,7 +13,7 @@ local StyleRuleContext = lwtk.internal.StyleRuleContext local Style = lwtk.newClass("lwtk.Style", lwtk.Object) -local childStyles = WeakKeysTable() +local childStyles = WeakKeysTable("lwtk.Style.childStyles") local toTypePattern = TypeRule.toPattern local toStylePattern = StyleRule.toPattern @@ -78,7 +78,7 @@ end local function addChildStyle(parent, child) local children = childStyles[parent] if not children then - children = WeakKeysTable() + children = WeakKeysTable("lwtk.Style.children") childStyles[parent] = children end children[child] = true diff --git a/src/lwtk/Styleable.lua b/src/lwtk/Styleable.lua index d11247d..e04ea94 100644 --- a/src/lwtk/Styleable.lua +++ b/src/lwtk/Styleable.lua @@ -11,7 +11,7 @@ local getStylePath = lwtk.get.stylePath local getSuperClass = lwtk.get.superClass local isInstanceOf = lwtk.isInstanceOf -local getStateStylePath = lwtk.WeakKeysTable() +local getStateStylePath = lwtk.WeakKeysTable("lwtk.Styleable.getStateStylePath") local NO_STYLE_SELECTOR = {} diff --git a/src/lwtk/ViewSwitcher.lua b/src/lwtk/ViewSwitcher.lua index 2aa273f..6c49f9e 100644 --- a/src/lwtk/ViewSwitcher.lua +++ b/src/lwtk/ViewSwitcher.lua @@ -62,7 +62,7 @@ function ViewSwitcher.implement:getMeasures() end end -function ViewSwitcher.override:addChild(child) +function ViewSwitcher.override:addChild(child, index) local childVisible = child.visible if childVisible then for i = 1, #self do @@ -75,7 +75,7 @@ function ViewSwitcher.override:addChild(child) end local topMargin, rightMargin, bottomMargin, leftMargin = getOuterMargins(self) setOuterMargins(child, topMargin, rightMargin, bottomMargin, leftMargin) - Super.addChild(self, child) + Super.addChild(self, child, index) child:setFrame(0, 0, self.w, self.h) if childVisible then child:setVisible(true) diff --git a/src/lwtk/WeakKeysTable.lua b/src/lwtk/WeakKeysTable.lua index 97cc5d6..1edd14f 100644 --- a/src/lwtk/WeakKeysTable.lua +++ b/src/lwtk/WeakKeysTable.lua @@ -1,7 +1,33 @@ local lwtk = require("lwtk") +local format = string.format +local getHashString = lwtk.util.getHashString + local WeakKeysTable = lwtk.newMeta("lwtk.WeakKeysTable") WeakKeysTable.__mode = "k" +WeakKeysTable.tableNames = setmetatable({}, { __mode = "k" }) + +local tableNames = WeakKeysTable.tableNames + +function WeakKeysTable:new(name) + tableNames[self] = name or false +end + +function WeakKeysTable:__tostring() + local n = tableNames[self] + if n then + return format("lwtk.WeakKeysTable(%q): %s", n, getHashString(self)) + else + return format("lwtk.WeakKeysTable: %s", getHashString(self)) + end +end + +function WeakKeysTable.discard(key) + for t, _ in pairs(tableNames) do + t[key] = nil + end +end + return WeakKeysTable diff --git a/src/lwtk/Widget.lua b/src/lwtk/Widget.lua index ec5946d..3f40d50 100644 --- a/src/lwtk/Widget.lua +++ b/src/lwtk/Widget.lua @@ -49,7 +49,7 @@ function Widget.override:_setApp(app) end Super._setApp(self, app) local onRealize = self.onRealize - if onRealize then + if onRealize and app then app:deferChanges(Callback(onRealize, self)) end end diff --git a/src/lwtk/Window.lua b/src/lwtk/Window.lua index f5cd865..1350976 100644 --- a/src/lwtk/Window.lua +++ b/src/lwtk/Window.lua @@ -53,7 +53,7 @@ local getFontInfos = lwtk.get.fontInfos local getChildLookup = lwtk.get.childLookup local extract = lwtk.extract -local childSizes = lwtk.WeakKeysTable() +local childSizes = lwtk.WeakKeysTable("lwtk.Window.childSizes") function Window.override:new(app, initParams) Super.new(self) diff --git a/src/lwtk/discard.lua b/src/lwtk/discard.lua new file mode 100644 index 0000000..79cd2b6 --- /dev/null +++ b/src/lwtk/discard.lua @@ -0,0 +1,37 @@ +local lwtk = require("lwtk") + +local pcall = pcall + +local WeakKeysTable = lwtk.WeakKeysTable + +local function tryget2(t, k) + return t[k] +end + +local function tryget(t, k) + local ok, rslt = pcall(tryget2, t, k) + if ok then + return rslt + end +end + +--[[ + Discard object that should no longer be used. + + This function could be useful under Lua 5.1 which does not have ephemeron tables. +]] +local function discard(arg) + if type(arg) == "table" then + local mt = getmetatable(arg) + if mt then + local d = tryget(mt, "discard") + if d then + return d(arg) + end + end + end + WeakKeysTable.discard(arg) + return arg +end + +return discard diff --git a/src/lwtk/get.lua b/src/lwtk/get.lua index 100a095..b2d67ba 100644 --- a/src/lwtk/get.lua +++ b/src/lwtk/get.lua @@ -4,25 +4,25 @@ local WeakKeysTable = lwtk.WeakKeysTable local get = {} -get.objectMeta = WeakKeysTable() -get.class = WeakKeysTable() -get.superClass = WeakKeysTable() -get.app = WeakKeysTable() -get.root = WeakKeysTable() -get.parent = WeakKeysTable() -get.style = WeakKeysTable() -get.focusHandler = WeakKeysTable() -get.parentFocusHandler = WeakKeysTable() -get.focusedChild = WeakKeysTable() +get.objectMeta = WeakKeysTable("lwtk.get.objectMeta") +get.class = WeakKeysTable("lwtk.get.class") +get.superClass = WeakKeysTable("lwtk.get.superClass") +get.app = WeakKeysTable("lwtk.get.app") +get.root = WeakKeysTable("lwtk.get.root") +get.parent = WeakKeysTable("lwtk.get.parent") +get.style = WeakKeysTable("lwtk.get.style") +get.focusHandler = WeakKeysTable("lwtk.get.focusHandler") +get.parentFocusHandler = WeakKeysTable("lwtk.get.parentFocusHandler") +get.focusedChild = WeakKeysTable("lwtk.get.focusedChild") -get.focusableChildren = WeakKeysTable() -get.actions = WeakKeysTable() -get.keyBinding = WeakKeysTable() -get.stylePath = WeakKeysTable() -get.fontInfos = WeakKeysTable() -get.childLookup = WeakKeysTable() -get.visibilityChanges = WeakKeysTable() -get.deferredChanges = WeakKeysTable() -get.mixinBase = WeakKeysTable() +get.focusableChildren = WeakKeysTable("lwtk.get.focusableChildren") +get.actions = WeakKeysTable("lwtk.get.actions") +get.keyBinding = WeakKeysTable("lwtk.get.keyBinding") +get.stylePath = WeakKeysTable("lwtk.get.stylePath") +get.fontInfos = WeakKeysTable("lwtk.get.fontInfos") +get.childLookup = WeakKeysTable("lwtk.get.childLookup") +get.visibilityChanges = WeakKeysTable("lwtk.get.visibilityChanges") +get.deferredChanges = WeakKeysTable("lwtk.get.deferredChanges") +get.mixinBase = WeakKeysTable("lwtk.get.mixinBase") return get diff --git a/src/lwtk/internal/ColumnImpl.lua b/src/lwtk/internal/ColumnImpl.lua index 2cf58a4..d7789a2 100644 --- a/src/lwtk/internal/ColumnImpl.lua +++ b/src/lwtk/internal/ColumnImpl.lua @@ -9,8 +9,8 @@ local calculateTBMeasures = lwtk.internal.LayoutImpl.calculateTBMeasures local applyLRLayout = lwtk.internal.LayoutImpl.applyLRLayout local applyTBLayout = lwtk.internal.LayoutImpl.applyTBLayout -local lr4Caches = lwtk.WeakKeysTable() -local tb4Caches = lwtk.WeakKeysTable() +local lr4Caches = lwtk.WeakKeysTable("lwtk.internal.ColumnImpl.lr4Caches") +local tb4Caches = lwtk.WeakKeysTable("lwtk.internal.ColumnImpl.tb4Caches") ------------------------------------------------------------------------------------------------- diff --git a/src/lwtk/layout.lua b/src/lwtk/layout.lua index 9cf6a29..b83e6d3 100644 --- a/src/lwtk/layout.lua +++ b/src/lwtk/layout.lua @@ -4,8 +4,8 @@ local format = string.format local floor = math.floor local type = lwtk.type -local outerMargins = lwtk.WeakKeysTable() -local measureCache = lwtk.WeakKeysTable() +local outerMargins = lwtk.WeakKeysTable("lwtk.layout.outerMargins") +local measureCache = lwtk.WeakKeysTable("lwtk.layout.measureCache") local isInLayout = false local layoutCounter = 0 diff --git a/src/lwtk/newMixin.lua b/src/lwtk/newMixin.lua index 59a7062..d61244a 100644 --- a/src/lwtk/newMixin.lua +++ b/src/lwtk/newMixin.lua @@ -7,8 +7,8 @@ local getSuperClass = lwtk.get.superClass local getObjectMeta = lwtk.get.objectMeta local getMixinBase = lwtk.get.mixinBase -local caches = lwtk.WeakKeysTable() -local mixins = lwtk.WeakKeysTable() +local caches = lwtk.WeakKeysTable("lwtk.newMixin.caches") +local mixins = lwtk.WeakKeysTable("lwtk.newMixin.mixins") local Mixin = lwtk.Mixin diff --git a/src/lwtk/undef.lua b/src/lwtk/undef.lua deleted file mode 100644 index 6d556b3..0000000 --- a/src/lwtk/undef.lua +++ /dev/null @@ -1,24 +0,0 @@ -local lwtk = require"lwtk" - -local get = lwtk.get - -local function undef(class) - if type(class) == "table" then - local objectMeta = get.objectMeta[class] - for k, v in pairs(get) do - v[class] = nil - if objectMeta then - v[objectMeta] = nil - end - end - if objectMeta then - for k, v in pairs(objectMeta) do - objectMeta[k] = nil - end - end - for k, v in pairs(class) do - class[k] = nil - end - end -end -return undef diff --git a/src/lwtk/util.lua b/src/lwtk/util.lua new file mode 100644 index 0000000..3b748ca --- /dev/null +++ b/src/lwtk/util.lua @@ -0,0 +1,29 @@ +local format = string.format + +local util = {} + +local lua_version = _VERSION:match("[%d%.]*$") +local isOldLua = (#lua_version == 3 and lua_version < "5.3") + +local getHashString + +if not isOldLua or pcall(function() format("%p", {}) end) then -- >=lua5.3, luajit + getHashString = function(self) + return format("%p", self) + end +else -- lua5.1, lua5.2 + local getmt = debug.getmetatable + local rawget, rawset, tostring, match = rawget, rawset, tostring, string.match + getHashString = function(self) + local mt = getmt(self) + local tmp = rawget(mt, "__tostring") + rawset(mt, "__tostring", nil) + local hash = match(tostring(self), "([^ :]*)$") + rawset(mt, "__tostring", tmp) + return hash + end +end + +util.getHashString = getHashString + +return util diff --git a/src/tests/test01.lua b/src/tests/test01.lua index a388ec4..4575165 100644 --- a/src/tests/test01.lua +++ b/src/tests/test01.lua @@ -110,16 +110,19 @@ do end PRINT("----------------------------------------------------------------------------------") do - local T = setmetatable({}, { __mode = "v" }) - T.C1 = lwtk.newClass("C1") + local ref = setmetatable({}, { __mode = "v" }) + ref.C1 = lwtk.newClass("C1") collectgarbage() if isLua51 then - assert(T.C1 ~= nil) - lwtk.undef(T.C1) + assert(ref.C1 ~= nil) + lwtk.discard(ref.C1) collectgarbage() - assert(T.C1 == nil) + collectgarbage() + collectgarbage() + collectgarbage() + assert(ref.C1 == nil) else - assert(T.C1 == nil) + assert(ref.C1 == nil) end end PRINT("----------------------------------------------------------------------------------") @@ -156,10 +159,6 @@ do assert(C3.extra.c == "c3") assert(not pcall(function() return c3.extra end)) end -if isLua51 then - lwtk.undef("C1") -- for Lua 5.1 - lwtk.undef("C2") -- for Lua 5.1 -end collectgarbage() PRINT("----------------------------------------------------------------------------------") do @@ -184,10 +183,6 @@ do assertEq(tostring(getSuperClass(getSuperClass(C2))), "lwtk.Class") assertEq(tostring(getSuperClass(getSuperClass(getSuperClass(C2)))), "lwtk.Class") end -if isLua51 then - lwtk.undef("C1") -- for Lua 5.1 - lwtk.undef("C2") -- for Lua 5.1 -end collectgarbage() PRINT("----------------------------------------------------------------------------------") do @@ -554,4 +549,189 @@ do end PRINT("----------------------------------------------------------------------------------") +do + local g= lwtk.Group { + style = { {"FooSize", 999} }, + lwtk.PushButton { text = "text1"}, + lwtk.PushButton { text = "text2"}, + lwtk.PushButton { text = "text3"}, + } + assert(g[1]:getStyleParam("FooSize") == 999) + assert(g[2]:getStyleParam("FooSize") == 999) + assert(g[3]:getStyleParam("FooSize") == 999) + local c = g:removeChild(g[2]) + assert(g[1]:getStyleParam("FooSize") == 999) + assert(g[2]:getStyleParam("FooSize") == 999) + assert(c :getStyleParam("FooSize") == nil) + g:addChild(c) + assert(g[1]:getStyleParam("FooSize") == 999) + assert(g[2]:getStyleParam("FooSize") == 999) + assert(g[3]:getStyleParam("FooSize") == 999) + assert(g[1].text == "text1") + assert(g[2].text == "text3") + assert(g[3].text == "text2") +end +PRINT("----------------------------------------------------------------------------------") +do + local g= lwtk.Group { + style = { {"FooSize", 999} }, + lwtk.PushButton { text = "text1"}, + lwtk.PushButton { text = "text2"}, + lwtk.PushButton { text = "text3"}, + } + assert(g[1]:getStyleParam("FooSize") == 999) + assert(g[2]:getStyleParam("FooSize") == 999) + assert(g[3]:getStyleParam("FooSize") == 999) + local c = g:removeChild(2) + assert(g[1]:getStyleParam("FooSize") == 999) + assert(g[2]:getStyleParam("FooSize") == 999) + assert(c :getStyleParam("FooSize") == nil) + g:addChild(c) + assert(g[1]:getStyleParam("FooSize") == 999) + assert(g[2]:getStyleParam("FooSize") == 999) + assert(g[3]:getStyleParam("FooSize") == 999) + assert(g[1].text == "text1") + assert(g[2].text == "text3") + assert(g[3].text == "text2") +end +PRINT("----------------------------------------------------------------------------------") +do + local g= lwtk.Group { + style = { {"FooSize", 999} }, + lwtk.PushButton { text = "text1"}, + lwtk.PushButton { text = "text2"}, + lwtk.PushButton { text = "text3"}, + } + assert(g[1]:getStyleParam("FooSize") == 999) + assert(g[2]:getStyleParam("FooSize") == 999) + assert(g[3]:getStyleParam("FooSize") == 999) + local c = g:removeChild(3) + assert(g[1]:getStyleParam("FooSize") == 999) + assert(g[2]:getStyleParam("FooSize") == 999) + assert(c :getStyleParam("FooSize") == nil) + g:addChild(c) + assert(g[1]:getStyleParam("FooSize") == 999) + assert(g[2]:getStyleParam("FooSize") == 999) + assert(g[3]:getStyleParam("FooSize") == 999) + assert(g[1].text == "text1") + assert(g[2].text == "text2") + assert(g[3].text == "text3") +end +PRINT("----------------------------------------------------------------------------------") +do + local g= lwtk.Group { + style = { {"FooSize", 999} }, + lwtk.PushButton { text = "text1"}, + lwtk.PushButton { text = "text2"}, + lwtk.PushButton { text = "text3"}, + } + assert(g[1]:getStyleParam("FooSize") == 999) + assert(g[2]:getStyleParam("FooSize") == 999) + assert(g[3]:getStyleParam("FooSize") == 999) + local c = g:removeChild(1) + assert(g[1]:getStyleParam("FooSize") == 999) + assert(g[2]:getStyleParam("FooSize") == 999) + assert(c :getStyleParam("FooSize") == nil) + g:addChild(c) + assert(g[1]:getStyleParam("FooSize") == 999) + assert(g[2]:getStyleParam("FooSize") == 999) + assert(g[3]:getStyleParam("FooSize") == 999) + assert(g[1].text == "text2") + assert(g[2].text == "text3") + assert(g[3].text == "text1") +end +PRINT("----------------------------------------------------------------------------------") +do + local g= lwtk.Group { + style = { {"FooSize", 999} }, + lwtk.PushButton { text = "text1"}, + lwtk.PushButton { text = "text2"}, + lwtk.PushButton { text = "text3"}, + } + assert(g[1]:getStyleParam("FooSize") == 999) + assert(g[2]:getStyleParam("FooSize") == 999) + assert(g[3]:getStyleParam("FooSize") == 999) + local ref = setmetatable({}, { __mode = "v" }) + ref.c = g:removeChild(g[2]) + assert(ref.c.text == "text2") + collectgarbage() + collectgarbage() + collectgarbage() + collectgarbage() + if isLua51 then + -- Lua 5.1 does not have ephemeron tables + assert(ref.c ~= nil) + ref.c:discard() + collectgarbage() + collectgarbage() + assert(ref.c == nil) + else + assert(ref.c == nil) + end +end +PRINT("----------------------------------------------------------------------------------") +do + local g1 = lwtk.Group { + lwtk.PushButton { text = "text11"}, + } + local g2 = lwtk.Group { + lwtk.PushButton { text = "text12"}, + } + local g0 = lwtk.Group { + style = { {"FooSize", 999} }, + g1, + g2 + } + assert(g2[1]:getStyleParam("FooSize") == 999) + assert(#g0 == 2) + assert(g0:removeChild(2) == g2) + assert(#g0 == 1) + assert(g2[1]:getStyleParam("FooSize") == nil) + local ref = setmetatable({}, { __mode = "v" }) + ref.c = g2 + g2 = nil + collectgarbage() + collectgarbage() + collectgarbage() + collectgarbage() + if isLua51 then + -- Lua 5.1 does not have ephemeron tables + assert(ref.c ~= nil) + lwtk.discard(ref.c) + collectgarbage() + collectgarbage() + assert(ref.c == nil) + else + assert(ref.c == nil) + end +end +PRINT("----------------------------------------------------------------------------------") +do + local g1 = lwtk.Group { + lwtk.PushButton { text = "text11"}, + } + local g2 = lwtk.Group { + lwtk.PushButton { text = "text12"}, + } + local g0 = lwtk.Group { + style = { {"FooSize", 999} }, + g1, + g2 + } + assert(g2[1]:getStyleParam("FooSize") == 999) + assert(#g0 == 2) + assert(g0:discardChild(2) == g2) + assert(#g0 == 1) + assert(g0[1] == g1) + assert(g2[1] == nil) + local ref = setmetatable({}, { __mode = "v" }) + ref.c = g2 + g2 = nil + collectgarbage() + collectgarbage() + collectgarbage() + collectgarbage() + assert(ref.c == nil) +end +PRINT("----------------------------------------------------------------------------------") print("OK.")