toolbars; fix focus problems in dock host

This commit is contained in:
Vadim Lopatin 2015-01-16 15:08:55 +03:00
parent fd4b00bfb4
commit 6f44eb5845
8 changed files with 137 additions and 4 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 251 B

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

View File

@ -101,6 +101,7 @@
<state state_pressed="true" backgroundColor="#C0404080"/>
<state state_hovered="true" backgroundColor="#F0404080"/>
</style>
<style id="TAB_UP"
backgroundImageId="tab_up_background"
layoutWidth="FILL_PARENT"
@ -125,9 +126,9 @@
backgroundColor="#F0F0F0"
/>
<style id="TAB_WIDGET"
padding="3,3,3,3"
backgroundColor="#EEEEEE"
/>
<style id="MAIN_MENU"
layoutWidth="FILL_PARENT"
backgroundColor="#EFEFF2"
@ -275,9 +276,10 @@
margins="2,2,2,2"
/>
<style id="TOOLBAR_BUTTON"
backgroundImageId="btn_background_transparent"
backgroundImageId="toolbar_button_background"
align="Center"
margins="2,2,2,2"
margins="1,1,1,1"
padding="4,4,4,4"
/>
<style id="TOOLBAR_SEPARATOR"
align="Center"

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:drawable="toolbar_button_hover"
android:state_enabled="false"
android:state_focused="true" />
<item
android:drawable="toolbar_button_hover"
android:state_hovered="true"
android:state_focused="true" />
<item
android:drawable="toolbar_button_hover"
android:state_focused="true"
/>
<item
android:drawable="toolbar_button_pressed"
android:state_pressed="true" />
<item
android:drawable="toolbar_button_hover"
android:state_hovered="true" />
<item
android:drawable="@null" />
</selector>

View File

@ -37,6 +37,7 @@ class DockHost : WidgetGroupDefaultDrawing {
_children.replace(widget, _bodyWidget);
_bodyWidget = widget;
_bodyWidget.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT);
_bodyWidget.parent = this;
}
void addDockedWindow(DockWindow dockWin) {
@ -158,6 +159,7 @@ class DockWindow : VerticalLayout {
_children.replace(widget, _bodyWidget);
_bodyWidget = widget;
_bodyWidget.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT);
_bodyWidget.parent = this;
requestLayout();
}

View File

@ -0,0 +1,104 @@
// Written in the D programming language.
/**
This module implements support of tool bars.
ToolBarHost is layout to hold one or more toolbars.
ToolBar is bar with tool buttons and other controls arranged horizontally.
Synopsis:
----
import dlangui.widgets.toolbars;
----
Copyright: Vadim Lopatin, 2015
License: Boost License 1.0
Authors: Vadim Lopatin, coolreader.org@gmail.com
*/
module dlangui.widgets.toolbars;
import dlangui.widgets.widget;
import dlangui.widgets.layouts;
import dlangui.widgets.controls;
/// Layout with several toolbars
class ToolBarHost : HorizontalLayout {
this(string ID) {
super(ID);
}
this() {
this("TOOLBAR_HOST");
styleId = STYLE_TOOLBAR_HOST;
}
/// create and add new toolbar (returns existing one if already exists)
ToolBar getOrAddToolbar(string ID) {
ToolBar res = getToolbar(ID);
if (!res) {
res = new ToolBar(ID);
addChild(res);
}
return res;
}
/// get toolbar by id; null if not found
ToolBar getToolbar(string ID) {
Widget res = childById(ID);
if (res) {
ToolBar tb = cast(ToolBar)res;
return tb;
}
return null;
}
}
/// image button for toolbar
class ToolBarImageButton : ImageButton {
this(Action a) {
super(a);
styleId = STYLE_TOOLBAR_BUTTON;
focusable = false;
}
}
/// separator for toolbars
class ToolBarSeparator : ImageWidget {
this() {
super("separator", "toolbar_separator");
styleId = STYLE_TOOLBAR_SEPARATOR;
}
}
/// Layout with buttons
class ToolBar : HorizontalLayout {
this(string ID) {
super(ID);
styleId = STYLE_TOOLBAR;
}
this() {
this("TOOLBAR");
}
void addCustomControl(Widget widget) {
addChild(widget);
}
/// adds image button to toolbar
void addButtons(Action[] actions...) {
foreach(a; actions) {
if (a.isSeparator) {
addChild(new ToolBarSeparator());
} else {
Widget btn;
if (a.iconId) {
btn = new ToolBarImageButton(a);
} else {
btn = new Button(a);
btn.styleId = STYLE_TOOLBAR_BUTTON;
}
addChild(btn);
}
}
}
}

View File

@ -1283,7 +1283,9 @@ class Widget {
return null;
}
/// sets window (to be used for top level widget from Window implementation). TODO: hide it from API?
@property void window(Window window) { _window = window; }
@property void window(Window window) {
_window = window;
}
void removeAllChildren() {
// override