mirror of https://github.com/buggins/dlangui.git
EditBox - zoomIn/zoomOut using Ctrl+keypad +/-
This commit is contained in:
parent
a6f68a5f52
commit
d66f79c019
|
@ -1262,7 +1262,6 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
|
||||||
|
|
||||||
new Action(EditorActions.ToggleReplaceMode, KeyCode.INS, 0),
|
new Action(EditorActions.ToggleReplaceMode, KeyCode.INS, 0),
|
||||||
new Action(EditorActions.SelectAll, KeyCode.KEY_A, KeyFlag.Control),
|
new Action(EditorActions.SelectAll, KeyCode.KEY_A, KeyFlag.Control),
|
||||||
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2084,16 +2083,16 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
|
||||||
uint keyFlags = event.flags & (MouseFlag.Shift | MouseFlag.Control | MouseFlag.Alt);
|
uint keyFlags = event.flags & (MouseFlag.Shift | MouseFlag.Control | MouseFlag.Alt);
|
||||||
if (event.wheelDelta < 0) {
|
if (event.wheelDelta < 0) {
|
||||||
if (keyFlags == MouseFlag.Shift)
|
if (keyFlags == MouseFlag.Shift)
|
||||||
return dispatchAction(new Action(EditorActions.ScrollRight));
|
return handleAction(new Action(EditorActions.ScrollRight));
|
||||||
if (keyFlags == MouseFlag.Control)
|
if (keyFlags == MouseFlag.Control)
|
||||||
return dispatchAction(new Action(EditorActions.ZoomOut));
|
return handleAction(new Action(EditorActions.ZoomOut));
|
||||||
return dispatchAction(new Action(EditorActions.ScrollLineDown));
|
return handleAction(new Action(EditorActions.ScrollLineDown));
|
||||||
} else if (event.wheelDelta > 0) {
|
} else if (event.wheelDelta > 0) {
|
||||||
if (keyFlags == MouseFlag.Shift)
|
if (keyFlags == MouseFlag.Shift)
|
||||||
return dispatchAction(new Action(EditorActions.ScrollLeft));
|
return handleAction(new Action(EditorActions.ScrollLeft));
|
||||||
if (keyFlags == MouseFlag.Control)
|
if (keyFlags == MouseFlag.Control)
|
||||||
return dispatchAction(new Action(EditorActions.ZoomIn));
|
return handleAction(new Action(EditorActions.ZoomIn));
|
||||||
return dispatchAction(new Action(EditorActions.ScrollLineUp));
|
return handleAction(new Action(EditorActions.ScrollLineUp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.onMouseEvent(event);
|
return super.onMouseEvent(event);
|
||||||
|
@ -2307,6 +2306,11 @@ class EditBox : EditWidgetBase {
|
||||||
_content.contentChangeListeners = this;
|
_content.contentChangeListeners = this;
|
||||||
styleId = STYLE_EDIT_BOX;
|
styleId = STYLE_EDIT_BOX;
|
||||||
text = initialContent;
|
text = initialContent;
|
||||||
|
acceleratorMap.add( [
|
||||||
|
// zoom
|
||||||
|
new Action(EditorActions.ZoomIn, KeyCode.ADD, KeyFlag.Control),
|
||||||
|
new Action(EditorActions.ZoomOut, KeyCode.SUB, KeyFlag.Control),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int _firstVisibleLine;
|
protected int _firstVisibleLine;
|
||||||
|
@ -2687,9 +2691,10 @@ class EditBox : EditWidgetBase {
|
||||||
return true;
|
return true;
|
||||||
case EditorActions.ZoomIn:
|
case EditorActions.ZoomIn:
|
||||||
{
|
{
|
||||||
if (_minFontSize < _maxFontSize && _minFontSize > 10 && _maxFontSize > 10) {
|
if (_minFontSize < _maxFontSize && _minFontSize >= 9 && _maxFontSize >= 9) {
|
||||||
int currentFontSize = fontSize;
|
int currentFontSize = fontSize;
|
||||||
int newFontSize = currentFontSize * 110 / 100;
|
int increment = currentFontSize >= 30 ? 2 : 1;
|
||||||
|
int newFontSize = currentFontSize + increment; //* 110 / 100;
|
||||||
if (currentFontSize != newFontSize && newFontSize <= _maxFontSize) {
|
if (currentFontSize != newFontSize && newFontSize <= _maxFontSize) {
|
||||||
fontSize = cast(ushort)newFontSize;
|
fontSize = cast(ushort)newFontSize;
|
||||||
updateFontProps();
|
updateFontProps();
|
||||||
|
@ -2702,9 +2707,10 @@ class EditBox : EditWidgetBase {
|
||||||
return true;
|
return true;
|
||||||
case EditorActions.ZoomOut:
|
case EditorActions.ZoomOut:
|
||||||
{
|
{
|
||||||
if (_minFontSize < _maxFontSize && _minFontSize > 10 && _maxFontSize > 10) {
|
if (_minFontSize < _maxFontSize && _minFontSize >= 9 && _maxFontSize >= 9) {
|
||||||
int currentFontSize = fontSize;
|
int currentFontSize = fontSize;
|
||||||
int newFontSize = currentFontSize * 100 / 110;
|
int increment = currentFontSize >= 30 ? 2 : 1;
|
||||||
|
int newFontSize = currentFontSize - increment; //* 100 / 110;
|
||||||
if (currentFontSize != newFontSize && newFontSize >= _minFontSize) {
|
if (currentFontSize != newFontSize && newFontSize >= _minFontSize) {
|
||||||
fontSize = cast(ushort)newFontSize;
|
fontSize = cast(ushort)newFontSize;
|
||||||
updateFontProps();
|
updateFontProps();
|
||||||
|
|
|
@ -30,6 +30,8 @@ class SourceEdit : EditBox {
|
||||||
fontSize = 17;
|
fontSize = 17;
|
||||||
layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT);
|
layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT);
|
||||||
minFontSize(10).maxFontSize(75); // allow font zoom with Ctrl + MouseWheel
|
minFontSize(10).maxFontSize(75); // allow font zoom with Ctrl + MouseWheel
|
||||||
|
|
||||||
|
|
||||||
_showLineNumbers = true;
|
_showLineNumbers = true;
|
||||||
}
|
}
|
||||||
this() {
|
this() {
|
||||||
|
|
Loading…
Reference in New Issue