summaryrefslogtreecommitdiffstats
path: root/ScreenManager.c
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2021-08-21 20:42:04 +0200
committerBenBE <BenBE@geshi.org>2021-08-22 10:40:59 +0200
commitb9e69223d02287f75c24c3f5be869a04979e5b17 (patch)
treea439a130dd89a6d141e6cdf43eb338427104679b /ScreenManager.c
parentedc3de7cb5970dcc7203042ff6833f2b42e27449 (diff)
ScreenManager: reduce ScreenManager_resize
The main change is the header hight being not included in y1. This is important if a sub-manager gets resized, e.g. a resize while editing the Settings or in a pickFromVector selection, and afterwards, then the sub-manager is closed, the super-ScreenManager gets resized, it uses the correct header hight. The header hight might have been changed since the last resize of the super-manager in the Settings by adding/removing some meters. This fixes new meters being hidden after added at runtime after a resize in the main window.
Diffstat (limited to 'ScreenManager.c')
-rw-r--r--ScreenManager.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/ScreenManager.c b/ScreenManager.c
index 5a985d4d..d403e24c 100644
--- a/ScreenManager.c
+++ b/ScreenManager.c
@@ -27,7 +27,7 @@ ScreenManager* ScreenManager_new(Header* header, const Settings* settings, const
ScreenManager* this;
this = xMalloc(sizeof(ScreenManager));
this->x1 = 0;
- this->y1 = header->height;
+ this->y1 = 0;
this->x2 = 0;
this->y2 = -1;
this->panels = Vector_new(Class(Panel), owner, DEFAULT_SIZE);
@@ -54,13 +54,13 @@ void ScreenManager_add(ScreenManager* this, Panel* item, int size) {
const Panel* last = (const Panel*) Vector_get(this->panels, this->panelCount - 1);
lastX = last->x + last->w + 1;
}
- int height = LINES - this->y1 + this->y2;
+ int height = LINES - this->y1 - (this->header ? this->header->height : 0) + this->y2;
if (size > 0) {
Panel_resize(item, size, height);
} else {
Panel_resize(item, COLS - this->x1 + this->x2 - lastX, height);
}
- Panel_move(item, lastX, this->y1);
+ Panel_move(item, lastX, this->y1 + (this->header ? this->header->height : 0));
Vector_add(this->panels, item);
item->needsRedraw = true;
this->panelCount++;
@@ -73,22 +73,19 @@ Panel* ScreenManager_remove(ScreenManager* this, int idx) {
return panel;
}
-void ScreenManager_resize(ScreenManager* this, int x1, int y1, int x2, int y2) {
- this->x1 = x1;
- this->y1 = y1;
- this->x2 = x2;
- this->y2 = y2;
+void ScreenManager_resize(ScreenManager* this) {
+ int y1_header = this->y1 + (this->header ? this->header->height : 0);
int panels = this->panelCount;
int lastX = 0;
for (int i = 0; i < panels - 1; i++) {
Panel* panel = (Panel*) Vector_get(this->panels, i);
- Panel_resize(panel, panel->w, LINES - y1 + y2);
- Panel_move(panel, lastX, y1);
+ Panel_resize(panel, panel->w, LINES - y1_header + this->y2);
+ Panel_move(panel, lastX, y1_header);
lastX = panel->x + panel->w + 1;
}
Panel* panel = (Panel*) Vector_get(this->panels, panels - 1);
- Panel_resize(panel, COLS - x1 + x2 - lastX, LINES - y1 + y2);
- Panel_move(panel, lastX, y1);
+ Panel_resize(panel, COLS - this->x1 + this->x2 - lastX, LINES - y1_header + this->y2);
+ Panel_move(panel, lastX, y1_header);
}
static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTimeout, bool* redraw, bool* rescan, bool* timedOut) {
@@ -260,7 +257,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
switch (ch) {
case KEY_RESIZE:
{
- ScreenManager_resize(this, this->x1, this->y1, this->x2, this->y2);
+ ScreenManager_resize(this);
continue;
}
case KEY_LEFT:

© 2014-2024 Faster IT GmbH | imprint | privacy policy