mirror of https://github.com/buggins/dlangui.git
toolbars support
This commit is contained in:
parent
462dcb2eb7
commit
fd4b00bfb4
|
@ -392,6 +392,7 @@
|
|||
<File path="src\dlangui\widgets\statusline.d" />
|
||||
<File path="src\dlangui\widgets\styles.d" />
|
||||
<File path="src\dlangui\widgets\tabs.d" />
|
||||
<File path="src\dlangui\widgets\toolbars.d" />
|
||||
<File path="src\dlangui\widgets\tree.d" />
|
||||
<File path="src\dlangui\widgets\widget.d" />
|
||||
</Folder>
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 251 B |
Binary file not shown.
After Width: | Height: | Size: 224 B |
|
@ -261,6 +261,28 @@
|
|||
layoutHeight="FILL_PARENT"
|
||||
padding="1,1,1,1"
|
||||
/>
|
||||
|
||||
<style id="TOOLBAR_HOST"
|
||||
backgroundColor="#d6dbe9"
|
||||
layoutWidth="FILL_PARENT"
|
||||
layoutHeight="WRAP_CONTENT"
|
||||
padding="1,1,1,1"
|
||||
/>
|
||||
<style id="TOOLBAR"
|
||||
backgroundImageId="toolbar_background"
|
||||
layoutWidth="WRAP_CONTENT"
|
||||
layoutHeight="WRAP_CONTENT"
|
||||
margins="2,2,2,2"
|
||||
/>
|
||||
<style id="TOOLBAR_BUTTON"
|
||||
backgroundImageId="btn_background_transparent"
|
||||
align="Center"
|
||||
margins="2,2,2,2"
|
||||
/>
|
||||
<style id="TOOLBAR_SEPARATOR"
|
||||
align="Center"
|
||||
/>
|
||||
|
||||
<style id="TREE_ITEM"
|
||||
padding="2,2,2,2"
|
||||
margins="0,0,0,0"
|
||||
|
|
|
@ -198,12 +198,21 @@ class Action {
|
|||
_iconId = id;
|
||||
return this;
|
||||
}
|
||||
/// returns true if it's dummy action to specify separator
|
||||
@property bool isSeparator() const {
|
||||
return _id == SEPARATOR_ACTION_ID;
|
||||
}
|
||||
|
||||
override string toString() const {
|
||||
return "Action(" ~ to!string(_id) ~ ")";
|
||||
}
|
||||
}
|
||||
|
||||
/// use this ID for menu and toolbar separators
|
||||
const int SEPARATOR_ACTION_ID = -1;
|
||||
__gshared Action ACTION_SEPARATOR = new Action(SEPARATOR_ACTION_ID);
|
||||
|
||||
|
||||
/// Map of Accelerator to Action
|
||||
struct ActionMap {
|
||||
protected Action[Accelerator] _map;
|
||||
|
|
|
@ -22,15 +22,19 @@ import dlangui.widgets.widget;
|
|||
import dlangui.widgets.menu;
|
||||
import dlangui.widgets.layouts;
|
||||
import dlangui.widgets.statusline;
|
||||
import dlangui.widgets.toolbars;
|
||||
|
||||
class AppFrame : VerticalLayout, MenuItemClickHandler {
|
||||
protected MainMenu _mainMenu;
|
||||
protected StatusLine _statusLine;
|
||||
protected ToolBarHost _toolbarHost;
|
||||
protected Widget _body;
|
||||
/// main menu widget
|
||||
@property MainMenu mainMenu() { return _mainMenu; }
|
||||
/// status line widget
|
||||
@property StatusLine statusLine() { return _statusLine; }
|
||||
/// tool bar host
|
||||
@property ToolBarHost toolbars() { return _toolbarHost; }
|
||||
/// body widget
|
||||
@property Widget frameBody() { return _body; }
|
||||
|
||||
|
@ -43,12 +47,19 @@ class AppFrame : VerticalLayout, MenuItemClickHandler {
|
|||
|
||||
protected void init() {
|
||||
_mainMenu = createMainMenu();
|
||||
_mainMenu.onMenuItemClickListener = &onMenuItemClick;
|
||||
_toolbarHost = createToolbars();
|
||||
_statusLine = createStatusLine();
|
||||
_body = createBody();
|
||||
addChild(_mainMenu);
|
||||
_body.focusGroup = true;
|
||||
if (_mainMenu) {
|
||||
_mainMenu.onMenuItemClickListener = &onMenuItemClick;
|
||||
addChild(_mainMenu);
|
||||
}
|
||||
if (_toolbarHost)
|
||||
addChild(_toolbarHost);
|
||||
addChild(_body);
|
||||
addChild(_statusLine);
|
||||
if (_statusLine)
|
||||
addChild(_statusLine);
|
||||
}
|
||||
|
||||
/// override to handle main menu commands
|
||||
|
@ -61,6 +72,14 @@ class AppFrame : VerticalLayout, MenuItemClickHandler {
|
|||
return new MainMenu(new MenuItem());
|
||||
}
|
||||
|
||||
|
||||
/// create app toolbars
|
||||
protected ToolBarHost createToolbars() {
|
||||
ToolBarHost res = new ToolBarHost();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/// create app status line widget
|
||||
protected StatusLine createStatusLine() {
|
||||
return new StatusLine();
|
||||
|
|
|
@ -1,8 +1,30 @@
|
|||
// Written in the D programming language.
|
||||
|
||||
/**
|
||||
|
||||
This module implements dockable windows UI support.
|
||||
|
||||
DockHost is main layout for docking support - contains body widget and optional docked windows.
|
||||
|
||||
DockWindow is window to use with DockHost - can be docked on top, left, right or bottom side of DockHost.
|
||||
|
||||
Synopsis:
|
||||
|
||||
----
|
||||
import dlangui.widgets.docks;
|
||||
----
|
||||
|
||||
|
||||
Copyright: Vadim Lopatin, 2015
|
||||
License: Boost License 1.0
|
||||
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||
*/
|
||||
module dlangui.widgets.docks;
|
||||
|
||||
import dlangui.widgets.layouts;
|
||||
import dlangui.widgets.controls;
|
||||
|
||||
/// Layout for docking support - contains body widget and optional docked windows
|
||||
class DockHost : WidgetGroupDefaultDrawing {
|
||||
|
||||
protected int _topSpace;
|
||||
|
@ -127,6 +149,7 @@ enum DockAlignment {
|
|||
Bottom
|
||||
}
|
||||
|
||||
/// docked window
|
||||
class DockWindow : VerticalLayout {
|
||||
|
||||
protected Widget _bodyWidget;
|
||||
|
|
|
@ -67,7 +67,7 @@ class MenuItem {
|
|||
/// handle menu item click action (parameter is Action)
|
||||
Signal!MenuItemActionHandler onMenuItemAction;
|
||||
/// item action id, 0 if no action
|
||||
@property int id() { return _action is null ? 0 : _action.id; }
|
||||
@property int id() const { return _action is null ? 0 : _action.id; }
|
||||
/// returns count of submenu items
|
||||
@property int subitemCount() {
|
||||
return cast(int)_subitems.length;
|
||||
|
@ -85,6 +85,8 @@ class MenuItem {
|
|||
}
|
||||
|
||||
@property MenuItemType type() const {
|
||||
if (id == SEPARATOR_ACTION_ID)
|
||||
return MenuItemType.Separator;
|
||||
if (_subitems.length > 0) // if there are children, force type to Submenu
|
||||
return MenuItemType.Submenu;
|
||||
return _type;
|
||||
|
@ -154,15 +156,24 @@ class MenuItem {
|
|||
return -1;
|
||||
}
|
||||
|
||||
/// Add separator item
|
||||
MenuItem addSeparator() {
|
||||
return add(new Action(SEPARATOR_ACTION_ID));
|
||||
}
|
||||
|
||||
/// adds submenu item
|
||||
MenuItem add(MenuItem subitem) {
|
||||
_subitems ~= subitem;
|
||||
subitem._parent = this;
|
||||
return this;
|
||||
}
|
||||
/// adds submenu item from action
|
||||
MenuItem add(Action subitemAction) {
|
||||
return add(new MenuItem(subitemAction));
|
||||
/// adds submenu item(s) from one or more actions (will return item for last action)
|
||||
MenuItem add(Action[] subitemActions...) {
|
||||
MenuItem res = null;
|
||||
foreach(subitemAction; subitemActions) {
|
||||
res = add(new MenuItem(subitemAction));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
/// returns text description for first accelerator of action; null if no accelerators
|
||||
@property dstring acceleratorText() {
|
||||
|
|
|
@ -132,6 +132,16 @@ immutable string STYLE_DOCK_WINDOW_CAPTION_LABEL = "DOCK_WINDOW_CAPTION_LABEL";
|
|||
/// standard style id for dock window body
|
||||
immutable string STYLE_DOCK_WINDOW_BODY = "DOCK_WINDOW_BODY";
|
||||
|
||||
/// standard style id for toolbars layout
|
||||
immutable string STYLE_TOOLBAR_HOST = "TOOLBAR_HOST";
|
||||
/// standard style id for toolbars
|
||||
immutable string STYLE_TOOLBAR = "TOOLBAR";
|
||||
/// standard style id for toolbar button
|
||||
immutable string STYLE_TOOLBAR_BUTTON = "TOOLBAR_BUTTON";
|
||||
/// standard style id for toolbar separator
|
||||
immutable string STYLE_TOOLBAR_SEPARATOR = "TOOLBAR_SEPARATOR";
|
||||
|
||||
|
||||
// Layout size constants
|
||||
/// layout option, to occupy all available place
|
||||
immutable int FILL_PARENT = int.max - 1;
|
||||
|
|
Loading…
Reference in New Issue