refactoring: standard style ids

This commit is contained in:
Vadim Lopatin 2015-01-14 15:51:16 +03:00
parent 50d82fd414
commit 22bd6fac35
11 changed files with 144 additions and 76 deletions

View File

@ -227,12 +227,12 @@ class FileDialog : Dialog, CustomGridCellAdapter {
protected ListWidget createRootsList() {
ListWidget res = new ListWidget("ROOTS_LIST");
res.styleId = "EDIT_BOX";
res.styleId = STYLE_EDIT_BOX;
WidgetListAdapter adapter = new WidgetListAdapter();
foreach(ref RootEntry root; _roots) {
ImageTextButton btn = new ImageTextButton(null, root.icon, root.label);
btn.orientation = Orientation.Vertical;
btn.styleId = "TRANSPARENT_BUTTON_BACKGROUND";
btn.styleId = STYLE_TRANSPARENT_BUTTON_BACKGROUND;
btn.focusable = false;
adapter.widgets.add(btn);
}
@ -418,17 +418,17 @@ class FilePathPanelItem : HorizontalLayout {
Listener!OnPathSelectionHandler onPathSelectionListener;
this(string path) {
super(null);
styleId = "LIST_ITEM";
styleId = STYLE_LIST_ITEM;
_path = path;
string fname = isRoot(path) ? path : baseName(path);
_text = new TextWidget(null, toUTF32(fname));
_text.styleId = "BUTTON_TRANSPARENT";
_text.styleId = STYLE_BUTTON_TRANSPARENT;
_text.clickable = true;
_text.onClickListener = &onTextClick;
//_text.backgroundColor = 0xC0FFFF;
_text.state = State.Parent;
_button = new ImageButton(null, "scrollbar_btn_right");
_button.styleId = "BUTTON_TRANSPARENT";
_button.styleId = STYLE_BUTTON_TRANSPARENT;
_button.focusable = false;
_button.onClickListener = &onButtonClick;
//_button.backgroundColor = 0xC0FFC0;

View File

@ -80,7 +80,7 @@ class ComboBoxBase : HorizontalLayout, OnClickHandler {
protected ImageButton createButton() {
ImageButton res = new ImageButton("COMBOBOX_BUTTON", "scrollbar_btn_down");
res.styleId = "COMBO_BOX_BUTTON";
res.styleId = STYLE_COMBO_BOX_BUTTON;
res.layoutWeight = 0;
res.onClickListener = this;
return res;
@ -100,7 +100,7 @@ class ComboBoxBase : HorizontalLayout, OnClickHandler {
_popupList = createPopup();
_popup = window.showPopup(_popupList, this, PopupAlign.Below | PopupAlign.FitAnchorSize);
_popup.flags = PopupFlags.CloseOnClickOutside;
_popup.styleId = "POPUP_MENU";
_popup.styleId = STYLE_POPUP_MENU;
_popup.onPopupCloseListener = delegate (PopupWidget source) {
_popup = null;
_popupList = null;
@ -122,7 +122,7 @@ class ComboBoxBase : HorizontalLayout, OnClickHandler {
super(ID);
_adapter = adapter;
_ownAdapter = ownAdapter;
styleId = "COMBO_BOX";
styleId = STYLE_COMBO_BOX;
trackHover = true;
init();
}
@ -201,14 +201,13 @@ class ComboBox : ComboBoxBase {
_body.focusable = false;
_body.clickable = true;
focusable = true;
//styleId = "COMBO_BOX";
clickable = true;
onClickListener = this;
}
override protected Widget createSelectedItemWidget() {
TextWidget res = new TextWidget("COMBO_BOX_BODY");
res.styleId = "COMBO_BOX_BODY";
res.styleId = STYLE_COMBO_BOX_BODY;
res.clickable = true;
res.layoutWidth = FILL_PARENT;
res.layoutHeight = WRAP_CONTENT;

View File

@ -36,7 +36,7 @@ private import std.conv : to;
/// vertical spacer to fill empty space in vertical layouts
class VSpacer : Widget {
this() {
styleId = "VSPACER";
styleId = STYLE_VSPACER;
}
//override void measure(int parentWidth, int parentHeight) {
// measuredContent(parentWidth, parentHeight, 8, 8);
@ -46,7 +46,7 @@ class VSpacer : Widget {
/// horizontal spacer to fill empty space in horizontal layouts
class HSpacer : Widget {
this() {
styleId = "HSPACER";
styleId = STYLE_HSPACER;
}
//override void measure(int parentWidth, int parentHeight) {
// measuredContent(parentWidth, parentHeight, 8, 8);
@ -199,7 +199,7 @@ class ImageButton : ImageWidget {
/// constructor by id and icon resource id
this(string ID = null, string drawableId = null) {
super(ID, drawableId);
styleId = "BUTTON";
styleId = STYLE_BUTTON;
_drawableId = drawableId;
clickable = true;
focusable = true;
@ -247,11 +247,11 @@ class ImageTextButton : HorizontalLayout {
}
protected void init(string drawableId, UIString caption) {
styleId = "BUTTON";
styleId = STYLE_BUTTON;
_icon = new ImageWidget("icon", drawableId);
_icon.styleId = "BUTTON_IMAGE";
_icon.styleId = STYLE_BUTTON_IMAGE;
_label = new TextWidget("label", caption);
_label.styleId = "BUTTON_LABEL";
_label.styleId = STYLE_BUTTON_LABEL;
_icon.state = State.Parent;
_label.state = State.Parent;
addChild(_icon);
@ -292,11 +292,11 @@ class CheckBox : ImageTextButton {
}
override protected void init(string drawableId, UIString caption) {
super.init(drawableId, caption);
styleId = "CHECKBOX";
styleId = STYLE_CHECKBOX;
if (_icon)
_icon.styleId = "CHECKBOX_IMAGE";
_icon.styleId = STYLE_CHECKBOX_IMAGE;
if (_label)
_label.styleId = "CHECKBOX_LABEL";
_label.styleId = STYLE_CHECKBOX_LABEL;
checkable = true;
}
// called to process click and notify listeners
@ -508,7 +508,7 @@ class ScrollBar : AbstractSlider, OnClickHandler {
class PageScrollButton : Widget {
this(string ID) {
super(ID);
styleId = "PAGE_SCROLL";
styleId = STYLE_PAGE_SCROLL;
trackHover = true;
clickable = true;
}
@ -522,7 +522,7 @@ class ScrollBar : AbstractSlider, OnClickHandler {
this(string resourceId) {
super("SLIDER", resourceId);
styleId = "BUTTON_NOMARGINS";
styleId = STYLE_BUTTON_NOMARGINS;
trackHover = true;
}
@ -682,14 +682,14 @@ class ScrollBar : AbstractSlider, OnClickHandler {
/// create with ID parameter
this(string ID, Orientation orient = Orientation.Vertical) {
super(ID);
styleId = "SCROLLBAR";
styleId = STYLE_SCROLLBAR;
_orientation = orient;
_btnBack = new ImageButton("BACK", style.customDrawableId(_orientation == Orientation.Vertical ? ATTR_SCROLLBAR_BUTTON_UP : ATTR_SCROLLBAR_BUTTON_LEFT));
_btnForward = new ImageButton("FORWARD", style.customDrawableId(_orientation == Orientation.Vertical ? ATTR_SCROLLBAR_BUTTON_DOWN : ATTR_SCROLLBAR_BUTTON_RIGHT));
_pageUp = new PageScrollButton("PAGE_UP");
_pageDown = new PageScrollButton("PAGE_DOWN");
_btnBack.styleId("SCROLLBAR_BUTTON");
_btnForward.styleId("SCROLLBAR_BUTTON");
_btnBack.styleId = STYLE_SCROLLBAR_BUTTON;
_btnForward.styleId = STYLE_SCROLLBAR_BUTTON;
_indicator = new SliderButton(style.customDrawableId(_orientation == Orientation.Vertical ? ATTR_SCROLLBAR_INDICATOR_VERTICAL : ATTR_SCROLLBAR_INDICATOR_HORIZONTAL));
addChild(_btnBack);
addChild(_btnForward);

View File

@ -1727,7 +1727,7 @@ class EditLine : EditWidgetBase {
_content = new EditableContent(false);
_content.contentChangeListeners = this;
wantTabs = false;
styleId = "EDIT_LINE";
styleId = STYLE_EDIT_LINE;
text = initialContent;
}
@ -1905,7 +1905,7 @@ class EditBox : EditWidgetBase {
super(ID, hscrollbarMode, vscrollbarMode);
_content = new EditableContent(true); // multiline
_content.contentChangeListeners = this;
styleId = "EDIT_BOX";
styleId = STYLE_EDIT_BOX;
text = initialContent;
}

View File

@ -1170,7 +1170,7 @@ class StringGridWidget : StringGridWidgetBase {
/// create with ID parameter
this(string ID) {
super(ID);
styleId = "EDIT_BOX";
styleId = STYLE_EDIT_BOX;
}
/// get cell text
override dstring cellText(int col, int row) {

View File

@ -114,7 +114,7 @@ class StringListAdapter : ListAdapter {
updateStatesLength();
if (_widget is null) {
_widget = new TextWidget("LIST_ITEM");
_widget.styleId = "LIST_ITEM";
_widget.styleId = STYLE_LIST_ITEM;
} else {
if (index == _lastItemIndex)
return _widget;

View File

@ -320,7 +320,7 @@ class MenuItemWidget : WidgetGroup {
id="menuitem";
_mainMenu = mainMenu;
_item = item;
styleId = "MENU_ITEM";
styleId = STYLE_MENU_ITEM;
updateState();
string iconId = _item.action.iconId;
if (_item.type == MenuItemType.Check)
@ -330,7 +330,7 @@ class MenuItemWidget : WidgetGroup {
// icon
if (_item.action && iconId.length) {
_icon = new ImageWidget("MENU_ICON", iconId);
_icon.styleId = "MENU_ICON";
_icon.styleId = STYLE_MENU_ICON;
_icon.state = State.Parent;
addChild(_icon);
}
@ -352,7 +352,7 @@ class MenuItemWidget : WidgetGroup {
}
if (acc !is null) {
_accel = new TextWidget("MENU_ACCEL");
_accel.styleId = "MENU_ACCEL";
_accel.styleId = STYLE_MENU_ACCEL;
_accel.text = acc;
_accel.state = State.Parent;
if (_item.isSubmenu && !mainMenu)
@ -382,13 +382,13 @@ class MenuWidgetBase : ListWidget {
_item = item;
this.orientation = orientation;
id = "popup_menu";
styleId = "POPUP_MENU";
styleId = STYLE_POPUP_MENU;
WidgetListAdapter adapter = new WidgetListAdapter();
for (int i=0; i < _item.subitemCount; i++) {
MenuItem subitem = _item.subitem(i);
MenuItemWidget widget = new MenuItemWidget(subitem, orientation == Orientation.Horizontal);
if (orientation == Orientation.Horizontal)
widget.styleId = "MAIN_MENU_ITEM";
widget.styleId = STYLE_MAIN_MENU_ITEM;
widget.parent = this;
adapter.widgets.add(widget);
}
@ -650,7 +650,7 @@ class MainMenu : MenuWidgetBase {
this(MenuItem item) {
super(null, item, Orientation.Horizontal);
id = "MAIN_MENU";
styleId = "MAIN_MENU";
styleId = STYLE_MAIN_MENU;
_clickOnButtonDown = true;
}
@ -799,7 +799,7 @@ class PopupMenu : MenuWidgetBase {
this(MenuItem item, MenuWidgetBase parentMenu = null) {
super(parentMenu, item, Orientation.Vertical);
id = "POPUP_MENU";
styleId = "POPUP_MENU";
styleId = STYLE_POPUP_MENU;
selectOnHover = true;
}
}

View File

@ -31,10 +31,19 @@ import dlangui.graphics.drawbuf;
import dlangui.graphics.resources;
// Standard style constants
// Themes should define all of these styles in order to support all controls
/// standard style id for TextWidget
immutable string STYLE_TEXT = "TEXT";
/// standard style id for Button
immutable string STYLE_BUTTON = "BUTTON";
/// standard style id for Button label
immutable string STYLE_BUTTON_LABEL = "BUTTON_LABEL";
/// standard style id for Button image
immutable string STYLE_BUTTON_IMAGE = "BUTTON_IMAGE";
/// style id for transparent Button
immutable string STYLE_BUTTON_TRANSPARENT = "BUTTON_TRANSPARENT";
/// style id for Button w/o margins
immutable string STYLE_BUTTON_NOMARGINS = "BUTTON_NOMARGINS";
/// standard style id for CheckBox
immutable string STYLE_CHECKBOX = "CHECKBOX";
/// standard style id for CheckBox image
@ -47,6 +56,66 @@ immutable string STYLE_RADIOBUTTON = "RADIOBUTTON";
immutable string STYLE_RADIOBUTTON_IMAGE = "RADIOBUTTON_IMAGE";
/// standard style id for RadioButton label
immutable string STYLE_RADIOBUTTON_LABEL = "RADIOBUTTON_LABEL";
/// standard style id for HSpacer
immutable string STYLE_HSPACER = "HSPACER";
/// standard style id for VSpacer
immutable string STYLE_VSPACER = "VSPACER";
/// standard style id for ScrollBar
immutable string STYLE_SCROLLBAR = "SCROLLBAR";
/// standard style id for ScrollBar button
immutable string STYLE_SCROLLBAR_BUTTON = "SCROLLBAR_BUTTON";
/// standard style id for ScrollBar page control
immutable string STYLE_PAGE_SCROLL = "PAGE_SCROLL";
/// standard style id for Slider
immutable string STYLE_SLIDER = "SLIDER";
/// standard style id for TabWidget
immutable string STYLE_TAB_WIDGET = "TAB_WIDGET";
/// standard style id for Tab with Up alignment
immutable string STYLE_TAB_UP = "TAB_UP";
/// standard style id for button of Tab with Up alignment
immutable string STYLE_TAB_UP_BUTTON = "TAB_UP_BUTTON";
/// standard style id for button of Tab with Up alignment
immutable string STYLE_TAB_UP_BUTTON_TEXT = "TAB_UP_BUTTON_TEXT";
/// standard style id for TabHost
immutable string STYLE_TAB_HOST = "TAB_HOST";
/// standard style id for PopupMenu
immutable string STYLE_POPUP_MENU = "POPUP_MENU";
/// standard style id for menu item
immutable string STYLE_MENU_ITEM = "MENU_ITEM";
/// standard style id for menu item label
immutable string STYLE_MENU_LABEL = "MENU_LABEL";
/// standard style id for menu item icon
immutable string STYLE_MENU_ICON = "MENU_ICON";
/// standard style id for menu item accelerators label
immutable string STYLE_MENU_ACCEL = "MENU_ACCEL";
/// standard style id for main menu item
immutable string STYLE_MAIN_MENU_ITEM = "MAIN_MENU_ITEM";
/// standard style id for main menu item label
immutable string STYLE_MAIN_MENU_LABEL = "MAIN_MENU_LABEL";
/// standard style id for main menu
immutable string STYLE_MAIN_MENU = "MAIN_MENU";
/// standard style id for list items
immutable string STYLE_LIST_ITEM = "LIST_ITEM";
/// standard style id for EditLine
immutable string STYLE_EDIT_LINE = "EDIT_LINE";
/// standard style id for EditBox
immutable string STYLE_EDIT_BOX = "EDIT_BOX";
/// standard style id for background similar to transparent button
immutable string STYLE_TRANSPARENT_BUTTON_BACKGROUND = "TRANSPARENT_BUTTON_BACKGROUND";
/// standard style id for tree item
immutable string STYLE_TREE_ITEM = "TREE_ITEM";
/// standard style id for tree item label
immutable string STYLE_TREE_ITEM_LABEL = "TREE_ITEM_LABEL";
/// standard style id for tree item icon
immutable string STYLE_TREE_ITEM_ICON = "TREE_ITEM_ICON";
/// standard style id for tree item expand icon
immutable string STYLE_TREE_ITEM_EXPAND_ICON = "TREE_ITEM_EXPAND_ICON";
/// standard style id for combo box
immutable string STYLE_COMBO_BOX = "COMBO_BOX";
/// standard style id for combo box button
immutable string STYLE_COMBO_BOX_BUTTON = "COMBO_BOX_BUTTON";
/// standard style id for combo box body (current item)
immutable string STYLE_COMBO_BOX_BODY = "COMBO_BOX_BODY";
// Layout size constants
/// layout option, to occupy all available place
@ -791,14 +860,14 @@ Theme createDefaultTheme() {
}
//res.fontFace = "Arial Narrow";
res.fontSize = 15; // TODO: choose based on DPI
Style button = res.createSubstyle("BUTTON").backgroundImageId("btn_background").alignment(Align.Center).setMargins(5,5,5,5);
res.createSubstyle("BUTTON_TRANSPARENT").backgroundImageId("btn_background_transparent").alignment(Align.Center);
res.createSubstyle("BUTTON_LABEL").layoutWidth(FILL_PARENT).alignment(Align.Left|Align.VCenter);
res.createSubstyle("BUTTON_ICON").alignment(Align.Center);
res.createSubstyle("TEXT").setMargins(2,2,2,2).setPadding(1,1,1,1);
res.createSubstyle("HSPACER").layoutWidth(FILL_PARENT).minWidth(5).layoutWeight(100);
res.createSubstyle("VSPACER").layoutHeight(FILL_PARENT).minHeight(5).layoutWeight(100);
res.createSubstyle("BUTTON_NOMARGINS").backgroundImageId("btn_background").alignment(Align.Center); // .setMargins(5,5,5,5)
Style button = res.createSubstyle(STYLE_BUTTON).backgroundImageId("btn_background").alignment(Align.Center).setMargins(5,5,5,5);
res.createSubstyle(STYLE_BUTTON_TRANSPARENT).backgroundImageId("btn_background_transparent").alignment(Align.Center);
res.createSubstyle(STYLE_BUTTON_LABEL).layoutWidth(FILL_PARENT).alignment(Align.Left|Align.VCenter);
res.createSubstyle(STYLE_BUTTON_IMAGE).alignment(Align.Center);
res.createSubstyle(STYLE_TEXT).setMargins(2,2,2,2).setPadding(1,1,1,1);
res.createSubstyle(STYLE_HSPACER).layoutWidth(FILL_PARENT).minWidth(5).layoutWeight(100);
res.createSubstyle(STYLE_VSPACER).layoutHeight(FILL_PARENT).minHeight(5).layoutWeight(100);
res.createSubstyle(STYLE_BUTTON_NOMARGINS).backgroundImageId("btn_background").alignment(Align.Center); // .setMargins(5,5,5,5)
//button.createState(State.Enabled | State.Focused, State.Focused).backgroundImageId("btn_default_small_normal_disable_focused");
//button.createState(State.Enabled, 0).backgroundImageId("btn_default_small_normal_disable");
//button.createState(State.Pressed, State.Pressed).backgroundImageId("btn_default_small_pressed");
@ -811,67 +880,67 @@ Theme createDefaultTheme() {
res.setCustomDrawable(ATTR_SCROLLBAR_INDICATOR_VERTICAL, "scrollbar_indicator_vertical");
res.setCustomDrawable(ATTR_SCROLLBAR_INDICATOR_HORIZONTAL, "scrollbar_indicator_horizontal");
Style scrollbar = res.createSubstyle("SCROLLBAR");
Style scrollbar = res.createSubstyle(STYLE_SCROLLBAR);
scrollbar.backgroundColor(0xC0808080);
Style scrollbarButton = button.createSubstyle("SCROLLBAR_BUTTON");
Style scrollbarSlider = res.createSubstyle("SLIDER");
Style scrollbarPage = res.createSubstyle("PAGE_SCROLL").backgroundColor(COLOR_TRANSPARENT);
Style scrollbarButton = button.createSubstyle(STYLE_SCROLLBAR_BUTTON);
Style scrollbarSlider = res.createSubstyle(STYLE_SLIDER);
Style scrollbarPage = res.createSubstyle(STYLE_PAGE_SCROLL).backgroundColor(COLOR_TRANSPARENT);
scrollbarPage.createState(State.Pressed, State.Pressed).backgroundColor(0xC0404080);
scrollbarPage.createState(State.Hovered, State.Hovered).backgroundColor(0xF0404080);
Style tabUp = res.createSubstyle("TAB_UP");
Style tabUp = res.createSubstyle(STYLE_TAB_UP);
tabUp.backgroundImageId("tab_up_background");
tabUp.layoutWidth(FILL_PARENT);
tabUp.createState(State.Selected, State.Selected).backgroundImageId("tab_up_backgrond_selected");
Style tabUpButtonText = res.createSubstyle("TAB_UP_BUTTON_TEXT");
Style tabUpButtonText = res.createSubstyle(STYLE_TAB_UP_BUTTON_TEXT);
tabUpButtonText.textColor(0x000000).fontSize(12).alignment(Align.Center);
tabUpButtonText.createState(State.Selected, State.Selected).textColor(0x000000);
tabUpButtonText.createState(State.Selected|State.Focused, State.Selected|State.Focused).textColor(0x000000);
tabUpButtonText.createState(State.Focused, State.Focused).textColor(0x000000);
tabUpButtonText.createState(State.Hovered, State.Hovered).textColor(0xFFE0E0);
Style tabUpButton = res.createSubstyle("TAB_UP_BUTTON");
Style tabUpButton = res.createSubstyle(STYLE_TAB_UP_BUTTON);
tabUpButton.backgroundImageId("tab_btn_up");
//tabUpButton.backgroundImageId("tab_btn_up_normal");
//tabUpButton.createState(State.Selected, State.Selected).backgroundImageId("tab_btn_up_selected");
//tabUpButton.createState(State.Selected|State.Focused, State.Selected|State.Focused).backgroundImageId("tab_btn_up_focused_selected");
//tabUpButton.createState(State.Focused, State.Focused).backgroundImageId("tab_btn_up_focused");
//tabUpButton.createState(State.Hovered, State.Hovered).backgroundImageId("tab_btn_up_hover");
Style tabHost = res.createSubstyle("TAB_HOST");
Style tabHost = res.createSubstyle(STYLE_TAB_HOST);
tabHost.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT);
tabHost.backgroundColor(0xF0F0F0);
Style tabWidget = res.createSubstyle("TAB_WIDGET");
Style tabWidget = res.createSubstyle(STYLE_TAB_WIDGET);
tabWidget.setPadding(3,3,3,3).backgroundColor(0xEEEEEE);
//tabWidget.backgroundImageId("frame_blue");
//res.dumpStats();
Style mainMenu = res.createSubstyle("MAIN_MENU").backgroundColor(0xEFEFF2).layoutWidth(FILL_PARENT);
Style mainMenuItem = res.createSubstyle("MAIN_MENU_ITEM").setPadding(4,2,4,2).backgroundImageId("main_menu_item_background").textFlags(TEXT_FLAGS_USE_PARENT);
Style menuItem = res.createSubstyle("MENU_ITEM").setPadding(4,2,4,2); //.backgroundColor(0xE0E080) ;
Style mainMenu = res.createSubstyle(STYLE_MAIN_MENU).backgroundColor(0xEFEFF2).layoutWidth(FILL_PARENT);
Style mainMenuItem = res.createSubstyle(STYLE_MAIN_MENU_ITEM).setPadding(4,2,4,2).backgroundImageId("main_menu_item_background").textFlags(TEXT_FLAGS_USE_PARENT);
Style menuItem = res.createSubstyle(STYLE_MENU_ITEM).setPadding(4,2,4,2); //.backgroundColor(0xE0E080) ;
menuItem.createState(State.Focused, State.Focused).backgroundColor(0x40C0C000);
menuItem.createState(State.Pressed, State.Pressed).backgroundColor(0x4080C000);
menuItem.createState(State.Selected, State.Selected).backgroundColor(0x00F8F9Fa);
menuItem.createState(State.Hovered, State.Hovered).backgroundColor(0xC0FFFF00);
res.createSubstyle("MENU_ICON").setMargins(2,2,2,2).alignment(Align.VCenter|Align.Left).createState(State.Enabled,0).alpha(0xA0);
res.createSubstyle("MENU_LABEL").setMargins(4,2,4,2).alignment(Align.VCenter|Align.Left).textFlags(TextFlag.UnderlineHotKeys).createState(State.Enabled,0).textColor(0x80404040);
res.createSubstyle("MAIN_MENU_LABEL").setMargins(4,2,4,2).alignment(Align.VCenter|Align.Left).textFlags(TEXT_FLAGS_USE_PARENT).createState(State.Enabled,0).textColor(0x80404040);
res.createSubstyle("MENU_ACCEL").setMargins(4,2,4,2).alignment(Align.VCenter|Align.Left).createState(State.Enabled,0).textColor(0x80404040);
res.createSubstyle(STYLE_MENU_ICON).setMargins(2,2,2,2).alignment(Align.VCenter|Align.Left).createState(State.Enabled,0).alpha(0xA0);
res.createSubstyle(STYLE_MENU_LABEL).setMargins(4,2,4,2).alignment(Align.VCenter|Align.Left).textFlags(TextFlag.UnderlineHotKeys).createState(State.Enabled,0).textColor(0x80404040);
res.createSubstyle(STYLE_MAIN_MENU_LABEL).setMargins(4,2,4,2).alignment(Align.VCenter|Align.Left).textFlags(TEXT_FLAGS_USE_PARENT).createState(State.Enabled,0).textColor(0x80404040);
res.createSubstyle(STYLE_MENU_ACCEL).setMargins(4,2,4,2).alignment(Align.VCenter|Align.Left).createState(State.Enabled,0).textColor(0x80404040);
Style transparentButtonBackground = res.createSubstyle("TRANSPARENT_BUTTON_BACKGROUND").backgroundImageId("transparent_button_background").setPadding(4,2,4,2); //.backgroundColor(0xE0E080) ;
Style transparentButtonBackground = res.createSubstyle(STYLE_TRANSPARENT_BUTTON_BACKGROUND).backgroundImageId("transparent_button_background").setPadding(4,2,4,2); //.backgroundColor(0xE0E080) ;
//transparentButtonBackground.createState(State.Focused, State.Focused).backgroundColor(0xC0C0C000);
//transparentButtonBackground.createState(State.Pressed, State.Pressed).backgroundColor(0x4080C000);
//transparentButtonBackground.createState(State.Selected, State.Selected).backgroundColor(0x00F8F9Fa);
//transparentButtonBackground.createState(State.Hovered, State.Hovered).backgroundColor(0xD0FFFF00);
Style poopupMenu = res.createSubstyle("POPUP_MENU").backgroundImageId("popup_menu_background_normal");
Style poopupMenu = res.createSubstyle(STYLE_POPUP_MENU).backgroundImageId("popup_menu_background_normal");
Style listItem = res.createSubstyle("LIST_ITEM").backgroundImageId("list_item_background");
Style listItem = res.createSubstyle(STYLE_LIST_ITEM).backgroundImageId("list_item_background");
//listItem.createState(State.Selected, State.Selected).backgroundColor(0xC04040FF).textColor(0x000000);
//listItem.createState(State.Enabled, 0).textColor(0x80000000); // half transparent text for disabled item
Style editLine = res.createSubstyle("EDIT_LINE").backgroundImageId("editbox_background")
Style editLine = res.createSubstyle(STYLE_EDIT_LINE).backgroundImageId("editbox_background")
.setPadding(5,6,5,6).setMargins(2,2,2,2).minWidth(40)
.fontFace("Arial").fontFamily(FontFamily.SansSerif).fontSize(16);
Style editBox = res.createSubstyle("EDIT_BOX").backgroundImageId("editbox_background")
Style editBox = res.createSubstyle(STYLE_EDIT_BOX).backgroundImageId("editbox_background")
.setPadding(5,6,5,6).setMargins(2,2,2,2).minWidth(100).minHeight(60).layoutHeight(FILL_PARENT).layoutWidth(FILL_PARENT)
.fontFace("Courier New").fontFamily(FontFamily.MonoSpace).fontSize(16);

View File

@ -67,14 +67,14 @@ class TabItemWidget : HorizontalLayout {
@property TabItem tabItem() { return _item; }
@property TabControl tabControl() { return cast(TabControl)parent; }
this(TabItem item, bool enableCloseButton = true) {
styleId = "TAB_UP_BUTTON";
styleId = STYLE_TAB_UP_BUTTON;
_enableCloseButton = enableCloseButton;
_icon = new ImageWidget();
_label = new TextWidget();
_label.styleId = "TAB_UP_BUTTON_TEXT";
_label.styleId = STYLE_TAB_UP_BUTTON_TEXT;
_label.state = State.Parent;
_closeButton = new ImageButton("CLOSE");
_closeButton.styleId = "BUTTON_TRANSPARENT";
_closeButton.styleId = STYLE_BUTTON_TRANSPARENT;
_closeButton.drawableId = "close";
_closeButton.trackHover = true;
_closeButton.onClickListener = &onClick;
@ -186,11 +186,11 @@ class TabControl : WidgetGroup {
super(ID);
_items = new TabItemList();
_moreButton = new ImageButton("MORE", "tab_more");
_moreButton.styleId = "BUTTON_TRANSPARENT";
_moreButton.styleId = STYLE_BUTTON_TRANSPARENT;
_moreButton.onClickListener = &onClick;
_moreButton.margins(Rect(3,3,3,6));
_enableCloseButton = true;
styleId = "TAB_UP";
styleId = STYLE_TAB_UP;
addChild(_moreButton); // first child is always MORE button, the rest corresponds to tab list
}
/// returns tab count
@ -388,7 +388,7 @@ class TabHost : FrameLayout, TabHandler {
_tabControl = tabControl;
if (_tabControl !is null)
_tabControl.onTabChangedListener = &onTabChanged;
styleId = "TAB_HOST";
styleId = STYLE_TAB_HOST;
}
protected TabControl _tabControl;
/// get currently set control widget
@ -478,7 +478,7 @@ class TabWidget : VerticalLayout, TabHandler {
_tabControl = new TabControl("TAB_CONTROL");
_tabHost = new TabHost("TAB_HOST", _tabControl);
_tabControl.onTabChangedListener.connect(this);
styleId = "TAB_WIDGET";
styleId = STYLE_TAB_WIDGET;
addChild(_tabControl);
addChild(_tabHost);
}

View File

@ -467,7 +467,7 @@ class TreeItemWidget : HorizontalLayout {
this(TreeItem item) {
super(item.id);
styleId = "TREE_ITEM";
styleId = STYLE_TREE_ITEM;
clickable = true;
focusable = true;
@ -485,7 +485,7 @@ class TreeItemWidget : HorizontalLayout {
_tab.maxWidth = w;
if (_item.hasChildren) {
_expander = new ImageWidget("expander", _item.hasChildren && _item.expanded ? "arrow_right_down_black" : "arrow_right_hollow");
_expander.styleId = "TREE_ITEM_EXPAND_ICON";
_expander.styleId = STYLE_TREE_ITEM_EXPAND_ICON;
_expander.clickable = true;
_expander.trackHover = true;
//_expander.setState(State.Parent);
@ -511,11 +511,11 @@ class TreeItemWidget : HorizontalLayout {
};
if (_item.iconRes.length > 0) {
_icon = new ImageWidget("icon", _item.iconRes);
_icon.styleId = "TREE_ITEM_ICON";
_icon.styleId = STYLE_TREE_ITEM_ICON;
_icon.setState(State.Parent);
}
_label = new TextWidget("label", _item.text);
_label.styleId = "TREE_ITEM_LABEL";
_label.styleId = STYLE_TREE_ITEM_LABEL;
_label.setState(State.Parent);
// append children
addChild(_tab);

View File

@ -705,7 +705,7 @@ class Widget {
applyPadding(rc);
if (!rc.intersects(clipRect))
return; // out of clip rectangle
if (focusable) {
if (canFocus) {
TabOrderInfo item = new TabOrderInfo(this, rc);
results ~= item;
return;