diff --git a/src/dlangui/core/events.d b/src/dlangui/core/events.d index 179050d5..092f252e 100644 --- a/src/dlangui/core/events.d +++ b/src/dlangui/core/events.d @@ -1016,25 +1016,26 @@ class ScrollEvent { /// default update position for actions like PageUp/PageDown, LineUp/LineDown int defaultUpdatePosition() { int delta = 0; - switch (_action) { - case ScrollAction.LineUp: + switch (_action) with(ScrollAction) + { + case LineUp: delta = _pageSize / 20; if (delta < 1) delta = 1; delta = -delta; break; - case ScrollAction.LineDown: + case LineDown: delta = _pageSize / 20; if (delta < 1) delta = 1; break; - case ScrollAction.PageUp: + case PageUp: delta = _pageSize * 3 / 4; if (delta < 1) delta = 1; delta = -delta; break; - case ScrollAction.PageDown: + case PageDown: delta = _pageSize * 3 / 4; if (delta < 1) delta = 1; diff --git a/src/dlangui/core/files.d b/src/dlangui/core/files.d index 5e92a088..69b61296 100644 --- a/src/dlangui/core/files.d +++ b/src/dlangui/core/files.d @@ -75,22 +75,23 @@ struct RootEntry { @property dstring label() { return _display; } /// Returns icon resource id @property string icon() { - switch (type) { - case RootEntryType.NETWORK: + switch (type) with(RootEntryType) + { + case NETWORK: return "folder-network"; - case RootEntryType.BOOKMARK: + case BOOKMARK: return "folder-bookmark"; - case RootEntryType.CDROM: + case CDROM: return "drive-optical"; - case RootEntryType.FIXED: + case FIXED: return "drive-harddisk"; - case RootEntryType.HOME: + case HOME: return "user-home"; - case RootEntryType.ROOT: + case ROOT: return "computer"; - case RootEntryType.SDCARD: + case SDCARD: return "media-flash-sd-mmc"; - case RootEntryType.REMOVABLE: + case REMOVABLE: return "device-removable-media"; default: return "folder-blue"; diff --git a/src/dlangui/core/linestream.d b/src/dlangui/core/linestream.d index 766e0c63..111fb5ec 100644 --- a/src/dlangui/core/linestream.d +++ b/src/dlangui/core/linestream.d @@ -139,8 +139,9 @@ class OutputLineStream { /// reserve buf space if (_buf.length < _len + s.length * 4 + 4) _buf.length = _len + s.length * 4 + 4; - switch (_format.encoding) { - case EncodingType.UTF8: + switch (_format.encoding) with(EncodingType) + { + case UTF8: default: char[4] d; for (int i = 0; i < s.length; i++) { @@ -149,7 +150,7 @@ class OutputLineStream { _buf[_len++] = d[j]; } break; - case EncodingType.UTF16BE: + case UTF16BE: wchar[2] d; for (int i = 0; i < s.length; i++) { int n = cast(int)encode(d, s[i]); @@ -159,7 +160,7 @@ class OutputLineStream { } } break; - case EncodingType.UTF16LE: + case UTF16LE: wchar[2] d; for (int i = 0; i < s.length; i++) { int n = cast(int)encode(d, s[i]); @@ -169,7 +170,7 @@ class OutputLineStream { } } break; - case EncodingType.UTF32LE: + case UTF32LE: for (int i = 0; i < s.length; i++) { dchar ch = s[i]; _buf[_len++] = cast(char)((ch >> 0) & 0xFF); @@ -178,7 +179,7 @@ class OutputLineStream { _buf[_len++] = cast(char)((ch >> 24) & 0xFF); } break; - case EncodingType.UTF32BE: + case UTF32BE: for (int i = 0; i < s.length; i++) { dchar ch = s[i]; _buf[_len++] = cast(char)((ch >> 24) & 0xFF); diff --git a/src/dlangui/core/logger.d b/src/dlangui/core/logger.d index 8587e7a0..489637d4 100644 --- a/src/dlangui/core/logger.d +++ b/src/dlangui/core/logger.d @@ -128,13 +128,14 @@ class Log { /// Log level to name helper function static public string logLevelName(LogLevel level) { - switch (level) { - case LogLevel.Fatal: return "F"; - case LogLevel.Error: return "E"; - case LogLevel.Warn: return "W"; - case LogLevel.Info: return "I"; - case LogLevel.Debug: return "D"; - case LogLevel.Trace: return "V"; + switch (level) with(LogLevel) + { + case Fatal: return "F"; + case Error: return "E"; + case Warn: return "W"; + case Info: return "I"; + case Debug: return "D"; + case Trace: return "V"; default: return "?"; } } diff --git a/src/dlangui/graphics/colors.d b/src/dlangui/graphics/colors.d index 6b288bb9..91701999 100644 --- a/src/dlangui/graphics/colors.d +++ b/src/dlangui/graphics/colors.d @@ -59,10 +59,10 @@ immutable int[3] COMPONENT_OFFSET_BGR = [2, 1, 0]; immutable int[3] COMPONENT_OFFSET_RGB = [0, 1, 2]; immutable int COMPONENT_OFFSET_ALPHA = 3; int subpixelComponentIndex(int x0, SubpixelRenderingMode mode) { - switch (mode) { - case SubpixelRenderingMode.RGB: + switch (mode) with(SubpixelRenderingMode) { + case RGB: return COMPONENT_OFFSET_BGR[x0]; - case SubpixelRenderingMode.BGR: + case BGR: default: return COMPONENT_OFFSET_BGR[x0]; } diff --git a/src/dlangui/platforms/dsfml/dsfmlapp.d b/src/dlangui/platforms/dsfml/dsfmlapp.d index 65cf3640..7af674b3 100644 --- a/src/dlangui/platforms/dsfml/dsfmlapp.d +++ b/src/dlangui/platforms/dsfml/dsfmlapp.d @@ -105,136 +105,137 @@ class DSFMLWindow : dlangui.platforms.common.platform.Window { } private MouseButton translateButton(uint btn) { - switch(btn) { + switch(btn) with(Mouse.Button) { default: - case Mouse.Button.Left: + case Left: return MouseButton.Left; - case Mouse.Button.Right: + case Right: return MouseButton.Right; - case Mouse.Button.Middle: + case Middle: return MouseButton.Middle; - case Mouse.Button.XButton1: + case XButton1: return MouseButton.XButton1; - case Mouse.Button.XButton2: + case XButton2: return MouseButton.XButton2; } } private uint translateKey(uint key) { - switch(key) { - case Keyboard.Key.A: return KeyCode.KEY_A; - case Keyboard.Key.B: return KeyCode.KEY_B; - case Keyboard.Key.C: return KeyCode.KEY_C; - case Keyboard.Key.D: return KeyCode.KEY_D; - case Keyboard.Key.E: return KeyCode.KEY_E; - case Keyboard.Key.F: return KeyCode.KEY_F; - case Keyboard.Key.G: return KeyCode.KEY_G; - case Keyboard.Key.H: return KeyCode.KEY_H; - case Keyboard.Key.I: return KeyCode.KEY_I; - case Keyboard.Key.J: return KeyCode.KEY_J; - case Keyboard.Key.K: return KeyCode.KEY_K; - case Keyboard.Key.L: return KeyCode.KEY_L; - case Keyboard.Key.M: return KeyCode.KEY_M; - case Keyboard.Key.N: return KeyCode.KEY_N; - case Keyboard.Key.O: return KeyCode.KEY_O; - case Keyboard.Key.P: return KeyCode.KEY_P; - case Keyboard.Key.Q: return KeyCode.KEY_Q; - case Keyboard.Key.R: return KeyCode.KEY_R; - case Keyboard.Key.S: return KeyCode.KEY_S; - case Keyboard.Key.T: return KeyCode.KEY_T; - case Keyboard.Key.U: return KeyCode.KEY_U; - case Keyboard.Key.V: return KeyCode.KEY_V; - case Keyboard.Key.W: return KeyCode.KEY_W; - case Keyboard.Key.X: return KeyCode.KEY_X; - case Keyboard.Key.Y: return KeyCode.KEY_Y; - case Keyboard.Key.Z: return KeyCode.KEY_Z; - case Keyboard.Key.Num0: return KeyCode.KEY_0; - case Keyboard.Key.Num1: return KeyCode.KEY_1; - case Keyboard.Key.Num2: return KeyCode.KEY_2; - case Keyboard.Key.Num3: return KeyCode.KEY_3; - case Keyboard.Key.Num4: return KeyCode.KEY_4; - case Keyboard.Key.Num5: return KeyCode.KEY_5; - case Keyboard.Key.Num6: return KeyCode.KEY_6; - case Keyboard.Key.Num7: return KeyCode.KEY_7; - case Keyboard.Key.Num8: return KeyCode.KEY_8; - case Keyboard.Key.Num9: return KeyCode.KEY_9; - case Keyboard.Key.Escape: return KeyCode.ESCAPE; - case Keyboard.Key.LControl: return KeyCode.LCONTROL; - case Keyboard.Key.LShift: return KeyCode.LSHIFT; - case Keyboard.Key.LAlt: return KeyCode.LALT; - case Keyboard.Key.RControl: return KeyCode.RCONTROL; - case Keyboard.Key.RShift: return KeyCode.RSHIFT; - case Keyboard.Key.RAlt: return KeyCode.RALT; + switch(key) with(Keyboard.Key) + { + case A: return KeyCode.KEY_A; + case B: return KeyCode.KEY_B; + case C: return KeyCode.KEY_C; + case D: return KeyCode.KEY_D; + case E: return KeyCode.KEY_E; + case F: return KeyCode.KEY_F; + case G: return KeyCode.KEY_G; + case H: return KeyCode.KEY_H; + case I: return KeyCode.KEY_I; + case J: return KeyCode.KEY_J; + case K: return KeyCode.KEY_K; + case L: return KeyCode.KEY_L; + case M: return KeyCode.KEY_M; + case N: return KeyCode.KEY_N; + case O: return KeyCode.KEY_O; + case P: return KeyCode.KEY_P; + case Q: return KeyCode.KEY_Q; + case R: return KeyCode.KEY_R; + case S: return KeyCode.KEY_S; + case T: return KeyCode.KEY_T; + case U: return KeyCode.KEY_U; + case V: return KeyCode.KEY_V; + case W: return KeyCode.KEY_W; + case X: return KeyCode.KEY_X; + case Y: return KeyCode.KEY_Y; + case Z: return KeyCode.KEY_Z; + case Num0: return KeyCode.KEY_0; + case Num1: return KeyCode.KEY_1; + case Num2: return KeyCode.KEY_2; + case Num3: return KeyCode.KEY_3; + case Num4: return KeyCode.KEY_4; + case Num5: return KeyCode.KEY_5; + case Num6: return KeyCode.KEY_6; + case Num7: return KeyCode.KEY_7; + case Num8: return KeyCode.KEY_8; + case Num9: return KeyCode.KEY_9; + case Escape: return KeyCode.ESCAPE; + case LControl: return KeyCode.LCONTROL; + case LShift: return KeyCode.LSHIFT; + case LAlt: return KeyCode.LALT; + case RControl: return KeyCode.RCONTROL; + case RShift: return KeyCode.RSHIFT; + case RAlt: return KeyCode.RALT; ///The [ key - case Keyboard.Key.LBracket: return KeyCode.KEY_BRACKETOPEN; + case LBracket: return KeyCode.KEY_BRACKETOPEN; ///The ] key - case Keyboard.Key.RBracket: return KeyCode.KEY_BRACKETCLOSE; + case RBracket: return KeyCode.KEY_BRACKETCLOSE; ///The ; key - case Keyboard.Key.SemiColon: return KeyCode.KEY_BRACKETOPEN; + case SemiColon: return KeyCode.KEY_BRACKETOPEN; ///The , key - case Keyboard.Key.Comma: return KeyCode.KEY_COMMA; + case Comma: return KeyCode.KEY_COMMA; ///The . key - case Keyboard.Key.Period: return KeyCode.KEY_PERIOD; + case Period: return KeyCode.KEY_PERIOD; ///The ' key - case Keyboard.Key.Quote: return KeyCode.QUOTE; + case Quote: return KeyCode.QUOTE; ///The / key - case Keyboard.Key.Slash: return KeyCode.KEY_DIVIDE; + case Slash: return KeyCode.KEY_DIVIDE; ///The \ key - case Keyboard.Key.BackSlash: return KeyCode.BACKSLASH; + case BackSlash: return KeyCode.BACKSLASH; ///The ~ key - case Keyboard.Key.Tilde: return KeyCode.TILDE; + case Tilde: return KeyCode.TILDE; ///The = key - case Keyboard.Key.Equal: return KeyCode.EQUAL; + case Equal: return KeyCode.EQUAL; ///The - key - case Keyboard.Key.Dash: return KeyCode.SUB; + case Dash: return KeyCode.SUB; ///The Space key - case Keyboard.Key.Space: return KeyCode.SPACE; + case Space: return KeyCode.SPACE; - case Keyboard.Key.Numpad0: return KeyCode.NUM_0; - case Keyboard.Key.Numpad1: return KeyCode.NUM_1; - case Keyboard.Key.Numpad2: return KeyCode.NUM_2; - case Keyboard.Key.Numpad3: return KeyCode.NUM_3; - case Keyboard.Key.Numpad4: return KeyCode.NUM_4; - case Keyboard.Key.Numpad5: return KeyCode.NUM_5; - case Keyboard.Key.Numpad6: return KeyCode.NUM_6; - case Keyboard.Key.Numpad7: return KeyCode.NUM_7; - case Keyboard.Key.Numpad8: return KeyCode.NUM_8; - case Keyboard.Key.Numpad9: return KeyCode.NUM_9; + case Numpad0: return KeyCode.NUM_0; + case Numpad1: return KeyCode.NUM_1; + case Numpad2: return KeyCode.NUM_2; + case Numpad3: return KeyCode.NUM_3; + case Numpad4: return KeyCode.NUM_4; + case Numpad5: return KeyCode.NUM_5; + case Numpad6: return KeyCode.NUM_6; + case Numpad7: return KeyCode.NUM_7; + case Numpad8: return KeyCode.NUM_8; + case Numpad9: return KeyCode.NUM_9; - case Keyboard.Key.F1: return KeyCode.F1; - case Keyboard.Key.F2: return KeyCode.F2; - case Keyboard.Key.F3: return KeyCode.F3; - case Keyboard.Key.F4: return KeyCode.F4; - case Keyboard.Key.F5: return KeyCode.F5; - case Keyboard.Key.F6: return KeyCode.F6; - case Keyboard.Key.F7: return KeyCode.F7; - case Keyboard.Key.F8: return KeyCode.F8; - case Keyboard.Key.F9: return KeyCode.F9; - case Keyboard.Key.F10: return KeyCode.F10; - case Keyboard.Key.F11: return KeyCode.F11; - case Keyboard.Key.F12: return KeyCode.F12; - case Keyboard.Key.F13: return KeyCode.F13; - case Keyboard.Key.F14: return KeyCode.F14; - case Keyboard.Key.F15: return KeyCode.F15; + case F1: return KeyCode.F1; + case F2: return KeyCode.F2; + case F3: return KeyCode.F3; + case F4: return KeyCode.F4; + case F5: return KeyCode.F5; + case F6: return KeyCode.F6; + case F7: return KeyCode.F7; + case F8: return KeyCode.F8; + case F9: return KeyCode.F9; + case F10: return KeyCode.F10; + case F11: return KeyCode.F11; + case F12: return KeyCode.F12; + case F13: return KeyCode.F13; + case F14: return KeyCode.F14; + case F15: return KeyCode.F15; - case Keyboard.Key.Return: return KeyCode.RETURN; - case Keyboard.Key.BackSpace: return KeyCode.BACK; - case Keyboard.Key.Tab: return KeyCode.TAB; - case Keyboard.Key.PageUp: return KeyCode.PAGEUP; - case Keyboard.Key.PageDown: return KeyCode.PAGEDOWN; - case Keyboard.Key.End: return KeyCode.END; - case Keyboard.Key.Home: return KeyCode.HOME; - case Keyboard.Key.Insert: return KeyCode.INS; - case Keyboard.Key.Delete: return KeyCode.DEL; - case Keyboard.Key.Add: return KeyCode.ADD; - case Keyboard.Key.Subtract: return KeyCode.SUB; - case Keyboard.Key.Multiply: return KeyCode.MUL; - case Keyboard.Key.Divide: return KeyCode.DIV; - case Keyboard.Key.Left: return KeyCode.LEFT; - case Keyboard.Key.Right: return KeyCode.RIGHT; - case Keyboard.Key.Up: return KeyCode.UP; - case Keyboard.Key.Down: return KeyCode.DOWN; + case Return: return KeyCode.RETURN; + case BackSpace: return KeyCode.BACK; + case Tab: return KeyCode.TAB; + case PageUp: return KeyCode.PAGEUP; + case PageDown: return KeyCode.PAGEDOWN; + case End: return KeyCode.END; + case Home: return KeyCode.HOME; + case Insert: return KeyCode.INS; + case Delete: return KeyCode.DEL; + case Add: return KeyCode.ADD; + case Subtract: return KeyCode.SUB; + case Multiply: return KeyCode.MUL; + case Divide: return KeyCode.DIV; + case Left: return KeyCode.LEFT; + case Right: return KeyCode.RIGHT; + case Up: return KeyCode.UP; + case Down: return KeyCode.DOWN; default: return 0x8000_0000 | key; } } @@ -243,46 +244,46 @@ class DSFMLWindow : dlangui.platforms.common.platform.Window { private ushort keyFlags; bool handleEvent(ref Event event) { - switch (event.type) { - case(event.EventType.Closed): { + switch (event.type) with(event.EventType) { + case Closed: { break; } - case(event.EventType.Resized): { + case Resized: { onResize(event.size.width, event.size.height); break; } - case(event.EventType.MouseButtonPressed): { + case MouseButtonPressed: { auto btn = translateButton(event.mouseButton.button); mouseFlags |= mouseButtonToFlag(btn); MouseEvent ev = new MouseEvent(MouseAction.ButtonDown, btn, mouseFlags, cast(short)event.mouseButton.x, cast(short)event.mouseButton.y); return dispatchMouseEvent(ev); } - case(event.EventType.MouseButtonReleased): { + case MouseButtonReleased: { auto btn = translateButton(event.mouseButton.button); mouseFlags &= ~mouseButtonToFlag(btn); MouseEvent ev = new MouseEvent(MouseAction.ButtonUp, btn, mouseFlags, cast(short)event.mouseButton.x, cast(short)event.mouseButton.y); return dispatchMouseEvent(ev); } - case(event.EventType.MouseMoved): { + case MouseMoved: { MouseEvent ev = new MouseEvent(MouseAction.Move, MouseButton.None, mouseFlags, cast(short)event.mouseMove.x, cast(short)event.mouseMove.y); return dispatchMouseEvent(ev); } - case(event.EventType.MouseEntered): { + case MouseEntered: { break; } - case(event.EventType.MouseLeft): { + case MouseLeft: { mouseFlags = 0; break; } - case(event.EventType.MouseWheelMoved): { + case MouseWheelMoved: { break; } - case(event.EventType.TextEntered): { + case TextEntered: { KeyEvent ev = new KeyEvent(KeyAction.Text, 0, 0, [event.text.unicode]); return dispatchKeyEvent(ev); } - case(event.EventType.KeyReleased): - case(event.EventType.KeyPressed): { + case KeyReleased: + case KeyPressed: { keyFlags = 0; if (event.key.alt) keyFlags |= KeyFlag.Alt; diff --git a/src/dlangui/platforms/sdl/sdlapp.d b/src/dlangui/platforms/sdl/sdlapp.d index 32a0cfb1..5e8a2b4e 100644 --- a/src/dlangui/platforms/sdl/sdlapp.d +++ b/src/dlangui/platforms/sdl/sdlapp.d @@ -346,41 +346,42 @@ class SDLWindow : Window { return; } // create new cursor - switch (cursorType) { - case CursorType.Arrow: + switch (cursorType) with(CursorType) + { + case Arrow: cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW); break; - case CursorType.IBeam: + case IBeam: cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM); break; - case CursorType.Wait: + case Wait: cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAIT); break; - case CursorType.WaitArrow: + case WaitArrow: cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAITARROW); break; - case CursorType.Crosshair: + case Crosshair: cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_CROSSHAIR); break; - case CursorType.No: + case No: cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NO); break; - case CursorType.Hand: + case Hand: cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND); break; - case CursorType.SizeNWSE: + case SizeNWSE: cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE); break; - case CursorType.SizeNESW: + case SizeNESW: cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW); break; - case CursorType.SizeWE: + case SizeWE: cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE); break; - case CursorType.SizeNS: + case SizeNS: cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS); break; - case CursorType.SizeAll: + case SizeAll: cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL); break; default: diff --git a/src/dlangui/platforms/windows/winapp.d b/src/dlangui/platforms/windows/winapp.d index 6c40880c..6156a33d 100644 --- a/src/dlangui/platforms/windows/winapp.d +++ b/src/dlangui/platforms/windows/winapp.d @@ -443,46 +443,47 @@ class Win32Window : Window { void onSetCursorType() { HANDLE winCursor = null; - switch (_cursorType) { - case CursorType.None: + switch (_cursorType) with(CursorType) + { + case None: winCursor = null; break; - case CursorType.Parent: + case Parent: break; - case CursorType.Arrow: + case Arrow: winCursor = loadCursor(IDC_ARROW); break; - case CursorType.IBeam: + case IBeam: winCursor = loadCursor(IDC_IBEAM); break; - case CursorType.Wait: + case Wait: winCursor = loadCursor(IDC_WAIT); break; - case CursorType.Crosshair: + case Crosshair: winCursor = loadCursor(IDC_CROSS); break; - case CursorType.WaitArrow: + case WaitArrow: winCursor = loadCursor(IDC_APPSTARTING); break; - case CursorType.SizeNWSE: + case SizeNWSE: winCursor = loadCursor(IDC_SIZENWSE); break; - case CursorType.SizeNESW: + case SizeNESW: winCursor = loadCursor(IDC_SIZENESW); break; - case CursorType.SizeWE: + case SizeWE: winCursor = loadCursor(IDC_SIZEWE); break; - case CursorType.SizeNS: + case SizeNS: winCursor = loadCursor(IDC_SIZENS); break; - case CursorType.SizeAll: + case SizeAll: winCursor = loadCursor(IDC_SIZEALL); break; - case CursorType.No: + case No: winCursor = loadCursor(IDC_NO); break; - case CursorType.Hand: + case Hand: winCursor = loadCursor(IDC_HAND); break; default: diff --git a/src/dlangui/widgets/docks.d b/src/dlangui/widgets/docks.d index 53174336..4bbbd836 100644 --- a/src/dlangui/widgets/docks.d +++ b/src/dlangui/widgets/docks.d @@ -56,17 +56,18 @@ struct DockSpace { ResizerWidget init(DockHost host, DockAlignment a) { _host = host; _alignment = a; - final switch (a) { - case DockAlignment.Top: + final switch (a) with(DockAlignment) + { + case Top: _resizer = new ResizerWidget("top_resizer", Orientation.Vertical); break; - case DockAlignment.Bottom: + case Bottom: _resizer = new ResizerWidget("bottom_resizer", Orientation.Vertical); break; - case DockAlignment.Left: + case Left: _resizer = new ResizerWidget("left_resizer", Orientation.Horizontal); break; - case DockAlignment.Right: + case Right: _resizer = new ResizerWidget("right_resizer", Orientation.Horizontal); break; } @@ -104,20 +105,21 @@ struct DockSpace { int rsWidth = 3; // resizer width if (_space) { _rc = rc; - final switch (_alignment) { - case DockAlignment.Top: + final switch (_alignment) with(DockAlignment) + { + case Top: _resizerRect = Rect(rc.left, rc.bottom - rsWidth, rc.right, rc.bottom + rsWidth); _dockRect = Rect(rc.left, rc.top, rc.right, rc.bottom - rsWidth); break; - case DockAlignment.Bottom: + case Bottom: _resizerRect = Rect(rc.left, rc.top - rsWidth, rc.right, rc.top + rsWidth); _dockRect = Rect(rc.left, rc.top + rsWidth, rc.right, rc.bottom); break; - case DockAlignment.Left: + case Left: _resizerRect = Rect(rc.right - rsWidth, rc.top, rc.right + rsWidth, rc.bottom); _dockRect = Rect(rc.left, rc.top, rc.right - rsWidth, rc.bottom); break; - case DockAlignment.Right: + case Right: _resizerRect = Rect(rc.left - rsWidth, rc.top, rc.left + rsWidth, rc.bottom); _dockRect = Rect(rc.left + rsWidth, rc.top, rc.right, rc.bottom); break; diff --git a/src/dlangui/widgets/editors.d b/src/dlangui/widgets/editors.d index 83839358..d927afcd 100644 --- a/src/dlangui/widgets/editors.d +++ b/src/dlangui/widgets/editors.d @@ -540,27 +540,28 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction /// override to change popup menu items state override bool isActionEnabled(const Action action) { - switch (action.id) { - case EditorActions.Tab: - case EditorActions.BackTab: - case EditorActions.Indent: - case EditorActions.Unindent: + switch (action.id) with(EditorActions) + { + case Tab: + case BackTab: + case Indent: + case Unindent: return enabled; - case EditorActions.Copy: + case Copy: return !_selectionRange.empty; - case EditorActions.Cut: + case Cut: return enabled && !_selectionRange.empty; - case EditorActions.Paste: + case Paste: return enabled && Platform.instance.getClipboardText().length > 0; - case EditorActions.Undo: + case Undo: return enabled && _content.hasUndo; - case EditorActions.Redo: + case Redo: return enabled && _content.hasRedo; - case EditorActions.ToggleBookmark: + case ToggleBookmark: return _content.multiline; - case EditorActions.GoToNextBookmark: + case GoToNextBookmark: return _content.multiline && _content.lineIcons.hasBookmarks; - case EditorActions.GoToPreviousBookmark: + case GoToPreviousBookmark: return _content.multiline && _content.lineIcons.hasBookmarks; default: return super.isActionEnabled(action); @@ -1092,8 +1093,9 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction /// override to handle specific actions state (e.g. change enabled state for supported actions) override bool handleActionStateRequest(const Action a) { - switch (a.id) { - case EditorActions.ToggleBlockComment: + switch (a.id) with(EditorActions) + { + case ToggleBlockComment: if (!_content.syntaxSupport || !_content.syntaxSupport.supportsToggleBlockComment) a.state = ACTION_STATE_INVISIBLE; else if (enabled && _content.syntaxSupport.canToggleBlockComment(_selectionRange)) @@ -1101,7 +1103,7 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction else a.state = ACTION_STATE_DISABLE; return true; - case EditorActions.ToggleLineComment: + case ToggleLineComment: if (!_content.syntaxSupport || !_content.syntaxSupport.supportsToggleLineComment) a.state = ACTION_STATE_INVISIBLE; else if (enabled && _content.syntaxSupport.canToggleLineComment(_selectionRange)) @@ -1109,15 +1111,15 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction else a.state = ACTION_STATE_DISABLE; return true; - case EditorActions.Copy: - case EditorActions.Cut: - case EditorActions.Paste: - case EditorActions.Undo: - case EditorActions.Redo: - case EditorActions.Tab: - case EditorActions.BackTab: - case EditorActions.Indent: - case EditorActions.Unindent: + case Copy: + case Cut: + case Paste: + case Undo: + case Redo: + case Tab: + case BackTab: + case Indent: + case Unindent: if (isActionEnabled(a)) a.state = ACTION_STATE_ENABLED; else @@ -1131,9 +1133,10 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction override protected bool handleAction(const Action a) { TextPosition oldCaretPos = _caretPos; dstring currentLine = _content[_caretPos.line]; - switch (a.id) { - case EditorActions.Left: - case EditorActions.SelectLeft: + switch (a.id) with(EditorActions) + { + case Left: + case SelectLeft: correctCaretPos(); if (_caretPos.pos > 0) { _caretPos.pos--; @@ -1145,8 +1148,8 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction ensureCaretVisible(); } return true; - case EditorActions.Right: - case EditorActions.SelectRight: + case Right: + case SelectRight: correctCaretPos(); if (_caretPos.pos < currentLine.length) { _caretPos.pos++; @@ -1159,8 +1162,8 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction ensureCaretVisible(); } return true; - case EditorActions.WordLeft: - case EditorActions.SelectWordLeft: + case WordLeft: + case SelectWordLeft: { TextPosition newpos = _content.moveByWord(_caretPos, -1, _camelCasePartsAsWords); if (newpos != _caretPos) { @@ -1170,8 +1173,8 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction } } return true; - case EditorActions.WordRight: - case EditorActions.SelectWordRight: + case WordRight: + case SelectWordRight: { TextPosition newpos = _content.moveByWord(_caretPos, 1, _camelCasePartsAsWords); if (newpos != _caretPos) { @@ -1181,8 +1184,8 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction } } return true; - case EditorActions.DocumentBegin: - case EditorActions.SelectDocumentBegin: + case DocumentBegin: + case SelectDocumentBegin: if (_caretPos.pos > 0 || _caretPos.line > 0) { _caretPos.line = 0; _caretPos.pos = 0; @@ -1190,16 +1193,16 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction updateSelectionAfterCursorMovement(oldCaretPos, (a.id & 1) != 0); } return true; - case EditorActions.LineBegin: - case EditorActions.SelectLineBegin: + case LineBegin: + case SelectLineBegin: if (_caretPos.pos > 0) { _caretPos.pos = 0; ensureCaretVisible(); updateSelectionAfterCursorMovement(oldCaretPos, (a.id & 1) != 0); } return true; - case EditorActions.DocumentEnd: - case EditorActions.SelectDocumentEnd: + case DocumentEnd: + case SelectDocumentEnd: if (_caretPos.line < _content.length - 1 || _caretPos.pos < _content[_content.length - 1].length) { _caretPos.line = _content.length - 1; _caretPos.pos = cast(int)_content[_content.length - 1].length; @@ -1207,15 +1210,15 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction updateSelectionAfterCursorMovement(oldCaretPos, (a.id & 1) != 0); } return true; - case EditorActions.LineEnd: - case EditorActions.SelectLineEnd: + case LineEnd: + case SelectLineEnd: if (_caretPos.pos < currentLine.length) { _caretPos.pos = cast(int)currentLine.length; ensureCaretVisible(); updateSelectionAfterCursorMovement(oldCaretPos, (a.id & 1) != 0); } return true; - case EditorActions.DelPrevWord: + case DelPrevWord: if (readOnly) return true; correctCaretPos(); @@ -1225,7 +1228,7 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction if (newpos < _caretPos) removeRangeText(TextRange(newpos, _caretPos)); return true; - case EditorActions.DelNextWord: + case DelNextWord: if (readOnly) return true; correctCaretPos(); @@ -1235,7 +1238,7 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction if (newpos > _caretPos) removeRangeText(TextRange(_caretPos, newpos)); return true; - case EditorActions.DelPrevChar: + case DelPrevChar: if (readOnly) return true; correctCaretPos(); @@ -1253,7 +1256,7 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction removeRangeText(range); } return true; - case EditorActions.DelNextChar: + case DelNextChar: if (readOnly) return true; correctCaretPos(); @@ -1272,13 +1275,13 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction removeRangeText(range); } return true; - case EditorActions.Copy: + case Copy: if (!_selectionRange.empty) { dstring selectionText = concatDStrings(_content.rangeText(_selectionRange)); platform.setClipboardText(selectionText); } return true; - case EditorActions.Cut: + case Cut: if (!_selectionRange.empty) { dstring selectionText = concatDStrings(_content.rangeText(_selectionRange)); platform.setClipboardText(selectionText); @@ -1288,7 +1291,7 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction _content.performOperation(op, this); } return true; - case EditorActions.Paste: + case Paste: { if (readOnly) return true; @@ -1303,27 +1306,27 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction _content.performOperation(op, this); } return true; - case EditorActions.Undo: + case Undo: { if (readOnly) return true; _content.undo(this); } return true; - case EditorActions.Redo: + case Redo: { if (readOnly) return true; _content.redo(this); } return true; - case EditorActions.Indent: + case Indent: indentRange(false); return true; - case EditorActions.Unindent: + case Unindent: indentRange(true); return true; - case EditorActions.Tab: + case Tab: { if (readOnly) return true; @@ -1357,7 +1360,7 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction } } return true; - case EditorActions.BackTab: + case BackTab: { if (readOnly) return true; @@ -1394,10 +1397,10 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction } } return true; - case EditorActions.ToggleReplaceMode: + case ToggleReplaceMode: replaceMode = !replaceMode; return true; - case EditorActions.SelectAll: + case SelectAll: _selectionRange.start.line = 0; _selectionRange.start.pos = 0; _selectionRange.end = _content.lineEnd(_content.length - 1); @@ -1405,15 +1408,15 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction ensureCaretVisible(); requestActionsUpdate(); return true; - case EditorActions.ToggleBookmark: + case ToggleBookmark: if (_content.multiline) { int line = a.longParam >= 0 ? cast(int)a.longParam : _caretPos.line; _content.lineIcons.toggleBookmark(line); return true; } return false; - case EditorActions.GoToNextBookmark: - case EditorActions.GoToPreviousBookmark: + case GoToNextBookmark: + case GoToPreviousBookmark: if (_content.multiline) { LineIcon mark = _content.lineIcons.findNext(LineIconType.bookmark, _selectionRange.end.line, a.id == EditorActions.GoToNextBookmark ? 1 : -1); if (mark) { @@ -1725,21 +1728,22 @@ class EditLine : EditWidgetBase { } override bool handleAction(const Action a) { - switch (a.id) { - case EditorActions.InsertNewLine: - case EditorActions.PrependNewLine: - case EditorActions.AppendNewLine: + switch (a.id) with(EditorActions) + { + case InsertNewLine: + case PrependNewLine: + case AppendNewLine: if (editorAction.assigned) { return editorAction(a); } break; - case EditorActions.Up: + case Up: break; - case EditorActions.Down: + case Down: break; - case EditorActions.PageUp: + case PageUp: break; - case EditorActions.PageDown: + case PageDown: break; default: break; @@ -2111,8 +2115,9 @@ class EditBox : EditWidgetBase { override protected bool handleAction(const Action a) { TextPosition oldCaretPos = _caretPos; dstring currentLine = _content[_caretPos.line]; - switch (a.id) { - case EditorActions.PrependNewLine: + switch (a.id) with(EditorActions) + { + case PrependNewLine: if (!readOnly) { correctCaretPos(); _caretPos.pos = 0; @@ -2120,39 +2125,39 @@ class EditBox : EditWidgetBase { _content.performOperation(op, this); } return true; - case EditorActions.InsertNewLine: + case InsertNewLine: if (!readOnly) { correctCaretPos(); EditOperation op = new EditOperation(EditAction.Replace, _selectionRange, [""d, ""d]); _content.performOperation(op, this); } return true; - case EditorActions.Up: - case EditorActions.SelectUp: + case Up: + case SelectUp: if (_caretPos.line > 0) { _caretPos.line--; updateSelectionAfterCursorMovement(oldCaretPos, (a.id & 1) != 0); ensureCaretVisible(); } return true; - case EditorActions.Down: - case EditorActions.SelectDown: + case Down: + case SelectDown: if (_caretPos.line < _content.length - 1) { _caretPos.line++; updateSelectionAfterCursorMovement(oldCaretPos, (a.id & 1) != 0); ensureCaretVisible(); } return true; - case EditorActions.PageBegin: - case EditorActions.SelectPageBegin: + case PageBegin: + case SelectPageBegin: { ensureCaretVisible(); _caretPos.line = _firstVisibleLine; updateSelectionAfterCursorMovement(oldCaretPos, (a.id & 1) != 0); } return true; - case EditorActions.PageEnd: - case EditorActions.SelectPageEnd: + case PageEnd: + case SelectPageEnd: { ensureCaretVisible(); int fullLines = _clientRect.height / _lineHeight; @@ -2163,8 +2168,8 @@ class EditBox : EditWidgetBase { updateSelectionAfterCursorMovement(oldCaretPos, (a.id & 1) != 0); } return true; - case EditorActions.PageUp: - case EditorActions.SelectPageUp: + case PageUp: + case SelectPageUp: { ensureCaretVisible(); int fullLines = _clientRect.height / _lineHeight; @@ -2182,8 +2187,8 @@ class EditBox : EditWidgetBase { updateSelectionAfterCursorMovement(oldCaretPos, (a.id & 1) != 0); } return true; - case EditorActions.PageDown: - case EditorActions.SelectPageDown: + case PageDown: + case SelectPageDown: { ensureCaretVisible(); int fullLines = _clientRect.height / _lineHeight; @@ -2200,7 +2205,7 @@ class EditBox : EditWidgetBase { updateSelectionAfterCursorMovement(oldCaretPos, (a.id & 1) != 0); } return true; - case EditorActions.ScrollLeft: + case ScrollLeft: { if (_scrollPos.x > 0) { int newpos = _scrollPos.x - _spaceWidth * 4; @@ -2212,7 +2217,7 @@ class EditBox : EditWidgetBase { } } return true; - case EditorActions.ScrollRight: + case ScrollRight: { if (_scrollPos.x < _maxLineWidth - _clientRect.width) { int newpos = _scrollPos.x + _spaceWidth * 4; @@ -2224,7 +2229,7 @@ class EditBox : EditWidgetBase { } } return true; - case EditorActions.ScrollLineUp: + case ScrollLineUp: { if (_firstVisibleLine > 0) { _firstVisibleLine -= 3; @@ -2236,7 +2241,7 @@ class EditBox : EditWidgetBase { } } return true; - case EditorActions.ScrollPageUp: + case ScrollPageUp: { int fullLines = _clientRect.height / _lineHeight; if (_firstVisibleLine > 0) { @@ -2249,7 +2254,7 @@ class EditBox : EditWidgetBase { } } return true; - case EditorActions.ScrollLineDown: + case ScrollLineDown: { int fullLines = _clientRect.height / _lineHeight; if (_firstVisibleLine + fullLines < _content.length) { @@ -2264,7 +2269,7 @@ class EditBox : EditWidgetBase { } } return true; - case EditorActions.ScrollPageDown: + case ScrollPageDown: { int fullLines = _clientRect.height / _lineHeight; if (_firstVisibleLine + fullLines < _content.length) { @@ -2279,10 +2284,10 @@ class EditBox : EditWidgetBase { } } return true; - case EditorActions.ZoomOut: - case EditorActions.ZoomIn: + case ZoomOut: + case ZoomIn: { - int dir = a.id == EditorActions.ZoomIn ? 1 : -1; + int dir = a.id == ZoomIn ? 1 : -1; if (_minFontSize < _maxFontSize && _minFontSize > 0 && _maxFontSize > 0) { int currentFontSize = fontSize; int increment = currentFontSize >= 30 ? 2 : 1; @@ -2300,15 +2305,15 @@ class EditBox : EditWidgetBase { } } return true; - case EditorActions.ToggleBlockComment: + case ToggleBlockComment: if (!readOnly && _content.syntaxSupport && _content.syntaxSupport.supportsToggleBlockComment && _content.syntaxSupport.canToggleBlockComment(_selectionRange)) _content.syntaxSupport.toggleBlockComment(_selectionRange, this); return true; - case EditorActions.ToggleLineComment: + case ToggleLineComment: if (!readOnly && _content.syntaxSupport && _content.syntaxSupport.supportsToggleLineComment && _content.syntaxSupport.canToggleLineComment(_selectionRange)) _content.syntaxSupport.toggleLineComment(_selectionRange, this); return true; - case EditorActions.AppendNewLine: + case AppendNewLine: if (!readOnly) { correctCaretPos(); TextPosition p = _content.lineEnd(_caretPos.line); @@ -2318,7 +2323,7 @@ class EditBox : EditWidgetBase { _caretPos = oldCaretPos; } return true; - case EditorActions.DeleteLine: + case DeleteLine: if (!readOnly) { correctCaretPos(); EditOperation op = new EditOperation(EditAction.Replace, _content.lineRange(_caretPos.line), [""d]); diff --git a/src/dlangui/widgets/grid.d b/src/dlangui/widgets/grid.d index 2d7dc070..015e8856 100644 --- a/src/dlangui/widgets/grid.d +++ b/src/dlangui/widgets/grid.d @@ -852,17 +852,18 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter { calcScrollableAreaPos(); int actionId = a.id; if (_rowSelect) { - switch(actionId) { - case GridActions.Left: + switch(actionId) with(GridActions) + { + case Left: actionId = GridActions.ScrollLeft; break; - case GridActions.Right: + case Right: actionId = GridActions.ScrollRight; break; - //case GridActions.LineBegin: + //case LineBegin: // actionId = GridActions.ScrollPageLeft; // break; - //case GridActions.LineEnd: + //case LineEnd: // actionId = GridActions.ScrollPageRight; // break; default: @@ -870,39 +871,40 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter { } } - switch (actionId) { - case GridActions.ActivateCell: + switch (actionId) with(GridActions) + { + case ActivateCell: if (cellActivated.assigned) { cellActivated(this, col, row); return true; } return false; - case GridActions.ScrollLeft: + case ScrollLeft: scrollBy(-1, 0); return true; - case GridActions.Left: + case Left: selectCell(_col - 1, _row); return true; - case GridActions.ScrollRight: + case ScrollRight: scrollBy(1, 0); return true; - case GridActions.Right: + case Right: selectCell(_col + 1, _row); return true; - case GridActions.ScrollUp: + case ScrollUp: scrollBy(0, -1); return true; - case GridActions.Up: + case Up: selectCell(_col, _row - 1); return true; - case GridActions.ScrollDown: + case ScrollDown: if (_fullyVisibleCells.bottom < _rows - 1) scrollBy(0, 1); return true; - case GridActions.Down: + case Down: selectCell(_col, _row + 1); return true; - case GridActions.ScrollPageLeft: + case ScrollPageLeft: // scroll left cell by cell int prevCol = _headerCols + fixedCols + _scrollCol; while (_scrollCol > 0) { @@ -911,14 +913,14 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter { break; } return true; - case GridActions.ScrollPageRight: + case ScrollPageRight: int prevCol = _fullyVisibleCells.right; while (_headerCols + fixedCols + _scrollCol < prevCol) { if (!scrollBy(1, 0)) break; } return true; - case GridActions.ScrollPageUp: + case ScrollPageUp: // scroll up line by line int prevRow = _headerRows + fixedRows + _scrollRow; while (_scrollRow > 0) { @@ -927,14 +929,14 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter { break; } return true; - case GridActions.ScrollPageDown: + case ScrollPageDown: int prevRow = _fullyVisibleCells.bottom; while (_headerRows + fixedRows + _scrollRow < prevRow) { if (!scrollBy(0, 1)) break; } return true; - case GridActions.LineBegin: + case LineBegin: if (_scrollCol > 0 && _col > _headerCols + fixedCols + _scrollCol && !_rowSelect) selectCell(_headerCols + fixedCols + _scrollCol, _row); else { @@ -946,10 +948,10 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter { selectCell(_headerCols, _row); } return true; - case GridActions.LineEnd: + case LineEnd: selectCell(_cols - 1, _row); return true; - case GridActions.DocumentBegin: + case DocumentBegin: if (_scrollRow > 0) { _scrollRow = 0; updateScrollBars(); @@ -957,16 +959,16 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter { } selectCell(_col, _headerRows); return true; - case GridActions.DocumentEnd: + case DocumentEnd: selectCell(_col, _rows - 1); return true; - case GridActions.PageBegin: + case PageBegin: if (_scrollRow > 0) selectCell(_col, _headerRows + fixedRows + _scrollRow); else selectCell(_col, _headerRows); return true; - case GridActions.PageEnd: + case PageEnd: int found = -1; for (int i = fixedRows; i < _rows; i++) { Rect rc = cellRect(_col, i); @@ -978,7 +980,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter { if (found >= 0) selectCell(_col, found); return true; - case GridActions.PageUp: + case PageUp: if (_row > _fullyVisibleCells.top) { // not at top scrollable cell selectCell(_col, _fullyVisibleCells.top); @@ -998,7 +1000,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter { } } return true; - case GridActions.PageDown: + case PageDown: if (_row < _rows) { if (_row < _fullyVisibleCells.bottom) { // not at top scrollable cell diff --git a/src/dlangui/widgets/tree.d b/src/dlangui/widgets/tree.d index 431924e6..65ca8130 100644 --- a/src/dlangui/widgets/tree.d +++ b/src/dlangui/widgets/tree.d @@ -605,9 +605,9 @@ class TreeItemWidget : HorizontalLayout { if (event.action != KeyAction.KeyDown) return false; int action = 0; - switch (event.keyCode) { - case KeyCode.SPACE: - case KeyCode.RETURN: + switch (event.keyCode) with(KeyCode) { + case SPACE: + case RETURN: if (_item.hasChildren) _item.toggleExpand(_item); else @@ -859,42 +859,43 @@ class TreeWidgetBase : ScrollWidget, OnTreeContentChangeListener, OnTreeStateCh override protected bool handleAction(const Action a) { Log.d("tree.handleAction ", a.id); - switch (a.id) { - case TreeActions.ScrollLeft: + switch (a.id) with(TreeActions) + { + case ScrollLeft: if (_hscrollbar) _hscrollbar.sendScrollEvent(ScrollAction.LineUp); break; - case TreeActions.ScrollRight: + case ScrollRight: if (_hscrollbar) _hscrollbar.sendScrollEvent(ScrollAction.LineDown); break; - case TreeActions.ScrollUp: + case ScrollUp: if (_vscrollbar) _vscrollbar.sendScrollEvent(ScrollAction.LineUp); break; - case TreeActions.ScrollPageUp: + case ScrollPageUp: if (_vscrollbar) _vscrollbar.sendScrollEvent(ScrollAction.PageUp); break; - case TreeActions.ScrollDown: + case ScrollDown: if (_vscrollbar) _vscrollbar.sendScrollEvent(ScrollAction.LineDown); break; - case TreeActions.ScrollPageDown: + case ScrollPageDown: if (_vscrollbar) _vscrollbar.sendScrollEvent(ScrollAction.PageDown); break; - case TreeActions.Up: + case Up: _tree.selectPrevious(); break; - case TreeActions.Down: + case Down: _tree.selectNext(); break; - case TreeActions.PageUp: + case PageUp: // TODO: implement page up _tree.selectPrevious(); break; - case TreeActions.PageDown: + case PageDown: // TODO: implement page down _tree.selectPrevious(); break; diff --git a/src/dlangui/widgets/widget.d b/src/dlangui/widgets/widget.d index a9162f34..64800651 100644 --- a/src/dlangui/widgets/widget.d +++ b/src/dlangui/widgets/widget.d @@ -946,24 +946,25 @@ class Widget { return false; FocusMovement direction = FocusMovement.None; uint flags = event.flags & (KeyFlag.Shift | KeyFlag.Control | KeyFlag.Alt); - switch (event.keyCode) { - case KeyCode.LEFT: + switch (event.keyCode) with(KeyCode) + { + case LEFT: if (flags == 0) direction = FocusMovement.Left; break; - case KeyCode.RIGHT: + case RIGHT: if (flags == 0) direction = FocusMovement.Right; break; - case KeyCode.UP: + case UP: if (flags == 0) direction = FocusMovement.Up; break; - case KeyCode.DOWN: + case DOWN: if (flags == 0) direction = FocusMovement.Down; break; - case KeyCode.TAB: + case TAB: if (flags == 0) direction = FocusMovement.Next; else if (flags == KeyFlag.Shift)