On 7/9/07, Andre Magalhaes <[EMAIL PROTECTED]> wrote:
> Hi,
>
> On 7/9/07, Gustavo Sverzut Barbieri <[EMAIL PROTECTED]> wrote:
> > On 7/9/07, Andre Magalhaes <[EMAIL PROTECTED]> wrote:
> > > Hey Raster,
> > >
> > > On 7/9/07, The Rasterman Carsten Haitzler <[EMAIL PROTECTED]> wrote:
> > > > On Fri, 6 Jul 2007 18:00:08 -0300 "Andre Magalhaes" <[EMAIL PROTECTED]>
> > > > babbled:
> > > >
> > > > > Hi all,
> > > > >
> > > > > As this is my first post here, let me introduce myself. I am Andre
> > > > > Moreira Magalhaes, aka andrunko, and I work for INdT in Brazil.
> > > >
> > > > hey andre :)
> > > >
> > > > > Now let's go to the point. I am working on a project that requires
> > > > > that an Evas_Object to have a custom click area. This object is a
> > > > > non-retangular object (a circle for eg) with a transparent backgroung.
> > > > > When i click on the background of this object, if the click was in a
> > > > > transparent area this object shouldn't receive any event. I was
> > > > > investigating the Evas code and i found 3 ways that this could be
> > > > > done.
> > > >
> > > > currently evas doesn't do this. in theory it could - but it doesn't.
> > > >
> > > > > 1 - Change evas_object_was_in_output_rect to always return 0 if the
> > > > > rect is in a transparent area of the object (not desired)
> > > > > 2 - Change evas_object_event_callback_call to return a boolean value
> > > > > indicating if the object handled the event and if not, keep sending
> > > > > event to the other objects in the list. If the object handled the
> > > > > event, stop there. This would require a lot of changes.
> > > > > 3 - Change evas_object_was_in_output_rect to check a for a custom
> > > > > "in_output_rect" method on the object, and if this method is set, use
> > > > > it to check if the rect is in output rect. This would require a new
> > > > > function, evas_object_is_in_output_rect_cb_set (or something similar)
> > > > > that could be implemented whenever is needed. If this method is not
> > > > > set, check the clip rectangle as it's done today.
> > > >
> > > > actually i already designed for this. there is an is_inside and
> > > > was_inside
> > > > method for objects. only line and polygon objects provide them and they
> > > > just
> > > > return 1 - these CAN be called if a point is inside the object rect and
> > > > the
> > > > code wants to determine if an event is still inside the object based on
> > > > private
> > > > object data (eg polygon outline, image pixel alpha channel data etc.).
> > > > right
> > > > now it basically isn't used - but its intent was to be used for this.
> > > > the
> > > > problem is this is actually relatively slow/expensive to do. you
> > > > probably also
> > > > want a way of enabling or disabling this level of event processing per
> > > > object
> > > > to save cost. so we probably need to add an object flag to use these
> > > > methods,
> > > > if they exist, or disable them (disabled by default), then provide
> > > > methods for
> > > > image objects at the least - then actually use them, if they are
> > > > provided, and
> > > > the flag is enabled for that object. implementing this won't be too
> > > > hrd, but it
> > > > won't be trivial. you need to be able to figure otu any x,y co-ord
> > > > within the
> > > > object and what pixel of the image that may map to based on paremeters
> > > > of the
> > > > object, then go check that pixel's alpha channel (if the image has an
> > > > alpha
> > > > channel). for polygon nd line objects you need to do some half-plane
> > > > point
> > > > intersection math (easy but its order(n) where n is the number of sides
> > > > of the
> > > > polygon). for lines its strange - you might want perfect inclusion, but
> > > > that's a
> > > > very small space unless its a thick line (doesn't exist currently). for
> > > > text...
> > > > thats hard as you need to figure out what character is in that x,y
> > > > (that's easy)
> > > > and then check the character glyph pixels to see if its inside...
> > > >
> > > > but anyway - i added this mechanism in at the very start but have never
> > > > used it
> > > > (or really needed it enough to implement the rest of it).
> > > hmmm, i didn't know about this is_inside method, it's similar to what
> > > i wanted but with some improvements :D. Attached there is a patch to
> > > implement it on evas_object_image and edje, and a callback to
> > > enable/disable it. I didn't like the name convention but this is
> > > something easy to change. I tested it here and it seems to be working.
> > > This is my first patch to evas, so please let me know where i can
> > > improve. Any comment is welcome
> >
> >
> > + if (x > w || y > h) {
> > + return 0;
> > + }
> >
> > coding style, raster likes ((cond1) || (cond2))
> Fixed.
>
> >
> > + o->engine_data =
> > obj->layer->evas->engine.func->image_data_get(obj->layer->evas->engine.data.output,
> > +
> > o->engine_data,
> > + 0,
> > + &data);
> > + data += (y * w) + x;
> > + a = (*data >> 24) & 0xff;
> >
> > this will not work for engines != 32bpp, like my 16bpp. If not
> > existent, we need to write an engine-provided get_pixel(), that give
> > normalized 0-255 components.
> I imagined that but in the documentation of evas_object_image_data_get it
> says:
> * @return A pointer to the raw data as 32 bit unsigned integer in format
> ARGB.
> I thought that all engines should convert it to 32 bits in this case,
> as it's stated on documentation. I am using the same method as
> evas_object_image_data_get uses. Please someone could clarify this.
Hum... I need to update this doc since it's not true anymore (since
16bpp engine, the first non-32bpp), maybe also providing engine
functions to manipulate this data.
It's a no-go to convert image buffers to 32bpp for these operations,
some images would take a lot of CPU and memory (800x600 = 480,000
iterations, 1440,000 bytes, to access one value of interest (alpha).
Also, your new patch still have some coding style inconsistencies
(according to raster's weird style):
+ (!obj->clip.clipees) &&
+ (!obj->precise_is_inside ||
+ evas_object_is_inside(obj, x, y)))
it should be:
+ (!obj->clip.clipees) &&
+ ((!obj->precise_is_inside) ||
+ evas_object_is_inside(obj, x, y)))
let's see what's his opinion to per-engine get_pixel(), maybe is there
something I fail to see, otherwise I can add this and you rebase your
patch on that, working on every engine (something you require, since
want to run this on desktop and nokia 770 ;-))
--
Gustavo Sverzut Barbieri
--------------------------------------
Jabber: [EMAIL PROTECTED]
MSN: [EMAIL PROTECTED]
ICQ#: 17249123
Skype: gsbarbieri
Mobile: +55 (81) 9927 0010
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel