summaryrefslogtreecommitdiff
path: root/fluid/Shortcut_Button.h
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2022-02-13 22:01:16 +0100
committerGitHub <noreply@github.com>2022-02-13 22:01:16 +0100
commit8c3778e13feebced373497a3e4060ae065cf65b7 (patch)
tree96ba807115e42e5f3cd35156343ccf5f700e5559 /fluid/Shortcut_Button.h
parentf196ffbb528f9ec5030697bc03fb956f79c9563e (diff)
Better Fluid Widget dimension controls (#394)
* Size and position widgets can evaluate basic math. * Allowing x, y, w, and h as variables for formulas. Also supporting 'i' as a counting index when selecting multiple widgets, so setting Y: to i*25+10 arranges all selected widgets vertically. * Additional variables cx, etc. for children box cx, cy, cw, ch
Diffstat (limited to 'fluid/Shortcut_Button.h')
-rw-r--r--fluid/Shortcut_Button.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/fluid/Shortcut_Button.h b/fluid/Shortcut_Button.h
index 1c46b8afc..443d2bd67 100644
--- a/fluid/Shortcut_Button.h
+++ b/fluid/Shortcut_Button.h
@@ -18,6 +18,7 @@
#define _FLUID_SHORTCUT_BUTTON_H
#include <FL/Fl_Button.H>
+#include <FL/Fl_Input.H>
class Shortcut_Button : public Fl_Button {
public:
@@ -42,5 +43,37 @@ public:
Fl_Button(X,Y,W,H,l) { }
};
+
+typedef int (Fluid_Coord_Callback)(class Fluid_Coord_Input const *, void*);
+
+typedef struct Fluid_Coord_Input_Vars {
+ const char *name_;
+ Fluid_Coord_Callback *callback_;
+} Fluid_Coord_Input_Vars;
+
+class Fluid_Coord_Input : public Fl_Input {
+ Fl_Callback *user_callback_;
+ Fluid_Coord_Input_Vars *vars_;
+ void *vars_user_data_;
+ static void callback_handler_cb(Fluid_Coord_Input *This, void *v);
+ void callback_handler(void *v);
+ int eval_var(uchar *&s) const;
+ int eval(uchar *&s, int prio) const;
+ int eval(const char *s) const;
+public:
+ Fluid_Coord_Input(int x, int y, int w, int h, const char *l=0L);
+ const char *text() const { return Fl_Input::value(); }
+ void text(const char *v) { Fl_Input::value(v); }
+ int value() const;
+ void value(int v);
+ void callback(Fl_Callback *cb) {
+ user_callback_ = cb;
+ }
+ void variables(Fluid_Coord_Input_Vars *vars, void *user_data) {
+ vars_ = vars;
+ vars_user_data_ = user_data;
+ }
+};
+
#endif