* fix , fix 

Fix  where the function `renameTab(string ID, dstring name)` in `src/dlangui/widgets/tabs.d` failed to find the tab with the given id because it uses the `TabControl`'s own id due to the misuse of lower/upper case names. Changed the function's argument `ID` that have never been used to `id`.  
  
Fix  where `EditWidgetBase` doesn't scroll when mouse selection is active and the cursor goes beyond the widget boundaries. Now it scrolls.  
Additionally, added new type of `EditorActions` to make 2 different types of `EditorActions.ScrollLineUp/Down`. The old `ScrollLineUp/Down` made 3 lines scrolling and it doesn't work well with new mouse selection scrolling when out of bounds (scrolls too fast). So now there are `ScrollLineUp/DownSingle` and `ScrollLineUp/DownTriple`. The single one is used by the mouse selection scrolling, the triple one used in all other cases just like before.

* Original ScrollLineUp + ScrollLineUpSingle
This commit is contained in:
Ermiq 2023-09-15 21:22:16 +05:00 committed by GitHub
parent 9e263cdb7f
commit 5fcb6527ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 6 deletions
src/dlangui/widgets

View File

@ -180,8 +180,12 @@ enum EditorActions : int {
// Scroll operations
/// Scroll one line up (not changing cursor)
ScrollLineUp,
ScrollLineUpSingle,
/// Scroll one line down (not changing cursor)
ScrollLineDownSingle,
/// Scroll three lines up (not changing cursor)
ScrollLineUp,
/// Scroll three lines down (not changing cursor)
ScrollLineDown,
/// Scroll one page up (not changing cursor)
ScrollPageUp,
@ -817,8 +821,8 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
new Action(EditorActions.DocumentEnd, KeyCode.END, KeyFlag.Control, ActionStateUpdateFlag.never),
new Action(EditorActions.SelectDocumentEnd, KeyCode.END, KeyFlag.Control | KeyFlag.Shift, ActionStateUpdateFlag.never),
new Action(EditorActions.ScrollLineUp, KeyCode.UP, KeyFlag.Control, ActionStateUpdateFlag.never),
new Action(EditorActions.ScrollLineDown, KeyCode.DOWN, KeyFlag.Control, ActionStateUpdateFlag.never),
new Action(EditorActions.ScrollLineUpSingle, KeyCode.UP, KeyFlag.Control, ActionStateUpdateFlag.never),
new Action(EditorActions.ScrollLineDownSingle, KeyCode.DOWN, KeyFlag.Control, ActionStateUpdateFlag.never),
// Backspace/Del
new Action(EditorActions.DelPrevChar, KeyCode.BACK, 0, ActionStateUpdateFlag.never),
@ -2205,6 +2209,12 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
}
if (event.action == MouseAction.Move && (event.flags & MouseButton.Left) != 0) {
updateCaretPositionByMouse(event.x - _clientRect.left, event.y - _clientRect.top, true);
if (event.y < _clientRect.top) {
handleAction(new Action(EditorActions.ScrollLineUpSingle));
}
else if (event.y > _clientRect.bottom) {
handleAction(new Action(EditorActions.ScrollLineDownSingle));
}
return true;
}
if (event.action == MouseAction.Move && event.flags == 0) {
@ -2917,9 +2927,9 @@ class EditBox : EditWidgetBase {
} else if (event.action == ScrollAction.PageDown) {
dispatchAction(new Action(EditorActions.ScrollPageDown));
} else if (event.action == ScrollAction.LineUp) {
dispatchAction(new Action(EditorActions.ScrollLineUp));
dispatchAction(new Action(EditorActions.ScrollLineUpSingle));
} else if (event.action == ScrollAction.LineDown) {
dispatchAction(new Action(EditorActions.ScrollLineDown));
dispatchAction(new Action(EditorActions.ScrollLineDownSingle));
}
return true;
}
@ -3240,6 +3250,18 @@ class EditBox : EditWidgetBase {
}
}
return true;
case ScrollLineUpSingle:
{
if (_firstVisibleLine > 0) {
_firstVisibleLine -= 1;
if (_firstVisibleLine < 0)
_firstVisibleLine = 0;
measureVisibleText();
updateScrollBars();
invalidate();
}
}
return true;
case ScrollPageUp:
{
int fullLines = _clientRect.height / _lineHeight;
@ -3268,6 +3290,21 @@ class EditBox : EditWidgetBase {
}
}
return true;
case ScrollLineDownSingle:
{
int fullLines = _clientRect.height / _lineHeight;
if (_firstVisibleLine + fullLines < _content.length) {
_firstVisibleLine += 1;
if (_firstVisibleLine > _content.length - fullLines)
_firstVisibleLine = _content.length - fullLines;
if (_firstVisibleLine < 0)
_firstVisibleLine = 0;
measureVisibleText();
updateScrollBars();
invalidate();
}
}
return true;
case ScrollPageDown:
{
int fullLines = _clientRect.height / _lineHeight;

View File

@ -475,7 +475,7 @@ class TabControl : WidgetGroupDefaultDrawing {
}
/// change name of tab
void renameTab(string ID, dstring name) {
void renameTab(string id, dstring name) {
int index = _items.indexById(id);
if (index >= 0) {
renameTab(index, name);