[iagno] Introduce GameActionBarPlaceHolder.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [iagno] Introduce GameActionBarPlaceHolder.
- Date: Mon, 30 Dec 2019 11:25:25 +0000 (UTC)
commit f63886b1e1653f860faa49c9509264a7e936d51d
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Mon Dec 30 12:05:15 2019 +0100
Introduce GameActionBarPlaceHolder.
Copied from Four-in-a-row.
data/iagno.css | 8 +++++++
data/iagno.gresource.xml | 25 +++++++++++-----------
data/ui/base-window.ui | 2 +-
data/ui/game-actionbar-placeholder.ui | 30 +++++++++++++++++++++++++++
src/base-window.vala | 8 ++++++-
src/game-actionbar.vala | 39 +++++++++++++++++++++++++++++++++++
src/game-window.vala | 6 +++++-
7 files changed, 103 insertions(+), 15 deletions(-)
---
diff --git a/data/iagno.css b/data/iagno.css
index e4abbfb..7c52f8f 100644
--- a/data/iagno.css
+++ b/data/iagno.css
@@ -82,6 +82,14 @@ label.game-name-label:dir(rtl) {
margin-right: 12px;
}
+/* the actionbar is in an overlay... */
+actionbar {
+ background-color:@theme_bg_color;
+}
+actionbar:backdrop {
+ background-color:@theme_unfocused_bg_color;
+}
+
/*\
* * games buttons
\*/
diff --git a/data/iagno.gresource.xml b/data/iagno.gresource.xml
index e40753c..c93997f 100644
--- a/data/iagno.gresource.xml
+++ b/data/iagno.gresource.xml
@@ -5,23 +5,24 @@
<file preprocess="to-pixdata" alias="reversi.png">../data/reversi.png</file>
</gresource>
<gresource prefix="/org/gnome/Reversi/ui">
- <file preprocess="xml-stripblanks" compressed="true" alias="adaptative-window.ui"
ui/adaptative-window.ui</file>
- <file preprocess="xml-stripblanks" compressed="true" alias="base-headerbar.ui"
ui/base-headerbar.ui</file>
- <file preprocess="xml-stripblanks" compressed="true" alias="base-view.ui"
ui/base-view.ui</file>
+ <file preprocess="xml-stripblanks" compressed="true" alias="adaptative-window.ui"
ui/adaptative-window.ui</file>
+ <file preprocess="xml-stripblanks" compressed="true" alias="base-headerbar.ui"
ui/base-headerbar.ui</file>
+ <file preprocess="xml-stripblanks" compressed="true" alias="base-view.ui"
ui/base-view.ui</file>
<file compressed="true">base-window.css</file>
- <file preprocess="xml-stripblanks" compressed="true" alias="base-window.ui"
ui/base-window.ui</file>
- <file preprocess="xml-stripblanks" compressed="true" alias="game-actionbar.ui"
ui/game-actionbar.ui</file>
- <file preprocess="xml-stripblanks" compressed="true" alias="game-headerbar.ui"
ui/game-headerbar.ui</file>
- <file preprocess="xml-stripblanks" compressed="true" alias="history-button.ui"
ui/history-button.ui</file>
+ <file preprocess="xml-stripblanks" compressed="true" alias="base-window.ui"
ui/base-window.ui</file>
+ <file preprocess="xml-stripblanks" compressed="true" alias="game-actionbar.ui"
ui/game-actionbar.ui</file>
+ <file preprocess="xml-stripblanks" compressed="true" alias="game-actionbar-placeholder.ui"
ui/game-actionbar-placeholder.ui</file>
+ <file preprocess="xml-stripblanks" compressed="true" alias="game-headerbar.ui"
ui/game-headerbar.ui</file>
+ <file preprocess="xml-stripblanks" compressed="true" alias="history-button.ui"
ui/history-button.ui</file>
<file compressed="true">iagno.css</file>
<file compressed="true">new-game-screen.css</file>
- <file preprocess="xml-stripblanks" compressed="true" alias="new-game-screen.ui"
ui/new-game-screen.ui</file>
- <file preprocess="xml-stripblanks" compressed="true" alias="notifications-revealer.ui"
ui/notifications-revealer.ui</file>
+ <file preprocess="xml-stripblanks" compressed="true" alias="new-game-screen.ui"
ui/new-game-screen.ui</file>
+ <file preprocess="xml-stripblanks" compressed="true" alias="notifications-revealer.ui"
ui/notifications-revealer.ui</file>
<file>noise.png</file>
- <file preprocess="xml-stripblanks" compressed="true" alias="overlayed-list.ui"
ui/overlayed-list.ui</file>
- <file preprocess="xml-stripblanks" compressed="true" alias="registry-placeholder.ui"
ui/registry-placeholder.ui</file>
+ <file preprocess="xml-stripblanks" compressed="true" alias="overlayed-list.ui"
ui/overlayed-list.ui</file>
+ <file preprocess="xml-stripblanks" compressed="true" alias="registry-placeholder.ui"
ui/registry-placeholder.ui</file>
</gresource>
<gresource prefix="/org/gnome/Reversi/gtk">
- <file preprocess="xml-stripblanks" alias="help-overlay.ui">ui/help-overlay.ui</file>
+ <file preprocess="xml-stripblanks" compressed="true" alias="help-overlay.ui"
ui/help-overlay.ui</file>
</gresource>
</gresources>
diff --git a/data/ui/base-window.ui b/data/ui/base-window.ui
index 049b28b..382d39a 100644
--- a/data/ui/base-window.ui
+++ b/data/ui/base-window.ui
@@ -21,7 +21,7 @@
<property name="visible">False</property>
<signal name="key-press-event" handler="on_key_press_event"/>
<child>
- <object class="GtkOverlay">
+ <object class="GtkOverlay" id="main_overlay">
<property name="visible">True</property>
<child>
<object class="GtkGrid" id="main_grid">
diff --git a/data/ui/game-actionbar-placeholder.ui b/data/ui/game-actionbar-placeholder.ui
new file mode 100644
index 0000000..2b69eee
--- /dev/null
+++ b/data/ui/game-actionbar-placeholder.ui
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ This file is part of a GNOME game
+
+ Copyright (C) 2019 – Arnaud Bonatti <arnaud bonatti gmail com>
+
+ This application is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This application is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this application. If not, see <https://www.gnu.org/licenses/>.
+-->
+<interface>
+ <requires lib="gtk+" version="3.12"/>
+ <template class="GameActionBarPlaceHolder" parent="GtkRevealer">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkDrawingArea" id="placeholder_child">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/src/base-window.vala b/src/base-window.vala
index 64e8f80..fe6369d 100644
--- a/src/base-window.vala
+++ b/src/base-window.vala
@@ -69,11 +69,17 @@ private class BaseWindow : AdaptativeWindow, AdaptativeWidget
}
/*\
- * * main grid
+ * * main layout
\*/
[GtkChild] private Grid main_grid;
[GtkChild] private Button unfullscreen_button;
+ [GtkChild] private Overlay main_overlay;
+
+ protected void add_to_main_overlay (Widget widget)
+ {
+ main_overlay.add_overlay (widget);
+ }
protected void add_to_main_grid (Widget widget)
{
diff --git a/src/game-actionbar.vala b/src/game-actionbar.vala
index 314ab40..e59bfdc 100644
--- a/src/game-actionbar.vala
+++ b/src/game-actionbar.vala
@@ -89,3 +89,42 @@ private class GameActionBar : Revealer, AdaptativeWidget
update_visibility ();
}
}
+
+[GtkTemplate (ui = "/org/gnome/Reversi/ui/game-actionbar-placeholder.ui")]
+private class GameActionBarPlaceHolder : Revealer, AdaptativeWidget
+{
+ [GtkChild] private Widget placeholder_child;
+ private GameActionBar actionbar;
+
+ internal GameActionBarPlaceHolder (GameActionBar _actionbar)
+ {
+ actionbar = _actionbar;
+ actionbar.size_allocate.connect (set_height);
+ set_height ();
+ set_reveal_child (true); // seems like setting it in the UI file does not work, while it is OK
for GameActionBar...
+ }
+
+ private void set_height ()
+ {
+ Requisition natural_size;
+ Widget? widget = actionbar.get_child ();
+ if (widget == null)
+ return;
+ ((!) widget).get_preferred_size (/* minimum size */ null, out natural_size);
+ placeholder_child.height_request = natural_size.height;
+ }
+
+ /*\
+ * * adaptative stuff
+ \*/
+
+ private bool is_extra_thin = true;
+ protected override void set_window_size (AdaptativeWidget.WindowSize new_size)
+ {
+ bool _is_extra_thin = AdaptativeWidget.WindowSize.is_extra_thin (new_size);
+ if (_is_extra_thin == is_extra_thin)
+ return;
+ is_extra_thin = _is_extra_thin;
+ set_reveal_child (is_extra_thin);
+ }
+}
diff --git a/src/game-window.vala b/src/game-window.vala
index 86baa63..19bcfa9 100644
--- a/src/game-window.vala
+++ b/src/game-window.vala
@@ -54,11 +54,15 @@ private class GameWindow : BaseWindow, AdaptativeWidget
game_view = _game_view;
actionbar = _actionbar;
- add_to_main_grid (actionbar);
+ GameActionBarPlaceHolder actionbar_placeholder = new GameActionBarPlaceHolder (actionbar);
+ add_to_main_grid (actionbar_placeholder);
+ add_to_main_overlay (actionbar);
+ actionbar.valign = Align.END;
add_adaptative_child ((AdaptativeWidget) new_game_screen);
add_adaptative_child ((AdaptativeWidget) game_view);
add_adaptative_child ((AdaptativeWidget) actionbar);
+ add_adaptative_child ((AdaptativeWidget) actionbar_placeholder);
/* CSS */
if (css_resource != null)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]