summaryrefslogtreecommitdiffstats
path: root/ScreenManager.c
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2018-01-28 04:09:06 -0200
committerHisham Muhammad <hisham@gobolinux.org>2018-01-30 12:59:11 -0200
commit5beff29a3df7097cc4d256b27888ee730b1a45d0 (patch)
treecdc2d5f30e82db0f7415c2998bbb75cd5beba78f /ScreenManager.c
parentd1219abc558141a96ea25aa1db1c2dd3171c5132 (diff)
Add support for multiple screens, switchable using Tab
Diffstat (limited to 'ScreenManager.c')
-rw-r--r--ScreenManager.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/ScreenManager.c b/ScreenManager.c
index 1a93ae00..081d887a 100644
--- a/ScreenManager.c
+++ b/ScreenManager.c
@@ -71,30 +71,46 @@ inline int ScreenManager_size(ScreenManager* this) {
}
void ScreenManager_add(ScreenManager* this, Panel* item, int size) {
+ ScreenManager_insert(this, item, size, Vector_size(this->panels));
+}
+
+void ScreenManager_insert(ScreenManager* this, Panel* item, int size, int idx) {
if (this->orientation == HORIZONTAL) {
int lastX = 0;
- if (this->panelCount > 0) {
- Panel* last = (Panel*) Vector_get(this->panels, this->panelCount - 1);
+ if (idx > 0) {
+ Panel* last = (Panel*) Vector_get(this->panels, idx - 1);
lastX = last->x + last->w + 1;
}
int height = LINES - this->y1 + this->y2;
- if (size > 0) {
- Panel_resize(item, size, height);
- } else {
- Panel_resize(item, COLS-this->x1+this->x2-lastX, height);
+ if (size <= 0) {
+ size = COLS-this->x1+this->x2-lastX;
}
+ Panel_resize(item, size, height);
Panel_move(item, lastX, this->y1);
+ if (idx < this->panelCount) {
+ for (int i = idx + 1; i <= this->panelCount; i++) {
+ Panel* p = (Panel*) Vector_get(this->panels, i);
+ Panel_move(p, p->x + size, p->y);
+ }
+ }
}
// TODO: VERTICAL
- Vector_add(this->panels, item);
+ Vector_insert(this->panels, idx, item);
item->needsRedraw = true;
this->panelCount++;
}
Panel* ScreenManager_remove(ScreenManager* this, int idx) {
assert(this->panelCount > idx);
+ int w = ((Panel*) Vector_get(this->panels, idx))->w;
Panel* panel = (Panel*) Vector_remove(this->panels, idx);
this->panelCount--;
+ if (idx < this->panelCount) {
+ for (int i = idx; i < this->panelCount; i++) {
+ Panel* p = (Panel*) Vector_get(this->panels, i);
+ Panel_move(p, p->x - w, p->y);
+ }
+ }
return panel;
}
@@ -131,7 +147,7 @@ static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTi
if (*rescan) {
*oldTime = newTime;
ProcessList_scan(pl);
- if (*sortTimeout == 0 || this->settings->treeView) {
+ if (*sortTimeout == 0 || this->settings->ss->treeView) {
ProcessList_sort(pl);
*sortTimeout = 1;
}

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