diff options
author | Marvin W <git@larma.de> | 2025-02-22 11:25:53 +0100 |
---|---|---|
committer | Marvin W <git@larma.de> | 2025-02-22 11:27:48 +0100 |
commit | 834b1336dbe2901eec99b69c3c32805bec5eaed2 (patch) | |
tree | 2fd975786e4d4ef883f5137603aae7ebf3bc0ac5 /main | |
parent | efe39b8ea008cea3106fcc268d29d6f2bdf3c76e (diff) | |
download | dino-834b1336dbe2901eec99b69c3c32805bec5eaed2.tar.gz dino-834b1336dbe2901eec99b69c3c32805bec5eaed2.zip |
Fix various sizing issues
Diffstat (limited to 'main')
-rw-r--r-- | main/data/call_widget.ui | 4 | ||||
-rw-r--r-- | main/data/file_default_widget.ui | 4 | ||||
-rw-r--r-- | main/data/unified_main_content.ui | 15 | ||||
-rw-r--r-- | main/src/ui/util/size_request_box.vala | 11 | ||||
-rw-r--r-- | main/src/ui/util/sizing_bin.vala | 63 | ||||
-rw-r--r-- | main/src/ui/widgets/natural_size_increase.vala | 27 |
6 files changed, 99 insertions, 25 deletions
diff --git a/main/data/call_widget.ui b/main/data/call_widget.ui index aed663b1..dd3d1539 100644 --- a/main/data/call_widget.ui +++ b/main/data/call_widget.ui @@ -7,8 +7,8 @@ </style> <child> <object class="DinoUiSizingBin"> - <property name="target-width">350</property> - <property name="max-width">350</property> + <property name="target-width">400</property> + <property name="max-width">400</property> <property name="hexpand">True</property> <child> <object class="GtkBox"> diff --git a/main/data/file_default_widget.ui b/main/data/file_default_widget.ui index bc89df1b..d1f0a72e 100644 --- a/main/data/file_default_widget.ui +++ b/main/data/file_default_widget.ui @@ -8,8 +8,8 @@ </style> <child> <object class="DinoUiSizingBin"> - <property name="target-width">500</property> - <property name="max-width">500</property> + <property name="target-width">400</property> + <property name="max-width">400</property> <property name="hexpand">True</property> <child> <object class="GtkBox"> diff --git a/main/data/unified_main_content.ui b/main/data/unified_main_content.ui index 7a3f92fc..45c0d332 100644 --- a/main/data/unified_main_content.ui +++ b/main/data/unified_main_content.ui @@ -104,11 +104,16 @@ <property name="maximum-size">400</property> <property name="tightening-threshold">400</property> <child> - <object class="AdwBin" id="search_frame"> - <property name="hexpand">true</property> - <style> - <class name="background"/> - </style> + <object class="DinoUiNaturalSizeIncrease"> + <property name="min-natural-width">400</property> + <child> + <object class="AdwBin" id="search_frame"> + <property name="hexpand">true</property> + <style> + <class name="background"/> + </style> + </object> + </child> </object> </child> </object> diff --git a/main/src/ui/util/size_request_box.vala b/main/src/ui/util/size_request_box.vala index 7d7b6185..98f1a20a 100644 --- a/main/src/ui/util/size_request_box.vala +++ b/main/src/ui/util/size_request_box.vala @@ -16,6 +16,17 @@ public class SizeRequestBin : Widget { this.layout_manager = new BinLayout(); } + public override void compute_expand_internal(out bool hexpand, out bool vexpand) { + hexpand = false; + vexpand = false; + Widget child = get_first_child(); + while (child != null) { + hexpand = hexpand || child.compute_expand(Orientation.HORIZONTAL); + vexpand = vexpand || child.compute_expand(Orientation.VERTICAL); + child = child.get_next_sibling(); + } + } + public override Gtk.SizeRequestMode get_request_mode() { return size_request_mode; } diff --git a/main/src/ui/util/sizing_bin.vala b/main/src/ui/util/sizing_bin.vala index c17cb3cc..7401ddbf 100644 --- a/main/src/ui/util/sizing_bin.vala +++ b/main/src/ui/util/sizing_bin.vala @@ -9,29 +9,72 @@ public class SizingBin : Widget { public int target_height { get; set; default = -1; } public int max_height { get; set; default = -1; } - construct { - layout_manager = new BinLayout(); + public override void compute_expand_internal(out bool hexpand, out bool vexpand) { + hexpand = false; + vexpand = false; + Widget child = get_first_child(); + while (child != null) { + hexpand = hexpand || child.compute_expand(Orientation.HORIZONTAL); + vexpand = vexpand || child.compute_expand(Orientation.VERTICAL); + child = child.get_next_sibling(); + } } public override void size_allocate(int width, int height, int baseline) { if (max_height != -1) height = int.min(height, max_height); if (max_width != -1) width = int.min(width, max_width); - base.size_allocate(width, height, baseline); + Widget child = get_first_child(); + while (child != null) { + if (child.should_layout()) { + child.allocate(width, height, baseline, null); + } + child = child.get_next_sibling(); + } } public override void measure(Orientation orientation, int for_size, out int minimum, out int natural, out int minimum_baseline, out int natural_baseline) { - base.measure(orientation, for_size, out minimum, out natural, out minimum_baseline, out natural_baseline); if (orientation == Orientation.HORIZONTAL) { - if (min_width != -1) minimum = int.max(minimum, min_width); + minimum = min_width; + natural = target_width; + } else { + minimum = min_height; + natural = target_height; + } + minimum_baseline = -1; + natural_baseline = -1; + Widget child = get_first_child(); + while (child != null) { + if (child.should_layout()) { + int child_min = 0; + int child_nat = 0; + int child_min_baseline = -1; + int child_nat_baseline = -1; + child.measure(orientation, for_size, out child_min, out child_nat, out child_min_baseline, out child_nat_baseline); + minimum = int.max(minimum, child_min); + natural = int.max(natural, child_nat); + if (child_min_baseline > 0) { + minimum_baseline = int.max(minimum_baseline, child_min_baseline); + } + if (child_nat_baseline > 0) { + natural_baseline = int.max(natural_baseline, child_nat_baseline); + } + } + child = child.get_next_sibling(); + } + if (orientation == Orientation.HORIZONTAL) { if (max_width != -1) natural = int.min(natural, max_width); - if (target_width != -1) natural = int.max(natural, target_width); - natural = int.max(natural, minimum); } else { - if (min_height != -1) minimum = int.max(minimum, min_height); if (max_height != -1) natural = int.min(natural, max_height); - if (target_height != -1) natural = int.max(natural, target_height); - natural = int.max(natural, minimum); } + natural = int.max(natural, minimum); + } + + public override SizeRequestMode get_request_mode() { + Widget child = get_first_child(); + if (child != null) { + return child.get_request_mode(); + } + return SizeRequestMode.CONSTANT_SIZE; } public override void dispose() { diff --git a/main/src/ui/widgets/natural_size_increase.vala b/main/src/ui/widgets/natural_size_increase.vala index 2b04d748..3aad486a 100644 --- a/main/src/ui/widgets/natural_size_increase.vala +++ b/main/src/ui/widgets/natural_size_increase.vala @@ -1,21 +1,31 @@ using Gtk; public class Dino.Ui.NaturalSizeIncrease : Gtk.Widget { - public int min_natural_height { get; set; default = -1; } - public int min_natural_width { get; set; default = -1; } + public uint min_natural_height { get; set; default = 0; } + public uint min_natural_width { get; set; default = 0; } construct { this.notify.connect(queue_resize); } + public override void compute_expand_internal(out bool hexpand, out bool vexpand) { + hexpand = false; + vexpand = false; + Widget child = get_first_child(); + while (child != null) { + hexpand = hexpand || child.compute_expand(Orientation.HORIZONTAL); + vexpand = vexpand || child.compute_expand(Orientation.VERTICAL); + child = child.get_next_sibling(); + } + } + public override void measure(Orientation orientation, int for_size, out int minimum, out int natural, out int minimum_baseline, out int natural_baseline) { minimum = 0; if (orientation == Orientation.HORIZONTAL) { - natural = min_natural_width; + natural = (int) min_natural_width; } else { - natural = min_natural_height; + natural = (int) min_natural_height; } - natural = int.max(0, natural); minimum_baseline = -1; natural_baseline = -1; Widget child = get_first_child(); @@ -25,7 +35,7 @@ public class Dino.Ui.NaturalSizeIncrease : Gtk.Widget { int child_nat = 0; int child_min_baseline = -1; int child_nat_baseline = -1; - child.measure(orientation, -1, out child_min, out child_nat, out child_min_baseline, out child_nat_baseline); + child.measure(orientation, for_size, out child_min, out child_nat, out child_min_baseline, out child_nat_baseline); minimum = int.max(minimum, child_min); natural = int.max(natural, child_nat); if (child_min_baseline > 0) { @@ -56,4 +66,9 @@ public class Dino.Ui.NaturalSizeIncrease : Gtk.Widget { } return SizeRequestMode.CONSTANT_SIZE; } + + public override void dispose() { + var child = this.get_first_child(); + if (child != null) child.unparent(); + } }
\ No newline at end of file |