From 8c3778e13feebced373497a3e4060ae065cf65b7 Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Sun, 13 Feb 2022 22:01:16 +0100 Subject: 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 --- fluid/Shortcut_Button.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'fluid/Shortcut_Button.h') 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 +#include 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 -- cgit v1.2.3