diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-10-30 15:03:09 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-10-30 15:03:09 +0200 |
commit | 114e52a60c789c5d1d885a994e8e1bd002b7cc93 (patch) | |
tree | 85c9e5281cb2f8066f18394a1db4dfe662dc5316 /src/ui | |
parent | f22ee7c9ac27fe05649219535a05c21281709607 (diff) |
Updating LabelWidget command key
If the key bindings have a key for a command, LabelWidget will use it.
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/keys.c | 12 | ||||
-rw-r--r-- | src/ui/keys.h | 10 | ||||
-rw-r--r-- | src/ui/labelwidget.c | 60 | ||||
-rw-r--r-- | src/ui/labelwidget.h | 9 | ||||
-rw-r--r-- | src/ui/listwidget.h | 2 | ||||
-rw-r--r-- | src/ui/sidebarwidget.c | 8 | ||||
-rw-r--r-- | src/ui/util.c | 71 | ||||
-rw-r--r-- | src/ui/window.c | 5 |
8 files changed, 104 insertions, 73 deletions
diff --git a/src/ui/keys.c b/src/ui/keys.c index 4d52b0a4..85304ef7 100644 --- a/src/ui/keys.c +++ b/src/ui/keys.c | |||
@@ -27,14 +27,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
27 | #include <the_Foundation/sortedarray.h> | 27 | #include <the_Foundation/sortedarray.h> |
28 | 28 | ||
29 | iDeclareType(Keys) | 29 | iDeclareType(Keys) |
30 | iDeclareType(Binding) | ||
31 | |||
32 | struct Impl_Binding { | ||
33 | int key; | ||
34 | int mods; | ||
35 | iString command; | ||
36 | iString label; | ||
37 | }; | ||
38 | 30 | ||
39 | static int cmp_Binding_(const void *a, const void *b) { | 31 | static int cmp_Binding_(const void *a, const void *b) { |
40 | const iBinding *d = a, *other = b; | 32 | const iBinding *d = a, *other = b; |
@@ -151,3 +143,7 @@ iBool processEvent_Keys(const SDL_Event *ev) { | |||
151 | } | 143 | } |
152 | return iFalse; | 144 | return iFalse; |
153 | } | 145 | } |
146 | |||
147 | const iBinding *findCommand_Keys(const char *command) { | ||
148 | return findCommand_Keys_(&keys_, command); | ||
149 | } | ||
diff --git a/src/ui/keys.h b/src/ui/keys.h index 157ddea5..0892bd81 100644 --- a/src/ui/keys.h +++ b/src/ui/keys.h | |||
@@ -43,6 +43,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
43 | # define byLine_KeyModifier 0 | 43 | # define byLine_KeyModifier 0 |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | iDeclareType(Binding) | ||
47 | |||
48 | struct Impl_Binding { | ||
49 | int key; | ||
50 | int mods; | ||
51 | iString command; | ||
52 | iString label; | ||
53 | }; | ||
54 | |||
46 | void init_Keys (void); | 55 | void init_Keys (void); |
47 | void deinit_Keys (void); | 56 | void deinit_Keys (void); |
48 | 57 | ||
@@ -51,6 +60,7 @@ void save_Keys (const char *saveDir); | |||
51 | 60 | ||
52 | void bind_Keys (const char *command, int key, int mods); | 61 | void bind_Keys (const char *command, int key, int mods); |
53 | void setLabel_Keys (const char *command, const char *label); | 62 | void setLabel_Keys (const char *command, const char *label); |
63 | const iBinding *findCommand_Keys (const char *command); | ||
54 | 64 | ||
55 | //const iString * label_Keys (const char *command); | 65 | //const iString * label_Keys (const char *command); |
56 | //const char * shortcutLabel_Keys (const char *command); | 66 | //const char * shortcutLabel_Keys (const char *command); |
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c index 0555bc4d..b4ba79fe 100644 --- a/src/ui/labelwidget.c +++ b/src/ui/labelwidget.c | |||
@@ -26,6 +26,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
26 | #include "paint.h" | 26 | #include "paint.h" |
27 | #include "app.h" | 27 | #include "app.h" |
28 | #include "util.h" | 28 | #include "util.h" |
29 | #include "keys.h" | ||
29 | 30 | ||
30 | iLocalDef iInt2 padding_(int flags) { | 31 | iLocalDef iInt2 padding_(int flags) { |
31 | return init_I2(flags & tight_WidgetFlag ? 3 * gap_UI / 2 : (3 * gap_UI), gap_UI); | 32 | return init_I2(flags & tight_WidgetFlag ? 3 * gap_UI / 2 : (3 * gap_UI), gap_UI); |
@@ -43,8 +44,8 @@ struct Impl_LabelWidget { | |||
43 | }; | 44 | }; |
44 | 45 | ||
45 | iDefineObjectConstructionArgs(LabelWidget, | 46 | iDefineObjectConstructionArgs(LabelWidget, |
46 | (const char *label, int key, int kmods, const char *cmd), | 47 | (const char *label, const char *cmd), |
47 | label, key, kmods, cmd) | 48 | label, cmd) |
48 | 49 | ||
49 | static iBool checkModifiers_(int have, int req) { | 50 | static iBool checkModifiers_(int have, int req) { |
50 | return keyMods_Sym(req) == keyMods_Sym(have); | 51 | return keyMods_Sym(req) == keyMods_Sym(have); |
@@ -60,11 +61,26 @@ static void trigger_LabelWidget_(const iLabelWidget *d) { | |||
60 | } | 61 | } |
61 | } | 62 | } |
62 | 63 | ||
64 | static void updateKey_LabelWidget_(iLabelWidget *d) { | ||
65 | if (!isEmpty_String(&d->command)) { | ||
66 | const iBinding *bind = findCommand_Keys(cstr_String(&d->command)); | ||
67 | if (bind) { | ||
68 | d->key = bind->key; | ||
69 | d->kmods = bind->mods; | ||
70 | } | ||
71 | } | ||
72 | } | ||
73 | |||
63 | static iBool processEvent_LabelWidget_(iLabelWidget *d, const SDL_Event *ev) { | 74 | static iBool processEvent_LabelWidget_(iLabelWidget *d, const SDL_Event *ev) { |
64 | iWidget *w = &d->widget; | 75 | iWidget *w = &d->widget; |
65 | if (isCommand_UserEvent(ev, "metrics.changed")) { | 76 | if (isCommand_UserEvent(ev, "metrics.changed")) { |
66 | updateSize_LabelWidget(d); | 77 | updateSize_LabelWidget(d); |
67 | } | 78 | } |
79 | else if (isCommand_UserEvent(ev, "bindings.changed")) { | ||
80 | /* Update the key used to trigger this label. */ | ||
81 | updateKey_LabelWidget_(d); | ||
82 | return iFalse; | ||
83 | } | ||
68 | if (!isEmpty_String(&d->command)) { | 84 | if (!isEmpty_String(&d->command)) { |
69 | switch (processEvent_Click(&d->click, ev)) { | 85 | switch (processEvent_Click(&d->click, ev)) { |
70 | case started_ClickResult: | 86 | case started_ClickResult: |
@@ -229,6 +245,18 @@ static void draw_LabelWidget_(const iLabelWidget *d) { | |||
229 | unsetClip_Paint(&p); | 245 | unsetClip_Paint(&p); |
230 | } | 246 | } |
231 | 247 | ||
248 | static void sizeChanged_LabelWidget_(iLabelWidget *d) { | ||
249 | iWidget *w = as_Widget(d); | ||
250 | if (flags_Widget(w) & wrapText_WidgetFlag) { | ||
251 | if (flags_Widget(w) & fixedHeight_WidgetFlag) { | ||
252 | /* Calculate a new height based on the wrapping. */ | ||
253 | w->rect.size.y = advanceWrapRange_Text( | ||
254 | d->font, innerBounds_Widget(w).size.x, range_String(&d->label)) | ||
255 | .y; | ||
256 | } | ||
257 | } | ||
258 | } | ||
259 | |||
232 | void updateSize_LabelWidget(iLabelWidget *d) { | 260 | void updateSize_LabelWidget(iLabelWidget *d) { |
233 | iWidget *w = as_Widget(d); | 261 | iWidget *w = as_Widget(d); |
234 | const int flags = flags_Widget(w); | 262 | const int flags = flags_Widget(w); |
@@ -249,19 +277,7 @@ void updateSize_LabelWidget(iLabelWidget *d) { | |||
249 | } | 277 | } |
250 | } | 278 | } |
251 | 279 | ||
252 | static void sizeChanged_LabelWidget_(iLabelWidget *d) { | 280 | void init_LabelWidget(iLabelWidget *d, const char *label, const char *cmd) { |
253 | iWidget *w = as_Widget(d); | ||
254 | if (flags_Widget(w) & wrapText_WidgetFlag) { | ||
255 | if (flags_Widget(w) & fixedHeight_WidgetFlag) { | ||
256 | /* Calculate a new height based on the wrapping. */ | ||
257 | w->rect.size.y = advanceWrapRange_Text( | ||
258 | d->font, innerBounds_Widget(w).size.x, range_String(&d->label)) | ||
259 | .y; | ||
260 | } | ||
261 | } | ||
262 | } | ||
263 | |||
264 | void init_LabelWidget(iLabelWidget *d, const char *label, int key, int kmods, const char *cmd) { | ||
265 | init_Widget(&d->widget); | 281 | init_Widget(&d->widget); |
266 | d->font = uiLabel_FontId; | 282 | d->font = uiLabel_FontId; |
267 | initCStr_String(&d->label, label); | 283 | initCStr_String(&d->label, label); |
@@ -271,12 +287,13 @@ void init_LabelWidget(iLabelWidget *d, const char *label, int key, int kmods, co | |||
271 | else { | 287 | else { |
272 | init_String(&d->command); | 288 | init_String(&d->command); |
273 | } | 289 | } |
274 | d->key = key; | 290 | d->key = 0; |
275 | d->kmods = kmods; | 291 | d->kmods = 0; |
276 | init_Click(&d->click, d, !isEmpty_String(&d->command) ? SDL_BUTTON_LEFT : 0); | 292 | init_Click(&d->click, d, !isEmpty_String(&d->command) ? SDL_BUTTON_LEFT : 0); |
277 | setFlags_Widget(&d->widget, hover_WidgetFlag, d->click.button != 0); | 293 | setFlags_Widget(&d->widget, hover_WidgetFlag, d->click.button != 0); |
278 | d->alignVisual = iFalse; | 294 | d->alignVisual = iFalse; |
279 | updateSize_LabelWidget(d); | 295 | updateSize_LabelWidget(d); |
296 | updateKey_LabelWidget_(d); | ||
280 | } | 297 | } |
281 | 298 | ||
282 | void deinit_LabelWidget(iLabelWidget *d) { | 299 | void deinit_LabelWidget(iLabelWidget *d) { |
@@ -321,8 +338,15 @@ const iString *command_LabelWidget(const iLabelWidget *d) { | |||
321 | return &d->command; | 338 | return &d->command; |
322 | } | 339 | } |
323 | 340 | ||
341 | iLabelWidget *newKeyMods_LabelWidget(const char *label, int key, int kmods, const char *command) { | ||
342 | iLabelWidget *d = new_LabelWidget(label, command); | ||
343 | d->key = key; | ||
344 | d->kmods = kmods; | ||
345 | return d; | ||
346 | } | ||
347 | |||
324 | iLabelWidget *newColor_LabelWidget(const char *text, int color) { | 348 | iLabelWidget *newColor_LabelWidget(const char *text, int color) { |
325 | iLabelWidget *d = new_LabelWidget(format_CStr("%s%s", escape_Color(color), text), 0, 0, NULL); | 349 | iLabelWidget *d = new_LabelWidget(format_CStr("%s%s", escape_Color(color), text), NULL); |
326 | setFlags_Widget(as_Widget(d), frameless_WidgetFlag, iTrue); | 350 | setFlags_Widget(as_Widget(d), frameless_WidgetFlag, iTrue); |
327 | return d; | 351 | return d; |
328 | } | 352 | } |
diff --git a/src/ui/labelwidget.h b/src/ui/labelwidget.h index c55ecd08..066c9b33 100644 --- a/src/ui/labelwidget.h +++ b/src/ui/labelwidget.h | |||
@@ -27,7 +27,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
27 | #include "widget.h" | 27 | #include "widget.h" |
28 | 28 | ||
29 | iDeclareWidgetClass(LabelWidget) | 29 | iDeclareWidgetClass(LabelWidget) |
30 | iDeclareObjectConstructionArgs(LabelWidget, const char *label, int key, int kmods, const char *command) | 30 | iDeclareObjectConstructionArgs(LabelWidget, const char *label, const char *command) |
31 | 31 | ||
32 | void setAlignVisually_LabelWidget(iLabelWidget *, iBool alignVisual); | 32 | void setAlignVisually_LabelWidget(iLabelWidget *, iBool alignVisual); |
33 | void setFont_LabelWidget (iLabelWidget *, int fontId); | 33 | void setFont_LabelWidget (iLabelWidget *, int fontId); |
@@ -41,13 +41,14 @@ void updateTextCStr_LabelWidget (iLabelWidget *, const char *text); /* not r | |||
41 | const iString *label_LabelWidget (const iLabelWidget *); | 41 | const iString *label_LabelWidget (const iLabelWidget *); |
42 | const iString *command_LabelWidget (const iLabelWidget *); | 42 | const iString *command_LabelWidget (const iLabelWidget *); |
43 | 43 | ||
44 | iLabelWidget *newColor_LabelWidget(const char *text, int color); | 44 | iLabelWidget *newKeyMods_LabelWidget(const char *label, int key, int kmods, const char *command); |
45 | iLabelWidget *newColor_LabelWidget (const char *text, int color); | ||
45 | 46 | ||
46 | iLocalDef iLabelWidget *newEmpty_LabelWidget(void) { | 47 | iLocalDef iLabelWidget *newEmpty_LabelWidget(void) { |
47 | return new_LabelWidget("", 0, 0, NULL); | 48 | return new_LabelWidget("", NULL); |
48 | } | 49 | } |
49 | iLocalDef iLabelWidget *newIcon_LabelWidget(const char *label, int key, int kmods, const char *command) { | 50 | iLocalDef iLabelWidget *newIcon_LabelWidget(const char *label, int key, int kmods, const char *command) { |
50 | iLabelWidget *d = new_LabelWidget(label, key, kmods, command); | 51 | iLabelWidget *d = newKeyMods_LabelWidget(label, key, kmods, command); |
51 | setAlignVisually_LabelWidget(d, iTrue); | 52 | setAlignVisually_LabelWidget(d, iTrue); |
52 | return d; | 53 | return d; |
53 | } | 54 | } |
diff --git a/src/ui/listwidget.h b/src/ui/listwidget.h index 3e1c6777..da6303e9 100644 --- a/src/ui/listwidget.h +++ b/src/ui/listwidget.h | |||
@@ -73,6 +73,6 @@ size_t itemIndex_ListWidget (const iListWidget *, iInt2 pos) | |||
73 | const iAnyObject * constItem_ListWidget (const iListWidget *, size_t index); | 73 | const iAnyObject * constItem_ListWidget (const iListWidget *, size_t index); |
74 | const iAnyObject * constHoverItem_ListWidget (const iListWidget *); | 74 | const iAnyObject * constHoverItem_ListWidget (const iListWidget *); |
75 | 75 | ||
76 | iLocalDef isEmpty_ListWidget(const iListWidget *d) { return numItems_ListWidget(d) == 0; } | 76 | iLocalDef iBool isEmpty_ListWidget(const iListWidget *d) { return numItems_ListWidget(d) == 0; } |
77 | 77 | ||
78 | iBool isMouseDown_ListWidget (const iListWidget *); | 78 | iBool isMouseDown_ListWidget (const iListWidget *); |
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c index f089f48d..d6292f5b 100644 --- a/src/ui/sidebarwidget.c +++ b/src/ui/sidebarwidget.c | |||
@@ -252,18 +252,16 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) { | |||
252 | iWidget *div = makeVDiv_Widget(); | 252 | iWidget *div = makeVDiv_Widget(); |
253 | setPadding_Widget(div, 3 * gap_UI, 0, 3 * gap_UI, 2 * gap_UI); | 253 | setPadding_Widget(div, 3 * gap_UI, 0, 3 * gap_UI, 2 * gap_UI); |
254 | addChildFlags_Widget(div, iClob(new_Widget()), expand_WidgetFlag); /* pad */ | 254 | addChildFlags_Widget(div, iClob(new_Widget()), expand_WidgetFlag); /* pad */ |
255 | iLabelWidget *msg = new_LabelWidget("No Identities", 0, 0, NULL); | 255 | iLabelWidget *msg = new_LabelWidget("No Identities", NULL); |
256 | setFont_LabelWidget(msg, uiLabelLarge_FontId); | 256 | setFont_LabelWidget(msg, uiLabelLarge_FontId); |
257 | addChildFlags_Widget(div, iClob(msg), frameless_WidgetFlag); | 257 | addChildFlags_Widget(div, iClob(msg), frameless_WidgetFlag); |
258 | addChild_Widget(div, iClob(makePadding_Widget(3 * gap_UI))); | 258 | addChild_Widget(div, iClob(makePadding_Widget(3 * gap_UI))); |
259 | addChild_Widget(div, iClob(new_LabelWidget("New Identity...", 0, 0, "ident.new"))); | 259 | addChild_Widget(div, iClob(new_LabelWidget("New Identity...", "ident.new"))); |
260 | addChildFlags_Widget(div, iClob(new_Widget()), expand_WidgetFlag); /* pad */ | 260 | addChildFlags_Widget(div, iClob(new_Widget()), expand_WidgetFlag); /* pad */ |
261 | addChildFlags_Widget( | 261 | addChildFlags_Widget( |
262 | div, | 262 | div, |
263 | iClob(new_LabelWidget("See " uiTextStrong_ColorEscape "Help" uiText_ColorEscape | 263 | iClob(new_LabelWidget("See " uiTextStrong_ColorEscape "Help" uiText_ColorEscape |
264 | " for more information about TLS client certificates.", | 264 | " for more information about TLS client certificates.", |
265 | 0, | ||
266 | 0, | ||
267 | "!open newtab:1 gotoheading:Identities url:about:help")), | 265 | "!open newtab:1 gotoheading:Identities url:about:help")), |
268 | frameless_WidgetFlag | fixedHeight_WidgetFlag | wrapText_WidgetFlag); | 266 | frameless_WidgetFlag | fixedHeight_WidgetFlag | wrapText_WidgetFlag); |
269 | addChild_Widget(d->blank, iClob(div)); | 267 | addChild_Widget(d->blank, iClob(div)); |
@@ -336,7 +334,7 @@ void init_SidebarWidget(iSidebarWidget *d) { | |||
336 | d->modeButtons[i] = addChildFlags_Widget( | 334 | d->modeButtons[i] = addChildFlags_Widget( |
337 | buttons, | 335 | buttons, |
338 | iClob( | 336 | iClob( |
339 | new_LabelWidget(tightModeLabels_[i], 0, 0, format_CStr("sidebar.mode arg:%d", i))), | 337 | new_LabelWidget(tightModeLabels_[i], format_CStr("sidebar.mode arg:%d", i))), |
340 | frameless_WidgetFlag); | 338 | frameless_WidgetFlag); |
341 | d->maxButtonLabelWidth = | 339 | d->maxButtonLabelWidth = |
342 | iMaxi(d->maxButtonLabelWidth, | 340 | iMaxi(d->maxButtonLabelWidth, |
diff --git a/src/ui/util.c b/src/ui/util.c index 16dea8d9..3c40d4a5 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -319,7 +319,7 @@ iWidget *makePadding_Widget(int size) { | |||
319 | } | 319 | } |
320 | 320 | ||
321 | iLabelWidget *makeHeading_Widget(const char *text) { | 321 | iLabelWidget *makeHeading_Widget(const char *text) { |
322 | iLabelWidget *heading = new_LabelWidget(text, 0, 0, NULL); | 322 | iLabelWidget *heading = new_LabelWidget(text, NULL); |
323 | setFlags_Widget(as_Widget(heading), frameless_WidgetFlag | fixedSize_WidgetFlag, iTrue); | 323 | setFlags_Widget(as_Widget(heading), frameless_WidgetFlag | fixedSize_WidgetFlag, iTrue); |
324 | setBackgroundColor_Widget(as_Widget(heading), none_ColorId); | 324 | setBackgroundColor_Widget(as_Widget(heading), none_ColorId); |
325 | return heading; | 325 | return heading; |
@@ -338,7 +338,7 @@ iWidget *makeHDiv_Widget(void) { | |||
338 | } | 338 | } |
339 | 339 | ||
340 | iWidget *addAction_Widget(iWidget *parent, int key, int kmods, const char *command) { | 340 | iWidget *addAction_Widget(iWidget *parent, int key, int kmods, const char *command) { |
341 | iLabelWidget *action = new_LabelWidget("", key, kmods, command); | 341 | iLabelWidget *action = newKeyMods_LabelWidget("", key, kmods, command); |
342 | setSize_Widget(as_Widget(action), zero_I2()); | 342 | setSize_Widget(as_Widget(action), zero_I2()); |
343 | addChildFlags_Widget(parent, iClob(action), hidden_WidgetFlag); | 343 | addChildFlags_Widget(parent, iClob(action), hidden_WidgetFlag); |
344 | return as_Widget(action); | 344 | return as_Widget(action); |
@@ -394,7 +394,7 @@ iWidget *makeMenu_Widget(iWidget *parent, const iMenuItem *items, size_t n) { | |||
394 | else { | 394 | else { |
395 | iLabelWidget *label = addChildFlags_Widget( | 395 | iLabelWidget *label = addChildFlags_Widget( |
396 | menu, | 396 | menu, |
397 | iClob(new_LabelWidget(item->label, item->key, item->kmods, item->command)), | 397 | iClob(newKeyMods_LabelWidget(item->label, item->key, item->kmods, item->command)), |
398 | frameless_WidgetFlag | alignLeft_WidgetFlag | drawKey_WidgetFlag); | 398 | frameless_WidgetFlag | alignLeft_WidgetFlag | drawKey_WidgetFlag); |
399 | updateSize_LabelWidget(label); /* drawKey was set */ | 399 | updateSize_LabelWidget(label); /* drawKey was set */ |
400 | } | 400 | } |
@@ -462,7 +462,7 @@ int checkContextMenu_Widget(iWidget *menu, const SDL_Event *ev) { | |||
462 | } | 462 | } |
463 | 463 | ||
464 | iLabelWidget *makeMenuButton_LabelWidget(const char *label, const iMenuItem *items, size_t n) { | 464 | iLabelWidget *makeMenuButton_LabelWidget(const char *label, const iMenuItem *items, size_t n) { |
465 | iLabelWidget *button = new_LabelWidget(label, 0, 0, "menu.open"); | 465 | iLabelWidget *button = new_LabelWidget(label, "menu.open"); |
466 | iWidget *menu = makeMenu_Widget(as_Widget(button), items, n); | 466 | iWidget *menu = makeMenu_Widget(as_Widget(button), items, n); |
467 | setId_Widget(menu, "menu"); | 467 | setId_Widget(menu, "menu"); |
468 | return button; | 468 | return button; |
@@ -538,7 +538,7 @@ static void addTabPage_Widget_(iWidget *tabs, enum iWidgetAddPos addPos, iWidget | |||
538 | iWidget * buttons = findChild_Widget(tabs, "tabs.buttons"); | 538 | iWidget * buttons = findChild_Widget(tabs, "tabs.buttons"); |
539 | iWidget * button = addChildPos_Widget( | 539 | iWidget * button = addChildPos_Widget( |
540 | buttons, | 540 | buttons, |
541 | iClob(new_LabelWidget(label, key, kmods, format_CStr("tabs.switch page:%p", page))), | 541 | iClob(newKeyMods_LabelWidget(label, key, kmods, format_CStr("tabs.switch page:%p", page))), |
542 | addPos); | 542 | addPos); |
543 | setFlags_Widget(buttons, hidden_WidgetFlag, iFalse); | 543 | setFlags_Widget(buttons, hidden_WidgetFlag, iFalse); |
544 | setFlags_Widget(button, selected_WidgetFlag, isSel); | 544 | setFlags_Widget(button, selected_WidgetFlag, isSel); |
@@ -732,7 +732,7 @@ void makeFilePath_Widget(iWidget * parent, | |||
732 | iWidget *dlg = makeSheet_Widget(command); | 732 | iWidget *dlg = makeSheet_Widget(command); |
733 | setCommandHandler_Widget(dlg, filePathHandler_); | 733 | setCommandHandler_Widget(dlg, filePathHandler_); |
734 | addChild_Widget(parent, iClob(dlg)); | 734 | addChild_Widget(parent, iClob(dlg)); |
735 | addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, 0, 0, NULL)), frameless_WidgetFlag); | 735 | addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, NULL)), frameless_WidgetFlag); |
736 | iInputWidget *input = addChild_Widget(dlg, iClob(new_InputWidget(0))); | 736 | iInputWidget *input = addChild_Widget(dlg, iClob(new_InputWidget(0))); |
737 | if (initialPath) { | 737 | if (initialPath) { |
738 | setText_InputWidget(input, collect_String(makeRelative_Path(initialPath))); | 738 | setText_InputWidget(input, collect_String(makeRelative_Path(initialPath))); |
@@ -742,8 +742,8 @@ void makeFilePath_Widget(iWidget * parent, | |||
742 | addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI))); | 742 | addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI))); |
743 | iWidget *div = new_Widget(); { | 743 | iWidget *div = new_Widget(); { |
744 | setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); | 744 | setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); |
745 | addChild_Widget(div, iClob(new_LabelWidget("Cancel", SDLK_ESCAPE, 0, "filepath.cancel"))); | 745 | addChild_Widget(div, iClob(newKeyMods_LabelWidget("Cancel", SDLK_ESCAPE, 0, "filepath.cancel"))); |
746 | addChild_Widget(div, iClob(new_LabelWidget(acceptLabel, SDLK_RETURN, 0, "filepath.accept"))); | 746 | addChild_Widget(div, iClob(newKeyMods_LabelWidget(acceptLabel, SDLK_RETURN, 0, "filepath.accept"))); |
747 | } | 747 | } |
748 | addChild_Widget(dlg, iClob(div)); | 748 | addChild_Widget(dlg, iClob(div)); |
749 | centerSheet_Widget(dlg); | 749 | centerSheet_Widget(dlg); |
@@ -818,10 +818,10 @@ iWidget *makeValueInput_Widget(iWidget *parent, const iString *initialValue, con | |||
818 | addChild_Widget(parent, iClob(dlg)); | 818 | addChild_Widget(parent, iClob(dlg)); |
819 | } | 819 | } |
820 | setId_Widget( | 820 | setId_Widget( |
821 | addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, 0, 0, NULL)), frameless_WidgetFlag), | 821 | addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, NULL)), frameless_WidgetFlag), |
822 | "valueinput.title"); | 822 | "valueinput.title"); |
823 | setId_Widget( | 823 | setId_Widget( |
824 | addChildFlags_Widget(dlg, iClob(new_LabelWidget(prompt, 0, 0, NULL)), frameless_WidgetFlag), | 824 | addChildFlags_Widget(dlg, iClob(new_LabelWidget(prompt, NULL)), frameless_WidgetFlag), |
825 | "valueinput.prompt"); | 825 | "valueinput.prompt"); |
826 | iInputWidget *input = addChild_Widget(dlg, iClob(new_InputWidget(0))); | 826 | iInputWidget *input = addChild_Widget(dlg, iClob(new_InputWidget(0))); |
827 | if (initialValue) { | 827 | if (initialValue) { |
@@ -832,12 +832,13 @@ iWidget *makeValueInput_Widget(iWidget *parent, const iString *initialValue, con | |||
832 | addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI))); | 832 | addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI))); |
833 | iWidget *div = new_Widget(); { | 833 | iWidget *div = new_Widget(); { |
834 | setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); | 834 | setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); |
835 | addChild_Widget(div, iClob(new_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel"))); | 835 | addChild_Widget(div, iClob(newKeyMods_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel"))); |
836 | addChild_Widget(div, | 836 | addChild_Widget( |
837 | iClob(new_LabelWidget(acceptLabel ? acceptLabel : uiTextAction_ColorEscape "OK", | 837 | div, |
838 | SDLK_RETURN, | 838 | iClob(newKeyMods_LabelWidget(acceptLabel ? acceptLabel : uiTextAction_ColorEscape "OK", |
839 | 0, | 839 | SDLK_RETURN, |
840 | "valueinput.accept"))); | 840 | 0, |
841 | "valueinput.accept"))); | ||
841 | } | 842 | } |
842 | addChild_Widget(dlg, iClob(div)); | 843 | addChild_Widget(dlg, iClob(div)); |
843 | centerSheet_Widget(dlg); | 844 | centerSheet_Widget(dlg); |
@@ -874,15 +875,15 @@ iWidget *makeQuestion_Widget(const char *title, const char *msg, const char *lab | |||
874 | processEvents_App(postedEventsOnly_AppEventMode); | 875 | processEvents_App(postedEventsOnly_AppEventMode); |
875 | iWidget *dlg = makeSheet_Widget(""); | 876 | iWidget *dlg = makeSheet_Widget(""); |
876 | setCommandHandler_Widget(dlg, messageHandler_); | 877 | setCommandHandler_Widget(dlg, messageHandler_); |
877 | addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, 0, 0, NULL)), frameless_WidgetFlag); | 878 | addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, NULL)), frameless_WidgetFlag); |
878 | addChildFlags_Widget(dlg, iClob(new_LabelWidget(msg, 0, 0, NULL)), frameless_WidgetFlag); | 879 | addChildFlags_Widget(dlg, iClob(new_LabelWidget(msg, NULL)), frameless_WidgetFlag); |
879 | addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI))); | 880 | addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI))); |
880 | iWidget *div = new_Widget(); { | 881 | iWidget *div = new_Widget(); { |
881 | setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); | 882 | setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); |
882 | for (size_t i = 0; i < count; ++i) { | 883 | for (size_t i = 0; i < count; ++i) { |
883 | /* The last one is the default option. */ | 884 | /* The last one is the default option. */ |
884 | const int key = (i == count - 1 ? SDLK_RETURN : 0); | 885 | const int key = (i == count - 1 ? SDLK_RETURN : 0); |
885 | addChild_Widget(div, iClob(new_LabelWidget(labels[i], key, 0, commands[i]))); | 886 | addChild_Widget(div, iClob(newKeyMods_LabelWidget(labels[i], key, 0, commands[i]))); |
886 | } | 887 | } |
887 | } | 888 | } |
888 | addChild_Widget(dlg, iClob(div)); | 889 | addChild_Widget(dlg, iClob(div)); |
@@ -912,7 +913,7 @@ static iBool toggleHandler_(iWidget *d, const char *cmd) { | |||
912 | } | 913 | } |
913 | 914 | ||
914 | iWidget *makeToggle_Widget(const char *id) { | 915 | iWidget *makeToggle_Widget(const char *id) { |
915 | iWidget *toggle = as_Widget(new_LabelWidget("YES", 0, 0, "toggle")); /* "YES" for sizing */ | 916 | iWidget *toggle = as_Widget(new_LabelWidget("YES", "toggle")); /* "YES" for sizing */ |
916 | setId_Widget(toggle, id); | 917 | setId_Widget(toggle, id); |
917 | updateTextCStr_LabelWidget((iLabelWidget *) toggle, "NO"); /* actual initial value */ | 918 | updateTextCStr_LabelWidget((iLabelWidget *) toggle, "NO"); /* actual initial value */ |
918 | setCommandHandler_Widget(toggle, toggleHandler_); | 919 | setCommandHandler_Widget(toggle, toggleHandler_); |
@@ -950,7 +951,7 @@ static void expandInputFieldWidth_(iInputWidget *input) { | |||
950 | 951 | ||
951 | static void addRadioButton_(iWidget *parent, const char *id, const char *label, const char *cmd) { | 952 | static void addRadioButton_(iWidget *parent, const char *id, const char *label, const char *cmd) { |
952 | setId_Widget( | 953 | setId_Widget( |
953 | addChildFlags_Widget(parent, iClob(new_LabelWidget(label, 0, 0, cmd)), radio_WidgetFlag), | 954 | addChildFlags_Widget(parent, iClob(new_LabelWidget(label, cmd)), radio_WidgetFlag), |
954 | id); | 955 | id); |
955 | } | 956 | } |
956 | 957 | ||
@@ -969,7 +970,7 @@ static void addFontButtons_(iWidget *parent, const char *id) { | |||
969 | iWidget *makePreferences_Widget(void) { | 970 | iWidget *makePreferences_Widget(void) { |
970 | iWidget *dlg = makeSheet_Widget("prefs"); | 971 | iWidget *dlg = makeSheet_Widget("prefs"); |
971 | addChildFlags_Widget(dlg, | 972 | addChildFlags_Widget(dlg, |
972 | iClob(new_LabelWidget(uiHeading_ColorEscape "PREFERENCES", 0, 0, NULL)), | 973 | iClob(new_LabelWidget(uiHeading_ColorEscape "PREFERENCES", NULL)), |
973 | frameless_WidgetFlag); | 974 | frameless_WidgetFlag); |
974 | iWidget *tabs = makeTabs_Widget(dlg); | 975 | iWidget *tabs = makeTabs_Widget(dlg); |
975 | setId_Widget(tabs, "prefs.tabs"); | 976 | setId_Widget(tabs, "prefs.tabs"); |
@@ -988,10 +989,10 @@ iWidget *makePreferences_Widget(void) { | |||
988 | addChild_Widget(headings, iClob(makeHeading_Widget("Theme:"))); | 989 | addChild_Widget(headings, iClob(makeHeading_Widget("Theme:"))); |
989 | iWidget *themes = new_Widget(); | 990 | iWidget *themes = new_Widget(); |
990 | /* Themes. */ { | 991 | /* Themes. */ { |
991 | setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("Pure Black", 0, 0, "theme.set arg:0"))), "prefs.theme.0"); | 992 | setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("Pure Black", "theme.set arg:0"))), "prefs.theme.0"); |
992 | setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("Dark", 0, 0, "theme.set arg:1"))), "prefs.theme.1"); | 993 | setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("Dark", "theme.set arg:1"))), "prefs.theme.1"); |
993 | setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("Light", 0, 0, "theme.set arg:2"))), "prefs.theme.2"); | 994 | setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("Light", "theme.set arg:2"))), "prefs.theme.2"); |
994 | setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("Pure White", 0, 0, "theme.set arg:3"))), "prefs.theme.3"); | 995 | setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("Pure White", "theme.set arg:3"))), "prefs.theme.3"); |
995 | } | 996 | } |
996 | addChildFlags_Widget(values, iClob(themes), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); | 997 | addChildFlags_Widget(values, iClob(themes), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); |
997 | addChild_Widget(headings, iClob(makeHeading_Widget("Retain window size:"))); | 998 | addChild_Widget(headings, iClob(makeHeading_Widget("Retain window size:"))); |
@@ -1084,7 +1085,7 @@ iWidget *makePreferences_Widget(void) { | |||
1084 | } | 1085 | } |
1085 | iWidget *div = new_Widget(); { | 1086 | iWidget *div = new_Widget(); { |
1086 | setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); | 1087 | setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); |
1087 | addChild_Widget(div, iClob(new_LabelWidget("Dismiss", SDLK_ESCAPE, 0, "prefs.dismiss"))); | 1088 | addChild_Widget(div, iClob(newKeyMods_LabelWidget("Dismiss", SDLK_ESCAPE, 0, "prefs.dismiss"))); |
1088 | } | 1089 | } |
1089 | addChild_Widget(dlg, iClob(div)); | 1090 | addChild_Widget(dlg, iClob(div)); |
1090 | addAction_Widget(dlg, prevTab_KeyShortcut, "tabs.prev"); | 1091 | addAction_Widget(dlg, prevTab_KeyShortcut, "tabs.prev"); |
@@ -1098,7 +1099,7 @@ iWidget *makeBookmarkEditor_Widget(void) { | |||
1098 | iWidget *dlg = makeSheet_Widget("bmed"); | 1099 | iWidget *dlg = makeSheet_Widget("bmed"); |
1099 | setId_Widget(addChildFlags_Widget( | 1100 | setId_Widget(addChildFlags_Widget( |
1100 | dlg, | 1101 | dlg, |
1101 | iClob(new_LabelWidget(uiHeading_ColorEscape "EDIT BOOKMARK", 0, 0, NULL)), | 1102 | iClob(new_LabelWidget(uiHeading_ColorEscape "EDIT BOOKMARK", NULL)), |
1102 | frameless_WidgetFlag), | 1103 | frameless_WidgetFlag), |
1103 | "bmed.heading"); | 1104 | "bmed.heading"); |
1104 | iWidget *page = new_Widget(); | 1105 | iWidget *page = new_Widget(); |
@@ -1121,10 +1122,10 @@ iWidget *makeBookmarkEditor_Widget(void) { | |||
1121 | } | 1122 | } |
1122 | iWidget *div = new_Widget(); { | 1123 | iWidget *div = new_Widget(); { |
1123 | setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); | 1124 | setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); |
1124 | addChild_Widget(div, iClob(new_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel"))); | 1125 | addChild_Widget(div, iClob(newKeyMods_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel"))); |
1125 | addChild_Widget( | 1126 | addChild_Widget( |
1126 | div, | 1127 | div, |
1127 | iClob(new_LabelWidget( | 1128 | iClob(newKeyMods_LabelWidget( |
1128 | uiTextCaution_ColorEscape "Save Bookmark", SDLK_RETURN, KMOD_PRIMARY, "bmed.accept"))); | 1129 | uiTextCaution_ColorEscape "Save Bookmark", SDLK_RETURN, KMOD_PRIMARY, "bmed.accept"))); |
1129 | } | 1130 | } |
1130 | addChild_Widget(dlg, iClob(div)); | 1131 | addChild_Widget(dlg, iClob(div)); |
@@ -1165,7 +1166,7 @@ iWidget *makeBookmarkCreation_Widget(const iString *url, const iString *title, i | |||
1165 | setId_Widget( | 1166 | setId_Widget( |
1166 | addChildFlags_Widget( | 1167 | addChildFlags_Widget( |
1167 | dlg, | 1168 | dlg, |
1168 | iClob(new_LabelWidget(cstrCollect_String(newUnicodeN_String(&icon, 1)), 0, 0, NULL)), | 1169 | iClob(new_LabelWidget(cstrCollect_String(newUnicodeN_String(&icon, 1)), NULL)), |
1169 | collapse_WidgetFlag | hidden_WidgetFlag | disabled_WidgetFlag), | 1170 | collapse_WidgetFlag | hidden_WidgetFlag | disabled_WidgetFlag), |
1170 | "bmed.icon"); | 1171 | "bmed.icon"); |
1171 | setCommandHandler_Widget(dlg, handleBookmarkCreationCommands_SidebarWidget_); | 1172 | setCommandHandler_Widget(dlg, handleBookmarkCreationCommands_SidebarWidget_); |
@@ -1176,14 +1177,14 @@ iWidget *makeIdentityCreation_Widget(void) { | |||
1176 | iWidget *dlg = makeSheet_Widget("ident"); | 1177 | iWidget *dlg = makeSheet_Widget("ident"); |
1177 | setId_Widget(addChildFlags_Widget( | 1178 | setId_Widget(addChildFlags_Widget( |
1178 | dlg, | 1179 | dlg, |
1179 | iClob(new_LabelWidget(uiHeading_ColorEscape "NEW IDENTITY", 0, 0, NULL)), | 1180 | iClob(new_LabelWidget(uiHeading_ColorEscape "NEW IDENTITY", NULL)), |
1180 | frameless_WidgetFlag), | 1181 | frameless_WidgetFlag), |
1181 | "ident.heading"); | 1182 | "ident.heading"); |
1182 | iWidget *page = new_Widget(); | 1183 | iWidget *page = new_Widget(); |
1183 | addChildFlags_Widget( | 1184 | addChildFlags_Widget( |
1184 | dlg, | 1185 | dlg, |
1185 | iClob( | 1186 | iClob( |
1186 | new_LabelWidget("Creating a 2048-bit self-signed RSA certificate.", 0, 0, NULL)), | 1187 | new_LabelWidget("Creating a 2048-bit self-signed RSA certificate.", NULL)), |
1187 | frameless_WidgetFlag); | 1188 | frameless_WidgetFlag); |
1188 | addChild_Widget(dlg, iClob(page)); | 1189 | addChild_Widget(dlg, iClob(page)); |
1189 | setFlags_Widget(page, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); | 1190 | setFlags_Widget(page, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); |
@@ -1214,10 +1215,10 @@ iWidget *makeIdentityCreation_Widget(void) { | |||
1214 | } | 1215 | } |
1215 | iWidget *div = new_Widget(); { | 1216 | iWidget *div = new_Widget(); { |
1216 | setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); | 1217 | setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); |
1217 | addChild_Widget(div, iClob(new_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel"))); | 1218 | addChild_Widget(div, iClob(newKeyMods_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel"))); |
1218 | addChild_Widget( | 1219 | addChild_Widget( |
1219 | div, | 1220 | div, |
1220 | iClob(new_LabelWidget( | 1221 | iClob(newKeyMods_LabelWidget( |
1221 | uiTextAction_ColorEscape "Create Identity", SDLK_RETURN, KMOD_PRIMARY, "ident.accept"))); | 1222 | uiTextAction_ColorEscape "Create Identity", SDLK_RETURN, KMOD_PRIMARY, "ident.accept"))); |
1222 | } | 1223 | } |
1223 | addChild_Widget(dlg, iClob(div)); | 1224 | addChild_Widget(dlg, iClob(div)); |
diff --git a/src/ui/window.c b/src/ui/window.c index fe731ecf..3ec4ff4f 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -388,7 +388,7 @@ static void setupUserInterface_Window(iWindow *d) { | |||
388 | addChildFlags_Widget(navBar, iClob(url), expand_WidgetFlag); | 388 | addChildFlags_Widget(navBar, iClob(url), expand_WidgetFlag); |
389 | /* Download progress indicator is inside the input field, but hidden normally. */ | 389 | /* Download progress indicator is inside the input field, but hidden normally. */ |
390 | setPadding_Widget(as_Widget(url),0, 0, gap_UI * 1, 0); | 390 | setPadding_Widget(as_Widget(url),0, 0, gap_UI * 1, 0); |
391 | iLabelWidget *progress = new_LabelWidget(uiTextCaution_ColorEscape "00.000 MB", 0, 0, NULL); | 391 | iLabelWidget *progress = new_LabelWidget(uiTextCaution_ColorEscape "00.000 MB", NULL); |
392 | setId_Widget(as_Widget(progress), "document.progress"); | 392 | setId_Widget(as_Widget(progress), "document.progress"); |
393 | setAlignVisually_LabelWidget(progress, iTrue); | 393 | setAlignVisually_LabelWidget(progress, iTrue); |
394 | shrink_Rect(&as_Widget(progress)->rect, init_I2(0, gap_UI)); | 394 | shrink_Rect(&as_Widget(progress)->rect, init_I2(0, gap_UI)); |
@@ -448,7 +448,7 @@ static void setupUserInterface_Window(iWindow *d) { | |||
448 | setBackgroundColor_Widget(searchBar, uiBackground_ColorId); | 448 | setBackgroundColor_Widget(searchBar, uiBackground_ColorId); |
449 | setCommandHandler_Widget(searchBar, handleSearchBarCommands_); | 449 | setCommandHandler_Widget(searchBar, handleSearchBarCommands_); |
450 | addChildFlags_Widget( | 450 | addChildFlags_Widget( |
451 | searchBar, iClob(new_LabelWidget("\U0001f50d Text", 0, 0, NULL)), frameless_WidgetFlag); | 451 | searchBar, iClob(new_LabelWidget("\U0001f50d Text", NULL)), frameless_WidgetFlag); |
452 | iInputWidget *input = new_InputWidget(0); | 452 | iInputWidget *input = new_InputWidget(0); |
453 | setId_Widget(addChildFlags_Widget(searchBar, iClob(input), expand_WidgetFlag), | 453 | setId_Widget(addChildFlags_Widget(searchBar, iClob(input), expand_WidgetFlag), |
454 | "find.input"); | 454 | "find.input"); |
@@ -597,6 +597,7 @@ void init_Window(iWindow *d, iRect rect) { | |||
597 | setId_Widget(d->root, "root"); | 597 | setId_Widget(d->root, "root"); |
598 | init_Text(d->render); | 598 | init_Text(d->render); |
599 | setupUserInterface_Window(d); | 599 | setupUserInterface_Window(d); |
600 | postCommand_App("bindings.changed"); /* update from bindings */ | ||
600 | updateRootSize_Window_(d); | 601 | updateRootSize_Window_(d); |
601 | } | 602 | } |
602 | 603 | ||