Ok, a fix has been committed to svn (r8276). A pointer to the parent
window is now kept in the Widget structure and updated on attach and
detach. Please test and send me your feedback.
On Tue, Aug 18, 2009 at 11:00:33PM +0000, Olexandr Sydorchuk wrote:
> Hi,
>
> I'm working on alpha blending style, only for openGL mode. For this I
> will rewrite primitive functions that will apply RGBA color (instead RGB
> like it in current), this way make possible use other style w/o
> rewriting style code. Al work good, but. I want to fade unfocudes
> window, but its seems no good fast way to find parent window for
> widget. Currently I use *AG_WidgetParentWindow* for this, but this hard
> and FPS decreased. Is it possible to have _cashed_ ->win field for all
> widget like it's in titlebar->win? Or other fast way for finding
> window?
>
> Some code:
> --8<---------------cut here---------------start------------->8---
>
> Uint8 alphaFadeUnfocusedWin = 100;
>
> // fade unfocused window
> inline Uint8 ComputeAlpha(AG_Widget *wid, Uint8 alpha)
> {
> if (AG_WindowIsFocused(AG_WidgetParentWindow(wid)))
> return alpha;
> else
> {
> int v = alpha;
> v -= alphaFadeUnfocusedWin;
> if (v < 0)
> return 0;
> else
> return (Uint8) v;
> }
> }
>
> static void
> _rectGL(void *p, AG_Rect r, Uint32 color)
> {
> AG_Widget *wid = (AG_Widget *)p;
> Uint8 red, green, blue, alpha;
> int x1 = wid->rView.x1 + r.x;
> int y1 = wid->rView.y1 + r.y;
> int x2 = x1 + r.w - 1;
> int y2 = y1 + r.h - 1;
>
> BeginBlending();
>
> AG_GetRGBA(color, agVideoFmt, &red,&green,&blue,&alpha);
> glBegin(GL_POLYGON);
> glColor4ub(red, green, blue, ComputeAlpha(wid, alpha));
> glVertex2i(x1, y1);
> glVertex2i(x2, y1);
> glVertex2i(x2, y2);
> glVertex2i(x1, y2);
> glEnd();
>
> EndBlending();
> }
> --8<---------------cut here---------------end--------------->8---
>
> --
> Olexandr
>
> _______________________________________________
> Agar mailing list
> [email protected]
> http://libagar.org/lists.html
_______________________________________________
Agar mailing list
[email protected]
http://libagar.org/lists.html