[gnome-games/wip/exalm/gtk4: 218/238] ui: Update size_allocate()
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/gtk4: 218/238] ui: Update size_allocate()
- Date: Mon, 19 Aug 2019 20:34:46 +0000 (UTC)
commit 71a222361abd15906d2d9272a30e088224db9536
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Sun Jul 29 13:31:05 2018 +0500
ui: Update size_allocate()
src/ui/application-window.vala | 4 ++--
src/ui/collection-icon-view.vala | 4 ++--
src/ui/display-bin.vala | 16 +++++-----------
src/ui/display-box.vala | 18 ++++++++----------
4 files changed, 17 insertions(+), 25 deletions(-)
---
diff --git a/src/ui/application-window.vala b/src/ui/application-window.vala
index 9d7ba858..11ba4c4c 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -155,8 +155,8 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
return display_view.quit_game ();
}
- public override void size_allocate (Gtk.Allocation allocation) {
- base.size_allocate (allocation);
+ public override void size_allocate (int width, int height, int baseline) {
+ base.size_allocate (width, height, baseline);
if (window_size_update_timeout == -1 && !is_maximized)
window_size_update_timeout = Timeout.add (WINDOW_SIZE_UPDATE_DELAY_MILLISECONDS,
store_window_size);
diff --git a/src/ui/collection-icon-view.vala b/src/ui/collection-icon-view.vala
index c7384884..d5768a3d 100644
--- a/src/ui/collection-icon-view.vala
+++ b/src/ui/collection-icon-view.vala
@@ -249,12 +249,12 @@ private class Games.CollectionIconView : Gtk.Bin {
}
[GtkCallback]
- private void on_size_allocate (Gtk.Allocation allocation) {
+ private void on_size_allocate (Gtk.Widget widget, int width, int height, int baseline) {
// If the window's width is less than half the width of a 1920×1080
// screen, display the game thumbnails at half the size to see more of
// them rather than a few huge thumbnails, making Games more usable on
// small screens.
- if (allocation.width < 960)
+ if (width < 960)
get_style_context ().remove_class ("large");
else
get_style_context ().add_class ("large");
diff --git a/src/ui/display-bin.vala b/src/ui/display-bin.vala
index e9ad67b1..1b0625ff 100644
--- a/src/ui/display-bin.vala
+++ b/src/ui/display-bin.vala
@@ -25,22 +25,16 @@ public class Games.DisplayBin : Gtk.Bin {
}
}
- public override void size_allocate (Gtk.Allocation allocation) {
- set_allocation (allocation);
-
+ public override void size_allocate (int width, int height, int baseline) {
var child = get_child ();
if (child != null && child.visible) {
- Gtk.Allocation child_allocation = {};
+ Graphene.Point point = { horizontal_offset, vertical_offset };
if (get_direction () == Gtk.TextDirection.RTL)
- child_allocation.x = allocation.x - horizontal_offset;
- else
- child_allocation.x = allocation.x + horizontal_offset;
- child_allocation.y = allocation.y + vertical_offset;
- child_allocation.width = allocation.width;
- child_allocation.height = allocation.height;
+ point.x = -horizontal_offset;
- child.size_allocate (child_allocation);
+ var transform = ((Gsk.Transform) null).translate (point);
+ child.allocate (width, height, baseline, transform);
}
}
}
diff --git a/src/ui/display-box.vala b/src/ui/display-box.vala
index 702a7869..556cb254 100644
--- a/src/ui/display-box.vala
+++ b/src/ui/display-box.vala
@@ -142,23 +142,21 @@ private class Games.DisplayBox : Gtk.Bin {
fullscreen_box.autohide = !savestates_list.state.is_revealed;
}
- private void on_fullscreen_header_bar_size_allocated (Gtk.Allocation allocation) {
- fullscreen_header_bar_height = allocation.height;
+ private void on_fullscreen_header_bar_size_allocated (Gtk.Widget widget, int width, int height, int
baseline) {
+ fullscreen_header_bar_height = height;
}
[GtkCallback]
- private void on_savestates_list_size_allocate (Gtk.Allocation allocation) {
- update_margin ();
+ private void on_savestates_list_size_allocate (Gtk.Widget widget, int width, int height, int
baseline) {
+ update_margin (width);
}
- public override void size_allocate (Gtk.Allocation allocation) {
- update_margin ();
- base.size_allocate (allocation);
+ public override void size_allocate (int width, int height, int baseline) {
+ update_margin (savestates_list.get_allocated_width ());
+ base.size_allocate (width, height, baseline);
}
- private void update_margin () {
- var width = savestates_list.get_allocated_width ();
-
+ private void update_margin (int width) {
display_bin.horizontal_offset = -width / 2;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]