cluttermm-0.9: scrolling broken



Hello guys,

It seems that by the time the example had been written cluttermm-0.9 was very different from what it's now. I've tried to adopt the scrolling example to latest cluttermm-1.0. Example is made by Murray Cumming I believe. Taken from here:
http://www.openismus.com/documents/cluttermm_tutorial/0.9/docs/tutorial/html/scrolling-container-example.html

I have attached a patch against http://www.openismus.com/documents/cluttermm_tutorial/0.9/examples/scrolling/ so the example can be compiled with either 0.9 or 1.0.
I didn't find what pick_vfunc() can be replaced with, I think it's deprecated so I removed it.

When it's run - nothing shows up, just receive warning:
Clutter-WARNING **: Attempting to map a child that does not meet the necessary invariants

Even the warning is kind of incomplete, what invariants aren't met?


--
Aarto
diff -Naburp scrollin_orig/scrollingcontainer.cc scrolling/scrollingcontainer.cc
--- scrollin_orig/scrollingcontainer.cc	2009-01-07 18:35:25.000000000 +0200
+++ scrolling/scrollingcontainer.cc	2009-10-16 21:23:44.000000000 +0300
@@ -21,22 +21,17 @@
 namespace
 {
 
-static void allocate_child(const Glib::RefPtr<Clutter::Actor>& actor,
-  int& child_x, bool absolute_origin_changed)
+static void allocate_child(const Glib::RefPtr<Clutter::Actor>& actor, int& child_x, Clutter::AllocationFlags flags)
 {
-  Clutter::Unit min_width  = 0;
-  Clutter::Unit min_height = 0;
-  Clutter::Unit width      = 0;
-  Clutter::Unit height     = 0;
+	float min_width  = 0;
+	float min_height = 0;
+	float width      = 0;
+	float height     = 0;
 
   actor->get_preferred_size(min_width, min_height, width, height);
-
-  const Clutter::ActorBox child_box (CLUTTER_UNITS_FROM_DEVICE(child_x), 0,
-    CLUTTER_UNITS_FROM_DEVICE(child_x) + width, height);
-
-  actor->allocate(child_box, absolute_origin_changed);
-
-  child_x += CLUTTER_UNITS_TO_DEVICE(width);
+	const Clutter::ActorBox child_box(child_x, 0, child_x + width, height);
+	actor->allocate(child_box, flags);
+	child_x += width;
 }
 
 } // anonymous namespace
@@ -153,34 +148,26 @@ void ScrollingContainer::hide_all_vfunc(
   children_->hide_all();
 }
 
-void ScrollingContainer::pick_vfunc(const Clutter::Color& color)
-{
-  if(border_->is_mapped())
-    border_->pick(color);
-
-  children_->pick(color);
-}
-
-void ScrollingContainer::allocate_vfunc(const Clutter::ActorBox& box, bool absolute_origin_changed)
+void ScrollingContainer::allocate_vfunc(const Clutter::ActorBox& box, Clutter::AllocationFlags flags)
 {
-  const Clutter::Unit width  = std::max<Clutter::Unit>(0, box.get_x2() - box.get_x1());
-  const Clutter::Unit height = std::max<Clutter::Unit>(0, box.get_y2() - box.get_y1());
+  const float width  = std::max<float>(0, box.get_x2() - box.get_x1());
+  const float height = std::max<float>(0, box.get_y2() - box.get_y1());
 
   Clutter::ActorBox child_box (0, 0, width, height);
 
   // Position the child at the top of the container:
-  children_->allocate(child_box, absolute_origin_changed);
+  children_->allocate(child_box, flags);
 
   // Make sure that the group only shows the specified area, by clipping:
-  children_->set_clip(0, 0, CLUTTER_UNITS_TO_DEVICE(width), CLUTTER_UNITS_TO_DEVICE(height));
+  children_->set_clip(0, 0, width, height);
 
   // Show a rectangle border to show the area:
-  border_->allocate(child_box, absolute_origin_changed);
+  border_->allocate(child_box, flags);
 
   int child_x = -offset_;
-  children_->foreach(sigc::bind(&allocate_child, sigc::ref(child_x), absolute_origin_changed));
+  children_->foreach(sigc::bind(&allocate_child, sigc::ref(child_x), flags));
 
-  Clutter::Actor::allocate_vfunc(box, absolute_origin_changed);
+  Clutter::Actor::allocate_vfunc(box, flags);
 }
 
 } // namespace Tutorial
diff -Naburp scrollin_orig/scrollingcontainer.h scrolling/scrollingcontainer.h
--- scrollin_orig/scrollingcontainer.h	2009-01-07 18:35:25.000000000 +0200
+++ scrolling/scrollingcontainer.h	2009-10-16 21:23:44.000000000 +0300
@@ -48,8 +48,7 @@ protected:
   virtual void on_hide();
   virtual void show_all_vfunc();
   virtual void hide_all_vfunc();
-  virtual void pick_vfunc(const Clutter::Color& color);
-  virtual void allocate_vfunc(const Clutter::ActorBox& box, bool absolute_origin_changed);
+  virtual void allocate_vfunc(const Clutter::ActorBox& box, Clutter::AllocationFlags flags);
 
 private:
   Glib::RefPtr<Clutter::Rectangle> border_;


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