summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-05-06 12:36:30 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-05-06 12:36:30 +0300
commitb2c7e9a206900af17145f3fe563a25c7a3c4a599 (patch)
treea1b7401bfe5c640ee23e236a8b9923d0bbdc2c67 /src/ui
parent4e8e62653549123e813707cdda4bc2526e9d59d0 (diff)
Split view: Fixed theme and title updates
Now every DocumentWidget is guaranteed a unique ID. The window title is updated when the keyroot chages.
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/documentwidget.c9
-rw-r--r--src/ui/widget.c6
-rw-r--r--src/ui/widget.h1
3 files changed, 13 insertions, 3 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 3175f274..5a5a4f84 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -298,10 +298,12 @@ struct Impl_DocumentWidget {
298 298
299iDefineObjectConstruction(DocumentWidget) 299iDefineObjectConstruction(DocumentWidget)
300 300
301static int docEnum_ = 0;
302
301void init_DocumentWidget(iDocumentWidget *d) { 303void init_DocumentWidget(iDocumentWidget *d) {
302 iWidget *w = as_Widget(d); 304 iWidget *w = as_Widget(d);
303 init_Widget(w); 305 init_Widget(w);
304 setId_Widget(w, "document000"); 306 setId_Widget(w, format_CStr("document%03d", ++docEnum_));
305 setFlags_Widget(w, hover_WidgetFlag, iTrue); 307 setFlags_Widget(w, hover_WidgetFlag, iTrue);
306 init_PersistentDocumentState(&d->mod); 308 init_PersistentDocumentState(&d->mod);
307 d->flags = 0; 309 d->flags = 0;
@@ -880,7 +882,7 @@ static void updateWindowTitle_DocumentWidget_(const iDocumentWidget *d) {
880 } 882 }
881 /* Take away parts if it doesn't fit. */ 883 /* Take away parts if it doesn't fit. */
882 const int avail = bounds_Widget(as_Widget(tabButton)).size.x - 3 * gap_UI; 884 const int avail = bounds_Widget(as_Widget(tabButton)).size.x - 3 * gap_UI;
883 iBool setWindow = (document_App() == d); 885 iBool setWindow = (document_App() == d && isUnderKeyRoot_Widget(d));
884 for (;;) { 886 for (;;) {
885 iString *text = collect_String(joinCStr_StringArray(title, " \u2014 ")); 887 iString *text = collect_String(joinCStr_StringArray(title, " \u2014 "));
886 if (setWindow) { 888 if (setWindow) {
@@ -1953,7 +1955,8 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
1953 } 1955 }
1954 return iTrue; 1956 return iTrue;
1955 } 1957 }
1956 else if (equal_Command(cmd, "window.resized") || equal_Command(cmd, "font.changed")) { 1958 else if (equal_Command(cmd, "window.resized") || equal_Command(cmd, "font.changed") ||
1959 equal_Command(cmd, "keyroot.changed")) {
1957 /* Alt/Option key may be involved in window size changes. */ 1960 /* Alt/Option key may be involved in window size changes. */
1958 setLinkNumberMode_DocumentWidget_(d, iFalse); 1961 setLinkNumberMode_DocumentWidget_(d, iFalse);
1959 d->phoneToolbar = findWidget_App("toolbar"); 1962 d->phoneToolbar = findWidget_App("toolbar");
diff --git a/src/ui/widget.c b/src/ui/widget.c
index 00fe0f5f..67ce1345 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -1346,6 +1346,12 @@ iBool isHover_Widget(const iAnyObject *d) {
1346 return get_Window()->hover == d; 1346 return get_Window()->hover == d;
1347} 1347}
1348 1348
1349iBool isUnderKeyRoot_Widget(const iAnyObject *d) {
1350 iAssert(isInstance_Object(d, &Class_Widget));
1351 const iWidget *w = d;
1352 return w && get_Window() && w->root == get_Window()->keyRoot;
1353}
1354
1349iBool isSelected_Widget(const iAnyObject *d) { 1355iBool isSelected_Widget(const iAnyObject *d) {
1350 if (d) { 1356 if (d) {
1351 iAssert(isInstance_Object(d, &Class_Widget)); 1357 iAssert(isInstance_Object(d, &Class_Widget));
diff --git a/src/ui/widget.h b/src/ui/widget.h
index 36797210..5b6b18e1 100644
--- a/src/ui/widget.h
+++ b/src/ui/widget.h
@@ -232,6 +232,7 @@ iBool isDisabled_Widget (const iAnyObject *);
232iBool isFocused_Widget (const iAnyObject *); 232iBool isFocused_Widget (const iAnyObject *);
233iBool isHover_Widget (const iAnyObject *); 233iBool isHover_Widget (const iAnyObject *);
234iBool isSelected_Widget (const iAnyObject *); 234iBool isSelected_Widget (const iAnyObject *);
235iBool isUnderKeyRoot_Widget (const iAnyObject *);
235iBool isCommand_Widget (const iWidget *d, const SDL_Event *ev, const char *cmd); 236iBool isCommand_Widget (const iWidget *d, const SDL_Event *ev, const char *cmd);
236iBool hasParent_Widget (const iWidget *d, const iWidget *someParent); 237iBool hasParent_Widget (const iWidget *d, const iWidget *someParent);
237iBool isAffectedByVisualOffset_Widget 238iBool isAffectedByVisualOffset_Widget