diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-11-25 18:04:23 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-11-25 18:04:23 +0200 |
commit | afe1bf47cbc2fa1d437f50e68a771eb23e8891f0 (patch) | |
tree | febc55065d42640d6e413485bee0d40b50b3984c | |
parent | dfefb9bf34e607cdc3a4def6049f3fd0816d5496 (diff) |
Unsplit button in toolbar
IssueID #378
-rw-r--r-- | res/about/version.gmi | 5 | ||||
-rw-r--r-- | src/app.c | 7 | ||||
-rw-r--r-- | src/ui/root.c | 27 | ||||
-rw-r--r-- | src/ui/window.c | 6 |
4 files changed, 39 insertions, 6 deletions
diff --git a/res/about/version.gmi b/res/about/version.gmi index 3b15f567..10c1b354 100644 --- a/res/about/version.gmi +++ b/res/about/version.gmi | |||
@@ -1,4 +1,4 @@ | |||
1 | ``` LAGRANGE | 1 | ```LAGRANGE |
2 | __ __ __ ___ | 2 | __ __ __ ___ |
3 | | /\ / _` |__) /\ |\ | / _` |__ | 3 | | /\ / _` |__) /\ |\ | / _` |__ |
4 | |___ /~~\ \__> | \ /~~\ | \| \__> |___ | 4 | |___ /~~\ \__> | \ /~~\ | \| \__> |___ |
@@ -10,11 +10,12 @@ | |||
10 | 10 | ||
11 | New features: | 11 | New features: |
12 | * Added a toolbar button for toggling the left sidebar. | 12 | * Added a toolbar button for toggling the left sidebar. |
13 | * Added an unsplit button in the toolbar when in split view mode. | ||
13 | * Choose parent folder when creating or editing a bookmark. | 14 | * Choose parent folder when creating or editing a bookmark. |
14 | * Support for ANSI background color escapes (disabled by default). | 15 | * Support for ANSI background color escapes (disabled by default). |
15 | * UI language for Turkish. | ||
16 | * macOS: Automatic updates using the Sparkle framework. | 16 | * macOS: Automatic updates using the Sparkle framework. |
17 | * Windows: Automatic updates using the WinSparkle library. | 17 | * Windows: Automatic updates using the WinSparkle library. |
18 | * UI language for Turkish. | ||
18 | 19 | ||
19 | Changes and enhancements: | 20 | Changes and enhancements: |
20 | * Adjusted font styles of heading levels 2 and 3. | 21 | * Adjusted font styles of heading levels 2 and 3. |
@@ -2204,6 +2204,13 @@ iBool handleCommand_App(const char *cmd) { | |||
2204 | swapRoots_MainWindow(d->window); | 2204 | swapRoots_MainWindow(d->window); |
2205 | return iTrue; | 2205 | return iTrue; |
2206 | } | 2206 | } |
2207 | if (argLabel_Command(cmd, "focusother")) { | ||
2208 | iWindow *baseWin = &d->window->base; | ||
2209 | if (baseWin->roots[1]) { | ||
2210 | baseWin->keyRoot = | ||
2211 | (baseWin->keyRoot == baseWin->roots[1] ? baseWin->roots[0] : baseWin->roots[1]); | ||
2212 | } | ||
2213 | } | ||
2207 | d->window->pendingSplitMode = | 2214 | d->window->pendingSplitMode = |
2208 | (argLabel_Command(cmd, "axis") ? vertical_WindowSplit : 0) | (arg_Command(cmd) << 1); | 2215 | (argLabel_Command(cmd, "axis") ? vertical_WindowSplit : 0) | (arg_Command(cmd) << 1); |
2209 | const char *url = suffixPtr_Command(cmd, "url"); | 2216 | const char *url = suffixPtr_Command(cmd, "url"); |
diff --git a/src/ui/root.c b/src/ui/root.c index d98701b8..5b1167d8 100644 --- a/src/ui/root.c +++ b/src/ui/root.c | |||
@@ -635,10 +635,12 @@ static void updateNavBarSize_(iWidget *navBar) { | |||
635 | iForIndices(k, lists) { | 635 | iForIndices(k, lists) { |
636 | iForEach(ObjectList, i, lists[k]) { | 636 | iForEach(ObjectList, i, lists[k]) { |
637 | iWidget *child = as_Widget(i.object); | 637 | iWidget *child = as_Widget(i.object); |
638 | setFlags_Widget(child, tight_WidgetFlag, isNarrow); | 638 | if (cmp_String(id_Widget(i.object), "navbar.unsplit")) { |
639 | if (isInstance_Object(i.object, &Class_LabelWidget)) { | 639 | setFlags_Widget(child, tight_WidgetFlag, isNarrow); |
640 | iLabelWidget *label = i.object; | 640 | if (isInstance_Object(i.object, &Class_LabelWidget)) { |
641 | updateSize_LabelWidget(label); | 641 | iLabelWidget *label = i.object; |
642 | updateSize_LabelWidget(label); | ||
643 | } | ||
642 | } | 644 | } |
643 | } | 645 | } |
644 | } | 646 | } |
@@ -1023,6 +1025,16 @@ void updateMetrics_Root(iRoot *d) { | |||
1023 | postRefresh_App(); | 1025 | postRefresh_App(); |
1024 | } | 1026 | } |
1025 | 1027 | ||
1028 | static void addUnsplitButton_(iWidget *navBar) { | ||
1029 | iLabelWidget *unsplit = addChildFlags_Widget( | ||
1030 | navBar, | ||
1031 | iClob(newIcon_LabelWidget(close_Icon, 0, 0, "ui.split arg:0 focusother:1")), | ||
1032 | collapse_WidgetFlag | frameless_WidgetFlag | tight_WidgetFlag | hidden_WidgetFlag); | ||
1033 | setId_Widget(as_Widget(unsplit), "navbar.unsplit"); | ||
1034 | setTextColor_LabelWidget(unsplit, uiTextAction_ColorId); | ||
1035 | updateSize_LabelWidget(unsplit); | ||
1036 | } | ||
1037 | |||
1026 | void createUserInterface_Root(iRoot *d) { | 1038 | void createUserInterface_Root(iRoot *d) { |
1027 | iWidget *root = d->widget = new_Widget(); | 1039 | iWidget *root = d->widget = new_Widget(); |
1028 | root->rect.size = get_Window()->size; | 1040 | root->rect.size = get_Window()->size; |
@@ -1101,6 +1113,9 @@ void createUserInterface_Root(iRoot *d) { | |||
1101 | addChild_Widget(div, iClob(navBar)); | 1113 | addChild_Widget(div, iClob(navBar)); |
1102 | setBackgroundColor_Widget(navBar, uiBackground_ColorId); | 1114 | setBackgroundColor_Widget(navBar, uiBackground_ColorId); |
1103 | setCommandHandler_Widget(navBar, handleNavBarCommands_); | 1115 | setCommandHandler_Widget(navBar, handleNavBarCommands_); |
1116 | #if defined (iPlatformApple) | ||
1117 | addUnsplitButton_(navBar); | ||
1118 | #endif | ||
1104 | iWidget *navBack; | 1119 | iWidget *navBack; |
1105 | setId_Widget(navBack = addChildFlags_Widget(navBar, iClob(newIcon_LabelWidget(backArrow_Icon, 0, 0, "navigate.back")), collapse_WidgetFlag), "navbar.back"); | 1120 | setId_Widget(navBack = addChildFlags_Widget(navBar, iClob(newIcon_LabelWidget(backArrow_Icon, 0, 0, "navigate.back")), collapse_WidgetFlag), "navbar.back"); |
1106 | setId_Widget(addChildFlags_Widget(navBar, iClob(newIcon_LabelWidget(forwardArrow_Icon, 0, 0, "navigate.forward")), collapse_WidgetFlag), "navbar.forward"); | 1121 | setId_Widget(addChildFlags_Widget(navBar, iClob(newIcon_LabelWidget(forwardArrow_Icon, 0, 0, "navigate.forward")), collapse_WidgetFlag), "navbar.forward"); |
@@ -1279,6 +1294,10 @@ void createUserInterface_Root(iRoot *d) { | |||
1279 | setAlignVisually_LabelWidget(navMenu, iTrue); | 1294 | setAlignVisually_LabelWidget(navMenu, iTrue); |
1280 | setId_Widget(addChildFlags_Widget(navBar, iClob(navMenu), collapse_WidgetFlag), "navbar.menu"); | 1295 | setId_Widget(addChildFlags_Widget(navBar, iClob(navMenu), collapse_WidgetFlag), "navbar.menu"); |
1281 | #endif | 1296 | #endif |
1297 | #if !defined (iPlatformApple) | ||
1298 | /* On PC platforms, the close buttons are generally on the top right. */ | ||
1299 | addUnsplitButton_(navBar); | ||
1300 | #endif | ||
1282 | } | 1301 | } |
1283 | /* Tab bar. */ { | 1302 | /* Tab bar. */ { |
1284 | iWidget *mainStack = new_Widget(); | 1303 | iWidget *mainStack = new_Widget(); |
diff --git a/src/ui/window.c b/src/ui/window.c index b8ce413b..4b39383c 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -1491,6 +1491,7 @@ void setSplitMode_MainWindow(iMainWindow *d, int splitFlags) { | |||
1491 | } | 1491 | } |
1492 | /* The last child is the [+] button for adding a tab. */ | 1492 | /* The last child is the [+] button for adding a tab. */ |
1493 | moveTabButtonToEnd_Widget(findChild_Widget(docTabs, "newtab")); | 1493 | moveTabButtonToEnd_Widget(findChild_Widget(docTabs, "newtab")); |
1494 | setFlags_Widget(findWidget_Root("navbar.unsplit"), hidden_WidgetFlag, iTrue); | ||
1494 | iRelease(tabs); | 1495 | iRelease(tabs); |
1495 | postCommandf_App("tabs.switch id:%s", cstr_String(id_Widget(constAs_Widget(curPage)))); | 1496 | postCommandf_App("tabs.switch id:%s", cstr_String(id_Widget(constAs_Widget(curPage)))); |
1496 | } | 1497 | } |
@@ -1540,6 +1541,11 @@ void setSplitMode_MainWindow(iMainWindow *d, int splitFlags) { | |||
1540 | postCommand_Root(w->roots[newRootIndex], "navigate.home"); | 1541 | postCommand_Root(w->roots[newRootIndex], "navigate.home"); |
1541 | } | 1542 | } |
1542 | } | 1543 | } |
1544 | /* Show unsplit buttons. */ | ||
1545 | for (int i = 0; i < 2; i++) { | ||
1546 | setFlags_Widget(findChild_Widget(w->roots[i]->widget, "navbar.unsplit"), | ||
1547 | hidden_WidgetFlag, iFalse); | ||
1548 | } | ||
1543 | setCurrent_Root(NULL); | 1549 | setCurrent_Root(NULL); |
1544 | } | 1550 | } |
1545 | d->splitMode = splitMode; | 1551 | d->splitMode = splitMode; |