diff options
| author | maxim nikonov <maxim.nikonov@hqo.co> | 2026-02-05 22:05:41 +0500 |
|---|---|---|
| committer | maxim nikonov <maxim.nikonov@hqo.co> | 2026-02-05 22:05:41 +0500 |
| commit | 57860e277f2298ad6c0830b1492087cfa124c862 (patch) | |
| tree | 50e9a7082c4143483fe01afc83293fb4ecbb4c22 /fluid/app/Snap_Action.cxx | |
| parent | dc39575fb3ef90e5a2689babe7fb335cd88f6727 (diff) | |
wip
Diffstat (limited to 'fluid/app/Snap_Action.cxx')
| -rw-r--r-- | fluid/app/Snap_Action.cxx | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/fluid/app/Snap_Action.cxx b/fluid/app/Snap_Action.cxx index 0de72919e..08e9bf1e5 100644 --- a/fluid/app/Snap_Action.cxx +++ b/fluid/app/Snap_Action.cxx @@ -30,9 +30,13 @@ #include <math.h> #include <string.h> #include <assert.h> -#undef min -#undef max -#include <algorithm> + +#ifndef MIN +#define MIN(a,b) ((a)<=(b) ? (a) : (b)) +#endif +#ifndef MAX +#define MAX(a,b) ((a)>=(b) ? (a) : (b)) +#endif using namespace fld; using namespace fld::app; @@ -700,14 +704,15 @@ void Layout_List::write(Fl_Preferences &prefs, fld::Tool_Store storage) { */ void Layout_List::read(Fl_Preferences &prefs, fld::Tool_Store storage) { Fl_Preferences prefs_list(prefs, "Layouts"); - std::string cs; + char *cs_ptr = 0; int cp = 0; - prefs_list.get("current_suite", cs, ""); + prefs_list.get("current_suite", cs_ptr, ""); prefs_list.get("current_preset", cp, 0); - for (int i = 0; i < prefs_list.groups(); ++i) { + int i; + for (i = 0; i < prefs_list.groups(); ++i) { Fl_Preferences prefs_suite(prefs_list, Fl_Preferences::Name(i)); - char *new_name = nullptr; - prefs_suite.get("name", new_name, nullptr); + char *new_name = 0; + prefs_suite.get("name", new_name, 0); if (new_name) { int n = add(new_name); list_[n].read(prefs_suite); @@ -715,7 +720,10 @@ void Layout_List::read(Fl_Preferences &prefs, fld::Tool_Store storage) { ::free(new_name); } } - current_suite(cs); + if (cs_ptr) { + current_suite(std::string(cs_ptr)); + ::free(cs_ptr); + } current_preset(cp); update_dialogs(); } @@ -1117,8 +1125,8 @@ void Snap_Action::better_size(int &w, int &h) { x_min = x_inc; y_min = y_inc; } - int ww = std::max(w - x_min, 0); w = (w - ww + x_inc - 1) / x_inc; w = w * x_inc; w = w + ww; - int hh = std::max(h - y_min, 0); h = (h - hh + y_inc - 1) / y_inc; h = h * y_inc; h = h + hh; + int ww = MAX(w - x_min, 0); w = (w - ww + x_inc - 1) / x_inc; w = w * x_inc; w = w + ww; + int hh = MAX(h - y_min, 0); h = (h - hh + y_inc - 1) / y_inc; h = h * y_inc; h = h + hh; } @@ -1511,7 +1519,7 @@ class Fd_Snap_Siblings_Left : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Left() { type = 1; mask = FD_LEFT|FD_DRAG; } int sibling_check(Snap_Data &d, Fl_Widget *s) override { - return std::min(check_x_(d, d.bx, s->x()+s->w()), + return MIN(check_x_(d, d.bx, s->x()+s->w()), check_x_(d, d.bx, s->x()+s->w()+Fluid.proj.layout->widget_gap_x) ); } void draw(Snap_Data &d) override { @@ -1536,7 +1544,7 @@ class Fd_Snap_Siblings_Right : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Right() { type = 1; mask = FD_RIGHT|FD_DRAG; } int sibling_check(Snap_Data &d, Fl_Widget *s) override { - return std::min(check_x_(d, d.br, s->x()), + return MIN(check_x_(d, d.br, s->x()), check_x_(d, d.br, s->x()-Fluid.proj.layout->widget_gap_x)); } void draw(Snap_Data &d) override { @@ -1561,7 +1569,7 @@ class Fd_Snap_Siblings_Top : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Top() { type = 2; mask = FD_TOP|FD_DRAG; } int sibling_check(Snap_Data &d, Fl_Widget *s) override { - return std::min(check_y_(d, d.by, s->y()+s->h()), + return MIN(check_y_(d, d.by, s->y()+s->h()), check_y_(d, d.by, s->y()+s->h()+Fluid.proj.layout->widget_gap_y)); } void draw(Snap_Data &d) override { @@ -1586,7 +1594,7 @@ class Fd_Snap_Siblings_Bottom : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Bottom() { type = 2; mask = FD_BOTTOM|FD_DRAG; } int sibling_check(Snap_Data &d, Fl_Widget *s) override { - return std::min(check_y_(d, d.bt, s->y()), + return MIN(check_y_(d, d.bt, s->y()), check_y_(d, d.bt, s->y()-Fluid.proj.layout->widget_gap_y)); } void draw(Snap_Data &d) override { |
