summaryrefslogtreecommitdiffstats
path: root/Panel.h
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2020-12-16 21:46:11 +0100
committerChristian Göttsche <cgzones@googlemail.com>2020-12-20 17:01:50 +0100
commite3862aa67e37ecef0eb8f82ba1f4a710ffac9c02 (patch)
treeaa906dac3ffca307c01b9dc78ed75082aecf238c /Panel.h
parent7e7a53c415b82cceee6173922987b772b1d51c10 (diff)
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
Diffstat (limited to 'Panel.h')
-rw-r--r--Panel.h27
1 files changed, 17 insertions, 10 deletions
diff --git a/Panel.h b/Panel.h
index 86c134e0..959c0b78 100644
--- a/Panel.h
+++ b/Panel.h
@@ -9,6 +9,7 @@ in the source distribution for its full text.
#include <stdbool.h>
+#include "CRT.h"
#include "FunctionBar.h"
#include "Object.h"
#include "RichString.h"
@@ -22,9 +23,10 @@ typedef enum HandlerResult_ {
HANDLED = 0x01,
IGNORED = 0x02,
BREAK_LOOP = 0x04,
- REDRAW = 0x08,
- RESCAN = 0x10,
- SYNTH_KEY = 0x20,
+ REFRESH = 0x08,
+ REDRAW = 0x10,
+ RESCAN = 0x20,
+ SYNTH_KEY = 0x40,
} HandlerResult;
#define EVENT_SET_SELECTED (-1)
@@ -33,16 +35,20 @@ typedef enum HandlerResult_ {
#define EVENT_IS_HEADER_CLICK(ev_) ((ev_) >= -10000 && (ev_) <= -9000)
#define EVENT_HEADER_CLICK_GET_X(ev_) ((ev_) + 10000)
-typedef HandlerResult(*Panel_EventHandler)(Panel*, int);
+typedef HandlerResult (*Panel_EventHandler)(Panel*, int);
+typedef void (*Panel_DrawFunctionBar)(Panel*);
typedef struct PanelClass_ {
const ObjectClass super;
const Panel_EventHandler eventHandler;
+ const Panel_DrawFunctionBar drawFunctionBar;
} PanelClass;
-#define As_Panel(this_) ((const PanelClass*)((this_)->super.klass))
-#define Panel_eventHandlerFn(this_) As_Panel(this_)->eventHandler
-#define Panel_eventHandler(this_, ev_) As_Panel(this_)->eventHandler((Panel*)(this_), ev_)
+#define As_Panel(this_) ((const PanelClass*)((this_)->super.klass))
+#define Panel_eventHandlerFn(this_) As_Panel(this_)->eventHandler
+#define Panel_eventHandler(this_, ev_) (assert(As_Panel(this_)->eventHandler), As_Panel(this_)->eventHandler((Panel*)(this_), ev_))
+#define Panel_drawFunctionBarFn(this_) As_Panel(this_)->drawFunctionBar
+#define Panel_drawFunctionBar(this_) (assert(As_Panel(this_)->drawFunctionBar), As_Panel(this_)->drawFunctionBar((Panel*)(this_)))
struct Panel_ {
Object super;
@@ -55,10 +61,11 @@ struct Panel_ {
int scrollV;
short scrollH;
bool needsRedraw;
+ bool wasFocus;
FunctionBar* currentBar;
FunctionBar* defaultBar;
RichString header;
- int selectionColor;
+ ColorElements selectionColorId;
};
#define Panel_setDefaultBar(this_) do { (this_)->currentBar = (this_)->defaultBar; } while (0)
@@ -75,7 +82,7 @@ void Panel_init(Panel* this, int x, int y, int w, int h, const ObjectClass* type
void Panel_done(Panel* this);
-void Panel_setSelectionColor(Panel* this, int color);
+void Panel_setSelectionColor(Panel* this, ColorElements colorId);
RichString* Panel_getHeader(Panel* this);
@@ -109,7 +116,7 @@ int Panel_size(Panel* this);
void Panel_setSelected(Panel* this, int selected);
-void Panel_draw(Panel* this, bool focus, bool highlightSelected);
+void Panel_draw(Panel* this, bool force_redraw, bool focus, bool highlightSelected);
void Panel_splice(Panel* this, Vector* from);

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