[cluttermm] tests/examples: Replace some use of deprecated API.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cluttermm] tests/examples: Replace some use of deprecated API.
- Date: Tue, 25 Mar 2014 10:53:24 +0000 (UTC)
commit c654016364caec44a2c6e0b9ba00da3d587697eb
Author: Murray Cumming <murrayc murrayc com>
Date: Tue Mar 25 11:00:31 2014 +0100
tests/examples: Replace some use of deprecated API.
For instance, replacing get_default() with create(),
replacing add_actor() with add_child(),
replacing set_color() with set_background_color(),
replacing Group with Actor,
replacing set_rotation() with set_rotation_angle() and
set_pivot_point().
clutter/src/actor.hg | 2 +-
examples/test-actors.cc | 47 +++++++++++++++++++----------------------
examples/test-boxes.cc | 8 ++----
tests/test-alpha-creation.cc | 2 +-
tests/test-alpha-func.cc | 2 +-
tests/test-size-class.cc | 4 +-
6 files changed, 30 insertions(+), 35 deletions(-)
---
diff --git a/clutter/src/actor.hg b/clutter/src/actor.hg
index 5617f5a..da8ddc3 100644
--- a/clutter/src/actor.hg
+++ b/clutter/src/actor.hg
@@ -160,7 +160,7 @@ _DEPRECATE_IFDEF_END
_WRAP_METHOD(void set_reactive(bool reactive = true), clutter_actor_set_reactive)
_WRAP_METHOD(bool get_reactive() const, clutter_actor_get_reactive)
- _WRAP_METHOD(void set_rotation(RotateAxis axis, double angle, float x, float y, float z),
clutter_actor_set_rotation, deprecated "Use set_rotation_angle() and cset_pivot_point() instead.")
+ _WRAP_METHOD(void set_rotation(RotateAxis axis, double angle, float x, float y, float z),
clutter_actor_set_rotation, deprecated "Use set_rotation_angle() and set_pivot_point() instead.")
_WRAP_METHOD(void set_z_rotation_from_gravity(double angle, Gravity gravity),
clutter_actor_set_z_rotation_from_gravity, deprecated "Use set_rotation_angle() and set_pivot_point()
instead.")
_WRAP_METHOD(double get_rotation(RotateAxis axis, float& x, float& y, float& z) const,
clutter_actor_get_rotation, deprecated "Use get_rotation_angle() and get_pivot_point() instead.")
_WRAP_METHOD(Gravity get_z_rotation_gravity() const, clutter_actor_get_z_rotation_gravity, deprecated "Use
the “pivot-point” instead of a Gravity.")
diff --git a/examples/test-actors.cc b/examples/test-actors.cc
index 1377cc1..629f7b6 100644
--- a/examples/test-actors.cc
+++ b/examples/test-actors.cc
@@ -4,13 +4,14 @@
namespace
{
+Glib::RefPtr<Clutter::Stage> stage;
const unsigned int TRAILS = 0;
const unsigned int N_ACTORS = 6;
-unsigned int get_radius(unsigned int num_actors)
+unsigned int get_radius(const Glib::RefPtr<Clutter::Stage>& stage, unsigned int num_actors)
{
- return (Clutter::Stage::get_default()->get_height()
- + Clutter::Stage::get_default()->get_height()) / num_actors;
+ return (stage
+ + stage) / num_actors;
}
class SuperOH
@@ -18,7 +19,7 @@ class SuperOH
public:
std::vector<Glib::RefPtr<Clutter::Actor> > hands;
Glib::RefPtr<Clutter::Actor> bgtex;
- Glib::RefPtr<Clutter::Group> group;
+ Glib::RefPtr<Clutter::Actor> group;
};
bool on_button_press(Clutter::ButtonEvent *event, const Glib::RefPtr<Clutter::Stage>& stage)
@@ -48,11 +49,11 @@ bool on_key_release(Clutter::KeyEvent *event)
void on_new_frame(int frame_num, SuperOH* oh)
{
// Rotate everything clockwise about stage center
- oh->group->set_rotation(Clutter::Z_AXIS,
- frame_num,
- Clutter::Stage::get_default()->get_width() / 2,
- Clutter::Stage::get_default()->get_height() / 2,
- 0);
+ oh->group->set_rotation_angle(Clutter::Z_AXIS,
+ frame_num);
+ oh->group->set_pivot_point(
+ stage->get_width() / 2,
+ stage->get_height() / 2);
for(unsigned int i = 0; i < oh->hands.size(); i++)
{
@@ -66,8 +67,9 @@ void on_new_frame(int frame_num, SuperOH* oh)
* TODO: scaling causes drift so disabled for now. Need rotation
* unit based functions to fix.
*/
- oh->hands[i]->set_rotation(Clutter::Z_AXIS,
- - 6.0 * frame_num, 0, 0, 0);
+ oh->hands[i]->set_rotation_angle(Clutter::Z_AXIS,
+ - 6.0 * frame_num);
+ oh->hands[i]->set_pivot_point(0, 0);
}
}
@@ -103,18 +105,18 @@ int main(int argc, char *argv[])
}
Clutter::Color stage_color(0x61, 0x64, 0x8c, 0xff);
- Glib::RefPtr<Clutter::Stage> stage = Clutter::Stage::get_default();
+ stage = Clutter::Stage::create();
stage->set_size(800, 600);
stage->set_title("Actors Test");
- stage->set_color(stage_color);
+ stage->set_background_color(stage_color);
SuperOH oh;
// Create a timeline to manage animation
Glib::RefPtr<Clutter::Timeline> timeline =
Clutter::Timeline::create(6000); // milliseconds
- timeline->set_loop(true); // have it loop
+ timeline->set_repeat_count(-1); // have it loop
// fire a callback for frame change
timeline->signal_new_frame().connect
@@ -141,12 +143,12 @@ int main(int argc, char *argv[])
0.5, 0.5);
// create a new group to hold multiple actors in a group
- oh.group = Clutter::Group::create();
+ oh.group = Clutter::Actor::create();
oh.hands.reserve(num_actors);
for(int i = 0; i < num_actors; i++)
{
- int radius = get_radius(num_actors);
+ int radius = get_radius(stage, num_actors);
// Create a texture from file, then clone it to save resources
if(i == 0)
@@ -174,11 +176,11 @@ int main(int argc, char *argv[])
int w = oh.hands[0]->get_width();
int h = oh.hands[0]->get_height();
- int x = Clutter::Stage::get_default()->get_width() / 2
+ int x = stage->get_width() / 2
+ radius
* cos(i * M_PI / (num_actors / 2))
- w / 2;
- int y = Clutter::Stage::get_default()->get_height() / 2
+ int y = stage->get_height() / 2
+ radius
* sin(i * M_PI / (num_actors / 2))
- h / 2;
@@ -187,7 +189,7 @@ int main(int argc, char *argv[])
oh.hands[i]->move_anchor_point_from_gravity(Clutter::GRAVITY_CENTER);
// Add to our group group
- oh.group->add_actor(oh.hands[i]);
+ oh.group->add_child(oh.hands[i]);
#if 1 /* TODO: disabled as causes drift - see comment above */
if(i % 2)
@@ -197,13 +199,8 @@ int main(int argc, char *argv[])
#endif
}
- oh.group->show_all();
-
// Add the group to the stage
- stage->add_actor(oh.group);
-
- // Show everying ( and map window )
- stage->show_all();
+ stage->add_child(oh.group);
stage->signal_button_press_event().connect(sigc::bind(sigc::ptr_fun
(on_button_press), stage));
diff --git a/examples/test-boxes.cc b/examples/test-boxes.cc
index 0d49585..c74c35f 100644
--- a/examples/test-boxes.cc
+++ b/examples/test-boxes.cc
@@ -43,9 +43,9 @@ main(int argc, char* argv[])
Clutter::init(&argc, &argv);
- stage = Clutter::Stage::get_default();
+ stage = Clutter::Stage::create();
stage->set_size(800, 600);
- stage->set_color(stage_color);
+ stage->set_background_color(stage_color);
stage->signal_button_press_event().connect(
sigc::bind(sigc::ptr_fun(&on_button_press_cb), stage));
@@ -55,7 +55,7 @@ main(int argc, char* argv[])
vbox->set_default_padding(10, 0, 10, 0);
vbox->set_position(100, 100);
- stage->add_actor(vbox);
+ stage->add_child(vbox);
vbox->show();
for(int i = 0; i < 3; i++)
@@ -99,8 +99,6 @@ main(int argc, char* argv[])
}
- stage->show_all();
-
g_print("vbox - (x:%3d, y:%3d, w:%3d, h:%3d)\n",
vbox->get_x(),
vbox->get_y(),
diff --git a/tests/test-alpha-creation.cc b/tests/test-alpha-creation.cc
index 9aaf988..1c19887 100644
--- a/tests/test-alpha-creation.cc
+++ b/tests/test-alpha-creation.cc
@@ -5,7 +5,7 @@ int main(int argc, char** argv)
// initialize the C++ wrapper types
Clutter::init(&argc, &argv);
- Glib::RefPtr<Clutter::Stage> stage = Clutter::Stage::get_default();
+ Glib::RefPtr<Clutter::Stage> stage = Clutter::Stage::create();
// Create a timeline to manage animation
Glib::RefPtr<Clutter::Timeline> timeline =
diff --git a/tests/test-alpha-func.cc b/tests/test-alpha-func.cc
index 48ec435..d6cb1e0 100644
--- a/tests/test-alpha-func.cc
+++ b/tests/test-alpha-func.cc
@@ -17,7 +17,7 @@ main (int argc, char *argv[])
// initialize the C++ wrapper types
Clutter::init(&argc, &argv);
- Glib::RefPtr<Clutter::Stage> stage = Clutter::Stage::get_default();
+ Glib::RefPtr<Clutter::Stage> stage = Clutter::Stage::create();
// Create a timeline to manage animation
Glib::RefPtr<Clutter::Timeline> timeline =
diff --git a/tests/test-size-class.cc b/tests/test-size-class.cc
index fe161f1..43f8110 100644
--- a/tests/test-size-class.cc
+++ b/tests/test-size-class.cc
@@ -20,8 +20,8 @@
std::ostream& operator<<(std::ostream& out, Clutter::Size size)
{
- out << size.get_width() << "/ " << size.get_height();
- return out;
+ out << size.get_width() << "/ " << size.get_height();
+ return out;
}
int main(int argc, char** argv)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]