mirror of https://github.com/buggins/dlangui.git
actions update - working
This commit is contained in:
parent
a1ee2ba8b1
commit
055979b9e7
|
@ -69,14 +69,14 @@ class ActionState {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// action is
|
/// action is
|
||||||
__gshared const(ActionState) ACTION_STATE_DEFAULT_ENABLED;
|
__gshared const(ActionState) ACTION_STATE_ENABLED;
|
||||||
__gshared const(ActionState) ACTION_STATE_DEFAULT_DISABLE;
|
__gshared const(ActionState) ACTION_STATE_DISABLE;
|
||||||
__gshared const(ActionState) ACTION_STATE_DEFAULT_INVISIBLE;
|
__gshared const(ActionState) ACTION_STATE_INVISIBLE;
|
||||||
|
|
||||||
__gshared static this() {
|
__gshared static this() {
|
||||||
ACTION_STATE_DEFAULT_ENABLED = cast(const(ActionState))new ActionState(true, true, false);
|
ACTION_STATE_ENABLED = cast(const(ActionState))new ActionState(true, true, false);
|
||||||
ACTION_STATE_DEFAULT_DISABLE = cast(const(ActionState))new ActionState(false, true, false);
|
ACTION_STATE_DISABLE = cast(const(ActionState))new ActionState(false, true, false);
|
||||||
ACTION_STATE_DEFAULT_INVISIBLE = cast(const(ActionState))new ActionState(false, false, false);
|
ACTION_STATE_INVISIBLE = cast(const(ActionState))new ActionState(false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -106,21 +106,25 @@ class Action {
|
||||||
|
|
||||||
protected ActionState _defaultState;
|
protected ActionState _defaultState;
|
||||||
|
|
||||||
|
/// set default state to disabled, visible, not-checked
|
||||||
|
Action disableByDefault() { _defaultState = new ActionState(false, true, false); return this; }
|
||||||
|
/// set default state to disabled, invisible, not-checked
|
||||||
|
Action hideByDefault() { _defaultState = new ActionState(false, false, false); return this; }
|
||||||
/// default state for action if action state lookup failed
|
/// default state for action if action state lookup failed
|
||||||
@property const(ActionState) defaultState() const { return _defaultState ? _defaultState : ACTION_STATE_DEFAULT_ENABLED; }
|
@property const(ActionState) defaultState() const { return _defaultState ? _defaultState : ACTION_STATE_ENABLED; }
|
||||||
/// default state for action if action state lookup failed
|
/// default state for action if action state lookup failed
|
||||||
@property Action defaultState(ActionState s) { _defaultState = s; return this; }
|
@property Action defaultState(ActionState s) { _defaultState = s; return this; }
|
||||||
/// action state
|
/// action state
|
||||||
@property const(ActionState) state() const { return _state ? _state : (_defaultState ? _defaultState : ACTION_STATE_DEFAULT_ENABLED); }
|
@property const(ActionState) state() const { return _state ? _state : (_defaultState ? _defaultState : ACTION_STATE_ENABLED); }
|
||||||
/// update action state (for non-const action)
|
/// update action state (for non-const action)
|
||||||
@property Action state(const ActionState s) {
|
@property Action state(const ActionState s) {
|
||||||
if (_state != s)
|
if (!_state || _state != s)
|
||||||
_state = s.clone();
|
_state = s.clone();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/// update action state (can be changed even for const objects)
|
/// update action state (can be changed even for const objects)
|
||||||
@property const(Action) state(const ActionState s) const {
|
@property const(Action) state(const ActionState s) const {
|
||||||
if (_state != s) {
|
if (!_state || _state != s) {
|
||||||
// hack
|
// hack
|
||||||
Action nonConstThis = cast(Action) this;
|
Action nonConstThis = cast(Action) this;
|
||||||
nonConstThis._state = s.clone();
|
nonConstThis._state = s.clone();
|
||||||
|
|
|
@ -848,14 +848,18 @@ class Window {
|
||||||
protected void setCursorType(uint cursorType) {
|
protected void setCursorType(uint cursorType) {
|
||||||
// override to support different mouse cursors
|
// override to support different mouse cursors
|
||||||
}
|
}
|
||||||
|
/// update action states
|
||||||
|
protected void dispatchWidgetUpdateActionStateRecursive() {
|
||||||
|
if (_mainWidget !is null)
|
||||||
|
dispatchWidgetUpdateActionStateRecursive(_mainWidget);
|
||||||
|
foreach(p; _popups)
|
||||||
|
dispatchWidgetUpdateActionStateRecursive(p);
|
||||||
|
}
|
||||||
/// checks content widgets for necessary redraw and/or layout
|
/// checks content widgets for necessary redraw and/or layout
|
||||||
bool checkUpdateNeeded(ref bool needDraw, ref bool needLayout, ref bool animationActive) {
|
bool checkUpdateNeeded(ref bool needDraw, ref bool needLayout, ref bool animationActive) {
|
||||||
if (_actionsUpdateRequested) {
|
if (_actionsUpdateRequested) {
|
||||||
// call update action check - as requested
|
// call update action check - as requested
|
||||||
if (_mainWidget !is null)
|
dispatchWidgetUpdateActionStateRecursive();
|
||||||
dispatchWidgetUpdateActionStateRecursive(_mainWidget);
|
|
||||||
foreach(p; _popups)
|
|
||||||
dispatchWidgetUpdateActionStateRecursive(p);
|
|
||||||
_actionsUpdateRequested = false;
|
_actionsUpdateRequested = false;
|
||||||
}
|
}
|
||||||
needDraw = needLayout = animationActive = false;
|
needDraw = needLayout = animationActive = false;
|
||||||
|
@ -884,10 +888,14 @@ class Window {
|
||||||
/// close window
|
/// close window
|
||||||
abstract void close();
|
abstract void close();
|
||||||
|
|
||||||
protected bool _actionsUpdateRequested;
|
protected bool _actionsUpdateRequested = true;
|
||||||
|
|
||||||
/// set action update request flag, will be cleared after redraw
|
/// set action update request flag, will be cleared after redraw
|
||||||
void requestActionsUpdate() {
|
void requestActionsUpdate(bool immediateUpdate = false) {
|
||||||
_actionsUpdateRequested = true;
|
if (!immediateUpdate)
|
||||||
|
_actionsUpdateRequested = true;
|
||||||
|
else
|
||||||
|
dispatchWidgetUpdateActionStateRecursive();
|
||||||
}
|
}
|
||||||
|
|
||||||
@property bool actionsUpdateRequested() {
|
@property bool actionsUpdateRequested() {
|
||||||
|
|
|
@ -86,6 +86,7 @@ class AppFrame : VerticalLayout, MenuItemClickHandler, MenuItemActionHandler {
|
||||||
destroy(_currentBackgroundOperation);
|
destroy(_currentBackgroundOperation);
|
||||||
_currentBackgroundOperation = null;
|
_currentBackgroundOperation = null;
|
||||||
_currentBackgroundOperationTimer = 0;
|
_currentBackgroundOperationTimer = 0;
|
||||||
|
requestActionsUpdate();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -106,6 +107,7 @@ class AppFrame : VerticalLayout, MenuItemClickHandler, MenuItemActionHandler {
|
||||||
_currentBackgroundOperation = op;
|
_currentBackgroundOperation = op;
|
||||||
if (op)
|
if (op)
|
||||||
_currentBackgroundOperationTimer = setTimer(op.updateInterval);
|
_currentBackgroundOperationTimer = setTimer(op.updateInterval);
|
||||||
|
requestActionsUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// main menu widget
|
/// main menu widget
|
||||||
|
|
|
@ -747,4 +747,14 @@ class TabWidget : VerticalLayout, TabHandler, TabCloseHandler {
|
||||||
}
|
}
|
||||||
return super.onKeyEvent(event);
|
return super.onKeyEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@property string selectedTabId() const {
|
||||||
|
return _tabControl._selectedTabId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// get tab content widget by id
|
||||||
|
Widget selectedTabBody() {
|
||||||
|
return _tabHost.tabBody(_tabControl._selectedTabId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -669,6 +669,12 @@ class Widget {
|
||||||
visibility = s.visible ? Visibility.Visible : Visibility.Gone;
|
visibility = s.visible ? Visibility.Visible : Visibility.Gone;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// set action update request flag, will be cleared after redraw
|
||||||
|
void requestActionsUpdate(bool immediateUpdate = false) {
|
||||||
|
if (Window w = window) {
|
||||||
|
w.requestActionsUpdate(immediateUpdate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected bool _focusGroup;
|
protected bool _focusGroup;
|
||||||
/*****************************************
|
/*****************************************
|
||||||
|
|
|
@ -311,13 +311,17 @@
|
||||||
align="Center"
|
align="Center"
|
||||||
margins="1,1,1,1"
|
margins="1,1,1,1"
|
||||||
padding="2,2,2,2"
|
padding="2,2,2,2"
|
||||||
/>
|
>
|
||||||
|
<state state_enabled="false" alpha="160" backgroundImageId="@null"/>
|
||||||
|
</style>
|
||||||
<style id="TOOLBAR_CONTROL"
|
<style id="TOOLBAR_CONTROL"
|
||||||
backgroundImageId="toolbar_control_background"
|
backgroundImageId="toolbar_control_background"
|
||||||
align="Center"
|
align="Center"
|
||||||
margins="1,1,1,1"
|
margins="1,1,1,1"
|
||||||
padding="2,2,2,2"
|
padding="2,2,2,2"
|
||||||
/>
|
>
|
||||||
|
<state state_enabled="false" alpha="160" backgroundImageId="@null"/>
|
||||||
|
</style>
|
||||||
<style id="TOOLBAR_SEPARATOR"
|
<style id="TOOLBAR_SEPARATOR"
|
||||||
align="Center"
|
align="Center"
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in New Issue