[gnome-2048/arnaudb/wip/gtk4: 4/36] Remove Clutter.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-2048/arnaudb/wip/gtk4: 4/36] Remove Clutter.
- Date: Tue, 14 Jul 2020 10:58:43 +0000 (UTC)
commit a4c6483c8a3600f1a495695b45230c61e2b360c9
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Fri Mar 6 18:34:28 2020 +0100
Remove Clutter.
src/application.vala | 39 ++------
src/game-window.vala | 22 +++--
src/game.vala | 265 ++++++++++++++++++++++++++-------------------------
src/view.vala | 74 +++++++-------
4 files changed, 189 insertions(+), 211 deletions(-)
---
diff --git a/src/application.vala b/src/application.vala
index a749a59..85737b6 100644
--- a/src/application.vala
+++ b/src/application.vala
@@ -22,6 +22,9 @@ using Gtk;
private class TwentyFortyEight : Gtk.Application
{
+ /* Translators: name of the program, as seen in the headerbar, in GNOME Shell, or in the about dialog */
+ private const string PROGRAM_NAME = _("2048");
+
private GameWindow _window;
private static bool show_version;
@@ -67,37 +70,6 @@ private class TwentyFortyEight : Gtk.Application
Intl.bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
Intl.textdomain (GETTEXT_PACKAGE);
- OptionContext context = new OptionContext ("");
- context.add_main_entries (option_entries, GETTEXT_PACKAGE);
-
- context.add_group (get_option_group (true));
- context.add_group (Clutter.get_option_group_without_init ());
-
- try {
- context.parse (ref args);
- } catch (Error e) {
- stderr.printf ("%s\n", e.message);
- return Posix.EXIT_FAILURE;
- }
-
- const string application_name = "org.gnome.TwentyFortyEight";
- Environment.set_application_name (application_name);
- Window.set_default_icon_name ("org.gnome.TwentyFortyEight");
-
- try {
- GtkClutter.init_with_args (ref args, "", new OptionEntry[0], null);
- } catch (Error e) {
- MessageDialog dialog = new MessageDialog (null,
- DialogFlags.MODAL,
- MessageType.ERROR,
- ButtonsType.NONE,
- "Unable to initialize Clutter:\n%s", e.message);
- dialog.set_title (application_name);
- dialog.run ();
- dialog.destroy ();
- return Posix.EXIT_FAILURE;
- }
-
TwentyFortyEight app = new TwentyFortyEight ();
return app.run (args);
}
@@ -105,6 +77,8 @@ private class TwentyFortyEight : Gtk.Application
private TwentyFortyEight ()
{
Object (application_id: "org.gnome.TwentyFortyEight", flags: ApplicationFlags.FLAGS_NONE);
+
+ add_main_option_entries (option_entries);
}
protected override int handle_local_options (GLib.VariantDict options) // options will be empty, we
used a custom OptionContext
@@ -151,6 +125,9 @@ private class TwentyFortyEight : Gtk.Application
{
base.startup ();
+ Environment.set_application_name (PROGRAM_NAME);
+ Window.set_default_icon_name ("org.gnome.TwentyFortyEight");
+
add_action_entries (action_entries, this);
_window = new GameWindow (this, cols, rows);
diff --git a/src/game-window.vala b/src/game-window.vala
index df4b517..016e147 100644
--- a/src/game-window.vala
+++ b/src/game-window.vala
@@ -21,13 +21,17 @@
using Games;
using Gtk;
+private class Board : Widget
+{
+}
+
[GtkTemplate (ui = "/org/gnome/TwentyFortyEight/ui/game-window.ui")]
private class GameWindow : ApplicationWindow
{
private GLib.Settings _settings;
[GtkChild] private GameHeaderBar _header_bar;
- [GtkChild] private GtkClutter.Embed _embed;
+ [GtkChild] private Board _board;
[GtkChild] private Button _unfullscreen_button;
@@ -47,7 +51,7 @@ private class GameWindow : ApplicationWindow
_init_window ();
_create_scores_dialog (); // the library forbids to delay the dialog creation
- notify ["has-toplevel-focus"].connect (() => _embed.grab_focus ());
+ notify ["has-toplevel-focus"].connect (() => _board.grab_focus ());
}
internal GameWindow (TwentyFortyEight application, uint8 cols, uint8 rows)
@@ -107,7 +111,7 @@ private class GameWindow : ApplicationWindow
_init_window_state (this);
_load_window_state (this, ref _settings);
- _header_bar.popover_closed.connect (() => _embed.grab_focus ());
+ _header_bar.popover_closed.connect (() => _board.grab_focus ());
_settings.changed.connect ((settings, key_name) => {
switch (key_name)
{
@@ -131,7 +135,7 @@ private class GameWindow : ApplicationWindow
_header_bar._update_hamburger_menu (_settings.get_boolean ("allow-undo"));
_game.load_settings (ref _settings);
- _game.view = _embed.get_stage ();
+ _game.view = _board;
set_events (get_events () | Gdk.EventMask.STRUCTURE_MASK | Gdk.EventMask.KEY_PRESS_MASK |
Gdk.EventMask.KEY_RELEASE_MASK);
}
@@ -258,14 +262,14 @@ private class GameWindow : ApplicationWindow
_header_bar.clear_subtitle ();
_game.undo ();
- _embed.grab_focus ();
+ _board.grab_focus ();
}
private void new_game_cb (/* SimpleAction action, Variant? variant */)
{
_header_bar.clear_subtitle ();
_game.new_game (ref _settings);
- _embed.grab_focus ();
+ _board.grab_focus ();
}
private void new_game_sized_cb (SimpleAction action, Variant? variant)
@@ -311,7 +315,7 @@ private class GameWindow : ApplicationWindow
private static inline bool on_key_pressed (EventControllerKey _key_controller, uint keyval, uint
keycode, Gdk.ModifierType state)
{
GameWindow _this = (GameWindow) _key_controller.get_widget ();
- if (_this._header_bar.has_popover () || (_this.focus_visible && !_this._embed.is_focus))
+ if (_this._header_bar.has_popover () || (_this.focus_visible && !_this._board.is_focus))
return false;
if (_this._game.cannot_move ())
return false;
@@ -346,13 +350,13 @@ private class GameWindow : ApplicationWindow
private inline void _init_gestures ()
{
- gesture_swipe = new GestureSwipe (_embed); // _window works, but problems with headerbar; the main
grid or the aspectframe do as _embed
+ gesture_swipe = new GestureSwipe (_board); // _window works, but problems with headerbar; the main
grid or the aspectframe do as _board
gesture_swipe.set_propagation_phase (PropagationPhase.CAPTURE);
gesture_swipe.set_button (/* all buttons */ 0);
gesture_swipe.swipe.connect (_on_swipe);
}
- private inline void _on_swipe (GestureSwipe _gesture_swipe, double velocity_x, double velocity_y) //
do not make static, _gesture_swipe.get_wigdet () is _embed, not the window
+ private inline void _on_swipe (GestureSwipe _gesture_swipe, double velocity_x, double velocity_y) //
do not make static, _gesture_swipe.get_wigdet () is _board, not the window
{
uint button = _gesture_swipe.get_current_button ();
if (button != Gdk.BUTTON_PRIMARY && button != Gdk.BUTTON_SECONDARY)
diff --git a/src/game.vala b/src/game.vala
index d2fca7a..c879c04 100644
--- a/src/game.vala
+++ b/src/game.vala
@@ -58,8 +58,8 @@ private class Game : Object
private Gee.LinkedList<Tile?> _to_show = new Gee.LinkedList<Tile?> ();
private GameState _state = GameState.STOPPED;
- private Clutter.TransitionGroup _show_hide_trans;
- private Clutter.TransitionGroup _move_trans;
+// private Clutter.TransitionGroup _show_hide_trans;
+// private Clutter.TransitionGroup _move_trans;
private int _animations_duration;
private string _saved_path = Path.build_filename (Environment.get_user_data_dir (), "gnome-2048",
"saved");
@@ -83,32 +83,33 @@ private class Game : Object
* * view
\*/
- private Clutter.Actor _view;
- private Clutter.Actor _view_background;
- private Clutter.Actor _view_foreground;
-
- [CCode (notify = false)] internal Clutter.Actor view {
- internal get { return _view; }
- internal set {
- _view = value;
- _view.allocation_changed.connect (_on_allocation_changed);
-
- _view_background = new Clutter.Actor ();
- _view_foreground = new Clutter.Actor ();
- _view_background.show ();
- _view_foreground.show ();
- _view.add_child (_view_background);
- _view.add_child (_view_foreground);
- }
- }
-
- private void _on_allocation_changed (Clutter.ActorBox box, Clutter.AllocationFlags flags)
- {
- if (_background_init_done)
- _resize_view ();
- else
- _init_background ();
- }
+ private Board _view;
+// private Clutter.Actor _view;
+// private Clutter.Actor _view_background;
+// private Clutter.Actor _view_foreground;
+
+// [CCode (notify = false)] internal Clutter.Actor view {
+// internal get { return _view; }
+// internal set {
+// _view = value;
+// _view.allocation_changed.connect (_on_allocation_changed);
+
+// _view_background = new Clutter.Actor ();
+// _view_foreground = new Clutter.Actor ();
+// _view_background.show ();
+// _view_foreground.show ();
+// _view.add_child (_view_background);
+// _view.add_child (_view_foreground);
+// }
+// }
+
+// private void _on_allocation_changed (Clutter.ActorBox box, Clutter.AllocationFlags flags)
+// {
+// if (_background_init_done)
+// _resize_view ();
+// else
+// _init_background ();
+// }
/*\
* * others
@@ -204,15 +205,15 @@ private class Game : Object
{
uint8 rows = _grid.rows;
uint8 cols = _grid.cols;
- Clutter.Color background_color = Clutter.Color.from_string ("#babdb6");
- _view.set_background_color (background_color);
+// Clutter.Color background_color = Clutter.Color.from_string ("#babdb6");
+// _view.set_background_color (background_color);
_background = new RoundedRectangle [rows, cols];
_foreground_cur = new TileView? [rows, cols];
_foreground_nxt = new TileView? [rows, cols];
- float canvas_width = _view.width;
- float canvas_height = _view.height;
+// float canvas_width = _view.width;
+// float canvas_height = _view.height;
canvas_width -= (cols + 1) * BLANK_COL_WIDTH;
canvas_height -= (rows + 1) * BLANK_ROW_HEIGHT;
@@ -229,7 +230,7 @@ private class Game : Object
RoundedRectangle rect = new RoundedRectangle (x, y, tile_width, tile_height);
- _view_background.add_child (rect.actor);
+// _view_background.add_child (rect.actor);
rect.canvas.invalidate ();
rect.actor.show ();
@@ -245,8 +246,8 @@ private class Game : Object
{
uint8 rows = _grid.rows;
uint8 cols = _grid.cols;
- float canvas_width = _view.width;
- float canvas_height = _view.height;
+// float canvas_width = _view.width;
+// float canvas_height = _view.height;
canvas_width -= (cols + 1) * BLANK_COL_WIDTH;
canvas_height -= (rows + 1) * BLANK_ROW_HEIGHT;
@@ -271,8 +272,8 @@ private class Game : Object
}
}
- if (_resize_view_id == 0)
- _resize_view_id = Clutter.Threads.Timeout.add (1000, _idle_resize_view);
+// if (_resize_view_id == 0)
+// _resize_view_id = Clutter.Threads.Timeout.add (1000, _idle_resize_view);
}
private bool _idle_resize_view ()
@@ -319,11 +320,11 @@ private class Game : Object
GridPosition pos = tile.pos;
assert (_foreground_nxt [pos.row, pos.col] == null);
- Clutter.Actor actor = _background [pos.row, pos.col].actor;
- _foreground_nxt [pos.row, pos.col] = new TileView (actor.x,
- actor.y,
- actor.width,
- actor.height,
+ RoundedRectangle rect = _background [pos.row, pos.col];
+ _foreground_nxt [pos.row, pos.col] = new TileView (rect.x,
+ rect.y,
+ rect.width,
+ rect.height,
tile.val);
}
@@ -331,38 +332,38 @@ private class Game : Object
{
debug (@"show tile pos $pos");
- Clutter.PropertyTransition trans;
+// Clutter.PropertyTransition trans;
TileView? tile_view = _foreground_nxt [pos.row, pos.col];
if (tile_view == null)
assert_not_reached ();
- Clutter.Actor actor = ((!) tile_view).actor;
-
- ((!) tile_view).canvas.invalidate ();
- actor.set_opacity (0);
- actor.show ();
- _view_foreground.add_child (actor);
-
- trans = new Clutter.PropertyTransition ("scale-x");
- trans.set_from_value (1.0);
- trans.set_to_value (1.1);
- trans.set_duration (_animations_duration);
- trans.set_animatable (actor);
- _show_hide_trans.add_transition (trans);
-
- trans = new Clutter.PropertyTransition ("scale-y");
- trans.set_from_value (1.0);
- trans.set_to_value (1.1);
- trans.set_duration (_animations_duration);
- trans.set_animatable (actor);
- _show_hide_trans.add_transition (trans);
-
- trans = new Clutter.PropertyTransition ("opacity");
- trans.set_from_value (0);
- trans.set_to_value (255);
- trans.set_remove_on_complete (true);
- trans.set_duration (_animations_duration / 2);
- actor.add_transition ("show", trans);
+// Clutter.Actor actor = ((!) tile_view).actor;
+
+// ((!) tile_view).canvas.invalidate ();
+// actor.set_opacity (0);
+// actor.show ();
+// _view_foreground.add_child (actor);
+
+// trans = new Clutter.PropertyTransition ("scale-x");
+// trans.set_from_value (1.0);
+// trans.set_to_value (1.1);
+// trans.set_duration (_animations_duration);
+// trans.set_animatable (actor);
+// _show_hide_trans.add_transition (trans);
+
+// trans = new Clutter.PropertyTransition ("scale-y");
+// trans.set_from_value (1.0);
+// trans.set_to_value (1.1);
+// trans.set_duration (_animations_duration);
+// trans.set_animatable (actor);
+// _show_hide_trans.add_transition (trans);
+
+// trans = new Clutter.PropertyTransition ("opacity");
+// trans.set_from_value (0);
+// trans.set_to_value (255);
+// trans.set_remove_on_complete (true);
+// trans.set_duration (_animations_duration / 2);
+// actor.add_transition ("show", trans);
}
private void _move_tile (GridPosition from, GridPosition to)
@@ -388,12 +389,12 @@ private class Game : Object
if (tile_view == null)
assert_not_reached ();
- Clutter.PropertyTransition trans = new Clutter.PropertyTransition (row_move ? "y" : "x");
- trans.set_from_value (row_move ? rect_from.actor.y : rect_from.actor.x);
- trans.set_to_value (row_move ? rect_to.actor.y : rect_to.actor.x);
- trans.set_duration (_animations_duration);
- trans.set_animatable (((!) tile_view).actor);
- _move_trans.add_transition (trans);
+// Clutter.PropertyTransition trans = new Clutter.PropertyTransition (row_move ? "y" : "x");
+// trans.set_from_value (row_move ? rect_from.actor.y : rect_from.actor.x);
+// trans.set_to_value (row_move ? rect_to.actor.y : rect_to.actor.x);
+// trans.set_duration (_animations_duration);
+// trans.set_animatable (((!) tile_view).actor);
+// _move_trans.add_transition (trans);
}
private void _dim_tile (GridPosition pos)
@@ -403,30 +404,30 @@ private class Game : Object
assert_not_reached ();
debug (@"diming tile at $pos " + ((!) tile_view).color.to_string ());
- Clutter.Actor actor;
- Clutter.PropertyTransition trans;
+// Clutter.Actor actor;
+// Clutter.PropertyTransition trans;
- actor = ((!) tile_view).actor;
+// actor = ((!) tile_view).actor;
- trans = new Clutter.PropertyTransition ("opacity");
- trans.set_from_value (actor.opacity);
- trans.set_to_value (0);
- trans.set_duration (_animations_duration);
- trans.set_animatable (actor);
+// trans = new Clutter.PropertyTransition ("opacity");
+// trans.set_from_value (actor.opacity);
+// trans.set_to_value (0);
+// trans.set_duration (_animations_duration);
+// trans.set_animatable (actor);
- _show_hide_trans.add_transition (trans);
+// _show_hide_trans.add_transition (trans);
}
private void _clear_background ()
{
- _view_background.remove_all_children ();
+// _view_background.remove_all_children ();
}
private void _clear_foreground ()
{
uint8 rows = _grid.rows;
uint8 cols = _grid.cols;
- _view_foreground.remove_all_children ();
+// _view_foreground.remove_all_children ();
for (uint8 i = 0; i < rows; i++)
{
for (uint8 j = 0; j < cols; j++)
@@ -484,9 +485,9 @@ private class Game : Object
Grid clone = _grid.clone ();
- _move_trans = new Clutter.TransitionGroup ();
- _move_trans.stopped.connect (_on_move_trans_stopped);
- _move_trans.set_duration (_animations_duration);
+// _move_trans = new Clutter.TransitionGroup ();
+// _move_trans.stopped.connect (_on_move_trans_stopped);
+// _move_trans.set_duration (_animations_duration);
_grid.move (request, ref _to_move, ref _to_hide, ref _to_show);
@@ -506,39 +507,39 @@ private class Game : Object
if ((_to_move.size > 0) || (_to_hide.size > 0) || (_to_show.size > 0))
{
_state = GameState.MOVING;
- _move_trans.start ();
+// _move_trans.start ();
_store_movement (clone);
}
_just_restored = false;
}
- private void _on_move_trans_stopped (Clutter.Timeline trans, bool is_finished)
- {
- debug (@"move animation stopped\n$_grid");
+// private void _on_move_trans_stopped (Clutter.Timeline trans, bool is_finished)
+// {
+// debug (@"move animation stopped\n$_grid");
- ((Clutter.TransitionGroup) trans).remove_all ();
+// ((Clutter.TransitionGroup) trans).remove_all ();
- foreach (TileMovement? e in _to_hide)
- {
- if (e == null)
- assert_not_reached ();
- _dim_tile (((!) e).from);
- }
+// foreach (TileMovement? e in _to_hide)
+// {
+// if (e == null)
+// assert_not_reached ();
+// _dim_tile (((!) e).from);
+// }
- long delta_score = 0; // do not notify["score"] multiple times
- foreach (Tile? e in _to_show)
- {
- if (e == null)
- assert_not_reached ();
- _create_tile ((!) e);
- _show_tile (((!) e).pos);
- delta_score += (long) Math.pow (2, ((!) e).val);
- }
- score += delta_score;
+// long delta_score = 0; // do not notify["score"] multiple times
+// foreach (Tile? e in _to_show)
+// {
+// if (e == null)
+// assert_not_reached ();
+// _create_tile ((!) e);
+// _show_tile (((!) e).pos);
+// delta_score += (long) Math.pow (2, ((!) e).val);
+// }
+// score += delta_score;
- _create_random_tile ();
- }
+// _create_random_tile ();
+// }
/*\
* * new tile animation
@@ -552,27 +553,27 @@ private class Game : Object
private void _create_show_hide_transition (bool animate)
{
- _show_hide_trans = new Clutter.TransitionGroup ();
- _show_hide_trans.stopped.connect (_on_show_hide_trans_stopped);
- /* _show_hide_trans should be finished two times (forward and backward) before
- one _move_trans is done, so at least animation time should be strictly half */
- _show_hide_trans.set_duration (animate ? _animations_duration / 3 : 10);
+// _show_hide_trans = new Clutter.TransitionGroup ();
+// _show_hide_trans.stopped.connect (_on_show_hide_trans_stopped);
+// /* _show_hide_trans should be finished two times (forward and backward) before
+// one _move_trans is done, so at least animation time should be strictly half */
+// _show_hide_trans.set_duration (animate ? _animations_duration / 3 : 10);
}
- private void _on_show_hide_trans_stopped (Clutter.Timeline trans, bool is_finished)
- {
- debug ("show/hide animation stopped");
+// private void _on_show_hide_trans_stopped (Clutter.Timeline trans, bool is_finished)
+// {
+// debug ("show/hide animation stopped");
- if (trans.direction == Clutter.TimelineDirection.FORWARD)
- {
- trans.direction = Clutter.TimelineDirection.BACKWARD;
- trans.start ();
- return;
- }
+// if (trans.direction == Clutter.TimelineDirection.FORWARD)
+// {
+// trans.direction = Clutter.TimelineDirection.BACKWARD;
+// trans.start ();
+// return;
+// }
- ((Clutter.TransitionGroup) trans).remove_all ();
- _apply_move ();
- }
+// ((Clutter.TransitionGroup) trans).remove_all ();
+// _apply_move ();
+// }
private void _apply_move ()
{
@@ -590,9 +591,9 @@ private class Game : Object
TileView? tile_view = _foreground_cur [pos.row, pos.col];
if (tile_view == null)
assert_not_reached ();
- ((!) tile_view).actor.hide ();
+// ((!) tile_view).actor.hide ();
debug (@"remove child " + ((!) tile_view).color.to_string ());
- _view_foreground.remove_child (((!) tile_view).actor);
+// _view_foreground.remove_child (((!) tile_view).actor);
_foreground_cur [pos.row, pos.col] = null;
}
diff --git a/src/view.vala b/src/view.vala
index 9392cda..65aa2d3 100644
--- a/src/view.vala
+++ b/src/view.vala
@@ -18,22 +18,16 @@
along with GNOME 2048. If not, see <https://www.gnu.org/licenses/>.
*/
-private class RoundedRectangle : Object
+private class RoundedRectangle : Gtk.DrawingArea
{
- [CCode (notify = false)] internal Clutter.Actor actor { internal get; default = new Clutter.Actor (); }
- [CCode (notify = false)] internal Clutter.Canvas canvas { internal get; default = new Clutter.Canvas ();
}
-
- [CCode (notify = false)] public float x { protected construct { actor.x = value; }}
- [CCode (notify = false)] public float y { protected construct { actor.y = value; }}
- [CCode (notify = false)] public float width { protected construct { actor.width = value; }}
- [CCode (notify = false)] public float height { protected construct { actor.height = value; }}
+ [CCode (notify = false)] public float x { internal get; protected construct set; }
+ [CCode (notify = false)] public float y { internal get; protected construct set; }
+ [CCode (notify = false)] public float width { internal get; protected construct set; }
+ [CCode (notify = false)] public float height { internal get; protected construct set; }
construct
{
- actor.set_content (canvas);
- actor.set_pivot_point (0.5f, 0.5f);
-
- canvas.draw.connect (_draw);
+ set_draw_func (_draw);
idle_resize ();
}
@@ -42,22 +36,22 @@ private class RoundedRectangle : Object
Object (x: x, y: y, width: width, height: height, color: 0);
}
- internal void resize (float x, float y, float width, float height)
+ internal void resize (float _x, float _y, float _width, float _height)
{
- actor.x = x;
- actor.y = y;
- actor.width = width;
- actor.height = height;
+ x = _x;
+ y = _y;
+ width = _width;
+ height = _height;
}
internal void idle_resize ()
{
- if (!canvas.set_size ((int) Math.ceilf (actor.width), (int) Math.ceilf (actor.height)))
- canvas.invalidate ();
+// if (!canvas.set_size ((int) Math.ceilf (actor.width), (int) Math.ceilf (actor.height)))
+// canvas.invalidate ();
}
private const double HALF_PI = Math.PI / 2.0;
- protected virtual bool _draw (Cairo.Context ctx, int width, int height)
+ protected virtual void _draw (Cairo.Context ctx, int width, int height)
{
double radius = (height > width) ? (height / 20.0) : (width / 20.0);
@@ -73,7 +67,7 @@ private class RoundedRectangle : Object
ctx.arc (radius, height - radius, radius, HALF_PI, Math.PI);
ctx.close_path ();
- Clutter.cairo_set_source_color (ctx, _color);
+ ctx.set_source_rgba (_color);
ctx.fill ();
return false;
@@ -83,31 +77,33 @@ private class RoundedRectangle : Object
* * color
\*/
- private static HashTable<int, Clutter.Color?> colors
- = new HashTable<int, Clutter.Color?> (direct_hash, direct_equal);
+ private static HashTable<int, Gdk.RGBA?> colors
+ = new HashTable<int, Gdk.RGBA?> (direct_hash, direct_equal);
static construct
{
- colors.insert (/* empty */ 0, Clutter.Color.from_string ("#ffffff")); // White
- colors.insert (/* 2 */ 1, Clutter.Color.from_string ("#fce94f")); // Butter 1
- colors.insert (/* 4 */ 2, Clutter.Color.from_string ("#8ae234")); // Chameleon 1
- colors.insert (/* 8 */ 3, Clutter.Color.from_string ("#fcaf3e")); // Orange 1
- colors.insert (/* 16 */ 4, Clutter.Color.from_string ("#729fcf")); // Sky blue 1
- colors.insert (/* 32 */ 5, Clutter.Color.from_string ("#ad7fa8")); // Plum 1
- colors.insert (/* 64 */ 6, Clutter.Color.from_string ("#c17d11")); // Chocolate 2
- colors.insert (/* 128 */ 7, Clutter.Color.from_string ("#ef2929")); // Scarlet red 1
- colors.insert (/* 256 */ 8, Clutter.Color.from_string ("#c4a000")); // Butter 3
- colors.insert (/* 512 */ 9, Clutter.Color.from_string ("#4e9a06")); // Chameleon 3
- colors.insert (/* 1024 */ 10, Clutter.Color.from_string ("#ce5c00")); // Orange 3
- colors.insert (/* 2048 */ 11, Clutter.Color.from_string ("#204a87")); // Sky blue 3
+ bool success;
+ Gdk.RGBA color;
+ if (color.parse ("#ffffff")) colors.insert (/* empty */ 0, color); else assert_not_reached (); //
White
+ if (color.parse ("#fce94f")) colors.insert (/* 2 */ 1, color); else assert_not_reached (); //
Butter 1
+ if (color.parse ("#8ae234")) colors.insert (/* 4 */ 2, color); else assert_not_reached (); //
Chameleon 1
+ if (color.parse ("#fcaf3e")) colors.insert (/* 8 */ 3, color); else assert_not_reached (); //
Orange 1
+ if (color.parse ("#729fcf")) colors.insert (/* 16 */ 4, color); else assert_not_reached (); //
Sky blue 1
+ if (color.parse ("#ad7fa8")) colors.insert (/* 32 */ 5, color); else assert_not_reached (); //
Plum 1
+ if (color.parse ("#c17d11")) colors.insert (/* 64 */ 6, color); else assert_not_reached (); //
Chocolate 2
+ if (color.parse ("#ef2929")) colors.insert (/* 128 */ 7, color); else assert_not_reached (); //
Scarlet red 1
+ if (color.parse ("#c4a000")) colors.insert (/* 256 */ 8, color); else assert_not_reached (); //
Butter 3
+ if (color.parse ("#4e9a06")) colors.insert (/* 512 */ 9, color); else assert_not_reached (); //
Chameleon 3
+ if (color.parse ("#ce5c00")) colors.insert (/* 1024 */ 10, color); else assert_not_reached (); //
Orange 3
+ if (color.parse ("#204a87")) colors.insert (/* 2048 */ 11, color); else assert_not_reached (); //
Sky blue 3
}
- private Clutter.Color _color;
+ private Gdk.RGBA _color;
private uint8 _color_index;
[CCode (notify = false)] public uint8 color {
internal get { return _color_index; } // protected for TileView, internal for debug
internal construct {
_color_index = value;
- Clutter.Color? color = colors.lookup ((int) value);
+ Gdk.RGBA? color = colors.lookup ((int) value);
if (color == null)
_new_color (value, out _color);
else
@@ -115,11 +111,11 @@ private class RoundedRectangle : Object
}
}
- private static void _new_color (uint8 tile_value, out Clutter.Color color)
+ private static void _new_color (uint8 tile_value, out Gdk.RGBA color)
requires (tile_value >= 12)
requires (tile_value <= 81)
{
- Clutter.Color? nullable_color = colors.lookup ((int) ((tile_value - 1) % 11 + 1));
+ Gdk.RGBA? nullable_color = colors.lookup ((int) ((tile_value - 1) % 11 + 1));
if (nullable_color == null)
assert_not_reached ();
color = (!) nullable_color;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]