[gnome-mines] Align buttons with minefield top and bottom
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-mines] Align buttons with minefield top and bottom
- Date: Sat, 17 Jan 2015 08:05:09 +0000 (UTC)
commit 8921619974439bb9d135c1c80645c20212d77395
Author: Robert Roth <robert roth off gmail com>
Date: Sat Jan 17 10:04:56 2015 +0200
Align buttons with minefield top and bottom
data/interface.ui | 337 ++++++++++++++++++++++-------------------------
src/gnome-mines.vala | 19 ++-
src/minefield-view.vala | 2 +-
3 files changed, 173 insertions(+), 185 deletions(-)
---
diff --git a/data/interface.ui b/data/interface.ui
index c9afefd..b88a3f3 100644
--- a/data/interface.ui
+++ b/data/interface.ui
@@ -2,6 +2,15 @@
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.10"/>
+ <object class="GtkSizeGroup" id="buttons_size_group">
+ <property name="mode">both</property>
+ <widgets>
+ <widget name="play_pause_button"/>
+ <widget name="high_scores_button"/>
+ <widget name="new_game_button"/>
+ <widget name="replay_button"/>
+ </widgets>
+ </object>
<object class="GtkApplicationWindow" id="main_window">
<property name="width_request">560</property>
<property name="height_request">380</property>
@@ -20,7 +29,6 @@
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
- <property name="transition-type">slide-left-right</property>
<child>
<object class="GtkAspectFrame" id="new_game_screen">
<property name="visible">True</property>
@@ -231,18 +239,6 @@
<child>
<object class="GtkBox" id="main_screen">
<property name="can_focus">False</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
<child>
<object class="GtkAspectFrame" id="minefield_aspect">
<property name="visible">True</property>
@@ -251,185 +247,181 @@
<property name="vexpand">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
- <property name="xalign">1</property>
+ <property name="xalign">0.5</property>
<property name="obey_child">False</property>
<child>
- <object class="GtkOverlay" id="minefield_overlay">
+ <object class="GtkBox" id="aspect_child">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="spacing">24</property>
<child>
- <object class="GtkScrolledWindow" id="scrolled">
+ <object class="GtkOverlay" id="minefield_overlay">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="shadow_type">none</property>
+ <property name="can_focus">False</property>
<child>
- <placeholder/>
+ <object class="GtkScrolledWindow" id="scrolled">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
</child>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
</child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="buttons_box">
- <property name="width_request">150</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">4</property>
- <child>
- <object class="GtkImage" id="flag_image">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="pixel_size">32</property>
- <property name="icon_name">flag-symbolic</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="flag_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_bottom">12</property>
- <property name="label">5/10</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkImage" id="clock_image">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="pixel_size">32</property>
- <property name="icon_name">preferences-system-time-symbolic</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="clock_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_bottom">12</property>
- <property name="yalign">0</property>
- <property name="label">0:00</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="play_pause_button">
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="action_name">app.pause</property>
- <property name="use_underline">True</property>
<child>
- <object class="GtkLabel" id="play_pause_label">
+ <object class="GtkBox" id="buttons_box">
+ <property name="width_request">150</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes">_Pause</property>
- <property name="use_underline">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">4</property>
+ <child>
+ <object class="GtkImage" id="flag_image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="pixel_size">32</property>
+ <property name="icon_name">flag-symbolic</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="flag_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_bottom">12</property>
+ <property name="label">5/10</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="clock_image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="pixel_size">32</property>
+ <property name="icon_name">preferences-system-time-symbolic</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="clock_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_bottom">12</property>
+ <property name="yalign">0</property>
+ <property name="label">0:00</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="play_pause_button">
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="action_name">app.pause</property>
+ <property name="use_underline">True</property>
+ <child>
+ <object class="GtkLabel" id="play_pause_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Pause</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="new_game_button">
+ <property name="label" translatable="yes">Change _Difficulty</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="action_name">app.new-game</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">6</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="high_scores_button">
+ <property name="label" translatable="yes">_Best Times</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="action_name">app.scores</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">6</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="replay_button">
+ <property name="label" translatable="yes">_Play Again</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="action_name">app.repeat-size</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">7</property>
+ </packing>
+ </child>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">end</property>
- <property name="position">4</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="new_game_button">
- <property name="label" translatable="yes">Change _Difficulty</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="action_name">app.new-game</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">end</property>
- <property name="position">6</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="high_scores_button">
- <property name="label" translatable="yes">_Best Times</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="action_name">app.scores</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">end</property>
- <property name="position">6</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="replay_button">
- <property name="label" translatable="yes">_Play Again</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="action_name">app.repeat-size</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">end</property>
- <property name="position">7</property>
- </packing>
</child>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- </object>
- <packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">3</property>
+ <property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="name" translatable="no">game</property>
- <property name="position">2</property>
</packing>
</child>
- <child>
- <placeholder/>
- </child>
</object>
<packing>
<property name="expand">True</property>
@@ -443,23 +435,8 @@
<object class="GtkSizeGroup" id="buttons_matcher">
<property name="mode">vertical</property>
<widgets>
- <widget name="minefield_overlay"/>
<widget name="buttons_box"/>
- </widgets>
- </object>
- <object class="GtkSizeGroup" id="buttons_size_group">
- <property name="mode">both</property>
- <widgets>
- <widget name="play_pause_button"/>
- <widget name="high_scores_button"/>
- <widget name="new_game_button"/>
- <widget name="replay_button"/>
- </widgets>
- </object>
- <object class="GtkSizeGroup" id="sides_size_group">
- <widgets>
- <widget name="label1"/>
- <widget name="label2"/>
+ <widget name="minefield_overlay"/>
</widgets>
</object>
<object class="GtkBox" id="paused_box">
diff --git a/src/gnome-mines.vala b/src/gnome-mines.vala
index 860abb2..55a3c5e 100644
--- a/src/gnome-mines.vala
+++ b/src/gnome-mines.vala
@@ -38,6 +38,8 @@ public class Mines : Gtk.Application
private Gtk.Button new_game_button;
private Gtk.AspectFrame minefield_aspect;
private Gtk.Overlay minefield_overlay;
+ private Gtk.Box aspect_child;
+ private Gtk.Box buttons_box;
private Gtk.Box paused_box;
private Gtk.ScrolledWindow scrolled;
private Gtk.Stack stack;
@@ -280,6 +282,9 @@ public class Mines : Gtk.Application
minefield_aspect.show ();
paused_box = (Gtk.Box) ui_builder.get_object ("paused_box");
+ buttons_box = (Gtk.Box) ui_builder.get_object ("buttons_box");
+ aspect_child = (Gtk.Box) ui_builder.get_object ("aspect_child");
+ paused_box = (Gtk.Box) ui_builder.get_object ("paused_box");
paused_box.button_press_event.connect (view_button_press_event);
minefield_overlay.add_overlay (paused_box);
@@ -619,13 +624,13 @@ public class Mines : Gtk.Application
minefield.paused_changed.connect (paused_changed_cb);
minefield.clock_started.connect (clock_started_cb);
- minefield_aspect.ratio = (float)x / y;
minefield_view.minefield = minefield;
+
int request_x = -1, request_y = -1;
- if (window.get_allocated_width () - scrolled.get_allocated_width () + 30 * x < Gdk.Screen.width ())
{
- request_x = 30 * x;
+ if (window.get_allocated_width () - scrolled.get_allocated_width () + 30 * x + aspect_child.spacing
+ buttons_box.get_allocated_width () < Gdk.Screen.width ()) {
+ request_x = 30 * x + aspect_child.spacing + 150;
} else {
- request_x = Gdk.Screen.width () - window.get_allocated_width () + scrolled.get_allocated_width
();
+ request_x = Gdk.Screen.width () - window.get_allocated_width () + scrolled.get_allocated_width
() + aspect_child.spacing + 150;
}
if (window.get_allocated_height () - scrolled.get_allocated_height () + 30 * y < Gdk.Screen.height
()) {
request_y = 30 * y;
@@ -633,6 +638,12 @@ public class Mines : Gtk.Application
request_y = Gdk.Screen.height () - window.get_allocated_height () +
scrolled.get_allocated_height ();
}
minefield_aspect.set_size_request (request_x, request_y);
+
+ uint width = x * 30;
+ width += aspect_child.spacing;
+ width += 150;
+ minefield_aspect.ratio = (float) (width) / (y * 30);
+
update_flag_label ();
minefield.paused = false;
diff --git a/src/minefield-view.vala b/src/minefield-view.vala
index faad916..633efb4 100644
--- a/src/minefield-view.vala
+++ b/src/minefield-view.vala
@@ -127,7 +127,7 @@ public class MinefieldView : Gtk.Grid
private Tile[,] mines;
- private uint mine_size
+ public uint mine_size
{
get
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]