[five-or-more/arnaudb/gtk3: 10/24] Revert "Use an AspectFrame."
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [five-or-more/arnaudb/gtk3: 10/24] Revert "Use an AspectFrame."
- Date: Thu, 22 Oct 2020 15:32:54 +0000 (UTC)
commit 713000da7b26add72567a1b6a04fec4846cc401a
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Thu Oct 22 17:28:15 2020 +0200
Revert "Use an AspectFrame."
This reverts commit a05733197fc5f09195837db434b539f2e461adf3.
data/ui/five-or-more.ui | 11 +----------
src/view.vala | 5 -----
src/window.vala | 16 ++++------------
3 files changed, 5 insertions(+), 27 deletions(-)
---
diff --git a/data/ui/five-or-more.ui b/data/ui/five-or-more.ui
index 22341dc..17b9116 100644
--- a/data/ui/five-or-more.ui
+++ b/data/ui/five-or-more.ui
@@ -145,16 +145,7 @@
</object>
</child>
<child>
- <object class="GtkAspectFrame" id="grid_frame">
- <property name="obey-child">False</property>
- <property name="ratio">1.0</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="margin-top">10</property>
- <property name="margin-start">10</property>
- <property name="margin-end">10</property>
- <property name="margin-bottom">10</property>
- </object>
+ <object class="GamesGridFrame" id="grid_frame"/>
</child>
</template>
</interface>
diff --git a/src/view.vala b/src/view.vala
index 2a24642..c572212 100644
--- a/src/view.vala
+++ b/src/view.vala
@@ -321,8 +321,6 @@ private class View : DrawingArea
piece_size = (width - 1) / game.n_cols;
board_rectangle.width = piece_size * game.n_cols;
board_rectangle.height = piece_size * game.n_rows;
- board_rectangle.x = (width - board_rectangle.width) / 2;
- board_rectangle.y = (height - board_rectangle.height) / 2;
}
private void fill_background (Cairo.Context cr)
@@ -421,12 +419,9 @@ private class View : DrawingArea
update_sizes (new_width, new_height);
fill_background (cr);
- cr.save ();
- cr.translate (board_rectangle.x, board_rectangle.y);
draw_gridlines (cr);
draw_shapes (cr);
draw_cursor_box (cr);
draw_path (cr);
- cr.restore ();
}
}
diff --git a/src/window.vala b/src/window.vala
index 9fcde90..74b4f24 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -33,7 +33,7 @@ private class GameWindow : ApplicationWindow
private Box preview_hbox;
[GtkChild]
- private AspectFrame grid_frame;
+ private Games.GridFrame grid_frame;
private GLib.Settings settings = new GLib.Settings ("org.gnome.five-or-more");
private bool window_tiled;
@@ -96,7 +96,6 @@ private class GameWindow : ApplicationWindow
default: assert_not_reached ();
}
((SimpleAction) board_size_action).set_state (board_size_string);
- update_ratio (board_size);
game = new Game (board_size);
theme = new ThemeRenderer (settings);
@@ -108,6 +107,8 @@ private class GameWindow : ApplicationWindow
NextPiecesWidget next_pieces_widget = new NextPiecesWidget (settings, game, theme);
preview_hbox.pack_start (next_pieces_widget);
+ grid_frame.set (game.n_cols, game.n_rows);
+ game.board.board_changed.connect (() => { grid_frame.set (game.n_cols, game.n_rows); });
game.notify["score"].connect ((s, p) => { set_status_message
(status[StatusMessage.NONE].printf(game.score)); });
game.notify["status-message"].connect ((s, p) => { set_status_message
(status[game.status_message].printf(game.score)); });
set_status_message (status[game.status_message]);
@@ -116,7 +117,7 @@ private class GameWindow : ApplicationWindow
SimpleAction reset_background_action = (SimpleAction) lookup_action ("reset-bg");
game_view.notify ["background-color"].connect (() => { reset_background_action.set_enabled
(game_view.background_color != View.default_background_color); });
settings.bind (FiveOrMoreApp.KEY_BACKGROUND_COLOR, game_view, "background-color",
SettingsBindFlags.DEFAULT);
- grid_frame.set_child (game_view);
+ grid_frame.add (game_view);
init_scores_dialog ();
}
@@ -167,14 +168,6 @@ private class GameWindow : ApplicationWindow
headerbar.set_subtitle (message);
}
- private void update_ratio (int size)
- {
- if (size == /* large */ 3)
- grid_frame.ratio = 4.0f/3.0f;
- else
- grid_frame.ratio = 1.0f;
- }
-
/*\
* * Scores dialog
\*/
@@ -276,7 +269,6 @@ private class GameWindow : ApplicationWindow
default: assert_not_reached ();
}
settings.set_int (FiveOrMoreApp.KEY_SIZE, size);
- update_ratio (size);
}
private inline void new_game (/* SimpleAction action, Variant? parameter */)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]