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
|
||||
__gshared const(ActionState) ACTION_STATE_DEFAULT_ENABLED;
|
||||
__gshared const(ActionState) ACTION_STATE_DEFAULT_DISABLE;
|
||||
__gshared const(ActionState) ACTION_STATE_DEFAULT_INVISIBLE;
|
||||
__gshared const(ActionState) ACTION_STATE_ENABLED;
|
||||
__gshared const(ActionState) ACTION_STATE_DISABLE;
|
||||
__gshared const(ActionState) ACTION_STATE_INVISIBLE;
|
||||
|
||||
__gshared static this() {
|
||||
ACTION_STATE_DEFAULT_ENABLED = cast(const(ActionState))new ActionState(true, true, false);
|
||||
ACTION_STATE_DEFAULT_DISABLE = cast(const(ActionState))new ActionState(false, true, false);
|
||||
ACTION_STATE_DEFAULT_INVISIBLE = cast(const(ActionState))new ActionState(false, false, false);
|
||||
ACTION_STATE_ENABLED = cast(const(ActionState))new ActionState(true, true, false);
|
||||
ACTION_STATE_DISABLE = cast(const(ActionState))new ActionState(false, true, false);
|
||||
ACTION_STATE_INVISIBLE = cast(const(ActionState))new ActionState(false, false, false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -106,21 +106,25 @@ class Action {
|
|||
|
||||
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
|
||||
@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
|
||||
@property Action defaultState(ActionState s) { _defaultState = s; return this; }
|
||||
/// 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)
|
||||
@property Action state(const ActionState s) {
|
||||
if (_state != s)
|
||||
if (!_state || _state != s)
|
||||
_state = s.clone();
|
||||
return this;
|
||||
}
|
||||
/// update action state (can be changed even for const objects)
|
||||
@property const(Action) state(const ActionState s) const {
|
||||
if (_state != s) {
|
||||
if (!_state || _state != s) {
|
||||
// hack
|
||||
Action nonConstThis = cast(Action) this;
|
||||
nonConstThis._state = s.clone();
|
||||
|
|
|
@ -848,14 +848,18 @@ class Window {
|
|||
protected void setCursorType(uint cursorType) {
|
||||
// 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
|
||||
bool checkUpdateNeeded(ref bool needDraw, ref bool needLayout, ref bool animationActive) {
|
||||
if (_actionsUpdateRequested) {
|
||||
// call update action check - as requested
|
||||
if (_mainWidget !is null)
|
||||
dispatchWidgetUpdateActionStateRecursive(_mainWidget);
|
||||
foreach(p; _popups)
|
||||
dispatchWidgetUpdateActionStateRecursive(p);
|
||||
dispatchWidgetUpdateActionStateRecursive();
|
||||
_actionsUpdateRequested = false;
|
||||
}
|
||||
needDraw = needLayout = animationActive = false;
|
||||
|
@ -884,10 +888,14 @@ class Window {
|
|||
/// close window
|
||||
abstract void close();
|
||||
|
||||
protected bool _actionsUpdateRequested;
|
||||
protected bool _actionsUpdateRequested = true;
|
||||
|
||||
/// set action update request flag, will be cleared after redraw
|
||||
void requestActionsUpdate() {
|
||||
_actionsUpdateRequested = true;
|
||||
void requestActionsUpdate(bool immediateUpdate = false) {
|
||||
if (!immediateUpdate)
|
||||
_actionsUpdateRequested = true;
|
||||
else
|
||||
dispatchWidgetUpdateActionStateRecursive();
|
||||
}
|
||||
|
||||
@property bool actionsUpdateRequested() {
|
||||
|
|
|
@ -86,6 +86,7 @@ class AppFrame : VerticalLayout, MenuItemClickHandler, MenuItemActionHandler {
|
|||
destroy(_currentBackgroundOperation);
|
||||
_currentBackgroundOperation = null;
|
||||
_currentBackgroundOperationTimer = 0;
|
||||
requestActionsUpdate();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -106,6 +107,7 @@ class AppFrame : VerticalLayout, MenuItemClickHandler, MenuItemActionHandler {
|
|||
_currentBackgroundOperation = op;
|
||||
if (op)
|
||||
_currentBackgroundOperationTimer = setTimer(op.updateInterval);
|
||||
requestActionsUpdate();
|
||||
}
|
||||
|
||||
/// main menu widget
|
||||
|
|
|
@ -401,7 +401,7 @@ class TabControl : WidgetGroupDefaultDrawing {
|
|||
return true;
|
||||
}
|
||||
/// Measure widget according to desired width and height constraints. (Step 1 of two phase layout).
|
||||
override void measure(int parentWidth, int parentHeight) {
|
||||
override void measure(int parentWidth, int parentHeight) {
|
||||
//Log.d("tabControl.measure enter");
|
||||
Rect m = margins;
|
||||
Rect p = padding;
|
||||
|
@ -747,4 +747,14 @@ class TabWidget : VerticalLayout, TabHandler, TabCloseHandler {
|
|||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
/// 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;
|
||||
/*****************************************
|
||||
|
|
|
@ -311,13 +311,17 @@
|
|||
align="Center"
|
||||
margins="1,1,1,1"
|
||||
padding="2,2,2,2"
|
||||
/>
|
||||
>
|
||||
<state state_enabled="false" alpha="160" backgroundImageId="@null"/>
|
||||
</style>
|
||||
<style id="TOOLBAR_CONTROL"
|
||||
backgroundImageId="toolbar_control_background"
|
||||
align="Center"
|
||||
margins="1,1,1,1"
|
||||
padding="2,2,2,2"
|
||||
/>
|
||||
>
|
||||
<state state_enabled="false" alpha="160" backgroundImageId="@null"/>
|
||||
</style>
|
||||
<style id="TOOLBAR_SEPARATOR"
|
||||
align="Center"
|
||||
/>
|
||||
|
|
Loading…
Reference in New Issue