[libchamplainmm] Label: Cleanup constructors



commit 61629adad2c06a1106dae5efff9b35d9c5e62cf5
Author: Juan R. GarcĂ­a Blanco <juanrgar gmail com>
Date:   Wed Feb 26 21:02:40 2014 +0100

    Label: Cleanup constructors
    
        * Add protected constructors.
        * Add more create() constructors.

 libchamplain/src/label.ccg |   49 ++++++++++++++++++++++--------
 libchamplain/src/label.hg  |   71 ++++++++++++++++++++++++++++++++++----------
 2 files changed, 91 insertions(+), 29 deletions(-)
---
diff --git a/libchamplain/src/label.ccg b/libchamplain/src/label.ccg
index 9e577fc..383759e 100644
--- a/libchamplain/src/label.ccg
+++ b/libchamplain/src/label.ccg
@@ -16,28 +16,51 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <champlain/champlain.h>
+
 namespace Champlain
 {
 
-Glib::RefPtr<Label> Label::create(const Glib::ustring & label,
-                                  const Glib::ustring & font,
-                                  const Clutter::Color & text_color,
-                                  const Clutter::Color & marker_color)
+Glib::RefPtr<Label> Label::create(const Glib::ustring& text,
+                                  const Glib::ustring& font,
+                                  const Clutter::Color& text_color,
+                                  const Clutter::Color& label_color)
+{
+  const Glib::RefPtr<Label> label(new Label());
+
+  label->set_text(text);
+  label->set_font_name(font);
+  label->set_text_color(text_color);
+  label->set_color(label_color);
+
+  return label;
+}
+
+Glib::RefPtr<Label> Label::create(const std::string& filename)
+{
+  const Glib::RefPtr<Label> label(new Label());
+
+  return label;
+}
+
+Glib::RefPtr<Label> Label::create(const Glib::RefPtr<Clutter::Actor>& actor)
 {
-  const Glib::RefPtr<Label> champlain_label(new Label());
+  const Glib::RefPtr<Label> label(new Label());
+
+  label->set_image(actor);
 
-  champlain_label->set_text(label);
-  champlain_label->set_font_name(font);
-  champlain_label->set_text_color(text_color);
-  champlain_label->set_color(marker_color);
-  return champlain_label;
+  return label;
 }
 
-Glib::RefPtr<Label> Label::create(const std::string & filename)
+Glib::RefPtr<Label> Label::create(const Glib::ustring& text,
+                                  const Glib::RefPtr<Clutter::Actor>& actor)
 {
-  const Glib::RefPtr<Label> champlain_label(new Label());
+  const Glib::RefPtr<Label> label(new Label());
+
+  label->set_image(actor);
+  label->set_text(text);
 
-  return champlain_label;
+  return label;
 }
 
 } // namespace Champlain
diff --git a/libchamplain/src/label.hg b/libchamplain/src/label.hg
index fb2518f..8f95033 100644
--- a/libchamplain/src/label.hg
+++ b/libchamplain/src/label.hg
@@ -16,15 +16,14 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <string>
-#include <cluttermm.h>
-#include <glibmm.h>
-#include <pangomm.h>
 #include <libchamplainmm/marker.h>
+#include <cluttermm/color.h>
+#include <cluttermm/actor.h>
+#include <pangomm/layout.h>
+#include <pangomm/attrlist.h>
+#include <string>
 
 _DEFS(libchamplainmm,libchamplain)
-
-_CC_INCLUDE(champlain/champlain.h)
 _PINCLUDE(libchamplainmm/private/marker_p.h)
 
 namespace Champlain
@@ -37,22 +36,62 @@ class Label : public Marker
 protected:
   _CTOR_DEFAULT()
 
+  /** Creates a new instance of Label with text value.
+   *
+   * @param text The text of the label
+   * @param font The font to use to draw the text, for example "Courrier Bold 11"
+   * @param text_color A Clutter::Color, the color of the text; default is {0xee, 0xee, 0xee, 0xff}
+   * @param label_color A Clutter::Color, the color of the label; default is {0x33, 0x33, 0x33, 0xff}
+   *
+   * @newin{0,10}
+   */
+  explicit Label(const Glib::ustring& text,
+                 const Glib::ustring& font = Glib::ustring("Sans 11"),
+                 const Clutter::Color& text_color = Clutter::Color(0xee, 0xee, 0xee, 0xff),
+                 const Clutter::Color& label_color = Clutter::Color(0x33, 0x33, 0x33, 0xff));
+  _IGNORE(champlain_label_new_with_text)
+
+  /** Creates a new instance of Label with image.
+   *
+   * @param actor The image as a Clutter::Actor.
+   *
+   * @newin{0,10}
+   */
+  explicit Label(const Glib::RefPtr<Clutter::Actor>& actor);
+  _IGNORE(champlain_label_new_with_image)
+
+//TODO
+  /** Creates a new instance of Label with image loaded from file.
+   *
+   * @param filename The filename of the image.
+   *
+   * @newin{0,10}
+   */
+  explicit Label(const std::string& filename);
   _IGNORE(champlain_label_new_from_file)
+
+  /** Creates a new instance of Label consisting of a custom Clutter::Actor.
+   *
+   * @param text The text of the label
+   * @param actor The image as a Clutter::Actor
+   *
+   * @newin{0,10}
+   */
+  explicit Label(const Glib::ustring& text,
+                 const Glib::RefPtr<Clutter::Actor>& actor);
   _IGNORE(champlain_label_new_full)
-  _IGNORE(champlain_label_new_with_image)
-  _IGNORE(champlain_label_new_with_text)
 
 public:
   _WRAP_CREATE()
-
-  static Glib::RefPtr<Label> create(
-      const Glib::ustring & label,
-      const Glib::ustring & font  = Glib::ustring("Sans 11"),
-      const Clutter::Color & text_color
-                                 = Clutter::Color(0x22, 0x22, 0x22, 0xFF),
-      const Clutter::Color & marker_color
-                                 = Clutter::Color(0x33, 0x33, 0x33, 0xFF));
+//TODO
+  static Glib::RefPtr<Label> create(const Glib::ustring& text,
+                                    const Glib::ustring& font = Glib::ustring("Sans 11"),
+                                    const Clutter::Color& text_color = Clutter::Color(0xee, 0xee, 0xee, 
0xff),
+                                    const Clutter::Color& label_color = Clutter::Color(0x33, 0x33, 0x33, 
0xff));
   static Glib::RefPtr<Label> create(const std::string & filename);
+  static Glib::RefPtr<Label> create(const Glib::RefPtr<Clutter::Actor>& actor);
+  static Glib::RefPtr<Label> create(const Glib::ustring& text,
+                                    const Glib::RefPtr<Clutter::Actor>& actor);
 
   _WRAP_METHOD(Pango::Alignment get_alignment(), champlain_label_get_alignment)
   _WRAP_METHOD(Pango::EllipsizeMode get_ellipsize() const, champlain_label_get_ellipsize)


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