diff --git a/examples/example1/res/hdpi/document-close.png b/examples/example1/res/hdpi/document-close.png new file mode 100644 index 00000000..0bcfe981 Binary files /dev/null and b/examples/example1/res/hdpi/document-close.png differ diff --git a/examples/example1/res/hdpi/document-open-recent.png b/examples/example1/res/hdpi/document-open-recent.png new file mode 100644 index 00000000..6a10e6ef Binary files /dev/null and b/examples/example1/res/hdpi/document-open-recent.png differ diff --git a/examples/example1/res/hdpi/document-open.png b/examples/example1/res/hdpi/document-open.png new file mode 100644 index 00000000..8ba54411 Binary files /dev/null and b/examples/example1/res/hdpi/document-open.png differ diff --git a/examples/example1/res/hdpi/document-save-as.png b/examples/example1/res/hdpi/document-save-as.png new file mode 100644 index 00000000..9695a564 Binary files /dev/null and b/examples/example1/res/hdpi/document-save-as.png differ diff --git a/examples/example1/res/hdpi/document-save.png b/examples/example1/res/hdpi/document-save.png new file mode 100644 index 00000000..7fa489c0 Binary files /dev/null and b/examples/example1/res/hdpi/document-save.png differ diff --git a/examples/example1/res/hdpi/edit-clear.png b/examples/example1/res/hdpi/edit-clear.png new file mode 100644 index 00000000..631ed445 Binary files /dev/null and b/examples/example1/res/hdpi/edit-clear.png differ diff --git a/examples/example1/res/hdpi/edit-copy.png b/examples/example1/res/hdpi/edit-copy.png new file mode 100644 index 00000000..477e83a6 Binary files /dev/null and b/examples/example1/res/hdpi/edit-copy.png differ diff --git a/examples/example1/res/hdpi/edit-cut.png b/examples/example1/res/hdpi/edit-cut.png new file mode 100644 index 00000000..07323280 Binary files /dev/null and b/examples/example1/res/hdpi/edit-cut.png differ diff --git a/examples/example1/res/hdpi/edit-delete.png b/examples/example1/res/hdpi/edit-delete.png new file mode 100644 index 00000000..cc6d2af8 Binary files /dev/null and b/examples/example1/res/hdpi/edit-delete.png differ diff --git a/examples/example1/res/hdpi/edit-paste.png b/examples/example1/res/hdpi/edit-paste.png new file mode 100644 index 00000000..6788b022 Binary files /dev/null and b/examples/example1/res/hdpi/edit-paste.png differ diff --git a/examples/example1/res/hdpi/edit-redo.png b/examples/example1/res/hdpi/edit-redo.png new file mode 100644 index 00000000..d759f136 Binary files /dev/null and b/examples/example1/res/hdpi/edit-redo.png differ diff --git a/examples/example1/res/hdpi/edit-undo.png b/examples/example1/res/hdpi/edit-undo.png new file mode 100644 index 00000000..c893a1a6 Binary files /dev/null and b/examples/example1/res/hdpi/edit-undo.png differ diff --git a/res/i18n/en.ini b/examples/example1/res/i18n/en.ini similarity index 100% rename from res/i18n/en.ini rename to examples/example1/res/i18n/en.ini diff --git a/res/i18n/ru.ini b/examples/example1/res/i18n/ru.ini similarity index 100% rename from res/i18n/ru.ini rename to examples/example1/res/i18n/ru.ini diff --git a/examples/example1/res/mdpi/document-close.png b/examples/example1/res/mdpi/document-close.png new file mode 100644 index 00000000..411031eb Binary files /dev/null and b/examples/example1/res/mdpi/document-close.png differ diff --git a/examples/example1/res/mdpi/document-open-recent.png b/examples/example1/res/mdpi/document-open-recent.png new file mode 100644 index 00000000..15847ce4 Binary files /dev/null and b/examples/example1/res/mdpi/document-open-recent.png differ diff --git a/examples/example1/res/mdpi/document-open.png b/examples/example1/res/mdpi/document-open.png new file mode 100644 index 00000000..17076a31 Binary files /dev/null and b/examples/example1/res/mdpi/document-open.png differ diff --git a/examples/example1/res/mdpi/document-properties.png b/examples/example1/res/mdpi/document-properties.png new file mode 100644 index 00000000..12c6b448 Binary files /dev/null and b/examples/example1/res/mdpi/document-properties.png differ diff --git a/examples/example1/res/mdpi/document-save-as.png b/examples/example1/res/mdpi/document-save-as.png new file mode 100644 index 00000000..41c52aaa Binary files /dev/null and b/examples/example1/res/mdpi/document-save-as.png differ diff --git a/examples/example1/res/mdpi/document-save.png b/examples/example1/res/mdpi/document-save.png new file mode 100644 index 00000000..3f7fd63c Binary files /dev/null and b/examples/example1/res/mdpi/document-save.png differ diff --git a/examples/example1/res/mdpi/edit-copy.png b/examples/example1/res/mdpi/edit-copy.png new file mode 100644 index 00000000..54eaf777 Binary files /dev/null and b/examples/example1/res/mdpi/edit-copy.png differ diff --git a/examples/example1/res/mdpi/edit-cut.png b/examples/example1/res/mdpi/edit-cut.png new file mode 100644 index 00000000..f4a55e3d Binary files /dev/null and b/examples/example1/res/mdpi/edit-cut.png differ diff --git a/examples/example1/res/mdpi/edit-paste.png b/examples/example1/res/mdpi/edit-paste.png new file mode 100644 index 00000000..3f71b1c7 Binary files /dev/null and b/examples/example1/res/mdpi/edit-paste.png differ diff --git a/examples/example1/res/mdpi/edit-redo.png b/examples/example1/res/mdpi/edit-redo.png new file mode 100644 index 00000000..c03bba0c Binary files /dev/null and b/examples/example1/res/mdpi/edit-redo.png differ diff --git a/examples/example1/res/mdpi/edit-undo.png b/examples/example1/res/mdpi/edit-undo.png new file mode 100644 index 00000000..f1239421 Binary files /dev/null and b/examples/example1/res/mdpi/edit-undo.png differ diff --git a/examples/example1/src/main.d b/examples/example1/src/main.d index 0cc34d45..8051231d 100644 --- a/examples/example1/src/main.d +++ b/examples/example1/src/main.d @@ -37,8 +37,13 @@ extern (C) int UIAppMain(string[] args) { appendPath(exePath, "../../../res/mdpi/"), // for Visual D and DUB builds appendPath(exePath, "../../../../res/"),// for Mono-D builds appendPath(exePath, "../../../../res/mdpi/"),// for Mono-D builds - appendPath(exePath, "res/mdpi/") // when res dir is located at the same directory as executable - ]; + appendPath(exePath, "res/"), // when res dir is located at the same directory as executable + appendPath(exePath, "../res/"), // when res dir is located at project directory + appendPath(exePath, "../../res/"), // when res dir is located at the same directory as executable + appendPath(exePath, "res/mdpi/"), // when res dir is located at the same directory as executable + appendPath(exePath, "../res/mdpi/"), // when res dir is located at project directory + appendPath(exePath, "../../res/mdpi/") // when res dir is located at the same directory as executable + ]; // setup resource directories - will use only existing directories drawableCache.setResourcePaths(resourceDirs); // setup i18n - look for i18n directory inside one of passed directories @@ -53,21 +58,24 @@ extern (C) int UIAppMain(string[] args) { VerticalLayout contentLayout = new VerticalLayout(); MenuItem mainMenuItems = new MenuItem(); MenuItem fileItem = new MenuItem(new Action(1, "File"d)); - fileItem.add(new Action(10, "Open..."d)); - fileItem.add(new Action(11, "Save..."d)); - MenuItem openRecentItem = new MenuItem(new Action(13, "Open recent..."d)); + fileItem.add(new Action(10, "Open..."d, "document-open", KeyCode.KEY_O, KeyFlag.Control)); + fileItem.add(new Action(11, "Save..."d, "document-save", KeyCode.KEY_S, KeyFlag.Control)); + MenuItem openRecentItem = new MenuItem(new Action(13, "Open recent..."d, "document-open-recent")); openRecentItem.add(new Action(100, "File 1"d)); openRecentItem.add(new Action(101, "File 2"d)); openRecentItem.add(new Action(102, "File 3"d)); openRecentItem.add(new Action(103, "File 4"d)); openRecentItem.add(new Action(104, "File 5"d)); fileItem.add(openRecentItem); - fileItem.add(new Action(12, "Exit"d)); + fileItem.add(new Action(12, "Exit"d, "document-close", KeyCode.KEY_X, KeyFlag.Alt)); MenuItem editItem = new MenuItem(new Action(2, "Edit"d)); - editItem.add(new Action(20, "Copy"d)); - editItem.add(new Action(21, "Paste"d)); - editItem.add(new Action(22, "Cut"d)); - MenuItem windowItem = new MenuItem(new Action(3, "Window"d)); + editItem.add(new Action(EditorActions.Copy, "Copy"d, "edit-copy", KeyCode.KEY_C, KeyFlag.Control)); + editItem.add(new Action(EditorActions.Paste, "Paste"d, "edit-paste", KeyCode.KEY_V, KeyFlag.Control)); + editItem.add(new Action(EditorActions.Cut, "Cut"d, "edit-cut", KeyCode.KEY_X, KeyFlag.Control)); + editItem.add(new Action(EditorActions.Undo, "Undo"d, "edit-undo", KeyCode.KEY_Z, KeyFlag.Control)); + editItem.add(new Action(EditorActions.Redo, "Redo"d, "edit-redo", KeyCode.KEY_Y, KeyFlag.Control)); + editItem.add(new Action(20, "Preferences..."d)); + MenuItem windowItem = new MenuItem(new Action(3, "Window"d)); windowItem.add(new Action(30, "Preferences"d)); MenuItem helpItem = new MenuItem(new Action(4, "Help"d)); helpItem.add(new Action(40, "View Help"d)); diff --git a/src/dlangui/core/events.d b/src/dlangui/core/events.d index 4230103a..7e4ae426 100644 --- a/src/dlangui/core/events.d +++ b/src/dlangui/core/events.d @@ -21,13 +21,175 @@ module dlangui.core.events; import dlangui.core.i18n; import dlangui.core.collections; + private import dlangui.widgets.widget; +import std.string; import std.conv; +import std.utf; + +string keyName(uint keyCode) { + switch (keyCode) { + case KeyCode.KEY_A: + return "A"; + case KeyCode.KEY_B: + return "B"; + case KeyCode.KEY_C: + return "C"; + case KeyCode.KEY_D: + return "D"; + case KeyCode.KEY_E: + return "E"; + case KeyCode.KEY_F: + return "F"; + case KeyCode.KEY_G: + return "G"; + case KeyCode.KEY_H: + return "H"; + case KeyCode.KEY_I: + return "I"; + case KeyCode.KEY_J: + return "J"; + case KeyCode.KEY_K: + return "K"; + case KeyCode.KEY_L: + return "L"; + case KeyCode.KEY_M: + return "M"; + case KeyCode.KEY_N: + return "N"; + case KeyCode.KEY_O: + return "O"; + case KeyCode.KEY_P: + return "P"; + case KeyCode.KEY_Q: + return "Q"; + case KeyCode.KEY_R: + return "R"; + case KeyCode.KEY_S: + return "S"; + case KeyCode.KEY_T: + return "T"; + case KeyCode.KEY_U: + return "U"; + case KeyCode.KEY_V: + return "V"; + case KeyCode.KEY_W: + return "W"; + case KeyCode.KEY_X: + return "X"; + case KeyCode.KEY_Y: + return "Y"; + case KeyCode.KEY_Z: + return "Z"; + case KeyCode.KEY_0: + return "0"; + case KeyCode.KEY_1: + return "1"; + case KeyCode.KEY_2: + return "2"; + case KeyCode.KEY_3: + return "3"; + case KeyCode.KEY_4: + return "4"; + case KeyCode.KEY_5: + return "5"; + case KeyCode.KEY_6: + return "6"; + case KeyCode.KEY_7: + return "7"; + case KeyCode.KEY_8: + return "8"; + case KeyCode.KEY_9: + return "9"; + case KeyCode.F1: + return "F1"; + case KeyCode.F2: + return "F2"; + case KeyCode.F3: + return "F3"; + case KeyCode.F4: + return "F4"; + case KeyCode.F5: + return "F5"; + case KeyCode.F6: + return "F6"; + case KeyCode.F7: + return "F7"; + case KeyCode.F8: + return "F8"; + case KeyCode.F9: + return "F9"; + case KeyCode.F10: + return "F10"; + case KeyCode.F11: + return "F11"; + case KeyCode.F12: + return "F12"; + case KeyCode.F13: + return "F13"; + case KeyCode.F14: + return "F14"; + case KeyCode.F15: + return "F15"; + case KeyCode.F16: + return "F16"; + case KeyCode.F17: + return "F17"; + case KeyCode.F18: + return "F18"; + case KeyCode.F19: + return "F19"; + case KeyCode.F20: + return "F20"; + case KeyCode.F21: + return "F21"; + case KeyCode.F22: + return "F22"; + case KeyCode.F23: + return "F23"; + case KeyCode.F24: + return "F24"; + case KeyCode.PAGEUP: + return "PageUp"; + case KeyCode.PAGEDOWN: + return "PageDown"; + case KeyCode.HOME: + return "Home"; + case KeyCode.END: + return "End"; + case KeyCode.LEFT: + return "Left"; + case KeyCode.RIGHT: + return "Right"; + case KeyCode.UP: + return "Up"; + case KeyCode.DOWN: + return "Down"; + case KeyCode.INS: + return "Ins"; + case KeyCode.DEL: + return "Del"; + default: + return format("0x%08x", keyCode); + } +} struct Accelerator { uint keyCode; uint keyFlags; + /// returns accelerator text description + @property dstring label() { + dstring buf; + if (keyFlags & KeyFlag.Control) + buf ~= "Ctrl+"; + if (keyFlags & KeyFlag.Alt) + buf ~= "Alt+"; + if (keyFlags & KeyFlag.Shift) + buf ~= "Shift+"; + buf ~= toUTF32(keyName(keyCode)); + return cast(dstring)buf; + } } /// UI action @@ -39,25 +201,36 @@ class Action { this(int id) { _id = id; } - this(int id, string labelResourceId, string iconResourceId = null) { + this(int id, string labelResourceId, string iconResourceId = null, uint keyCode = 0, uint keyFlags = 0) { _id = id; _label = labelResourceId; _iconId = iconResourceId; - } - this(int id, dstring label, string iconResourceId = null) { - _id = id; - _label = label; - _iconId = iconResourceId; - } + if (keyCode) + _accelerators ~= Accelerator(keyCode, keyFlags); + } /// action with accelerator, w/o label this(int id, uint keyCode, uint keyFlags = 0) { _id = id; _accelerators ~= Accelerator(keyCode, keyFlags); } + /// action with label, icon, and accelerator + this(int id, dstring label, string iconResourceId = null, uint keyCode = 0, uint keyFlags = 0) { + _id = id; + _label = label; + _iconId = iconResourceId; + if (keyCode) + _accelerators ~= Accelerator(keyCode, keyFlags); + } /// returs array of accelerators @property Accelerator[] accelerators() { return _accelerators; } + /// returns text description for first accelerator of action; null if no accelerators + @property dstring acceleratorText() { + if (_accelerators.length < 1) + return null; + return _accelerators[0].label; + } /// returns true if accelerator matches provided key code and flags bool checkAccelerator(uint keyCode, uint keyFlags) { foreach(a; _accelerators) diff --git a/src/dlangui/core/i18n.d b/src/dlangui/core/i18n.d index d7c13e0a..71fb79d5 100644 --- a/src/dlangui/core/i18n.d +++ b/src/dlangui/core/i18n.d @@ -114,7 +114,8 @@ class UIStringTranslator { import std.file; foreach(dir; dirs) { string path = appendPath(dir, "i18n/"); - if (exists(path) && isDir(path)) { + if (exists(path) && isDir(path)) { + Log.i("Adding i18n dir ", path); _resourceDir = path; return _resourceDir; } diff --git a/src/dlangui/widgets/editors.d b/src/dlangui/widgets/editors.d index fd87fa46..02f32f77 100644 --- a/src/dlangui/widgets/editors.d +++ b/src/dlangui/widgets/editors.d @@ -30,6 +30,125 @@ import std.algorithm; immutable dchar EOL = '\n'; +/// Editor action codes +enum EditorActions { + None = 0, + /// move cursor one char left + Left = 1000, + /// move cursor one char left with selection + SelectLeft, + /// move cursor one char right + Right, + /// move cursor one char right with selection + SelectRight, + /// move cursor one line up + Up, + /// move cursor one line up with selection + SelectUp, + /// move cursor one line down + Down, + /// move cursor one line down with selection + SelectDown, + /// move cursor one word left + WordLeft, + /// move cursor one word left with selection + SelectWordLeft, + /// move cursor one word right + WordRight, + /// move cursor one word right with selection + SelectWordRight, + /// move cursor one page up + PageUp, + /// move cursor one page up with selection + SelectPageUp, + /// move cursor one page down + PageDown, + /// move cursor one page down with selection + SelectPageDown, + /// move cursor to the beginning of page + PageBegin, + /// move cursor to the beginning of page with selection + SelectPageBegin, + /// move cursor to the end of page + PageEnd, + /// move cursor to the end of page with selection + SelectPageEnd, + /// move cursor to the beginning of line + LineBegin, + /// move cursor to the beginning of line with selection + SelectLineBegin, + /// move cursor to the end of line + LineEnd, + /// move cursor to the end of line with selection + SelectLineEnd, + /// move cursor to the beginning of document + DocumentBegin, + /// move cursor to the beginning of document with selection + SelectDocumentBegin, + /// move cursor to the end of document + DocumentEnd, + /// move cursor to the end of document with selection + SelectDocumentEnd, + /// delete char before cursor (backspace) + DelPrevChar, + /// delete char after cursor (del key) + DelNextChar, + /// delete word before cursor (ctrl + backspace) + DelPrevWord, + /// delete char after cursor (ctrl + del key) + DelNextWord, + + /// insert new line (Enter) + InsertNewLine, + /// insert new line after current position (Ctrl+Enter) + PrependNewLine, + + /// Turn On/Off replace mode + ToggleReplaceMode, + + /// Copy selection to clipboard + Copy, + /// Cut selection to clipboard + Cut, + /// Paste selection from clipboard + Paste, + /// Undo last change + Undo, + /// Redo last undoed change + Redo, + + /// Tab (e.g., Tab key to insert tab character or indent text) + Tab, + /// Tab (unindent text, or remove whitespace before cursor, usually Shift+Tab) + BackTab, + + /// Select whole content (usually, Ctrl+A) + SelectAll, + + // Scroll operations + + /// Scroll one line up (not changing cursor) + ScrollLineUp, + /// Scroll one line down (not changing cursor) + ScrollLineDown, + /// Scroll one page up (not changing cursor) + ScrollPageUp, + /// Scroll one page down (not changing cursor) + ScrollPageDown, + /// Scroll window left + ScrollLeft, + /// Scroll window right + ScrollRight, + + /// Zoom in editor font + ZoomIn, + /// Zoom out editor font + ZoomOut, + +} + + + /// split dstring by delimiters dstring[] splitDString(dstring source, dchar delimiter = EOL) { int start = 0; @@ -683,123 +802,6 @@ class EditableContent { } } -/// Editor action codes -enum EditorActions { - None = 0, - /// move cursor one char left - Left = 1000, - /// move cursor one char left with selection - SelectLeft, - /// move cursor one char right - Right, - /// move cursor one char right with selection - SelectRight, - /// move cursor one line up - Up, - /// move cursor one line up with selection - SelectUp, - /// move cursor one line down - Down, - /// move cursor one line down with selection - SelectDown, - /// move cursor one word left - WordLeft, - /// move cursor one word left with selection - SelectWordLeft, - /// move cursor one word right - WordRight, - /// move cursor one word right with selection - SelectWordRight, - /// move cursor one page up - PageUp, - /// move cursor one page up with selection - SelectPageUp, - /// move cursor one page down - PageDown, - /// move cursor one page down with selection - SelectPageDown, - /// move cursor to the beginning of page - PageBegin, - /// move cursor to the beginning of page with selection - SelectPageBegin, - /// move cursor to the end of page - PageEnd, - /// move cursor to the end of page with selection - SelectPageEnd, - /// move cursor to the beginning of line - LineBegin, - /// move cursor to the beginning of line with selection - SelectLineBegin, - /// move cursor to the end of line - LineEnd, - /// move cursor to the end of line with selection - SelectLineEnd, - /// move cursor to the beginning of document - DocumentBegin, - /// move cursor to the beginning of document with selection - SelectDocumentBegin, - /// move cursor to the end of document - DocumentEnd, - /// move cursor to the end of document with selection - SelectDocumentEnd, - /// delete char before cursor (backspace) - DelPrevChar, - /// delete char after cursor (del key) - DelNextChar, - /// delete word before cursor (ctrl + backspace) - DelPrevWord, - /// delete char after cursor (ctrl + del key) - DelNextWord, - - /// insert new line (Enter) - InsertNewLine, - /// insert new line after current position (Ctrl+Enter) - PrependNewLine, - - /// Turn On/Off replace mode - ToggleReplaceMode, - - /// Copy selection to clipboard - Copy, - /// Cut selection to clipboard - Cut, - /// Paste selection from clipboard - Paste, - /// Undo last change - Undo, - /// Redo last undoed change - Redo, - - /// Tab (e.g., Tab key to insert tab character or indent text) - Tab, - /// Tab (unindent text, or remove whitespace before cursor, usually Shift+Tab) - BackTab, - - /// Select whole content (usually, Ctrl+A) - SelectAll, - - // Scroll operations - - /// Scroll one line up (not changing cursor) - ScrollLineUp, - /// Scroll one line down (not changing cursor) - ScrollLineDown, - /// Scroll one page up (not changing cursor) - ScrollPageUp, - /// Scroll one page down (not changing cursor) - ScrollPageDown, - /// Scroll window left - ScrollLeft, - /// Scroll window right - ScrollRight, - - /// Zoom in editor font - ZoomIn, - /// Zoom out editor font - ZoomOut, - -} - /// base for all editor widgets class EditWidgetBase : WidgetGroup, EditableContentListener { protected EditableContent _content; diff --git a/src/dlangui/widgets/menu.d b/src/dlangui/widgets/menu.d index 99431e57..9b6f15f6 100644 --- a/src/dlangui/widgets/menu.d +++ b/src/dlangui/widgets/menu.d @@ -53,7 +53,13 @@ class MenuItem { _subitems ~= new MenuItem(subitemAction); return this; } - /// returns true if item is submenu (contains subitems) + /// returns text description for first accelerator of action; null if no accelerators + @property dstring acceleratorText() { + if (!_action) + return null; + return _action.acceleratorText; + } + /// returns true if item is submenu (contains subitems) @property bool isSubmenu() { return _subitems.length > 0; } @@ -80,15 +86,33 @@ class MenuItem { /// widget to draw menu item class MenuItemWidget : HorizontalLayout { protected MenuItem _item; + protected ImageWidget _icon; + protected TextWidget _accel; protected TextWidget _label; @property MenuItem item() { return _item; } this(MenuItem item) { id="menuitem"; _item = item; styleId = "MENU_ITEM"; - _label = new TextWidget("MENU_LABEL"); + // icon + if (_item.action && _item.action.iconId.length) { + _icon = new ImageWidget("MENU_ICON", _item.action.iconId); + _icon.styleId = "MENU_ICON"; + addChild(_icon); + } + // label + _label = new TextWidget("MENU_LABEL"); _label.text = _item.label; - addChild(_label); + _label.styleId = "MENU_LABEL"; + addChild(_label); + // accelerator + dstring acc = _item.acceleratorText; + if (acc !is null) { + _accel = new TextWidget("MENU_ACCEL"); + _accel.styleId = "MENU_ACCEL"; + _accel.text = acc; + addChild(_accel); + } trackHover = true; clickable = true; } diff --git a/src/dlangui/widgets/styles.d b/src/dlangui/widgets/styles.d index 62acf8bb..f7934a92 100644 --- a/src/dlangui/widgets/styles.d +++ b/src/dlangui/widgets/styles.d @@ -705,6 +705,9 @@ Theme createDefaultTheme() { 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").margins(Rect(4,2,4,2)).alignment(Align.VCenter|Align.Left); + res.createSubstyle("MENU_LABEL").margins(Rect(8,2,8,2)).alignment(Align.VCenter|Align.Left); + res.createSubstyle("MENU_ACCEL").margins(Rect(4,2,4,2)).alignment(Align.VCenter|Align.Left); Style transparentButtonBackground = res.createSubstyle("TRANSPARENT_BUTTON_BACKGROUND").backgroundImageId("transparent_button_background").padding(Rect(4,2,4,2)); //.backgroundColor(0xE0E080) ; //transparentButtonBackground.createState(State.Focused, State.Focused).backgroundColor(0xC0C0C000);