[beast: 6/12] BSE: Item: add 'icon' property



commit 17cbea6fadda3ee42f84ced4d5bd10c17b813669
Author: Tim Janik <timj gnu org>
Date:   Fri Sep 18 11:03:57 2015 +0200

    BSE: Item: add 'icon' property

 bse/bseapi.idl |    1 +
 bse/bseitem.cc |   20 ++++++++++++++++++++
 bse/bseitem.hh |   10 ++++++----
 3 files changed, 27 insertions(+), 4 deletions(-)
---
diff --git a/bse/bseapi.idl b/bse/bseapi.idl
index a9fa7ec..1ca4005 100644
--- a/bse/bseapi.idl
+++ b/bse/bseapi.idl
@@ -356,6 +356,7 @@ interface Object {
 
 /// Base interface type for objects that can be added to a container.
 interface Item : Object {
+  Icon icon = Record ("Icon", "State dependent icon representation of this item", "r:G");
   Item common_ancestor (Item other);    ///< Find a common container (parent or grand-parent) of two items 
if any.
 };
 
diff --git a/bse/bseitem.cc b/bse/bseitem.cc
index 5f401ab..e89e3f1 100644
--- a/bse/bseitem.cc
+++ b/bse/bseitem.cc
@@ -1344,4 +1344,24 @@ ItemImpl::common_ancestor (ItemIface &other)
   return common->as<ItemIfaceP>();
 }
 
+Icon
+ItemImpl::icon () const
+{
+  BseItem *self = const_cast<ItemImpl*> (this)->as<BseItem*>();
+  const BseIc0n *ic0n = bse_object_get_icon (self);
+  Icon icon;
+  if (ic0n && ic0n->width && ic0n->height && ic0n->width * ic0n->height == ssize_t 
(ic0n->pixel_seq->n_pixels))
+    {
+      icon.width = ic0n->width;
+      icon.height = ic0n->height;
+      icon.pixels.insert (icon.pixels.end(), &ic0n->pixel_seq->pixels[0], 
&ic0n->pixel_seq->pixels[ic0n->pixel_seq->n_pixels]);
+    }
+  return icon;
+}
+
+void
+ItemImpl::icon (const Icon&)
+{
+}
+
 } // Bse
diff --git a/bse/bseitem.hh b/bse/bseitem.hh
index de6d898..f874d39 100644
--- a/bse/bseitem.hh
+++ b/bse/bseitem.hh
@@ -162,11 +162,13 @@ private:
   UndoDescriptorData make_undo_descriptor_data    (ItemImpl &item);
   ItemImpl&          resolve_undo_descriptor_data (const UndoDescriptorData &udd);
 protected:
-  virtual           ~ItemImpl         ();
+  virtual           ~ItemImpl        ();
 public:
-  explicit           ItemImpl         (BseObject*);
-  ContainerImpl*     parent           ();
-  virtual ItemIfaceP common_ancestor  (ItemIface &other) override;
+  explicit           ItemImpl        (BseObject*);
+  ContainerImpl*     parent          ();
+  virtual ItemIfaceP common_ancestor (ItemIface &other) override;
+  virtual Icon       icon            () const override;
+  virtual void       icon            (const Icon&) override;
   /// Push handler onto the undo stack, @a self must match @a this.
   template<typename ItemT, typename... FuncArgs, typename... CallArgs> void
   push_undo (const String &blurb, ItemT &self, ErrorType (ItemT::*function) (FuncArgs...), CallArgs... args)


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