diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-03-04 09:14:30 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-03-04 09:14:30 +0200 |
commit | 1d735299127aaf0474d8fc2a1c5ec4947c1dca9a (patch) | |
tree | 926f4d136a2799c5fcf62589259ede57c04c35a9 /src/ui/labelwidget.c | |
parent | 2f6fd59952ce3d76b15a4b7b8f526e27edd39775 (diff) |
Changing UI scaling at runtime
UI scaling factor is applied when closing the Preferences dialog.
IssueID #83
Diffstat (limited to 'src/ui/labelwidget.c')
-rw-r--r-- | src/ui/labelwidget.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c index 8cba2d00..87c33562 100644 --- a/src/ui/labelwidget.c +++ b/src/ui/labelwidget.c | |||
@@ -78,7 +78,7 @@ static void updateKey_LabelWidget_(iLabelWidget *d) { | |||
78 | 78 | ||
79 | static iBool processEvent_LabelWidget_(iLabelWidget *d, const SDL_Event *ev) { | 79 | static iBool processEvent_LabelWidget_(iLabelWidget *d, const SDL_Event *ev) { |
80 | iWidget *w = &d->widget; | 80 | iWidget *w = &d->widget; |
81 | if (isCommand_UserEvent(ev, "metrics.changed")) { | 81 | if (isMetricsChange_UserEvent(ev)) { |
82 | updateSize_LabelWidget(d); | 82 | updateSize_LabelWidget(d); |
83 | } | 83 | } |
84 | else if (isCommand_UserEvent(ev, "bindings.changed")) { | 84 | else if (isCommand_UserEvent(ev, "bindings.changed")) { |
@@ -277,8 +277,8 @@ static void sizeChanged_LabelWidget_(iLabelWidget *d) { | |||
277 | } | 277 | } |
278 | } | 278 | } |
279 | 279 | ||
280 | void updateSize_LabelWidget(iLabelWidget *d) { | 280 | iInt2 defaultSize_LabelWidget(const iLabelWidget *d) { |
281 | iWidget *w = as_Widget(d); | 281 | const iWidget *w = constAs_Widget(d); |
282 | const int64_t flags = flags_Widget(w); | 282 | const int64_t flags = flags_Widget(w); |
283 | iInt2 size = add_I2(measure_Text(d->font, cstr_String(&d->label)), muli_I2(padding_(flags), 2)); | 283 | iInt2 size = add_I2(measure_Text(d->font, cstr_String(&d->label)), muli_I2(padding_(flags), 2)); |
284 | if ((flags & drawKey_WidgetFlag) && d->key) { | 284 | if ((flags & drawKey_WidgetFlag) && d->key) { |
@@ -288,6 +288,17 @@ void updateSize_LabelWidget(iLabelWidget *d) { | |||
288 | size.x += 2 * gap_UI + measure_Text(uiShortcuts_FontId, cstr_String(&str)).x; | 288 | size.x += 2 * gap_UI + measure_Text(uiShortcuts_FontId, cstr_String(&str)).x; |
289 | deinit_String(&str); | 289 | deinit_String(&str); |
290 | } | 290 | } |
291 | return size; | ||
292 | } | ||
293 | |||
294 | int font_LabelWidget(const iLabelWidget *d) { | ||
295 | return d->font; | ||
296 | } | ||
297 | |||
298 | void updateSize_LabelWidget(iLabelWidget *d) { | ||
299 | iWidget *w = as_Widget(d); | ||
300 | const int64_t flags = flags_Widget(w); | ||
301 | const iInt2 size = defaultSize_LabelWidget(d); | ||
291 | /* Wrapped text implies that width must be defined by arrangement. */ | 302 | /* Wrapped text implies that width must be defined by arrangement. */ |
292 | if (!(flags & (fixedWidth_WidgetFlag | wrapText_WidgetFlag))) { | 303 | if (!(flags & (fixedWidth_WidgetFlag | wrapText_WidgetFlag))) { |
293 | w->rect.size.x = size.x; | 304 | w->rect.size.x = size.x; |