Menu improvements
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 828 B |
After Width: | Height: | Size: 892 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 605 B |
After Width: | Height: | Size: 593 B |
After Width: | Height: | Size: 701 B |
After Width: | Height: | Size: 635 B |
After Width: | Height: | Size: 771 B |
After Width: | Height: | Size: 559 B |
After Width: | Height: | Size: 436 B |
After Width: | Height: | Size: 368 B |
After Width: | Height: | Size: 598 B |
After Width: | Height: | Size: 753 B |
After Width: | Height: | Size: 810 B |
|
@ -37,7 +37,12 @@ extern (C) int UIAppMain(string[] args) {
|
||||||
appendPath(exePath, "../../../res/mdpi/"), // for Visual D and DUB builds
|
appendPath(exePath, "../../../res/mdpi/"), // for Visual D and DUB builds
|
||||||
appendPath(exePath, "../../../../res/"),// for Mono-D builds
|
appendPath(exePath, "../../../../res/"),// for Mono-D builds
|
||||||
appendPath(exePath, "../../../../res/mdpi/"),// 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
|
// setup resource directories - will use only existing directories
|
||||||
drawableCache.setResourcePaths(resourceDirs);
|
drawableCache.setResourcePaths(resourceDirs);
|
||||||
|
@ -53,20 +58,23 @@ extern (C) int UIAppMain(string[] args) {
|
||||||
VerticalLayout contentLayout = new VerticalLayout();
|
VerticalLayout contentLayout = new VerticalLayout();
|
||||||
MenuItem mainMenuItems = new MenuItem();
|
MenuItem mainMenuItems = new MenuItem();
|
||||||
MenuItem fileItem = new MenuItem(new Action(1, "File"d));
|
MenuItem fileItem = new MenuItem(new Action(1, "File"d));
|
||||||
fileItem.add(new Action(10, "Open..."d));
|
fileItem.add(new Action(10, "Open..."d, "document-open", KeyCode.KEY_O, KeyFlag.Control));
|
||||||
fileItem.add(new Action(11, "Save..."d));
|
fileItem.add(new Action(11, "Save..."d, "document-save", KeyCode.KEY_S, KeyFlag.Control));
|
||||||
MenuItem openRecentItem = new MenuItem(new Action(13, "Open recent..."d));
|
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(100, "File 1"d));
|
||||||
openRecentItem.add(new Action(101, "File 2"d));
|
openRecentItem.add(new Action(101, "File 2"d));
|
||||||
openRecentItem.add(new Action(102, "File 3"d));
|
openRecentItem.add(new Action(102, "File 3"d));
|
||||||
openRecentItem.add(new Action(103, "File 4"d));
|
openRecentItem.add(new Action(103, "File 4"d));
|
||||||
openRecentItem.add(new Action(104, "File 5"d));
|
openRecentItem.add(new Action(104, "File 5"d));
|
||||||
fileItem.add(openRecentItem);
|
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));
|
MenuItem editItem = new MenuItem(new Action(2, "Edit"d));
|
||||||
editItem.add(new Action(20, "Copy"d));
|
editItem.add(new Action(EditorActions.Copy, "Copy"d, "edit-copy", KeyCode.KEY_C, KeyFlag.Control));
|
||||||
editItem.add(new Action(21, "Paste"d));
|
editItem.add(new Action(EditorActions.Paste, "Paste"d, "edit-paste", KeyCode.KEY_V, KeyFlag.Control));
|
||||||
editItem.add(new Action(22, "Cut"d));
|
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));
|
MenuItem windowItem = new MenuItem(new Action(3, "Window"d));
|
||||||
windowItem.add(new Action(30, "Preferences"d));
|
windowItem.add(new Action(30, "Preferences"d));
|
||||||
MenuItem helpItem = new MenuItem(new Action(4, "Help"d));
|
MenuItem helpItem = new MenuItem(new Action(4, "Help"d));
|
||||||
|
|
|
@ -21,13 +21,175 @@ module dlangui.core.events;
|
||||||
|
|
||||||
import dlangui.core.i18n;
|
import dlangui.core.i18n;
|
||||||
import dlangui.core.collections;
|
import dlangui.core.collections;
|
||||||
|
|
||||||
private import dlangui.widgets.widget;
|
private import dlangui.widgets.widget;
|
||||||
|
|
||||||
|
import std.string;
|
||||||
import std.conv;
|
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 {
|
struct Accelerator {
|
||||||
uint keyCode;
|
uint keyCode;
|
||||||
uint keyFlags;
|
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
|
/// UI action
|
||||||
|
@ -39,25 +201,36 @@ class Action {
|
||||||
this(int id) {
|
this(int id) {
|
||||||
_id = 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;
|
_id = id;
|
||||||
_label = labelResourceId;
|
_label = labelResourceId;
|
||||||
_iconId = iconResourceId;
|
_iconId = iconResourceId;
|
||||||
}
|
if (keyCode)
|
||||||
this(int id, dstring label, string iconResourceId = null) {
|
_accelerators ~= Accelerator(keyCode, keyFlags);
|
||||||
_id = id;
|
|
||||||
_label = label;
|
|
||||||
_iconId = iconResourceId;
|
|
||||||
}
|
}
|
||||||
/// action with accelerator, w/o label
|
/// action with accelerator, w/o label
|
||||||
this(int id, uint keyCode, uint keyFlags = 0) {
|
this(int id, uint keyCode, uint keyFlags = 0) {
|
||||||
_id = id;
|
_id = id;
|
||||||
_accelerators ~= Accelerator(keyCode, keyFlags);
|
_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
|
/// returs array of accelerators
|
||||||
@property Accelerator[] accelerators() {
|
@property Accelerator[] accelerators() {
|
||||||
return _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
|
/// returns true if accelerator matches provided key code and flags
|
||||||
bool checkAccelerator(uint keyCode, uint keyFlags) {
|
bool checkAccelerator(uint keyCode, uint keyFlags) {
|
||||||
foreach(a; _accelerators)
|
foreach(a; _accelerators)
|
||||||
|
|
|
@ -115,6 +115,7 @@ class UIStringTranslator {
|
||||||
foreach(dir; dirs) {
|
foreach(dir; dirs) {
|
||||||
string path = appendPath(dir, "i18n/");
|
string path = appendPath(dir, "i18n/");
|
||||||
if (exists(path) && isDir(path)) {
|
if (exists(path) && isDir(path)) {
|
||||||
|
Log.i("Adding i18n dir ", path);
|
||||||
_resourceDir = path;
|
_resourceDir = path;
|
||||||
return _resourceDir;
|
return _resourceDir;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,125 @@ import std.algorithm;
|
||||||
|
|
||||||
immutable dchar EOL = '\n';
|
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
|
/// split dstring by delimiters
|
||||||
dstring[] splitDString(dstring source, dchar delimiter = EOL) {
|
dstring[] splitDString(dstring source, dchar delimiter = EOL) {
|
||||||
int start = 0;
|
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
|
/// base for all editor widgets
|
||||||
class EditWidgetBase : WidgetGroup, EditableContentListener {
|
class EditWidgetBase : WidgetGroup, EditableContentListener {
|
||||||
protected EditableContent _content;
|
protected EditableContent _content;
|
||||||
|
|
|
@ -52,6 +52,12 @@ class MenuItem {
|
||||||
MenuItem add(Action subitemAction) {
|
MenuItem add(Action subitemAction) {
|
||||||
_subitems ~= new MenuItem(subitemAction);
|
_subitems ~= new MenuItem(subitemAction);
|
||||||
return this;
|
return this;
|
||||||
|
}
|
||||||
|
/// 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)
|
/// returns true if item is submenu (contains subitems)
|
||||||
@property bool isSubmenu() {
|
@property bool isSubmenu() {
|
||||||
|
@ -80,15 +86,33 @@ class MenuItem {
|
||||||
/// widget to draw menu item
|
/// widget to draw menu item
|
||||||
class MenuItemWidget : HorizontalLayout {
|
class MenuItemWidget : HorizontalLayout {
|
||||||
protected MenuItem _item;
|
protected MenuItem _item;
|
||||||
|
protected ImageWidget _icon;
|
||||||
|
protected TextWidget _accel;
|
||||||
protected TextWidget _label;
|
protected TextWidget _label;
|
||||||
@property MenuItem item() { return _item; }
|
@property MenuItem item() { return _item; }
|
||||||
this(MenuItem item) {
|
this(MenuItem item) {
|
||||||
id="menuitem";
|
id="menuitem";
|
||||||
_item = item;
|
_item = item;
|
||||||
styleId = "MENU_ITEM";
|
styleId = "MENU_ITEM";
|
||||||
|
// 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 = new TextWidget("MENU_LABEL");
|
||||||
_label.text = _item.label;
|
_label.text = _item.label;
|
||||||
|
_label.styleId = "MENU_LABEL";
|
||||||
addChild(_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;
|
trackHover = true;
|
||||||
clickable = true;
|
clickable = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -705,6 +705,9 @@ Theme createDefaultTheme() {
|
||||||
menuItem.createState(State.Pressed, State.Pressed).backgroundColor(0x4080C000);
|
menuItem.createState(State.Pressed, State.Pressed).backgroundColor(0x4080C000);
|
||||||
menuItem.createState(State.Selected, State.Selected).backgroundColor(0x00F8F9Fa);
|
menuItem.createState(State.Selected, State.Selected).backgroundColor(0x00F8F9Fa);
|
||||||
menuItem.createState(State.Hovered, State.Hovered).backgroundColor(0xC0FFFF00);
|
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) ;
|
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);
|
//transparentButtonBackground.createState(State.Focused, State.Focused).backgroundColor(0xC0C0C000);
|
||||||
|
|