View
@@ -7,23 +7,36 @@
namespace Rapicorn {
// == Forward Declarations ==
+class FactoryContext;
+class ObjectImpl;
typedef std::shared_ptr<ObjectIface> ObjectIfaceP;
+typedef std::shared_ptr<ObjectImpl> ObjectImplP;
/// ObjectImpl is the base type for all server side objects in Rapicorn and implements the IDL base type ObjectIface.
class ObjectImpl : public virtual ObjectIface, public virtual DataListContainer {
- static void shared_ptr_deleter (ObjectImpl *object) { delete object; }
+ static void ctor_factory_context (FactoryContext *fc);
protected:
virtual /*dtor*/ ~ObjectImpl () override;
+ virtual void constructed ();
virtual void dispose ();
virtual void do_changed (const String &name);
class InterfaceMatcher;
template<class C> class InterfaceMatch;
+ FactoryContext& ctor_factory_context ();
public:
explicit ObjectImpl ();
Signal<void (const String &name)> sig_changed;
virtual void changed (const String &name);
String typeid_name ();
- ObjectIfaceP temp_factory_workaround () { return std::shared_ptr<ObjectImpl> (this, shared_ptr_deleter); }
+ template<class InstanceType> static
+ std::shared_ptr<InstanceType> make_instance (FactoryContext &fc)
+ {
+ ctor_factory_context (&fc);
+ std::shared_ptr<InstanceType> sptr = std::make_shared<InstanceType>();
+ ctor_factory_context (NULL);
+ static_cast<ObjectImpl*> (&*sptr)->constructed();
+ return sptr;
+ }
};
inline bool operator== (const ObjectImpl &object1, const ObjectImpl &object2) { return &object1 == &object2; }
inline bool operator!= (const ObjectImpl &object1, const ObjectImpl &object2) { return &object1 != &object2; }
View
@@ -13,9 +13,9 @@ class AmbienceImpl : public virtual SingleContainerImpl, public virtual Ambience
protected:
void render_shade (cairo_t *cairo, int x, int y, int width, int height, LightingType st);
virtual void render (RenderContext &rcontext, const Rect &rect) override;
- virtual ~AmbienceImpl () override;
public:
explicit AmbienceImpl ();
+ virtual ~AmbienceImpl () override;
virtual void insensitive_background (const String &color) override;
virtual String insensitive_background () const override;
virtual void prelight_background (const String &color) override;
@@ -56,13 +56,13 @@ class FrameImpl : public virtual SingleContainerImpl, public virtual FrameIface
bool is_tight_focus () const;
protected:
bool tap_tight_focus (int onoffx);
- virtual ~FrameImpl () override;
virtual void do_changed (const String &name) override;
virtual void size_request (Requisition &requisition) override;
virtual void size_allocate (Allocation area, bool changed) override;
virtual void render (RenderContext &rcontext, const Rect &rect) override;
public: // FrameIface
explicit FrameImpl ();
+ virtual ~FrameImpl () override;
virtual FrameType current_frame () override;
virtual FrameType normal_frame () const override;
virtual void normal_frame (FrameType) override;
@@ -76,11 +76,11 @@ public: // FrameIface
class FocusFrameImpl : public virtual FrameImpl, public virtual FocusFrameIface {
protected:
- virtual ~FocusFrameImpl () override;
virtual void set_focus_child (WidgetImpl *widget) override;
virtual void hierarchy_changed (WidgetImpl *old_toplevel) override;
public:
explicit FocusFrameImpl ();
+ virtual ~FocusFrameImpl () override;
/** FocusFrame registers itself with ancestors that implement the FocusFrameImpl::Client interface.
* This is useful for ancestors to be notified about a FocusFrameImpl descendant to implement
* .can_focus() efficiently and for a FocusFrame to reflect its ancestor's .has_focus() state.
View
@@ -9,12 +9,12 @@ namespace Rapicorn {
class ArrowImpl : public virtual WidgetImpl, public virtual ArrowIface {
DirType dir_;
protected:
- virtual ~ArrowImpl () override;
virtual void size_request (Requisition &requisition) override;
virtual void size_allocate (Allocation area, bool changed) override;
virtual void render (RenderContext &rcontext, const Rect &rect) override;
public:
explicit ArrowImpl ();
+ virtual ~ArrowImpl () override;
virtual void arrow_dir (DirType dir) override;
virtual DirType arrow_dir () const override;
virtual void size_policy (SizePolicyType spol) override;
@@ -27,12 +27,12 @@ class DotGridImpl : public virtual WidgetImpl, public virtual DotGridIface {
uint16 right_padding_dots_, top_padding_dots_, left_padding_dots_, bottom_padding_dots_;
virtual FrameType dot_type () const override;
protected:
- virtual ~DotGridImpl () override;
virtual void size_request (Requisition &requisition) override;
virtual void size_allocate (Allocation area, bool changed) override;
virtual void render (RenderContext &rcontext, const Rect &rect) override;
public:
explicit DotGridImpl ();
+ virtual ~DotGridImpl () override;
virtual void dot_type (FrameType ft) override;
virtual void normal_dot (FrameType ft) override;
virtual FrameType normal_dot () const override;
View
@@ -15,13 +15,13 @@ class SliderAreaImpl : public virtual TableLayoutImpl, public virtual SliderArea
void unset_adjustment ();
bool move (MoveType);
protected:
- virtual ~SliderAreaImpl () override;
virtual void hierarchy_changed (WidgetImpl *old_toplevel) override;
virtual const CommandList& list_commands () override;
virtual void slider_changed ();
typedef Aida::Signal<void ()> SignalSliderChanged;
public:
explicit SliderAreaImpl ();
+ virtual ~SliderAreaImpl () override;
Adjustment* adjustment () const;
void adjustment (Adjustment &adjustment);
virtual AdjustmentSourceType adjustment_source () const override;
@@ -42,9 +42,9 @@ protected:
virtual void hierarchy_changed (WidgetImpl *old_toplevel) override;
virtual bool handle_event (const Event &event) override;
virtual void reset (ResetMode mode = RESET_ALL) override;
- virtual ~SliderTroughImpl () override;
public:
explicit SliderTroughImpl ();
+ virtual ~SliderTroughImpl () override;
bool flipped () const;
Adjustment* adjustment () const;
};
View
@@ -45,16 +45,12 @@ WidgetIface::impl () const
WidgetImpl::WidgetImpl () :
flags_ (VISIBLE | SENSITIVE),
- parent_ (NULL), ainfo_ (NULL), heritage_ (NULL), factory_context_ (NULL),
- sig_invalidate (Aida::slot (*this, &WidgetImpl::do_invalidate)),
+ parent_ (NULL), ainfo_ (NULL), heritage_ (NULL),
+ factory_context_ (ctor_factory_context()), sig_invalidate (Aida::slot (*this, &WidgetImpl::do_invalidate)),
sig_hierarchy_changed (Aida::slot (*this, &WidgetImpl::hierarchy_changed))
{}
void
-WidgetImpl::constructed()
-{}
-
-void
WidgetImpl::foreach_recursive (const std::function<void (WidgetImpl&)> &f)
{
f (*this);
@@ -1758,22 +1754,6 @@ WidgetImpl::name (const String &str)
changed ("name");
}
-FactoryContext*
-WidgetImpl::factory_context () const
-{
- return factory_context_;
-}
-
-void
-WidgetImpl::factory_context (FactoryContext *fc)
-{
- if (fc)
- assert_return (factory_context_ == NULL);
- factory_context_ = fc;
- if (factory_context_)
- constructed();
-}
-
UserSource
WidgetImpl::user_source () const
{
View
@@ -55,7 +55,7 @@ class WidgetImpl : public virtual WidgetIface, public virtual ObjectImpl {
ContainerImpl *parent_; // inlined for fast access
const AnchorInfo *ainfo_;
HeritageP heritage_;
- FactoryContext *factory_context_;
+ FactoryContext &factory_context_;
Allocation allocation_;
Requisition requisition_;
Requisition inner_size_request (); // ungrouped size requisition
@@ -68,7 +68,6 @@ class WidgetImpl : public virtual WidgetIface, public virtual ObjectImpl {
void data_context_changed ();
protected:
const AnchorInfo* force_anchor_info () const;
- virtual void constructed ();
virtual void foreach_recursive (const std::function<void (WidgetImpl&)> &f);
/* flag handling */
bool change_flags_silently (uint64 mask, bool on);
@@ -189,8 +188,7 @@ public:
virtual void vsize_group (const String &group_list);
virtual String name () const; ///< Get Widget name or "id"
virtual void name (const String &str); ///< Set Widget name and "id"
- FactoryContext* factory_context () const;
- void factory_context (FactoryContext *fc);
+ FactoryContext& factory_context () const { return factory_context_; }
UserSource user_source () const;
ColorSchemeType color_scheme () const;
void color_scheme (ColorSchemeType cst);
View
@@ -238,15 +238,9 @@ WindowImpl::WindowImpl() :
}
void
-temp_window_factory_workaround (ObjectIfaceP o)
+WindowImpl::constructed ()
{
- ObjectIface *oi = o.get();
- if (oi)
- {
- WindowImpl *w = dynamic_cast<WindowImpl*> (oi);
- if (w)
- ApplicationImpl::the().add_window (*w);
- }
+ ApplicationImpl::the().add_window (*this);
}
void
View
@@ -25,14 +25,16 @@ class WindowImpl : public virtual ViewportImpl, public virtual WindowIface {
uint entered_ : 1;
uint pending_win_size_ : 1;
uint pending_expose_ : 1;
- void uncross_focus (WidgetImpl &fwidget);
+ void uncross_focus (WidgetImpl &fwidget);
protected:
- void set_focus (WidgetImpl *widget);
- virtual void set_parent (ContainerImpl *parent);
- virtual void dispose ();
+ void set_focus (WidgetImpl *widget);
+ virtual void set_parent (ContainerImpl *parent);
+ virtual void constructed () override;
+ virtual void dispose () override;
public:
static const int PRIORITY_RESIZE = EventLoop::PRIORITY_UPDATE - 1; ///< Execute resizes right before GUI updates.
explicit WindowImpl ();
+ virtual ~WindowImpl () override;
virtual WindowImpl* as_window_impl () { return this; }
WidgetImpl* get_focus () const;
cairo_surface_t* create_snapshot (const Rect &subarea);
@@ -71,7 +73,6 @@ private:
void notify_displayed (void);
virtual void remove_grab_widget (WidgetImpl &child);
void grab_stack_changed ();
- virtual ~WindowImpl ();
virtual void dispose_widget (WidgetImpl &widget);
/* misc */
vector<WidgetImplP> widget_difference (const vector<WidgetImplP> &clist, /* preserves order of clist */