summaryrefslogtreecommitdiff
path: root/FL
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2023-11-22 14:45:07 +0100
committerMatthias Melcher <github@matthiasm.com>2023-11-22 14:45:13 +0100
commit81e26b9089f83a608768fdb39aa63f33ce169521 (patch)
treee07955ac9c6299184f1a9e557174efd2b2ce2039 /FL
parent9383f172a88f847192e0082e080c0855316b794a (diff)
Adding size range settings to Fl_Tile, initial commit.
- some documentation missing - Fl_Tile::resize() not satisfying yet - minimums work, maximums currently ignored - 0 size children may make program hang
Diffstat (limited to 'FL')
-rw-r--r--FL/Fl_Rect.H11
-rw-r--r--FL/Fl_Tile.H23
2 files changed, 34 insertions, 0 deletions
diff --git a/FL/Fl_Rect.H b/FL/Fl_Rect.H
index 29e7fd451..386deb427 100644
--- a/FL/Fl_Rect.H
+++ b/FL/Fl_Rect.H
@@ -88,6 +88,9 @@ public:
void w(int W) { w_ = W; } ///< sets the width
void h(int H) { h_ = H; } ///< sets the height
+ void r(int R) { w_ = R - x_; } ///< sets the width based on R and x
+ void b(int B) { h_ = B - y_; } ///< sets the height based on B and y
+
/** Move all edges in by \p d.
Shrinks the rectangle by \p d at all sides keeping the center of the
@@ -143,6 +146,14 @@ public:
h_ -= (top + bottom);
}
+ friend bool operator==(const Fl_Rect& lhs, const Fl_Rect& rhs) {
+ return (lhs.x_==rhs.x_) && (lhs.y_==rhs.y_) && (lhs.w_==rhs.w_) && (lhs.h_==rhs.h_);
+ }
+
+ friend bool operator!=(const Fl_Rect& lhs, const Fl_Rect& rhs) {
+ return !(lhs==rhs);
+ }
+
}; // class Fl_Rect
#endif // Fl_Rect_H
diff --git a/FL/Fl_Tile.H b/FL/Fl_Tile.H
index a7de02fea..64a3ba530 100644
--- a/FL/Fl_Tile.H
+++ b/FL/Fl_Tile.H
@@ -28,11 +28,16 @@ class FL_EXPORT Fl_Tile : public Fl_Group {
public:
int handle(int event) FL_OVERRIDE;
Fl_Tile(int X, int Y, int W, int H, const char *L=0);
+ ~Fl_Tile() FL_OVERRIDE;
void resize(int X, int Y, int W, int H) FL_OVERRIDE;
virtual void move_intersection(int oldx, int oldy, int newx, int newy);
+ virtual void drag_intersection(int oldx, int oldy, int newx, int newy);
FL_DEPRECATED("in 1.4.0 - use move_intersection(p) instead",
void position(int oldx, int oldy, int newx, int newy)) { move_intersection(oldx, oldy, newx, newy); }
void position(int x, int y) { Fl_Group::position(x, y); }
+ void size_range(int index, int minw, int minh, int maxw=0x7FFFFFFF, int maxh=0x7FFFFFFF);
+ void size_range(Fl_Widget *w , int minw, int minh, int maxw=0x7FFFFFFF, int maxh=0x7FFFFFFF);
+ void init_size_range(int default_min_w = -1, int default_min_h = -1);
protected:
int cursor_; ///< current cursor index (0..3)
@@ -47,6 +52,24 @@ protected:
}
void set_cursor(int n); // set one of n (0..3) cursors
+
+ typedef struct { int minw, minh, maxw, maxh; } Size_Range;
+
+ Size_Range *size_range_;
+ int size_range_size_, size_range_capacity_;
+ int default_min_w_, default_min_h_;
+ void request_shrink_l(int old_l, int &new_l, Fl_Rect *final_size);
+ void request_shrink_r(int old_r, int &new_r, Fl_Rect *final_size);
+ void request_shrink_t(int old_t, int &new_t, Fl_Rect *final_size);
+ void request_shrink_b(int old_b, int &new_b, Fl_Rect *final_size);
+ void request_grow_l(int old_l, int &new_l, Fl_Rect *final_size);
+ void request_grow_r(int old_r, int &new_r, Fl_Rect *final_size);
+ void request_grow_t(int old_t, int &new_t, Fl_Rect *final_size);
+ void request_grow_b(int old_b, int &new_b, Fl_Rect *final_size);
+
+ int on_insert(Fl_Widget*, int) FL_OVERRIDE;
+ int on_move(int, int) FL_OVERRIDE;
+ void on_remove(int) FL_OVERRIDE;
};
#endif