4
I Use This!
Activity Not Available

News

Analyzed 3 months ago. based on code collected 5 months ago.
Posted about 10 years ago by Agar-SVN
Author: vedge Date: 2015-05-25 09:08:26 -0400 (Mon, 25 May 2015) New Revision: 9796 Modified: trunk/gui/AG_Cursor.3 trunk/gui/cursors.c trunk/gui/cursors.h trunk/gui/editable.c trunk/gui/editable.h trunk/gui/mouse.c ... [More] trunk/gui/pane.c trunk/gui/pane.h trunk/gui/table.c trunk/gui/table.h trunk/gui/window.c trunk/gui/window.h Log: introduce AG_SetCursor() and AG_SetStockCursor() as convenient alternatives to AG_MapCursor() and AG_MapStockCursor() when updating an existing rectangle. Modified: trunk/gui/AG_Cursor.3 =================================================================== --- trunk/gui/AG_Cursor.32015-05-25 13:06:45 UTC (rev 9795) trunk/gui/AG_Cursor.32015-05-25 13:08:26 UTC (rev 9796) < at >< at > -1,4 1,4 < at >< at > -.\" Copyright (c) 2008-2014 Hypertriton, Inc. <http://hypertriton.com/> .\" Copyright (c) 2008-2015 Hypertriton, Inc. <http://hypertriton.com/> .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without < at >< at > -51,6 51,12 < at >< at > .Fn AG_MapStockCursor "AG_Widget *wid" "AG_Rect r" "int cursorName" .Pp .Ft "void" .Fn AG_SetCursor "AG_Widget *wid" "AG_CursorArea **cursorArea" "AG_Rect r" "AG_Cursor *c" .Pp .Ft "void" .Fn AG_SetStockCursor "AG_Widget *wid" "AG_CursorArea **cursorArea" "AG_Rect r" "int cursorName" .Pp .Ft "void" .Fn AG_UnmapCursor "AG_Widget *wid" "AG_CursorArea *cursorArea" .Pp .nr nS 0 < at >< at > -92,6 98,20 < at >< at > .Ft AG_CursorArea structure describing the cursor-change area, or NULL if an error has occured. .Pp The .Fn AG_SetCursor and .Fn AG_SetStockCursor routines provide an alternate interface to .Fn AG_MapCursor and .Fn AG_MapStockCursor . If the pointer at .Fa cursorArea is NULL, a new cursor area is mapped and returned into it. Otherwise, the rectangle of the existing cursor area is updated from .Fa r . .Pp .Fn AG_UnmapCursor removes the specified cursor-change area. If the mouse happens to be currently in this area, the cursor will be Modified: trunk/gui/cursors.c =================================================================== --- trunk/gui/cursors.c2015-05-25 13:06:45 UTC (rev 9795) trunk/gui/cursors.c2015-05-25 13:08:26 UTC (rev 9796) < at >< at > -152,8 152,3 < at >< at > TAILQ_INIT(&drv->cursors); drv->nCursors = 0; } - -#ifdef AG_LEGACY -void AG_SetCursor(int builtin) { } -void AG_UnsetCursor(void) { } -#endif /* AG_LEGACY */ Modified: trunk/gui/cursors.h =================================================================== --- trunk/gui/cursors.h2015-05-25 13:06:45 UTC (rev 9795) trunk/gui/cursors.h2015-05-25 13:08:26 UTC (rev 9796) < at >< at > -96,11 96,6 < at >< at > { AGDRIVER_CLASS(drv)->setCursorVisibility(drv, 0); } - -#ifdef AG_LEGACY -void AG_SetCursor(int)DEPRECATED_ATTRIBUTE; -void AG_UnsetCursor(void)DEPRECATED_ATTRIBUTE; -#endif __END_DECLS #include <agar/gui/close.h> Modified: trunk/gui/editable.c =================================================================== --- trunk/gui/editable.c2015-05-25 13:06:45 UTC (rev 9795) trunk/gui/editable.c2015-05-25 13:08:26 UTC (rev 9796) < at >< at > -1027,11 1027,7 < at >< at > /* Map cursor-change area */ r = AG_RECT(0, 0, a->w, a->h); -if (ed->ca == NULL) { -ed->ca = AG_MapStockCursor(ed, r, AG_TEXT_CURSOR); -} else { -ed->ca->r = r; -} AG_SetStockCursor(ed, &ed->ca, r, AG_TEXT_CURSOR); return (0); } Modified: trunk/gui/editable.h =================================================================== --- trunk/gui/editable.h2015-05-25 13:06:45 UTC (rev 9795) trunk/gui/editable.h2015-05-25 13:08:26 UTC (rev 9796) < at >< at > -8,7 8,6 < at >< at > #include <agar/gui/begin.h> -struct ag_cursor_area; struct ag_popup_menu; /* Working UCS-4 text buffer for internal use */ < at >< at > -73,7 72,7 < at >< at > Uint32 wheelTicks;/* For wheel acceleration */ AG_EditableBuffer sBuf;/* Working buffer (for STATIC) */ AG_Rect r;/* View area */ -struct ag_cursor_area *ca;/* For "text" cursor change */ AG_CursorArea *ca;/* Text cursor-change area */ int fontMaxHeight;/* Maximum character height */ int lineSkip;/* Y-increment in multiline mode */ struct ag_popup_menu *pm;/* Right-click popup menu */ Modified: trunk/gui/mouse.c =================================================================== --- trunk/gui/mouse.c2015-05-25 13:06:45 UTC (rev 9795) trunk/gui/mouse.c2015-05-25 13:08:26 UTC (rev 9796) < at >< at > -104,8 104,10 < at >< at > if (AG_RectInside(&r, x,y)) break; } -if (ca == NULL && drv->activeCursor != TAILQ_FIRST(&drv->cursors)) { -AGDRIVER_CLASS(drv)->unsetCursor(drv); if (ca == NULL) { if (drv->activeCursor != TAILQ_FIRST(&drv->cursors)) { AGDRIVER_CLASS(drv)->unsetCursor(drv); } } else if (ca->c != drv->activeCursor) { AGDRIVER_CLASS(drv)->setCursor(drv, ca->c); } Modified: trunk/gui/pane.c =================================================================== --- trunk/gui/pane.c2015-05-25 13:06:45 UTC (rev 9795) trunk/gui/pane.c2015-05-25 13:08:26 UTC (rev 9796) < at >< at > -440,11 440,7 < at >< at > r.y = 0; r.w = pa->wDiv; r.h = a->h; -if (pa->ca == NULL) { -pa->ca = AG_MapStockCursor(pa, r, AG_HRESIZE_CURSOR); -} else { -pa->ca->r = r; -} AG_SetStockCursor(pa, &pa->ca, r, AG_HRESIZE_CURSOR); break; case AG_PANE_VERT: if (pa->dx == 0 && pa->rx == -1) { < at >< at > -496,11 492,7 < at >< at > r.y = pa->dx; r.w = a->w; r.h = pa->wDiv; -if (pa->ca == NULL) { -pa->ca = AG_MapStockCursor(pa, r, AG_VRESIZE_CURSOR); -} else { -pa->ca->r = r; -} AG_SetStockCursor(pa, &pa->ca, r, AG_VRESIZE_CURSOR); break; } AG_WidgetSizeAlloc(pa->div[0], &a1); Modified: trunk/gui/pane.h =================================================================== --- trunk/gui/pane.h2015-05-25 13:06:45 UTC (rev 9795) trunk/gui/pane.h2015-05-25 13:08:26 UTC (rev 9796) < at >< at > -8,8 8,6 < at >< at > #include <agar/gui/begin.h> -struct ag_cursor_area; - enum ag_pane_type { AG_PANE_HORIZ, AG_PANE_VERT < at >< at > -48,7 46,7 < at >< at > intrx;/* Requested divider position */ int rxPct;/* Requested position in % */ intwDiv;/* Divider width */ -struct ag_cursor_area *ca;/* Cursor-change area in divider */ AG_CursorArea *ca;/* Divider cursor-change area */ enum ag_pane_resize_action resizeAction;/* Resize action */ } AG_Pane; Modified: trunk/gui/table.c =================================================================== --- trunk/gui/table.c2015-05-25 13:06:45 UTC (rev 9795) trunk/gui/table.c2015-05-25 13:08:26 UTC (rev 9796) < at >< at > -194,9 194,6 < at >< at > AG_Rect r; int n, x; -if (WIDGET(t)->window != NULL) -AG_UnmapAllCursors(WIDGET(t)->window, t); - t->wTot = 0; for (n = 0; n < t->n; n ) { tc = &t->cols[n]; < at >< at > -228,7 225,6 < at >< at > } /* Update the cursor change areas for column resize. */ -r.x = 0; r.y = 0; r.h = t->hCol; for (n = 0, x = 0; n < t->n; n ) { < at >< at > -236,11 232,7 < at >< at > r.x = x - COLUMN_RESIZE_RANGE/2; r.w = COLUMN_RESIZE_RANGE; -if (tc->ca == NULL) { -tc->ca = AG_MapStockCursor(t, r, AG_HRESIZE_CURSOR); -} else { -tc->ca->r = r; -} AG_SetStockCursor(t, &tc->ca, r, AG_HRESIZE_CURSOR); x = tc->w; } } Modified: trunk/gui/table.h =================================================================== --- trunk/gui/table.h2015-05-25 13:06:45 UTC (rev 9795) trunk/gui/table.h2015-05-25 13:08:26 UTC (rev 9796) < at >< at > -113,7 113,7 < at >< at > int wPct;/* Width (percent or -1) */ int x;/* Current position */ int surface;/* Text surface mapping */ -struct ag_cursor_area *ca;/* For column resize */ AG_CursorArea *ca;/* Column resize cursor-change area */ } AG_TableCol; typedef struct ag_table { Modified: trunk/gui/window.c =================================================================== --- trunk/gui/window.c2015-05-25 13:06:45 UTC (rev 9795) trunk/gui/window.c2015-05-25 13:08:26 UTC (rev 9796) < at >< at > -42,7 42,7 < at >< at > static void OnFocusLoss(AG_Event *); int agWindowSideBorderDefault = 0; -int agWindowBotBorderDefault = 6; int agWindowBotBorderDefault = 8; /* Protected by agDrivers VFS lock */ AG_WindowQ agWindowDetachQ;/* Windows to detach */ < at >< at > -376,6 376,7 < at >< at > { AG_Window *win = obj; AG_Event *ev; int i; win->wmType = AG_WINDOW_WM_NORMAL; win->flags = AG_WINDOW_NOCURSORCHG; < at >< at > -412,6 413,8 < at >< at > win->zoom = AG_ZOOM_DEFAULT; TAILQ_INIT(&win->subwins); TAILQ_INIT(&win->cursorAreas); for (i = 0; i < 5; i ) win->caResize[i] = NULL; AG_InitTimer(&win->fadeTo, "fade", 0); < at >< at > -1706,7 1709,31 < at >< at > int wAvail, hAvail; int totFixed; int nWidgets; AG_Rect r; if (win->wBorderSide > 0) { r.x = 0; r.y = 0; r.w = win->wBorderSide; r.h = a->h - win->wBorderBot; AG_SetStockCursor(win, &win->caResize[0], r, AG_HRESIZE_CURSOR); r.x = a->w - win->wBorderSide; AG_SetStockCursor(win, &win->caResize[4], r, AG_HRESIZE_CURSOR); } if (win->wBorderBot > 0) { r.x = 0; r.y = a->h - win->wBorderBot; r.w = win->wResizeCtrl; r.h = win->wBorderBot; AG_SetStockCursor(win, &win->caResize[1], r, AG_LRDIAG_CURSOR); r.x = win->wResizeCtrl; r.w = a->w - win->wResizeCtrl*2; AG_SetStockCursor(win, &win->caResize[2], r, AG_VRESIZE_CURSOR); r.x = a->w - win->wResizeCtrl; r.w = win->wResizeCtrl; AG_SetStockCursor(win, &win->caResize[3], r, AG_LLDIAG_CURSOR); } /* Calculate total space available for widgets. */ wAvail = a->w - win->lPad - win->rPad - win->wBorderSide*2; hAvail = a->h - win->bPad - win->tPad - win->wBorderBot; Modified: trunk/gui/window.h =================================================================== --- trunk/gui/window.h2015-05-25 13:06:45 UTC (rev 9795) trunk/gui/window.h2015-05-25 13:08:26 UTC (rev 9796) < at >< at > -125,6 125,7 < at >< at > int nFocused;/* Widgets in focus chain */ AG_Widget *widExclMotion;/* Widget exclusively receiving mousemotion */ AG_CursorAreaQ cursorAreas;/* Cursor-change areas */ AG_CursorArea *caResize[5];/* Window-resize areas */ AG_Timer fadeTo;/* Fade timer */ float fadeInTime, fadeOutTime;/* Fade time (s) */ < at >< at > -392,6 393,30 < at >< at > } /* * Alternate interface to AG_MapCursor(). Create a new mapping or * update the rectangle of an existing one. */ static __inline__ void AG_SetCursor(void *obj, AG_CursorArea **ca, AG_Rect r, struct ag_cursor *c) { if (*ca == NULL) { *ca = AG_MapCursor(obj, r, c); } else { (*ca)->r = r; } } static __inline__ void AG_SetStockCursor(void *obj, AG_CursorArea **ca, AG_Rect r, int cName) { if (*ca == NULL) { *ca = AG_MapStockCursor(obj, r, cName); } else { (*ca)->r = r; } } /* * Process synchronous window operations. This includes focus changes, * visibility changes and the detach operation. Called from custom event * loops or driver code, after all queued events have been processed. [Less]
Posted about 10 years ago by Agar-SVN
Author: vedge Date: 2015-05-25 09:06:45 -0400 (Mon, 25 May 2015) New Revision: 9795 Modified: trunk/gui/drv_sdl_common.c Log: - add missing redraw when setting winop. - reset cursor when moving outside of window boundaries. Modified: ... [More] trunk/gui/drv_sdl_common.c =================================================================== --- trunk/gui/drv_sdl_common.c2015-05-24 12:36:20 UTC (rev 9794) +++ trunk/gui/drv_sdl_common.c2015-05-25 13:06:45 UTC (rev 9795) < at >< at > -830,6 +830,7 < at >< at > dsw->winop = GenericMouseOverCtrl(win, dev->data.button.x, dev->data.button.y); if (dsw->winop != AG_WINOP_NONE) { +win->dirty = 1; dsw->winSelected = win; AG_ObjectUnlock(win); return (1); < at >< at > -860,6 +861,13 < at >< at > } AG_ObjectUnlock(win); } +switch (dev->type) { +case AG_DRIVER_MOUSE_MOTION: +if (winTop == NULL) { +AGDRIVER_CLASS(drv)->unsetCursor(drv); +} +break; +} return (0); } [Less]
Posted about 10 years ago by Agar-SVN
Author: vedge Date: 2015-05-24 08:36:20 -0400 (Sun, 24 May 2015) New Revision: 9794 Modified: trunk/gui/drv_sdl_common.c trunk/gui/mouse.c Log: fix incorrect cursor-change behavior in sdlfb/sdlgl Modified: trunk/gui/drv_sdl_common.c ... [More] =================================================================== --- trunk/gui/drv_sdl_common.c2015-05-24 12:32:11 UTC (rev 9793) +++ trunk/gui/drv_sdl_common.c2015-05-24 12:36:20 UTC (rev 9794) < at >< at > -765,7 +765,7 < at >< at > ProcessInputEvent(AG_Driver *drv, AG_DriverEvent *dev) { AG_DriverSw *dsw = (AG_DriverSw *)drv; -AG_Window *win; +AG_Window *win, *winTop = NULL; switch (dev->type) { case AG_DRIVER_MOUSE_BUTTON_UP: < at >< at > -797,9 +797,14 < at >< at > dev->data.motion.x, dev->data.motion.y, drv->mouse->xRel, drv->mouse->yRel, drv->mouse->btnState); -AG_MouseCursorUpdate(win, - dev->data.motion.x, - dev->data.motion.y); +if (winTop == NULL && + AG_WidgetArea(win, dev->data.motion.x, + dev->data.motion.y)) { +winTop = win; +AG_MouseCursorUpdate(win, + dev->data.motion.x, + dev->data.motion.y); +} break; case AG_DRIVER_MOUSE_BUTTON_UP: AG_ProcessMouseButtonUp(win, Modified: trunk/gui/mouse.c =================================================================== --- trunk/gui/mouse.c2015-05-24 12:32:11 UTC (rev 9793) +++ trunk/gui/mouse.c2015-05-24 12:36:20 UTC (rev 9794) < at >< at > -104,12 +104,10 < at >< at > if (AG_RectInside(&r, x,y)) break; } -if (ca == NULL) { -if (AGDRIVER_CLASS(drv)->unsetCursor != NULL) -AGDRIVER_CLASS(drv)->unsetCursor(drv); +if (ca == NULL && drv->activeCursor != TAILQ_FIRST(&drv->cursors)) { +AGDRIVER_CLASS(drv)->unsetCursor(drv); } else if (ca->c != drv->activeCursor) { -if (AGDRIVER_CLASS(drv)->setCursor != NULL) -AGDRIVER_CLASS(drv)->setCursor(drv, ca->c); +AGDRIVER_CLASS(drv)->setCursor(drv, ca->c); } } [Less]
Posted about 10 years ago by Agar-SVN
Author: vedge Date: 2015-05-24 08:32:11 -0400 (Sun, 24 May 2015) New Revision: 9793 Modified: trunk/gui/table.c Log: update the existing cursor-change area rectangle on resize. Modified: trunk/gui/table.c ... [More] =================================================================== --- trunk/gui/table.c2015-05-24 12:31:33 UTC (rev 9792) +++ trunk/gui/table.c2015-05-24 12:32:11 UTC (rev 9793) < at >< at > -236,7 +236,11 < at >< at > r.x = x - COLUMN_RESIZE_RANGE/2; r.w = COLUMN_RESIZE_RANGE; -tc->ca = AG_MapStockCursor(t, r, AG_HRESIZE_CURSOR); +if (tc->ca == NULL) { +tc->ca = AG_MapStockCursor(t, r, AG_HRESIZE_CURSOR); +} else { +tc->ca->r = r; +} x += tc->w; } } [Less]
Posted about 10 years ago by Agar-SVN
Author: vedge Date: 2015-05-24 08:31:33 -0400 (Sun, 24 May 2015) New Revision: 9792 Modified: trunk/gui/editable.c Log: fix cursor-change code; it is safe to use AG_MapStockCursor() without the widget having a parent window. Modified: ... [More] trunk/gui/editable.c =================================================================== --- trunk/gui/editable.c2015-05-24 08:19:54 UTC (rev 9791) +++ trunk/gui/editable.c2015-05-24 12:31:33 UTC (rev 9792) < at >< at > -1017,27 +1017,20 < at >< at > SizeAllocate(void *obj, const AG_SizeAlloc *a) { AG_Editable *ed = obj; +AG_Rect r; if (a->w < 2 || a->h < 2) { -if (WIDGET(ed)->window != NULL && - ed->ca != NULL) { -AG_UnmapCursor(ed, ed->ca); -ed->ca = NULL; -} return (-1); } ed->yVis = a->h/ed->lineSkip; ed->r = AG_RECT(-1, -1, a->w-1, a->h-1); -if (WIDGET(ed)->window != NULL && - !(WIDGET(ed)->window->flags & AG_WINDOW_NOCURSORCHG)) { -AG_Rect r = AG_RECT(0, 0, a->w, a->h); - -if (ed->ca == NULL) { -ed->ca = AG_MapStockCursor(ed, r, AG_TEXT_CURSOR); -} else { -ed->ca->r = r; -} +/* Map cursor-change area */ +r = AG_RECT(0, 0, a->w, a->h); +if (ed->ca == NULL) { +ed->ca = AG_MapStockCursor(ed, r, AG_TEXT_CURSOR); +} else { +ed->ca->r = r; } return (0); } [Less]
Posted about 10 years ago by Agar-SVN
Author: vedge Date: 2015-05-24 04:19:54 -0400 (Sun, 24 May 2015) New Revision: 9791 Modified: trunk/gui/AG_DriverSDLFB.3 trunk/gui/AG_DriverSDLGL.3 trunk/gui/drv_sdl_common.c trunk/gui/drv_sdlfb.c trunk/gui/drv_sdlgl.c ... [More] trunk/gui/drv_sw.c trunk/gui/drv_sw.h trunk/gui/titlebar.c trunk/gui/window.c trunk/gui/window.h Log: - SDL: Implement "fpsMax" option for limiting GUI video updates in sdlfb/sdlgl. - SDL: In ProcessInputEvent(), fix bogus mousebuttondown processing. Eliminate redundant window-position test and focus operation. - SDL: Process all queued events in one AG_SDL_EventSink() cycle. - SDLGL: Fix bgColor option. Eliminate unneeded background updates in WM_Move(), etc. - AG_DriverSW: Introduce AG_DRIVER_SW_REDRAW flag. Fix video updates when detaching windows. Modified: trunk/gui/AG_DriverSDLFB.3 =================================================================== --- trunk/gui/AG_DriverSDLFB.32015-05-24 07:29:24 UTC (rev 9790) trunk/gui/AG_DriverSDLFB.32015-05-24 08:19:54 UTC (rev 9791) < at >< at > -62,10 62,14 < at >< at > .It depth Depth in bits per pixel (or .Sq auto ) . .It fpsMax Limit GUI refresh rate in frames/second (default = 60fps). .It bgColor -Background color (see -.Xr AG_Color 3 ) . Solid background color (see .Xr AG_ColorFromString 3 ) . Default is "rgb(0,0,0)". .It bgPopup Show popup menu upon middle / right-button click in the background. .El .Sh SEE ALSO .Xr AG_Driver 3 , Modified: trunk/gui/AG_DriverSDLGL.3 =================================================================== --- trunk/gui/AG_DriverSDLGL.32015-05-24 07:29:24 UTC (rev 9790) trunk/gui/AG_DriverSDLGL.32015-05-24 08:19:54 UTC (rev 9791) < at >< at > -70,6 70,8 < at >< at > .It depth Depth in bits per pixel (or .Sq auto ) . .It fpsMax Limit GUI refresh rate in frames/second (default = 60fps). .It out Dump video frames to JPEG or PNG image files. The filename path may include a printf-style (with frame number as argument). < at >< at > -81,9 83,11 < at >< at > .It outLast Terminate application after # frames have been rendered. .It bgColor -Background color ( -.Xr AG_Color 3 ) . Solid background color (see .Xr AG_ColorFromString 3 ) . Default is "rgb(0,0,0)". .It bgPopup Show popup menu upon middle / right-button click in the background. .It jpegQual If exporting to JPEG, set quality factor (100% = best). .It jpegDCT Modified: trunk/gui/drv_sdl_common.c =================================================================== --- trunk/gui/drv_sdl_common.c2015-05-24 07:29:24 UTC (rev 9790) trunk/gui/drv_sdl_common.c2015-05-24 08:19:54 UTC (rev 9791) < at >< at > -1,5 1,5 < at >< at > /* - * Copyright (c) 2009-2013 Hypertriton, Inc. <http://hypertriton.com/> * Copyright (c) 2009-2015 Hypertriton, Inc. <http://hypertriton.com/> * All rights reserved. * * Redistribution and use in source and binary forms, with or without < at >< at > -451,6 451,9 < at >< at > AG_SDL_SetCursor(void *obj, AG_Cursor *ac) { AG_Driver *drv = obj; if (drv->activeCursor == ac) return (0); SDL_SetCursor((SDL_Cursor *)ac->p); drv->activeCursor = ac; < at >< at > -464,6 467,9 < at >< at > AG_Driver *drv = obj; AG_Cursor *ac0 = TAILQ_FIRST(&drv->cursors); if (drv->activeCursor == ac0) return; SDL_SetCursor((SDL_Cursor *)ac0->p); drv->activeCursor = ac0; } < at >< at > -479,7 485,6 < at >< at > return (-1); } dsw->rNom = 1000/fps; -dsw->rCur = 0; return (0); } < at >< at > -579,6 584,7 < at >< at > { char buf[16]; AG_Driver *drv = obj; AG_DriverSw *dsw = obj; Uint wDisp, hDisp; if (*w == 0 || *h == 0) { < at >< at > -610,6 616,20 < at >< at > *depth = 32; } } if (AG_Defined(drv, "fpsMax")) { float v; char *ep; AG_GetString(drv, "fpsMax", buf, sizeof(buf)); v = strtof(buf, &ep); if (*ep == '\0') dsw->rNom = (Uint)(1000.0/v); } if (AG_Defined(drv, "bgColor")) { dsw->bgColor = AG_ColorFromString(AG_GetStringP(drv,"bgColor"), NULL); } if (AG_Defined(drv, "bgPopup")) dsw->flags |= AG_DRIVER_SW_BGPOPUP; } /* Standard beginEventProcessing() method for SDL drivers. */ < at >< at > -747,13 767,10 < at >< at > AG_DriverSw *dsw = (AG_DriverSw *)drv; AG_Window *win; -/* Process WM events */ switch (dev->type) { -case AG_DRIVER_MOUSE_BUTTON_DOWN:/* Focus on window */ -AG_WindowFocusAtPos(dsw, dev->data.button.x, dev->data.button.y); -break; -case AG_DRIVER_MOUSE_BUTTON_UP:/* Terminate WM op */ case AG_DRIVER_MOUSE_BUTTON_UP: dsw->winop = AG_WINOP_NONE; dsw->winSelected = NULL; break; } < at >< at > -780,19 797,11 < at >< at > dev->data.motion.x, dev->data.motion.y, drv->mouse->xRel, drv->mouse->yRel, drv->mouse->btnState); -if (AG_WindowIsFocused(win)) { -AG_MouseCursorUpdate(win, - dev->data.motion.x, - dev->data.motion.y); -} AG_MouseCursorUpdate(win, dev->data.motion.x, dev->data.motion.y); break; case AG_DRIVER_MOUSE_BUTTON_UP: -/* Terminate active window operations. */ -/* XXX redundant? */ -if (dsw->winop != AG_WINOP_NONE) { -dsw->winop = AG_WINOP_NONE; -dsw->winSelected = NULL; -} AG_ProcessMouseButtonUp(win, dev->data.button.x, dev->data.button.y, dev->data.button.which); < at >< at > -808,6 817,9 < at >< at > AG_ObjectUnlock(win); continue; } if (win != agWindowFocused) { agWindowToFocus = win; } if (win->wBorderBot > 0 && !(win->flags & AG_WINDOW_NORESIZE)) { dsw->winop = GenericMouseOverCtrl(win, < at >< at > -821,12 833,8 < at >< at > AG_ProcessMouseButtonDown(win, dev->data.button.x, dev->data.button.y, dev->data.button.which); -if (agWindowToFocus != NULL || - !TAILQ_EMPTY(&agWindowDetachQ)) { -AG_ObjectUnlock(win); -return (1); -} -break; AG_ObjectUnlock(win); return (1); case AG_DRIVER_KEY_UP: if (dsw->winLastKeydown != NULL && dsw->winLastKeydown != win) { < at >< at > -918,14 926,15 < at >< at > { AG_DriverEvent dev; AG_Driver *drv = AG_PTR(1); int rv = 0; -if (SDL_PollEvent(NULL) != 0 && - AG_SDL_GetNextEvent(drv, &dev) == 1) { -return AG_SDL_ProcessEvent(drv, &dev); if (SDL_PollEvent(NULL) != 0) { while (AG_SDL_GetNextEvent(drv, &dev) == 1) rv = AG_SDL_ProcessEvent(drv, &dev); } else { AG_Delay(1); -return (0); } return (0); } int AG_SDL_EventEpilogue(AG_EventSink *es, AG_Event *event) Modified: trunk/gui/drv_sdlfb.c =================================================================== --- trunk/gui/drv_sdlfb.c2015-05-24 07:29:24 UTC (rev 9790) trunk/gui/drv_sdlfb.c2015-05-24 08:19:54 UTC (rev 9791) < at >< at > -58,7 58,6 < at >< at > Init(void *obj) { AG_DriverSDLFB *sfb = obj; -AG_DriverSw *dsw = obj; sfb->s = NULL; sfb->nDirty = 0; < at >< at > -66,9 65,6 < at >< at > sfb->dirty = Malloc(sfb->maxDirty*sizeof(SDL_Rect)); sfb->clipRects = NULL; sfb->nClipRects = 0; - -dsw->rNom = 16; -dsw->rCur = 0; } static void < at >< at > -1242,7 1238,7 < at >< at > Verbose(_("SDLFB: Setting mode %ux%u (%d bpp)\n"), w, h, depth); newDepth = SDL_VideoModeOK(w, h, depth, sFlags); if (newDepth == 8) { -Verbose(_("Enabling hardware palette")); Verbose(_("SDLFB: Enabling hardware palette")); sFlags |= SDL_HWPALETTE; } if ((sfb->s = SDL_SetVideoMode((int)w, (int)h, newDepth, sFlags)) < at >< at > -1276,7 1272,6 < at >< at > goto fail; /* Set background color. */ -dsw->bgColor = AG_ColorFromString(AG_GetStringP(sfb,"bgColor"), NULL); SDL_FillRect(sfb->s, NULL, SDL_MapRGB(sfb->s->format, dsw->bgColor.r, dsw->bgColor.g, dsw->bgColor.b)); SDL_UpdateRect(sfb->s, 0, 0, (Sint32)w, (Sint32)h); < at >< at > -1437,7 1432,6 < at >< at > return (0); } - AG_DriverSwClass agDriverSDLFB = { { { Modified: trunk/gui/drv_sdlgl.c =================================================================== --- trunk/gui/drv_sdlgl.c2015-05-24 07:29:24 UTC (rev 9790) trunk/gui/drv_sdlgl.c2015-05-24 08:19:54 UTC (rev 9791) < at >< at > -53,7 53,7 < at >< at > Uint outLast;/* Terminate after this many frames */ Uint8 *outBuf;/* Output capture buffer */ Uint outJpegQual;/* Quality (%) for jpeg output */ -Uint outJpegFlags; Uint outJpegFlags;/* DCT options */ } AG_DriverSDLGL; static int nDrivers = 0;/* Opened driver instances */ < at >< at > -65,12 65,9 < at >< at > static void Init(void *obj) { -AG_DriverSw *dsw = obj; AG_DriverSDLGL *sgl = obj; sgl->s = NULL; -dsw->rNom = 16; -dsw->rCur = 0; } /* < at >< at > -256,7 253,7 < at >< at > } if ( sgl->outFrame == sgl->outLast) { -Verbose("Reached last frame; terminating\n"); Verbose("SDLGL: Reached last frame; terminating\n"); AG_Terminate(0); } AG_SurfaceFree(s); < at >< at > -264,7 261,7 < at >< at > fail: AG_SurfaceFree(s); fail_disable: -AG_Verbose("%s; disabling capture\n", AG_GetError()); Verbose("SDLGL: %s; disabling capture\n", AG_GetError()); sgl->outMode = AG_SDLGL_OUT_NONE; } < at >< at > -303,10 300,12 < at >< at > * Operations specific to single-display drivers. */ -static void static __inline__ void ClearBackground(AG_DriverSw *dsw) { -glClearColor(dsw->bgColor.r, dsw->bgColor.g, dsw->bgColor.b, 1.0); glClearColor(dsw->bgColor.r/255.0, dsw->bgColor.g/255.0, dsw->bgColor.b/255.0, 1.0); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); } < at >< at > -332,8 331,7 < at >< at > dsw->flags |= AG_DRIVER_SW_OVERLAY; if (flags & AG_VIDEO_BGPOPUPMENU) dsw->flags |= AG_DRIVER_SW_BGPOPUP; - -/* Apply the output capture settings. */ if (AG_Defined(drv, "out")) { char *ext; < at >< at > -364,21 362,20 < at >< at > sgl->outLast = atoi(buf); } } -} - -if (AG_Defined(drv, "jpegQual")) { -AG_GetString(drv, "jpegQual", buf, sizeof(buf)); -sgl->outJpegQual = atoi(buf); -} -if (AG_Defined(drv, "jpegDCT")) { -AG_GetString(drv, "jpegDCT", buf, sizeof(buf)); -if (Strcasecmp(buf, "islow")) { -sgl->outJpegFlags = AG_EXPORT_JPEG_JDCT_ISLOW; -} else if (Strcasecmp(buf, "ifast")) { -sgl->outJpegFlags = AG_EXPORT_JPEG_JDCT_IFAST; -} else if (Strcasecmp(buf, "float")) { -sgl->outJpegFlags = AG_EXPORT_JPEG_JDCT_FLOAT; if (AG_Defined(drv, "jpegQual")) { AG_GetString(drv, "jpegQual", buf, sizeof(buf)); sgl->outJpegQual = atoi(buf); } if (AG_Defined(drv, "jpegDCT")) { AG_GetString(drv, "jpegDCT", buf, sizeof(buf)); if (Strcasecmp(buf, "islow")) { sgl->outJpegFlags = AG_EXPORT_JPEG_JDCT_ISLOW; } else if (Strcasecmp(buf, "ifast")) { sgl->outJpegFlags = AG_EXPORT_JPEG_JDCT_IFAST; } else if (Strcasecmp(buf, "float")) { sgl->outJpegFlags = AG_EXPORT_JPEG_JDCT_FLOAT; } } } /* Set the video mode. Force hardware palette in 8bpp. */ < at >< at > -386,7 383,7 < at >< at > Verbose(_("SDLGL: Setting mode %ux%u (%d bpp)\n"), w, h, depth); newDepth = SDL_VideoModeOK(w, h, depth, sFlags); if (newDepth == 8) { -Verbose(_("Enabling hardware palette")); Verbose(_("SDLGL: Enabling hardware palette")); sFlags |= SDL_HWPALETTE; } if ((sgl->s = SDL_SetVideoMode((int)w, (int)h, newDepth, sFlags)) < at >< at > -412,9 409,6 < at >< at > AG_InitStockCursors(drv) == -1) goto fail; -/* Set background color. */ -dsw->bgColor = AG_ColorFromString(AG_GetStringP(drv,"bgColor"), NULL); - /* Initialize our OpenGL context and viewport. */ if (AG_GL_InitContext(sgl, &sgl->gl) == -1) { goto fail; < at >< at > -427,7 421,7 < at >< at > /* Initialize the output capture buffer. */ Free(sgl->outBuf); if ((sgl->outBuf = AG_TryMalloc(dsw->w*dsw->h*4)) == NULL) { -AG_Verbose("Out of memory for buffer; disabling capture\n"); Verbose("SDLGL: Out of memory; disabling capture\n"); sgl->outMode = AG_SDLGL_OUT_NONE; } < at >< at > -543,7 537,7 < at >< at > if (sgl->outBuf != NULL) { Free(sgl->outBuf); if ((sgl->outBuf = AG_TryMalloc(dsw->w*dsw->h*4)) == NULL) { -AG_Verbose("Out of memory for buffer; disabling capture\n"); Verbose("SDLGL: Out of memory; disabling capture\n"); sgl->outMode = AG_SDLGL_OUT_NONE; } } < at >< at > -584,8 578,7 < at >< at > static void SDLGL_VideoClear(void *obj, AG_Color c) { -glClearColor(c.r, c.g, c.b, 1.0); -glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); ClearBackground(obj); } static int Modified: trunk/gui/drv_sw.c =================================================================== --- trunk/gui/drv_sw.c2015-05-24 07:29:24 UTC (rev 9790) trunk/gui/drv_sw.c2015-05-24 08:19:54 UTC (rev 9791) < at >< at > -1,5 1,5 < at >< at > /* - * Copyright (c) 2009-2013 Hypertriton, Inc. <http://hypertriton.com/> * Copyright (c) 2009-2015 Hypertriton, Inc. <http://hypertriton.com/> * All rights reserved. * * Redistribution and use in source and binary forms, with or without < at >< at > -51,8 51,9 < at >< at > dsw->winop = AG_WINOP_NONE; dsw->winSelected = NULL; dsw->winLastKeydown = NULL; -dsw->rNom = 20; dsw->rNom = 1000/60; dsw->rCur = 0; dsw->rLast = 0; dsw->windowXOutLimit = 32; dsw->windowBotOutLimit = 32; dsw->windowIconWidth = 32; < at >< at > -60,7 61,7 < at >< at > if ((dsw->Lmodal = AG_ListNew()) == NULL) AG_FatalError(NULL); - AG_SetString(dsw, "bgColor", "rgb(0,0,0)"); } < at >< at > -223,6 224,7 < at >< at > WM_Move(AG_Window *win, int xRel, int yRel) { AG_DriverSw *dsw = (AG_DriverSw *)WIDGET(win)->drv; AG_DriverClass *dc = AGDRIVER_CLASS(dsw); AG_Rect rPrev, rNew; AG_Rect rFill1, rFill2; < at >< at > -237,50 239,51 < at >< at > AG_WidgetUpdateCoords(win, WIDGET(win)->x, WIDGET(win)->y); -/* Update the background. */ -/* XXX TODO Avoid drawing over KEEPABOVE windows */ -rNew.x = WIDGET(win)->x; -rNew.y = WIDGET(win)->y; -rNew.w = WIDTH(win); -rNew.h = HEIGHT(win); -rFill1.w = 0; -rFill2.w = 0; -if (rNew.x > rPrev.x) {/* Right */ -rFill1.x = rPrev.x; -rFill1.y = rPrev.y; -rFill1.w = rNew.x - rPrev.x; -rFill1.h = rNew.h; -} else if (rNew.x < rPrev.x) {/* Left */ -rFill1.x = rNew.x rNew.w; -rFill1.y = rNew.y; -rFill1.w = rPrev.x - rNew.x; -rFill1.h = rPrev.h; if (dc->type == AG_FRAMEBUFFER) { /* Update the background. */ rNew.x = WIDGET(win)->x; rNew.y = WIDGET(win)->y; rNew.w = WIDTH(win); rNew.h = HEIGHT(win); rFill1.w = 0; rFill2.w = 0; if (rNew.x > rPrev.x) {/* Right */ rFill1.x = rPrev.x; rFill1.y = rPrev.y; rFill1.w = rNew.x - rPrev.x; rFill1.h = rNew.h; } else if (rNew.x < rPrev.x) {/* Left */ rFill1.x = rNew.x rNew.w; rFill1.y = rNew.y; rFill1.w = rPrev.x - rNew.x; rFill1.h = rPrev.h; } if (rNew.y > rPrev.y) {/* Downward */ rFill2.x = rPrev.x; rFill2.y = rPrev.y; rFill2.w = rNew.w; rFill2.h = rNew.y - rPrev.y; } else if (rNew.y < rPrev.y) {/* Upward */ rFill2.x = rPrev.x; rFill2.y = rNew.y rNew.h; rFill2.w = rPrev.w; rFill2.h = rPrev.y - rNew.y; } if (rFill1.w > 0) { AGDRIVER_CLASS(dsw)->fillRect(dsw, rFill1, dsw->bgColor); if (AGDRIVER_CLASS(dsw)->updateRegion != NULL) AGDRIVER_CLASS(dsw)->updateRegion(dsw, rFill1); } if (rFill2.w > 0) { AGDRIVER_CLASS(dsw)->fillRect(dsw, rFill2, dsw->bgColor); if (AGDRIVER_CLASS(dsw)->updateRegion != NULL) AGDRIVER_CLASS(dsw)->updateRegion(dsw, rFill2); } } -if (rNew.y > rPrev.y) {/* Downward */ -rFill2.x = rPrev.x; -rFill2.y = rPrev.y; -rFill2.w = rNew.w; -rFill2.h = rNew.y - rPrev.y; -} else if (rNew.y < rPrev.y) {/* Upward */ -rFill2.x = rPrev.x; -rFill2.y = rNew.y rNew.h; -rFill2.w = rPrev.w; -rFill2.h = rPrev.y - rNew.y; -} - -if (rFill1.w > 0) { -AGDRIVER_CLASS(dsw)->fillRect(dsw, rFill1, dsw->bgColor); -if (AGDRIVER_CLASS(dsw)->updateRegion != NULL) -AGDRIVER_CLASS(dsw)->updateRegion(dsw, rFill1); -} -if (rFill2.w > 0) { -AGDRIVER_CLASS(dsw)->fillRect(dsw, rFill2, dsw->bgColor); -if (AGDRIVER_CLASS(dsw)->updateRegion != NULL) -AGDRIVER_CLASS(dsw)->updateRegion(dsw, rFill2); -} - win->dirty = 1; AG_WindowMovePinned(win, xRel, yRel); -win->dirty = 1; } /* Process a window resize operation initiated by the WM. */ < at >< at > -328,7 331,28 < at >< at > AG_WindowSetGeometry(win, x, y, w, h); } /* Start window move operation. */ void AG_WM_MoveBegin(AG_Window *win) { AG_DriverSw *dsw = (AG_DriverSw *)WIDGET(win)->drv; agWindowToFocus = win; dsw->winSelected = win; if (!(win->flags & AG_WINDOW_NOMOVE)) dsw->winop = AG_WINOP_MOVE; } /* Terminate window move operation. */ void AG_WM_MoveEnd(AG_Window *win) { AG_DriverSw *dsw = (AG_DriverSw *)WIDGET(win)->drv; dsw->winop = AG_WINOP_NONE; dsw->winSelected = NULL; } /* * Window-manager specific processing of mouse-motion events. This is * called by low-level event processing code whenever a WM operation is Modified: trunk/gui/drv_sw.h =================================================================== --- trunk/gui/drv_sw.h2015-05-24 07:29:24 UTC (rev 9790) trunk/gui/drv_sw.h2015-05-24 08:19:54 UTC (rev 9791) < at >< at > -56,6 56,7 < at >< at > #define AG_DRIVER_SW_OVERLAY0x01/* "Overlay" mode */ #define AG_DRIVER_SW_BGPOPUP0x02/* Enable generic background popup */ #define AG_DRIVER_SW_FULLSCREEN0x04/* Currently in full-screen mode */ #define AG_DRIVER_SW_REDRAW0x08/* Global redraw request */ struct ag_window *winSelected;/* Window being moved/resized/etc */ struct ag_window *winLastKeydown; /* For keyboard processing */ < at >< at > -69,6 70,7 < at >< at > Uint rNom;/* Nominal refresh rate (ms) */ int rCur;/* Effective refresh rate (ms) */ AG_Color bgColor;/* "bgColor" setting */ Uint rLast;/* Refresh rate timestamp */ } AG_DriverSw; #define AGDRIVER_SW(obj) ((AG_DriverSw *)(obj)) < at >< at > -91,6 93,8 < at >< at > void AG_WM_LimitWindowToDisplaySize(AG_Driver *, struct ag_size_alloc *); void AG_WM_GetPrefPosition(struct ag_window *, int *, int *, int, int); void AG_WM_MoveBegin(struct ag_window *); void AG_WM_MoveEnd(struct ag_window *); void AG_WM_MouseMotion(AG_DriverSw *, struct ag_window *, int, int); /* Blank the display background. */ Modified: trunk/gui/titlebar.c =================================================================== --- trunk/gui/titlebar.c2015-05-24 07:29:24 UTC (rev 9790) trunk/gui/titlebar.c2015-05-24 08:19:54 UTC (rev 9791) < at >< at > -135,27 135,19 < at >< at > tbar->pressed = 1; -if (AGDRIVER_SINGLE(WIDGET(tbar)->drv)) { -AG_DriverSw *dsw = (AG_DriverSw *)WIDGET(tbar)->drv; -agWindowToFocus = tbar->win; -dsw->winSelected = tbar->win; -if (!(tbar->win->flags & AG_WINDOW_NOMOVE)) -dsw->winop = AG_WINOP_MOVE; -} if (AGDRIVER_SINGLE(WIDGET(tbar)->drv)) AG_WM_MoveBegin(tbar->win); } static void MouseButtonUp(AG_Event *event) { AG_Titlebar *tbar = AG_SELF(); -AG_DriverSw *dsw = (AG_DriverSw *)WIDGET(tbar)->drv; tbar->pressed = 0; -if (AGDRIVER_SINGLE(dsw)) { -dsw->winop = AG_WINOP_NONE; -dsw->winSelected = NULL; -} if (AGDRIVER_SINGLE(WIDGET(tbar)->drv)) AG_WM_MoveEnd(tbar->win); } static void Modified: trunk/gui/window.c =================================================================== --- trunk/gui/window.c2015-05-24 07:29:24 UTC (rev 9790) trunk/gui/window.c2015-05-24 08:19:54 UTC (rev 9791) < at >< at > -960,6 960,67 < at >< at > AG_UnlockVFS(&agDrivers); } /* * Render all windows that need to be redrawn. This is typically invoked * by the main event loop, once events have been processed. */ void AG_WindowDrawQueued(void) { AG_Driver *drv; AG_Window *win; AG_LockVFS(&agDrivers); AGOBJECT_FOREACH_CHILD(drv, &agDrivers, ag_driver) { switch (AGDRIVER_CLASS(drv)->wm) { case AG_WM_MULTIPLE: if ((win = AGDRIVER_MW(drv)->win) != NULL) { AG_ObjectLock(win); if (win->visible && win->dirty) { AG_BeginRendering(drv); AGDRIVER_CLASS(drv)->renderWindow(win); AG_EndRendering(drv); win->dirty = 0; } AG_ObjectUnlock(win); } break; case AG_WM_SINGLE: { AG_DriverSw *dsw = (AG_DriverSw *)drv; Uint32 t; t = AG_GetTicks(); if ((t - dsw->rLast) < dsw->rNom) { AG_Delay(1); goto out; } dsw->rLast = t; AG_FOREACH_WINDOW(win, drv) { if (win->visible && win->dirty) break; } if (win != NULL || (dsw->flags & AG_DRIVER_SW_REDRAW)) { dsw->flags &= ~(AG_DRIVER_SW_REDRAW); AG_BeginRendering(drv); AG_FOREACH_WINDOW(win, drv) { AG_ObjectLock(win); AG_WindowDraw(win); AG_ObjectUnlock(win); } AG_EndRendering(drv); } } break; } } out: AG_UnlockVFS(&agDrivers); } /* Build an ordered list of the focusable widgets in a window. */ static void ListFocusableWidgets(AG_List *L, AG_Widget *wid) < at >< at > -1180,6 1241,7 < at >< at > AG_WindowSetGeometryRect(AG_Window *win, AG_Rect r, int bounded) { AG_Driver *drv = WIDGET(win)->drv; AG_DriverClass *dc = AGDRIVER_CLASS(drv); AG_SizeReq rWin; AG_SizeAlloc a; AG_Rect rPrev; < at >< at > -1243,7 1305,7 < at >< at > switch (AGDRIVER_CLASS(drv)->wm) { case AG_WM_SINGLE: -if (win->visible && !new) { if (dc->type == AG_FRAMEBUFFER && win->visible && !new) { UpdateWindowBG(win, rPrev); } break; < at >< at > -1949,7 2011,10 < at >< at > AGDRIVER_MW(drv)->flags &= ~(AG_DRIVER_MW_OPEN); } } else { -win->tbar = NULL;/* No longer safe to use */ AG_DriverSw *dsw = (AG_DriverSw *)drv; dsw->flags |= AG_DRIVER_SW_REDRAW; win->tbar = NULL;/* No longer safe */ win->icon = NULL; } Modified: trunk/gui/window.h =================================================================== --- trunk/gui/window.h2015-05-24 07:29:24 UTC (rev 9790) trunk/gui/window.h2015-05-24 08:19:54 UTC (rev 9791) < at >< at > -211,6 211,7 < at >< at > void AG_WindowMovePinned(AG_Window *, int, int); void AG_WindowShow(AG_Window *); void AG_WindowHide(AG_Window *); void AG_WindowDrawQueued(void); void AG_WindowResize(AG_Window *); void AG_WindowFocus(AG_Window *); < at >< at > -265,51 266,6 < at >< at > } /* - * Render all windows that need to be redrawn. This is typically invoked - * by the main event loop, once events have been processed. - */ -static __inline__ void -AG_WindowDrawQueued(void) -{ -AG_Driver *drv; -AG_Window *win; - -AG_LockVFS(&agDrivers); -AGOBJECT_FOREACH_CHILD(drv, &agDrivers, ag_driver) { -switch (AGDRIVER_CLASS(drv)->wm) { -case AG_WM_MULTIPLE: -if ((win = AGDRIVER_MW(drv)->win) != NULL) { -AG_ObjectLock(win); -if (win->visible && win->dirty) { -AG_BeginRendering(drv); -AGDRIVER_CLASS(drv)->renderWindow(win); -AG_EndRendering(drv); -win->dirty = 0; -} -AG_ObjectUnlock(win); -} -break; -case AG_WM_SINGLE: -AG_FOREACH_WINDOW(win, drv) { -if (win->visible && win->dirty) -break; -} -if (win != NULL) { -AG_BeginRendering(drv); -AG_FOREACH_WINDOW(win, drv) { -AG_ObjectLock(win); -AG_WindowDraw(win); -AG_ObjectUnlock(win); -} -AG_EndRendering(drv); -} -break; -} -} -AG_UnlockVFS(&agDrivers); -} - -/* * Return the effective focus state of a widget. * The Widget and agDrivers VFS must be locked. */ [Less]
Posted about 10 years ago by Agar-SVN
Author: vedge Date: 2015-05-24 03:29:24 -0400 (Sun, 24 May 2015) New Revision: 9790 Modified: trunk/gui/AG_Color.3 trunk/gui/colors.c Log: in AG_ColorFromString(), recognize new formats: "r,g,b[,a]", "r:g:b[:a]" and #rrggbb in hex. Modified: ... [More] trunk/gui/AG_Color.3 =================================================================== --- trunk/gui/AG_Color.32015-05-07 04:21:41 UTC (rev 9789) trunk/gui/AG_Color.32015-05-24 07:29:24 UTC (rev 9790) < at >< at > -1,4 1,4 < at >< at > -.\" Copyright (c) 2009 Hypertriton, Inc. <http://hypertriton.com/> .\" Copyright (c) 2009-2015 Hypertriton, Inc. <http://hypertriton.com/> .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without < at >< at > -84,11 84,21 < at >< at > .Pp The .Fn AG_ColorFromString -function parses a color specification of the form "rgb(r,g,b[,a])" or -"hsv(h,s,v[,a])", returning the corresponding color. -If function converts a text-based color representation to an .Nm . The following formats are allowed: .Bd -literal "#RRGGBB" "r:g:b[:a]" "r,g,b[,a]" "rgb(r,g,b[,a])" "hsv(h,s,v[,a])" .Ed .Pp If components are given with a terminating "%" character, they are interpreted as a percentage of the corresponding component in .Fa parentColor -is non-NULL, the components may be expressed as percent ratios. (assuming the argument is non-NULL). .Pp The .Fn AG_ColorCompare Modified: trunk/gui/colors.c =================================================================== --- trunk/gui/colors.c2015-05-07 04:21:41 UTC (rev 9789) trunk/gui/colors.c2015-05-24 07:29:24 UTC (rev 9790) < at >< at > -44,9 44,16 < at >< at > Sint8 agLowColorShift[3] = { -30, -30, -20 }; /* - * Parse a string color specification of the form "rgb(r,g,b[,a])" or - * "hsv(h,s,v[,a])". Color components may be specified as literal values - * or % of some parent color. * Parse a string color specification string. Acceptable forms include: * * r,g,b[,a] * r:g:b[:a] * rgb(r,g,b[,a]) * hsv(h,s,v[,a]) * #rrggbb * * If components are specified with a terminating "%" sign, they may be * interpreted as percent of some parent color. */ static __inline__ double ColorPct(Uint8 in, double v) < at >< at > -74,23 81,39 < at >< at > ;; } switch (*c) { -case 'r':/* rgb(r,g,b[,a]) */ case 'r':/* "rgb(r,g,b[,a])" */ break; -case 'h':/* hsv(h,s,v[,a]) */ case 'h':/* "hsv(h,s,v[,a])" */ isHSV = 1; break; -default: -return (cOut); case '#':/* "#rrggbb" */ { Uint32 hexVal; memmove(&c[2], &c[1], strlen(&c[1]) 1); c[0] = '0'; c[1] = 'x'; hexVal = (Uint32)strtoul(c, NULL, 16); cOut.r = (Uint8)((hexVal >> 16) & 0xff); cOut.g = (Uint8)((hexVal >> 8) & 0xff); cOut.b = (Uint8)((hexVal) & 0xff); return (cOut); } break; } -for (; *c != '\0' && *c != '('; c ) -;; -if (*c == '\0' || c[1] == '\0') { -goto out; if (*c == 'r' || *c == 'h') { for (; *c != '\0' && *c != '('; c ) ;; if (*c == '\0' || c[1] == '\0') { goto out; } pc = &c[1]; } else { pc = &c[0];/* Just "r,g,b[,a]" */ } -pc = &c[1]; for (i = 0, argc = 0; i < 4; i ) { char *tok, *ep; -if ((tok = AG_Strsep(&pc, ",")) == NULL) { if ((tok = AG_Strsep(&pc, ",:")) == NULL) { break; } v[i] = strtod(tok, &ep); [Less]
Posted about 10 years ago by Agar-SVN
Author: vedge Date: 2015-05-07 00:21:41 -0400 (Thu, 07 May 2015) New Revision: 9789 Modified: trunk/gui/gui.c Log: if bad driver is specified, return a list of available drivers in error message. Modified: trunk/gui/gui.c ... [More] =================================================================== --- trunk/gui/gui.c2015-05-04 07:11:41 UTC (rev 9788) trunk/gui/gui.c2015-05-07 04:21:41 UTC (rev 9789) < at >< at > -411,6 411,7 < at >< at > dc = agDriverList[i]; len = strlen(dc->name); if (strncmp(dc->name, tok, len) == 0 && (tok[len] == '\0' || tok[len] == '(') && (drv = AG_DriverOpen(dc)) != NULL) { sOpts = &tok[len]; break; < at >< at > -420,8 421,17 < at >< at > break; } if (tok == NULL) { -AG_SetError(_("Requested drivers (%s) are not " - "available"), specBuf); char availDrvs[256]; for (availDrvs[0] = '\0', i = 0; i < agDriverListSize; i ) { dc = agDriverList[i]; Strlcat(availDrvs, " ", sizeof(availDrvs)); Strlcat(availDrvs, dc->name, sizeof(availDrvs)); } AG_SetError(_("Agar driver is not available: \"%s\"\n" "(compiled-in drivers: <%s >)"), specBuf, availDrvs); goto fail; } } [Less]
Posted about 10 years ago by Agar-SVN
Author: vedge Date: 2015-03-18 23:24:12 -0400 (Wed, 18 Mar 2015) New Revision: 9787 Modified: trunk/tests/agartest.c Log: ignore the '-psn' argument passed to applications started by Finder on OSX. Modified: trunk/tests/agartest.c ... [More] =================================================================== --- trunk/tests/agartest.c2015-03-13 04:11:36 UTC (rev 9786) +++ trunk/tests/agartest.c2015-03-19 03:24:12 UTC (rev 9787) < at >< at > -455,8 +455,10 < at >< at > TAILQ_INIT(&tests); -while ((c = AG_Getopt(argc, argv, "?hd:t:", &optArg, &optInd)) != -1) { +while ((c = AG_Getopt(argc, argv, "p:?hd:t:", &optArg, &optInd)) != -1) { switch (c) { +case 'p': +break; case 'd': driverSpec = optArg; break; [Less]
Posted over 10 years ago by Agar-SVN
Author: vedge Date: 2015-03-13 00:11:36 -0400 (Fri, 13 Mar 2015) New Revision: 9786 Modified: trunk/gui/drv_cocoa.m Log: avoid referencing a bad drawable in PostResize; set up autorelease pool in Close and PostResize. Modified: ... [More] trunk/gui/drv_cocoa.m =================================================================== --- trunk/gui/drv_cocoa.m2015-03-06 04:53:57 UTC (rev 9785) +++ trunk/gui/drv_cocoa.m2015-03-13 04:11:36 UTC (rev 9786) < at >< at > -1,5 +1,5 < at >< at > /* - * Copyright (c) 2012-2013 Hypertriton, Inc. <http://hypertriton.com/> + * Copyright (c) 2012-2015 Hypertriton, Inc. <http://hypertriton.com/> * All rights reserved. * * Redistribution and use in source and binary forms, with or without < at >< at > -203,7 +203,7 < at >< at > _driver = co; _window = AGDRIVER_MW(co)->win; - + nc = [NSNotificationCenter defaultCenter]; if ([win delegate] != nil) { < at >< at > -236,7 +236,7 < at >< at > AG_DriverCocoa *co = _driver; NSWindow *win = co->win; NSView *view = [win contentView]; - + nc = [NSNotificationCenter defaultCenter]; if ([win delegate] != self) { < at >< at > -652,7 +652,7 < at >< at > case NSRightMouseDown: { AG_MouseButton btn = GetMouseButton([event buttonNumber]); - + AG_MouseButtonUpdate(drv->mouse, AG_BUTTON_PRESSED, btn); dev->type = AG_DRIVER_MOUSE_BUTTON_DOWN; dev->win = win; < at >< at > -823,7 +823,7 < at >< at > if (dev->win == NULL || dev->win->flags & AG_WINDOW_DETACHING) return (0); - + AG_LockVFS(&agDrivers); drv = WIDGET(dev->win)->drv; < at >< at > -887,10 +887,8 < at >< at > { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; -if (win->visible) { -[co->glCtx setView:[co->win contentView]]; -[co->glCtx update]; -} +[co->glCtx setView:[co->win contentView]]; +[co->glCtx update]; [co->glCtx makeCurrentContext]; [pool release]; < at >< at > -911,7 +909,7 < at >< at > AG_DriverCocoa *co = (AG_DriverCocoa *)WIDGET(win)->drv; AG_GL_Context *gl = &co->gl; AG_Color c = WCOLOR(win,0); - + gl->clipStates[0] = glIsEnabled(GL_CLIP_PLANE0); glEnable(GL_CLIP_PLANE0); gl->clipStates[1] = glIsEnabled(GL_CLIP_PLANE1); glEnable(GL_CLIP_PLANE1); gl->clipStates[2] = glIsEnabled(GL_CLIP_PLANE2); glEnable(GL_CLIP_PLANE2); < at >< at > -931,7 +929,7 < at >< at > AG_DriverCocoa *co = obj; AG_GL_Context *gl = &co->gl; Uint i; - + [co->glCtx flushBuffer]; /* Remove textures and display lists queued for deletion. */ < at >< at > -1047,9 +1045,6 < at >< at > /* Set our event listener. */ [co->evListener listen:co]; -/* Get the visibility status. */ -win->visible = [co->win isVisible]; - /* Retrieve the effective style flags. */ winStyle = [co->win styleMask]; if (winStyle == NSBorderlessWindowMask) { < at >< at > -1083,10 +1078,6 < at >< at > } pfAttr[i++] = NSOpenGLPFADoubleBuffer; if (agStereo) { pfAttr[i++] = NSOpenGLPFAStereo; } -#if 0 -pfAttr[i++] = NSOpenGLPFAScreenMask; -pfAttr[i++] = CGDisplayIDToOpenGLDisplayMask(display); -#endif pfAttr[i] = 0; pf = [[NSOpenGLPixelFormat alloc] initWithAttributes:pfAttr]; if (pf == nil) { < at >< at > -1099,7 +1090,8 < at >< at > AG_SetError("Cannot create NSOpenGLContext"); goto fail; } -COCOA_GL_MakeCurrent(co, win); +[co->glCtx update]; +[co->glCtx makeCurrentContext]; if (AG_GL_InitContext(co, &co->gl) == -1) goto fail; < at >< at > -1150,6 +1142,7 < at >< at > { AG_Driver *drv = WIDGET(win)->drv; AG_DriverCocoa *co = (AG_DriverCocoa *)drv; +NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; AG_MutexLock(&co->lock); < at >< at > -1175,6 +1168,7 < at >< at > drv->videoFmt = NULL; AG_MutexUnlock(&co->lock); +[pool release]; } static int < at >< at > -1302,6 +1296,7 < at >< at > static void COCOA_PostResizeCallback(AG_Window *win, AG_SizeAlloc *a) { +NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; AG_Driver *drv = WIDGET(win)->drv; AG_DriverCocoa *co = (AG_DriverCocoa *)drv; int x = a->x; < at >< at > -1317,7 +1312,7 < at >< at > AG_WidgetUpdateCoords(win, 0, 0); /* The viewport coordinates have changed. */ -COCOA_GL_MakeCurrent(co, win); +[co->glCtx makeCurrentContext]; AG_GL_SetViewport(&co->gl, AG_RECT(0, 0, WIDTH(win), HEIGHT(win))); #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 < at >< at > -1344,6 +1339,8 < at >< at > /* Save the new effective window position. */ WIDGET(win)->x = a->x = x; WIDGET(win)->y = a->y = y; + +[pool release]; } static void [Less]