From e3862aa67e37ecef0eb8f82ba1f4a710ffac9c02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Wed, 16 Dec 2020 21:46:11 +0100 Subject: Rework drawing of FunctionBar Draw the FunctionBar within Panel_draw instead of manually throughout the code. Add an optional PanelClass function drawFunctionBar, to allow specific panels to override the default FunctionBar_draw call. Rework the code on color change, to really change all colors (selection markers and panel headers). Closes: #402 --- MainPanel.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'MainPanel.c') diff --git a/MainPanel.c b/MainPanel.c index 815609f6..949138dc 100644 --- a/MainPanel.c +++ b/MainPanel.c @@ -100,16 +100,12 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) { if (reaction & HTOP_REDRAW_BAR) { MainPanel_updateTreeFunctions(this, this->state->settings->treeView); - IncSet_drawBar(this->inc); - if (this->state->pauseProcessUpdate) { - FunctionBar_append("PAUSED", CRT_colors[PAUSED]); - } } if (reaction & HTOP_UPDATE_PANELHDR) { ProcessList_printHeader(this->state->pl, Panel_getHeader(super)); } if (reaction & HTOP_REFRESH) { - result |= REDRAW; + result |= REFRESH; } if (reaction & HTOP_RECALCULATE) { result |= RESCAN; @@ -122,7 +118,7 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) { } if (!(reaction & HTOP_KEEP_FOLLOWING)) { this->state->pl->following = -1; - Panel_setSelectionColor(super, CRT_colors[PANEL_SELECTION_FOCUS]); + Panel_setSelectionColor(super, PANEL_SELECTION_FOCUS); } return result; } @@ -164,12 +160,21 @@ bool MainPanel_foreachProcess(MainPanel* this, MainPanel_ForeachProcessFn fn, Ar return ok; } +static void MainPanel_drawFunctionBar(Panel* super) { + MainPanel* this = (MainPanel*) super; + IncSet_drawBar(this->inc); + if (this->state->pauseProcessUpdate) { + FunctionBar_append("PAUSED", CRT_colors[PAUSED]); + } +} + const PanelClass MainPanel_class = { .super = { .extends = Class(Panel), .delete = MainPanel_delete }, - .eventHandler = MainPanel_eventHandler + .eventHandler = MainPanel_eventHandler, + .drawFunctionBar = MainPanel_drawFunctionBar }; MainPanel* MainPanel_new() { -- cgit v1.2.3