[gnome-nibbles/arnaudb/kill-preferences-dialog: 10/27] Clean ControlsGrid.



commit afbf2a3bc71dabe05ec750b9c8aaf3331e612710
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Sat Jun 6 20:02:41 2020 +0200

    Clean ControlsGrid.

 data/controls-grid.ui | 60 +++++++++++++++++++++------------------------------
 data/nibbles.css      |  5 +++++
 src/controls.vala     | 32 +++++++++++----------------
 3 files changed, 41 insertions(+), 56 deletions(-)
---
diff --git a/data/controls-grid.ui b/data/controls-grid.ui
index 4e0a3bb..c4c645a 100644
--- a/data/controls-grid.ui
+++ b/data/controls-grid.ui
@@ -46,16 +46,13 @@
       </packing>
     </child>
     <child>
-      <object class="GtkOverlay" id="move_up">
+      <object class="GtkLabel" id="move_up_label">
         <property name="visible">True</property>
-        <child>
-          <object class="GtkLabel" id="move_up_label">
-            <property name="visible">True</property>
-            <property name="height-request">45</property>
-            <property name="width-request">45</property>
-            <style><class name="controls-button"/></style>
-          </object>
-        </child>
+        <property name="height-request">45</property>
+        <property name="width-request">45</property>
+        <style>
+          <class name="controls-button"/>
+        </style>
       </object>
       <packing>
         <property name="left-attach">2</property>
@@ -72,16 +69,13 @@
       </packing>
     </child>
     <child>
-      <object class="GtkOverlay" id="move_left">
+      <object class="GtkLabel" id="move_left_label">
         <property name="visible">True</property>
-        <child>
-          <object class="GtkLabel" id="move_left_label">
-            <property name="visible">True</property>
-            <property name="height-request">45</property>
-            <property name="width-request">45</property>
-            <style><class name="controls-button"/></style>
-          </object>
-        </child>
+        <property name="height-request">45</property>
+        <property name="width-request">45</property>
+        <style>
+          <class name="controls-button"/>
+        </style>
       </object>
       <packing>
         <property name="left-attach">1</property>
@@ -89,16 +83,13 @@
       </packing>
     </child>
     <child>
-      <object class="GtkOverlay" id="move_right">
+      <object class="GtkLabel" id="move_right_label">
         <property name="visible">True</property>
-        <child>
-          <object class="GtkLabel" id="move_right_label">
-            <property name="visible">True</property>
-            <property name="height-request">45</property>
-            <property name="width-request">45</property>
-            <style><class name="controls-button"/></style>
-          </object>
-        </child>
+        <property name="height-request">45</property>
+        <property name="width-request">45</property>
+        <style>
+          <class name="controls-button"/>
+        </style>
       </object>
       <packing>
         <property name="left-attach">3</property>
@@ -115,16 +106,13 @@
       </packing>
     </child>
     <child>
-      <object class="GtkOverlay" id="move_down">
+      <object class="GtkLabel" id="move_down_label">
         <property name="visible">True</property>
-        <child>
-          <object class="GtkLabel" id="move_down_label">
-            <property name="visible">True</property>
-            <property name="height-request">45</property>
-            <property name="width-request">45</property>
-            <style><class name="controls-button"/></style>
-          </object>
-        </child>
+        <property name="height-request">45</property>
+        <property name="width-request">45</property>
+        <style>
+          <class name="controls-button"/>
+        </style>
       </object>
       <packing>
         <property name="left-attach">2</property>
diff --git a/data/nibbles.css b/data/nibbles.css
index 7ed931c..e50de50 100644
--- a/data/nibbles.css
+++ b/data/nibbles.css
@@ -101,6 +101,11 @@ modelbutton.speed-box > check {
   background-image: linear-gradient(to bottom, #343a3a, #2f3434 60%, #2a2f2f);
   text-shadow: 0 -1px rgba(0, 0, 0, 0.81176);
   box-shadow: inset 0 1px rgba(255, 255, 255, 0.05), 0 1px rgba(238, 238, 236, 0);
+  font-weight:bold;
+}
+
+.controls-button.arrow {
+  font-size:175%;
 }
 
 /*\
diff --git a/src/controls.vala b/src/controls.vala
index dde9551..4622165 100644
--- a/src/controls.vala
+++ b/src/controls.vala
@@ -57,13 +57,9 @@ private class ControlsGrid : Grid
     [GtkChild] private Image arrow_down;
     [GtkChild] private Image arrow_left;
     [GtkChild] private Image arrow_right;
-    [GtkChild] private Overlay move_up;
     [GtkChild] private Label move_up_label;
-    [GtkChild] private Overlay move_down;
     [GtkChild] private Label move_down_label;
-    [GtkChild] private Overlay move_left;
     [GtkChild] private Label move_left_label;
-    [GtkChild] private Overlay move_right;
     [GtkChild] private Label move_right_label;
 
     internal ControlsGrid (int worm_id, WormProperties worm_props, Gdk.Pixbuf arrow, Gdk.Pixbuf arrow_key)
@@ -84,41 +80,37 @@ private class ControlsGrid : Grid
         upper_key = Gdk.keyval_name (worm_props.up).up ();
         if (upper_key == "UP")
         {
-            var rotated_pixbuf = arrow_key.rotate_simple (Gdk.PixbufRotation.NONE);
-            move_up.add_overlay (new Image.from_pixbuf (rotated_pixbuf));
-            move_up.show_all ();
+            move_up_label.get_style_context ().add_class ("arrow");
+            move_up_label.set_label ("↑");
         }
         else
-            move_up_label.set_markup (@"<b>$(upper_key)</b>");
+            move_up_label.set_label (@"$(upper_key)");
 
         upper_key = Gdk.keyval_name (worm_props.down).up ();
         if (upper_key == "DOWN")
         {
-            var rotated_pixbuf = arrow_key.rotate_simple (Gdk.PixbufRotation.UPSIDEDOWN);
-            move_down.add_overlay (new Image.from_pixbuf (rotated_pixbuf));
-            move_down.show_all ();
+            move_down_label.get_style_context ().add_class ("arrow");
+            move_down_label.set_label ("↓");
         }
         else
-            move_down_label.set_markup (@"<b>$(upper_key)</b>");
+            move_down_label.set_label (@"$(upper_key)");
 
         upper_key = Gdk.keyval_name (worm_props.left).up ();
         if (upper_key == "LEFT")
         {
-            var rotated_pixbuf = arrow_key.rotate_simple (Gdk.PixbufRotation.COUNTERCLOCKWISE);
-            move_left.add_overlay (new Image.from_pixbuf (rotated_pixbuf));
-            move_left.show_all ();
+            move_left_label.get_style_context ().add_class ("arrow");
+            move_left_label.set_label ("←");
         }
         else
-            move_left_label.set_markup (@"<b>$(upper_key)</b>");
+            move_left_label.set_label (@"$(upper_key)");
 
         upper_key = Gdk.keyval_name (worm_props.right).up ();
         if (upper_key == "RIGHT")
         {
-            var rotated_pixbuf = arrow_key.rotate_simple (Gdk.PixbufRotation.CLOCKWISE);
-            move_right.add_overlay (new Image.from_pixbuf (rotated_pixbuf));
-            move_right.show_all ();
+            move_right_label.get_style_context ().add_class ("arrow");
+            move_right_label.set_label ("→");
         }
         else
-            move_right_label.set_markup (@"<b>$(upper_key)</b>");
+            move_right_label.set_label (@"$(upper_key)");
     }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]