diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-11-03 07:09:16 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-11-03 07:09:16 +0200 |
commit | f4172885428f9849ff29bd09490db8b167a8d705 (patch) | |
tree | c82af9c46bce0f56627e61d180a630e11fb8baee /src/app.c | |
parent | 20b5a9bbad524e242b7ade9fdcd06f34721c5f3a (diff) |
Redo cached document layout if needed
Changing the fonts, zoom level, or window width will cause cached documents to be laid out again if they are restored from memory.
Diffstat (limited to 'src/app.c')
-rw-r--r-- | src/app.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -2125,6 +2125,12 @@ void resetFonts_App(void) { | |||
2125 | } | 2125 | } |
2126 | } | 2126 | } |
2127 | 2127 | ||
2128 | static void invalidateCachedDocuments_App_(void) { | ||
2129 | iForEach(ObjectList, i, iClob(listDocuments_App(NULL))) { | ||
2130 | invalidateCachedLayout_History(history_DocumentWidget(i.object)); | ||
2131 | } | ||
2132 | } | ||
2133 | |||
2128 | iBool handleCommand_App(const char *cmd) { | 2134 | iBool handleCommand_App(const char *cmd) { |
2129 | iApp *d = &app_; | 2135 | iApp *d = &app_; |
2130 | const iBool isFrozen = !d->window || d->window->isDrawFrozen; | 2136 | const iBool isFrozen = !d->window || d->window->isDrawFrozen; |
@@ -2289,7 +2295,10 @@ iBool handleCommand_App(const char *cmd) { | |||
2289 | if (!isFrozen) { | 2295 | if (!isFrozen) { |
2290 | setFreezeDraw_MainWindow(get_MainWindow(), iTrue); /* no intermediate draws before docs updated */ | 2296 | setFreezeDraw_MainWindow(get_MainWindow(), iTrue); /* no intermediate draws before docs updated */ |
2291 | } | 2297 | } |
2292 | d->prefs.zoomPercent = arg_Command(cmd); | 2298 | if (arg_Command(cmd) != d->prefs.zoomPercent) { |
2299 | d->prefs.zoomPercent = arg_Command(cmd); | ||
2300 | invalidateCachedDocuments_App_(); | ||
2301 | } | ||
2293 | setDocumentFontSize_Text(text_Window(d->window), (float) d->prefs.zoomPercent / 100.0f); | 2302 | setDocumentFontSize_Text(text_Window(d->window), (float) d->prefs.zoomPercent / 100.0f); |
2294 | if (!isFrozen) { | 2303 | if (!isFrozen) { |
2295 | postCommand_App("font.changed"); | 2304 | postCommand_App("font.changed"); |
@@ -2306,6 +2315,7 @@ iBool handleCommand_App(const char *cmd) { | |||
2306 | delta /= 2; | 2315 | delta /= 2; |
2307 | } | 2316 | } |
2308 | d->prefs.zoomPercent = iClamp(d->prefs.zoomPercent + delta, 50, 200); | 2317 | d->prefs.zoomPercent = iClamp(d->prefs.zoomPercent + delta, 50, 200); |
2318 | invalidateCachedDocuments_App_(); | ||
2309 | setDocumentFontSize_Text(text_Window(d->window), (float) d->prefs.zoomPercent / 100.0f); | 2319 | setDocumentFontSize_Text(text_Window(d->window), (float) d->prefs.zoomPercent / 100.0f); |
2310 | if (!isFrozen) { | 2320 | if (!isFrozen) { |
2311 | postCommand_App("font.changed"); | 2321 | postCommand_App("font.changed"); |