From 1a70cf5b8ea0ed3bc9d9fc6656e13784611281c9 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 29 Jul 2021 12:19:08 -0600 Subject: [PATCH] canvasL Item gets packing options similar to GTK --- libs/canvas/canvas/item.h | 4 ++++ libs/canvas/canvas/types.h | 12 ++++++++---- libs/canvas/item.cc | 3 +++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/libs/canvas/canvas/item.h b/libs/canvas/canvas/item.h index 43695c9e06..dc390cba1d 100644 --- a/libs/canvas/canvas/item.h +++ b/libs/canvas/canvas/item.h @@ -236,6 +236,9 @@ public: void lower_child_to_bottom (Item *); virtual void child_changed (bool bbox_changed); + PackOptions pack_options () const { return _pack_options; } + void set_pack_options (PackOptions); + static int default_items_per_cell; @@ -330,6 +333,7 @@ public: mutable Rect _bounding_box; /** true if _bounding_box might be out of date, false if its definitely not */ mutable bool _bounding_box_dirty; + PackOptions _pack_options; void bb_clean () const; diff --git a/libs/canvas/canvas/types.h b/libs/canvas/canvas/types.h index 70f4cc6bf0..52a7da558d 100644 --- a/libs/canvas/canvas/types.h +++ b/libs/canvas/canvas/types.h @@ -195,10 +195,14 @@ struct LIBCANVAS_API Rect }; enum PackOptions { - PackExpand = 0x1, - PackFill = 0x2, - PackFromStart = 0x4, - PackFromEnd = 0x8 + PackExpand = 0x1, /* use all available space ... */ + PackFill = 0x2, /* if PackExpand set, this means actually + expand size of Item; if PackExpand not + set, this does nothing. + */ + PackShrink = 0x4, /* allow Item to be smaller than its natural size */ + PackFromStart = 0x8, + PackFromEnd = 0x10 }; extern LIBCANVAS_API std::ostream & operator<< (std::ostream &, Rect const &); diff --git a/libs/canvas/item.cc b/libs/canvas/item.cc index d84ae03097..4e13235d90 100644 --- a/libs/canvas/item.cc +++ b/libs/canvas/item.cc @@ -43,6 +43,7 @@ Item::Item (Canvas* canvas) , _scroll_parent (0) , _visible (true) , _bounding_box_dirty (true) + , _pack_options (PackOptions (0)) , _layout_sensitive (false) , _intrinsic_width (-1.) , _intrinsic_height(-1.) @@ -63,6 +64,7 @@ Item::Item (Item* parent) , _scroll_parent (0) , _visible (true) , _bounding_box_dirty (true) + , _pack_options (PackOptions (0)) , _layout_sensitive (false) , _intrinsic_width (-1.) , _intrinsic_height(-1.) @@ -90,6 +92,7 @@ Item::Item (Item* parent, Duple const& p) , _position (p) , _visible (true) , _bounding_box_dirty (true) + , _pack_options (PackOptions (0)) , _layout_sensitive (false) , _intrinsic_width (-1.) , _intrinsic_height(-1.)