From: dooglus Date: Sat, 22 Nov 2008 15:41:21 +0000 (+0000) Subject: Add FilledRect::hit_check() to allow Filled Rectangles to be selected by clicking... X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=284f2de6f33ed153630ffda94653a9eea093095e;p=synfig.git Add FilledRect::hit_check() to allow Filled Rectangles to be selected by clicking on them. git-svn-id: https://synfig.svn.sourceforge.net/svnroot/synfig@2253 1f10aa63-cdf2-0310-b900-c93c546f37ac --- diff --git a/synfig-core/trunk/src/modules/example/filledrect.cpp b/synfig-core/trunk/src/modules/example/filledrect.cpp index 0c165ed..f6f842f 100644 --- a/synfig-core/trunk/src/modules/example/filledrect.cpp +++ b/synfig-core/trunk/src/modules/example/filledrect.cpp @@ -144,6 +144,26 @@ FilledRect::get_param_vocab()const return ret; } +synfig::Layer::Handle +FilledRect::hit_check(synfig::Context context, const synfig::Point &point)const +{ + Color clr; + Real amt; + + if (!get_color(point,clr,amt)) + return context.hit_check(point); + + synfig::Layer::Handle tmp; + + if (get_blend_method()==Color::BLEND_BEHIND && (tmp=context.hit_check(point))) + return tmp; + + if (Color::is_onto(get_blend_method()) && !(context.hit_check(point))) + return 0; + + return const_cast(this); +} + bool FilledRect::get_color(const Point &pos, Color &out, Real &outamount) const { diff --git a/synfig-core/trunk/src/modules/example/filledrect.h b/synfig-core/trunk/src/modules/example/filledrect.h index 421f80e..b540105 100644 --- a/synfig-core/trunk/src/modules/example/filledrect.h +++ b/synfig-core/trunk/src/modules/example/filledrect.h @@ -72,6 +72,8 @@ public: virtual bool accelerated_render(synfig::Context context,synfig::Surface *surface,int quality, const synfig::RendDesc &renddesc, synfig::ProgressCallback *cb)const; virtual Vocab get_param_vocab()const; + + virtual synfig::Layer::Handle hit_check(synfig::Context context, const synfig::Point &point)const; }; // END of class FilledRect /* === E N D =============================================================== */