summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--AvailableMetersPanel.c2
-rw-r--r--DisplayOptionsPanel.c2
-rw-r--r--MetersPanel.c2
-rw-r--r--ScreenManager.c23
-rw-r--r--ScreenManager.h2
5 files changed, 14 insertions, 17 deletions
diff --git a/AvailableMetersPanel.c b/AvailableMetersPanel.c
index 55a45d15..a8af8d0a 100644
--- a/AvailableMetersPanel.c
+++ b/AvailableMetersPanel.c
@@ -81,7 +81,7 @@ static HandlerResult AvailableMetersPanel_eventHandler(Panel* super, int ch) {
Header_calculateHeight(header);
Header_updateData(header);
Header_draw(header);
- ScreenManager_resize(this->scr, this->scr->x1, header->height, this->scr->x2, this->scr->y2);
+ ScreenManager_resize(this->scr);
}
return result;
}
diff --git a/DisplayOptionsPanel.c b/DisplayOptionsPanel.c
index 23b16bb2..7e05ae07 100644
--- a/DisplayOptionsPanel.c
+++ b/DisplayOptionsPanel.c
@@ -74,7 +74,7 @@ static HandlerResult DisplayOptionsPanel_eventHandler(Panel* super, int ch) {
Header_reinit(header);
Header_updateData(header);
Header_draw(header);
- ScreenManager_resize(this->scr, this->scr->x1, header->height, this->scr->x2, this->scr->y2);
+ ScreenManager_resize(this->scr);
}
return result;
}
diff --git a/MetersPanel.c b/MetersPanel.c
index d0ad9389..ccf8d0ed 100644
--- a/MetersPanel.c
+++ b/MetersPanel.c
@@ -186,7 +186,7 @@ static HandlerResult MetersPanel_eventHandler(Panel* super, int ch) {
this->settings->changed = true;
Header_calculateHeight(header);
Header_draw(header);
- ScreenManager_resize(this->scr, this->scr->x1, header->height, this->scr->x2, this->scr->y2);
+ ScreenManager_resize(this->scr);
}
return result;
}
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:
diff --git a/ScreenManager.h b/ScreenManager.h
index 59d30bd6..bf55f17d 100644
--- a/ScreenManager.h
+++ b/ScreenManager.h
@@ -39,7 +39,7 @@ void ScreenManager_add(ScreenManager* this, Panel* item, int size);
Panel* ScreenManager_remove(ScreenManager* this, int idx);
-void ScreenManager_resize(ScreenManager* this, int x1, int y1, int x2, int y2);
+void ScreenManager_resize(ScreenManager* this);
void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey);

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