Posted
over 8 years
ago
by
Agar-SVN
Author: vedge
Date: 2015-11-02 02:04:20 -0500 (Mon, 02 Nov 2015)
New Revision: 9832
Modified:
trunk/gui/drv_cocoa.m
Log:
use makeMainWindow() on main windows
Modified: trunk/gui/drv_cocoa.m
... [More]
===================================================================
--- trunk/gui/drv_cocoa.m2015-09-12 11:01:22 UTC (rev 9831)
+++ trunk/gui/drv_cocoa.m2015-11-02 07:04:20 UTC (rev 9832)
< at >< at > -1032,6 +1032,9 < at >< at >
co->win->_agarWindow = win;
SetBackgroundColor(co, WCOLOR(win,0));
+if (win->flags & AG_WINDOW_MAIN)
+[co->win makeMainWindow];
+
/* Create an event listener. */
co->evListener = [[AG_CocoaListener alloc] init];
[Less]
|
Posted
over 8 years
ago
by
Agar-SVN
Author: vedge
Date: 2015-09-12 07:01:22 -0400 (Sat, 12 Sep 2015)
New Revision: 9831
Modified:
trunk/vg/vg_tool.c
trunk/vg/vg_view.c
Log:
use AG_SetVoidFn()
Modified: trunk/vg/vg_tool.c
... [More]
===================================================================
--- trunk/vg/vg_tool.c2015-09-12 11:01:14 UTC (rev 9830)
trunk/vg/vg_tool.c2015-09-12 11:01:22 UTC (rev 9831)
< at >< at > -1,5 1,5 < at >< at >
/*
- * Copyright (c) 2004-2009 Hypertriton, Inc. <http://hypertriton.com/>
* Copyright (c) 2004-2015 Hypertriton, Inc. <http://hypertriton.com/>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
< at >< at > -157,7 157,7 < at >< at >
Debug(tool->vgv, "%s: CMD: <%s>\n", tool->ops->name, name);
AG_EventInit(&evPost);
AG_EVENT_GET_ARGS(&evPost, fmt);
-cmd->fn->handler(&evPost);
cmd->fn->fn.fnVoid(&evPost);
AG_ObjectUnlock(tool->vgv);
return (0);
Modified: trunk/vg/vg_view.c
===================================================================
--- trunk/vg/vg_view.c2015-09-12 11:01:14 UTC (rev 9830)
trunk/vg/vg_view.c2015-09-12 11:01:22 UTC (rev 9831)
< at >< at > -1,5 1,5 < at >< at >
/*
- * Copyright (c) 2005-2010 Hypertriton, Inc. <http://hypertriton.com/>
* Copyright (c) 2005-2015 Hypertriton, Inc. <http://hypertriton.com/>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
< at >< at > -143,8 143,8 < at >< at >
return;
}
if (vv->btndown_ev != NULL)
-AG_PostEvent(NULL, vv, vv->btndown_ev->name,
- "%i,%f,%f", button, x, y);
AG_PostEventByPtr(NULL, vv, vv->btndown_ev, "%i,%f,%f",
button, x, y);
}
static void
< at >< at > -175,7 175,7 < at >< at >
return;
}
if (vv->btnup_ev != NULL) {
-AG_PostEvent(NULL, vv, vv->btnup_ev->name, "%i,%f,%f",
AG_PostEventByPtr(NULL, vv, vv->btnup_ev, "%i,%f,%f",
button, x, y);
AG_Redraw(vv);
}
< at >< at > -207,7 207,7 < at >< at >
TAILQ_FOREACH(cmd, &tool->cmds, cmds) {
if (cmd->kSym == sym &&
(cmd->kMod == AG_KEYMOD_NONE || mod & cmd->kMod)) {
-AG_PostEvent(NULL, tool->vgv, cmd->fn->name, "%p", tool);
AG_PostEventByPtr(NULL, tool->vgv, cmd->fn, "%p", tool);
AG_Redraw(vv);
}
}
< at >< at > -445,7 445,7 < at >< at >
VG_ViewDrawFn(VG_View *vv, AG_EventFn fn, const char *fmt, ...)
{
AG_ObjectLock(vv);
-vv->draw_ev = AG_SetEvent(vv, NULL, fn, NULL);
vv->draw_ev = AG_SetVoidFn(vv, fn, NULL);
AG_EVENT_GET_ARGS(vv->draw_ev, fmt);
AG_ObjectUnlock(vv);
}
< at >< at > -455,7 455,7 < at >< at >
VG_ViewScaleFn(VG_View *vv, AG_EventFn fn, const char *fmt, ...)
{
AG_ObjectLock(vv);
-vv->scale_ev = AG_SetEvent(vv, NULL, fn, NULL);
vv->scale_ev = AG_SetVoidFn(vv, fn, NULL);
AG_EVENT_GET_ARGS(vv->scale_ev, fmt);
AG_ObjectUnlock(vv);
}
< at >< at > -485,7 485,7 < at >< at >
VG_ViewButtondownFn(VG_View *vv, AG_EventFn fn, const char *fmt, ...)
{
AG_ObjectLock(vv);
-vv->btndown_ev = AG_SetEvent(vv, NULL, fn, NULL);
vv->btndown_ev = AG_SetVoidFn(vv, fn, NULL);
AG_EVENT_GET_ARGS(vv->btndown_ev, fmt);
AG_ObjectUnlock(vv);
}
< at >< at > -637,7 637,7 < at >< at >
vv->curtool->ops->predraw(vv->curtool, vv);
}
if (vv->draw_ev != NULL) {
-vv->draw_ev->handler(vv->draw_ev);
vv->draw_ev->fn.fnVoid(vv->draw_ev);
}
if (vv->curtool != NULL && vv->curtool->ops->postdraw != NULL) {
vv->curtool->ops->postdraw(vv->curtool, vv);
[Less]
|
Posted
over 8 years
ago
by
Agar-SVN
Author: vedge
Date: 2015-09-12 06:59:44 -0400 (Sat, 12 Sep 2015)
New Revision: 9828
Modified:
trunk/gui/AG_Menu.3
trunk/gui/console.c
trunk/gui/editable.c
trunk/gui/graph.c
trunk/gui/menu.c
trunk/gui/menu.h
trunk/gui/menu_view.c
... [More]
trunk/gui/widget.c
trunk/gui/widget.h
Log:
- Make AG_MenuExpand() and AG_MenuCollapse() more efficient: hide and reuse
MenuView windows instead of recreating them.
- AG_MenuItem: allow dynamically-determined states with stateFn.
Modified: trunk/gui/AG_Menu.3
===================================================================
--- trunk/gui/AG_Menu.32015-09-12 03:09:52 UTC (rev 9827)
trunk/gui/AG_Menu.32015-09-12 10:59:44 UTC (rev 9828)
< at >< at > -418,7 418,7 < at >< at >
given widget is destroyed.
.Pp
Once a popup menu is created, new items can be inserted using the
-.Va item
.Va root
member of the
.Ft AG_PopupMenu
structure as parent.
< at >< at > -460,7 460,7 < at >< at >
For the
.Ft AG_MenuItem
structure:
-.Bl -tag -width "AG_MenuItem *subitems "
.Bl -tag -width "int (*stateFn)(AG_Event *)"
.It Ft char *text
Displayed text for the menu item (read-only, set by
.Fn AG_MenuSetLabel ) .
< at >< at > -477,8 477,12 < at >< at >
.Fn AG_MenuSetIntBool ) ,
this value is ignored.
.It Ft int state
-If this flag is set (the default), the item is "enabled".
-Otherwise, the user is not allowed to select the item.
Make item clickable (1) or disabled (0).
.It Ft int (*stateFn)(AG_Event *)
Evaluate function to determine if item is active.
Overrides the
.Va state
flag.
.It Ft AG_Menu *pmenu
Back pointer to the parent
.Ft AG_Menu
< at >< at > -485,6 489,36 < at >< at >
(read-only).
.El
.Sh EXAMPLES
The following code fragment creates a popup menu with a disabled item:
.Bd -literal -offset indent
AG_PopupMenu *pm;
AG_MenuItem *mi;
pm = AG_PopupNew(myParentWidget);
AG_MenuAction(pm->root, "Copy", NULL, DoCopy, NULL);
mi = AG_MenuAction(pm->root, "Paste", NULL, DoPaste, NULL);
mi->state = (myClipboard->contents > 0);
.Ed
.Pp
The following code fragment creates a popup menu with a dynamically
determined "disabled" state:
.Bd -literal -offset indent
static int
PasteActive(AG_Event *event)
{
Clipboard *C = AG_PTR(1);
return (C->contents > 0);
}
AG_PopupMenu *pm;
AG_MenuItem *mi;
pm = AG_PopupNew(myParentWidget);
AG_MenuAction(pm->root, "Copy", NULL, DoCopy, NULL);
mi = AG_MenuAction(pm->root, "Paste", NULL, DoPaste, NULL);
mi->stateFn = AG_SetIntFn(pm->menu, PasteActive, "%p", myClipboard);
.Ed
.Pp
The following code fragment associates a menu with an
.Xr AG_Toolbar 3 .
Buttons and menu entries are created for the same actions.
Modified: trunk/gui/console.c
===================================================================
--- trunk/gui/console.c2015-09-12 03:09:52 UTC (rev 9827)
trunk/gui/console.c2015-09-12 10:59:44 UTC (rev 9828)
< at >< at > -318,15 318,15 < at >< at >
if ((pm = cons->pm = AG_PopupNew(cons)) == NULL) {
return;
}
-mi = AG_MenuAction(pm->item, _("Copy"), NULL, MenuCopy, "%p", cons);
mi = AG_MenuAction(pm->root, _("Copy"), NULL, MenuCopy, "%p", cons);
mi->stateFn = AG_SetIntFn(pm->menu, MenuCopyActive, "%p", cons);
-AG_MenuAction(pm->item, _("Export to file..."), NULL,
AG_MenuAction(pm->root, _("Export to file..."), NULL,
MenuExportToFileDlg, "%p", cons);
-AG_MenuSeparator(pm->item);
AG_MenuSeparator(pm->root);
-AG_MenuAction(pm->item, _("Select All"), NULL,
AG_MenuAction(pm->root, _("Select All"), NULL,
MenuSelectAll, "%p", cons);
AG_PopupShowAt(pm, x, y);
Modified: trunk/gui/editable.c
===================================================================
--- trunk/gui/editable.c2015-09-12 03:09:52 UTC (rev 9827)
trunk/gui/editable.c2015-09-12 10:59:44 UTC (rev 9828)
< at >< at > -1,5 1,5 < at >< at >
/*
- * Copyright (c) 2002-2012 Hypertriton, Inc. <http://hypertriton.com/>
* Copyright (c) 2002-2015 Hypertriton, Inc. <http://hypertriton.com/>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
< at >< at > -547,6 547,17 < at >< at >
}
static void
OnHide(AG_Event *event)
{
AG_Editable *ed = AG_SELF();
if (ed->pm != NULL) {
AG_PopupHide(ed->pm);
}
OnFocusLoss(event);
}
static void
OnFontChange(AG_Event *event)
{
AG_Editable *ed = AG_SELF();
< at >< at > -1292,6 1303,13 < at >< at >
ReleaseBuffer(ed, buf);
}
}
static int
MenuCutActive(AG_Event *event)
{
AG_Editable *ed = AG_PTR(1);
return (!AG_EditableReadOnly(ed) && ed->sel != 0);
}
static void
MenuCopy(AG_Event *event)
{
< at >< at > -1303,6 1321,13 < at >< at >
ReleaseBuffer(ed, buf);
}
}
static int
MenuCopyActive(AG_Event *event)
{
AG_Editable *ed = AG_PTR(1);
return (ed->sel != 0);
}
static void
MenuPaste(AG_Event *event)
{
< at >< at > -1316,6 1341,13 < at >< at >
ReleaseBuffer(ed, buf);
}
}
static int
MenuPasteActive(AG_Event *event)
{
AG_Editable *ed = AG_PTR(1);
return !AG_EditableReadOnly(ed) && agEditableClipbrd.len > 0;
}
static void
MenuDelete(AG_Event *event)
{
< at >< at > -1329,6 1361,13 < at >< at >
ReleaseBuffer(ed, buf);
}
}
static int
MenuDeleteActive(AG_Event *event)
{
AG_Editable *ed = AG_PTR(1);
return (!AG_EditableReadOnly(ed) && ed->sel != 0);
}
static void
MenuSelectAll(AG_Event *event)
{
< at >< at > -1352,7 1391,7 < at >< at >
PopupMenu(AG_Editable *ed)
{
AG_PopupMenu *pm;
-AG_MenuItem *m;
AG_MenuItem *mi;
AG_Variable *vText;
AG_Text *txt;
< at >< at > -1359,16 1398,19 < at >< at >
if ((pm = AG_PopupNew(ed)) == NULL) {
return (NULL);
}
-m = AG_MenuAction(pm->item, _("Cut"), NULL, MenuCut, "%p", ed);
-m->state = (!AG_EditableReadOnly(ed) && ed->sel != 0);
-m = AG_MenuAction(pm->item, _("Copy"), NULL, MenuCopy, "%p", ed);
-m->state = (ed->sel != 0);
-m = AG_MenuAction(pm->item, _("Paste"), NULL, MenuPaste, "%p", ed);
-m->state = (!AG_EditableReadOnly(ed) && agEditableClipbrd.len > 0);
-m = AG_MenuAction(pm->item, _("Delete"), NULL, MenuDelete, "%p", ed);
-m->state = (!AG_EditableReadOnly(ed) && ed->sel != 0);
-AG_MenuSeparator(pm->item);
-AG_MenuAction(pm->item, _("Select All"), NULL, MenuSelectAll, "%p", ed);
mi = AG_MenuAction(pm->root, _("Cut"), NULL, MenuCut, "%p", ed);
mi->stateFn = AG_SetIntFn(pm->menu, MenuCutActive, "%p", ed);
mi = AG_MenuAction(pm->root, _("Copy"), NULL, MenuCopy, "%p", ed);
mi->stateFn = AG_SetIntFn(pm->menu, MenuCopyActive, "%p", ed);
mi = AG_MenuAction(pm->root, _("Paste"), NULL, MenuPaste, "%p", ed);
mi->stateFn = AG_SetIntFn(pm->menu, MenuPasteActive, "%p", ed);
mi = AG_MenuAction(pm->root, _("Delete"), NULL, MenuDelete, "%p", ed);
mi->stateFn = AG_SetIntFn(pm->menu, MenuDeleteActive, "%p", ed);
AG_MenuSeparator(pm->root);
AG_MenuAction(pm->root, _("Select All"), NULL, MenuSelectAll, "%p", ed);
if ((ed->flags & AG_EDITABLE_MULTILINGUAL) &&
AG_Defined(ed, "text") &&
(vText = AG_GetVariable(ed, "text", &txt)) != NULL) {
< at >< at > -1375,8 1417,8 < at >< at >
AG_MenuItem *mLang;
int i;
-AG_MenuSeparator(pm->item);
-mLang = AG_MenuNode(pm->item, _("Select Language"), NULL);
AG_MenuSeparator(pm->root);
mLang = AG_MenuNode(pm->root, _("Select Language"), NULL);
for (i = 0; i < AG_LANG_LAST; i ) {
AG_TextEnt *te = &txt->ent[i];
< at >< at > -1416,8 1458,7 < at >< at >
switch (btn) {
case AG_MOUSE_LEFT:
if (ed->pm != NULL) {
-AG_PopupDestroy(ed, ed->pm);
-ed->pm = NULL;
AG_PopupHide(ed->pm);
}
ed->flags |= AG_EDITABLE_CURSOR_MOVING|AG_EDITABLE_BLINK_ON;
mx = ed->x;
< at >< at > -1440,10 1481,11 < at >< at >
case AG_MOUSE_RIGHT:
if ((ed->flags & AG_EDITABLE_NOPOPUP) == 0) {
if (ed->pm != NULL) {
-AG_PopupDestroy(ed, ed->pm);
AG_PopupShowAt(ed->pm, mx, my);
} else {
if ((ed->pm = PopupMenu(ed)) != NULL)
AG_PopupShowAt(ed->pm, mx,my);
}
-if ((ed->pm = PopupMenu(ed)) != NULL)
-AG_PopupShowAt(ed->pm, mx,my);
}
break;
case AG_MOUSE_WHEELUP:
< at >< at > -1809,7 1851,7 < at >< at >
AG_SetEvent(ed, "bound", OnBindingChange, NULL);
AG_AddEvent(ed, "font-changed", OnFontChange, NULL);
-AG_AddEvent(ed, "widget-hidden", OnFocusLoss, NULL);
AG_AddEvent(ed, "widget-hidden", OnHide, NULL);
AG_SetEvent(ed, "widget-lostfocus", OnFocusLoss, NULL);
AG_SetEvent(ed, "key-down", KeyDown, NULL);
AG_SetEvent(ed, "key-up", KeyUp, NULL);
< at >< at > -1841,9 1883,12 < at >< at >
{
AG_Editable *ed = obj;
if (ed->pm != NULL) {
AG_PopupDestroy(ed->pm);
}
if (ed->flags & AG_EDITABLE_EXCL)
Free(ed->sBuf.s);
-
AG_TextFree(ed->text);
}
Modified: trunk/gui/graph.c
===================================================================
--- trunk/gui/graph.c2015-09-12 03:09:52 UTC (rev 9827)
trunk/gui/graph.c2015-09-12 10:59:44 UTC (rev 9828)
< at >< at > -405,14 405,13 < at >< at >
AG_PopupShowAt(vtx->popupMenu, x,y);
} else {
pm = AG_PopupNew(gf);
-AG_MenuUintFlags(pm->item, _("Hide vertex"),
- NULL,
AG_MenuUintFlags(pm->root, _("Hide vertex"), NULL,
&vtx->flags, AG_GRAPH_HIDDEN, 1);
-AG_MenuSeparator(pm->item);
-AG_MenuAction(pm->item, _("Rectangular"), NULL,
AG_MenuSeparator(pm->root);
AG_MenuAction(pm->root, _("Rectangular"), NULL,
SetVertexStyle, "%p,%i", vtx,
AG_GRAPH_RECTANGLE);
-AG_MenuAction(pm->item, _("Circular"), NULL,
AG_MenuAction(pm->root, _("Circular"), NULL,
SetVertexStyle, "%p,%i", vtx,
AG_GRAPH_CIRCLE);
AG_PopupShowAt(pm, x,y);
< at >< at > -427,7 426,7 < at >< at >
AG_PopupShowAt(edge->popupMenu, x,y);
} else {
pm = AG_PopupNew(gf);
-AG_MenuUintFlags(pm->item, _("Hide edge"), NULL,
AG_MenuUintFlags(pm->root, _("Hide edge"), NULL,
&edge->flags, AG_GRAPH_HIDDEN, 1);
AG_PopupShowAt(pm, x,y);
}
Modified: trunk/gui/menu.c
===================================================================
--- trunk/gui/menu.c2015-09-12 03:09:52 UTC (rev 9827)
trunk/gui/menu.c2015-09-12 10:59:44 UTC (rev 9828)
< at >< at > -122,31 122,27 < at >< at >
}
static void
-ModalClose(AG_Event *event)
MenuCollapseAll(AG_Event *event)
{
AG_Menu *m = AG_PTR(1);
-int x = AG_INT(2);
-int y = AG_INT(3);
-
AG_MenuCollapseAll(m);
-m->itemSel = NULL;
-m->selecting = 0;
-if (AG_WidgetArea(m, x, y))
-m->flags |= AG_MENU_MODALCLOSED;
}
-/* Create a child window with a MenuView for the specified menu item. */
/*
* Expand an AG_MenuItem. Create a window containing the AG_MenuView
* at coordinates x1,y1 (relative to widget parent).
*
* The associated AG_Menu object must be locked.
*/
AG_Window *
AG_MenuExpand(void *parent, AG_MenuItem *mi, int x1, int y1)
{
AG_Window *win, *winParent;
-AG_MenuView *mv;
AG_Menu *m;
int x = x1;
int y = y1;
if (parent != NULL) {
-/* XXX AG_Menu and AG_MenuView should share subclasses */
if (AG_OfClass(parent, "AG_Widget:AG_MenuView")) {
m = ((AG_MenuView *)parent)->pmenu;
} else if (AG_OfClass(parent, "AG_Widget:AG_Menu")) {
< at >< at > -157,7 153,7 < at >< at >
x = WIDGET(parent)->rView.x1;
y = WIDGET(parent)->rView.y1;
if ((winParent = WIDGET(parent)->window) == NULL) {
-return (NULL);
AG_FatalError("AG_MenuExpand: %s has no window", OBJECT(parent)->name);
}
if (WIDGET(winParent)->drv != NULL &&
AGDRIVER_MULTIPLE(WIDGET(winParent)->drv)) {
< at >< at > -175,8 171,15 < at >< at >
if (mi->nSubItems == 0)
return (NULL);
if (mi->view != NULL) {
win = WIDGET(mi->view)->window;
AG_WindowSetGeometry(win, x, y, -1, -1);
AG_WindowShow(win);
return (win);
}
win = AG_WindowNew(
- AG_WINDOW_MODAL|AG_WINDOW_NOTITLE|AG_WINDOW_NOBORDERS|
AG_WINDOW_NOTITLE|AG_WINDOW_NOBORDERS|
AG_WINDOW_NORESIZE|AG_WINDOW_DENYFOCUS|AG_WINDOW_KEEPABOVE);
if (win == NULL) {
return (NULL);
< at >< at > -187,17 190,16 < at >< at >
AG_ObjectSetName(win, "_Popup-%s",
(parent != NULL) ? OBJECT(parent)->name : "generic");
AG_WindowSetPadding(win, 0, 0, 0, 0);
-AG_SetEvent(win, "window-modal-close", ModalClose, "%p", m);
-mv = Malloc(sizeof(AG_MenuView));
-AG_ObjectInit(mv, &agMenuViewClass);
-mv->pmenu = m;
-mv->pitem = mi;
-AG_ObjectAttach(win, mv);
AG_SetEvent(win, "window-modal-close", MenuCollapseAll, "%p", m);
AG_SetEvent(win, "window-close", MenuCollapseAll, "%p", m);
mi->view = Malloc(sizeof(AG_MenuView));
AG_ObjectInit(mi->view, &agMenuViewClass);
mi->view->pmenu = m;
mi->view->pitem = mi;
AG_ObjectAttach(win, mi->view);
-/* Attach the MenuItem to this view. */
-mi->view = mv;
-
if (winParent != NULL) {
AG_WindowAttach(winParent, win);
AG_WindowMakeTransient(winParent, win);
< at >< at > -208,29 210,6 < at >< at >
return (win);
}
-static void
-MenuWindowDetached(AG_Event *event)
-{
-AG_Menu *m = AG_PTR(1);
-AG_MenuItem *mi = AG_PTR(2);
-AG_MenuItem *miSub;
-Uint j;
-
-AG_ObjectLock(m);
-
-mi->view = NULL;
-mi->sel_subitem = NULL;/* Loose selection */
-
-/* The surface handles are no longer valid. */
-TAILQ_FOREACH(miSub, &mi->subItems, items) {
-for (j = 0; j < 2; j ) {
-miSub->lblView[j] = -1;
-}
-miSub->icon = -1;
-}
-AG_ObjectUnlock(m);
-}
-
/*
* Collapse the window displaying the specified item and its sub-menus
* (if any).
< at >< at > -240,7 219,6 < at >< at >
{
AG_Menu *m;
AG_MenuItem *miSub;
-AG_Window *miWin;
if (mi == NULL || mi->view == NULL || (m = mi->pmenu) == NULL)
return;
< at >< at > -247,17 225,14 < at >< at >
AG_ObjectLock(m);
-/* Collapse any expanded submenus as well. */
-TAILQ_FOREACH(miSub, &mi->subItems, items) {
-if (miSub->view != NULL)
-AG_MenuCollapse(miSub);
TAILQ_FOREACH(miSub, &mi->subItems, items)
AG_MenuCollapse(miSub);
if (mi->view != NULL) {
AG_WindowHide(WIDGET(mi->view)->window);
}
mi->sel_subitem = NULL;
-/* Destroy the MenuView's window. */
-miWin = WIDGET(mi->view)->window;
-AG_ObjectDetach(miWin);
-AG_SetEvent(miWin, "window-detached", MenuWindowDetached, "%p,%p", m, mi);
-
AG_ObjectUnlock(m);
}
< at >< at > -313,6 288,26 < at >< at >
AG_Redraw(m);
}
static __inline__ int
IntersectItem(AG_MenuItem *mi, int x, int y, int *hLbl)
{
AG_Menu *m = mi->pmenu;
int lbl, wLbl;
lbl = (mi->lblMenu[1] != -1) ? mi->lblMenu[1] :
(mi->lblMenu[0] != -1) ? mi->lblMenu[0] :
-1;
if (lbl != -1) {
wLbl = WSURFACE(m,lbl)->w m->lPadLbl m->rPadLbl;
*hLbl = WSURFACE(m,lbl)->h m->tPadLbl m->bPadLbl;
} else {
wLbl = 0;
*hLbl = 0;
}
return (x >= mi->x && x < (mi->x wLbl) &&
y >= mi->y && y < (mi->y m->itemh));
}
static void
MouseButtonDown(AG_Event *event)
{
< at >< at > -320,45 315,31 < at >< at >
int x = AG_INT(2);
int y = AG_INT(3);
AG_MenuItem *mi;
int hLbl;
if (m->root == NULL)
return;
-if (m->flags & AG_MENU_MODALCLOSED) {
-m->flags &= ~(AG_MENU_MODALCLOSED);
-return;
-}
TAILQ_FOREACH(mi, &m->root->subItems, items) {
-int lbl = (mi->lblMenu[1] != -1) ? mi->lblMenu[1] :
- (mi->lblMenu[0] != -1) ? mi->lblMenu[0] :
- -1;
-int wLbl, hLbl;
-
-if (lbl == -1) { continue; }
-wLbl = WSURFACE(m,lbl)->w m->lPadLbl m->rPadLbl;
-hLbl = WSURFACE(m,lbl)->h m->tPadLbl m->bPadLbl;
-
-if (x >= mi->x &&
- x < (mi->x wLbl) &&
- y >= mi->y &&
- y < (mi->y m->itemh)) {
- if (m->itemSel == mi) {
-AG_MenuCollapse(mi);
-m->itemSel = NULL;
-m->selecting = 0;
-} else {
-if (m->itemSel != NULL) {
-AG_MenuCollapse(m->itemSel);
-}
-m->itemSel = mi;
-AG_MenuExpand(m, mi,
- mi->x,
- mi->y hLbl m->bPad - 1);
-m->selecting = 1;
if (!IntersectItem(mi, x, y, &hLbl)) {
continue;
}
if (m->itemSel == mi) {
AG_MenuCollapse(mi);
m->itemSel = NULL;
m->selecting = 0;
} else {
if (m->itemSel != NULL) {
AG_MenuCollapse(m->itemSel);
}
-AG_Redraw(m);
-break;
m->itemSel = mi;
AG_MenuExpand(m, mi,
mi->x,
mi->y hLbl m->bPad - 1);
m->selecting = 1;
}
AG_Redraw(m);
break;
}
}
< at >< at > -369,39 350,27 < at >< at >
int x = AG_INT(1);
int y = AG_INT(2);
AG_MenuItem *mi;
int hLbl;
-if (!m->selecting || y < 0 || y >= HEIGHT(m)-1)
if (!m->selecting || y < 0 || y >= HEIGHT(m)-1 ||
m->root == NULL)
return;
-if (m->root == NULL) {
-return;
-}
TAILQ_FOREACH(mi, &m->root->subItems, items) {
-int lbl = (mi->lblMenu[1] != -1) ? mi->lblMenu[1] :
- (mi->lblMenu[0] != -1) ? mi->lblMenu[0] :
- -1;
-int wLbl, hLbl;
-
-if (lbl == -1) { continue; }
-wLbl = WSURFACE(m,lbl)->w m->lPadLbl m->rPadLbl;
-hLbl = WSURFACE(m,lbl)->h m->tPadLbl m->bPadLbl;
-
-if (x >= mi->x &&
- x < (mi->x wLbl) &&
- y >= mi->y &&
- y < (mi->y m->itemh)) {
- if (mi != m->itemSel) {
-if (m->itemSel != NULL) {
-AG_MenuCollapse(m->itemSel);
-}
-m->itemSel = mi;
-AG_MenuExpand(m, mi,
- mi->x,
- mi->y hLbl m->bPad - 1);
if (!IntersectItem(mi, x, y, &hLbl)) {
continue;
}
if (mi != m->itemSel) {
if (m->itemSel != NULL) {
AG_MenuCollapse(m->itemSel);
}
-AG_Redraw(m);
-break;
m->itemSel = mi;
AG_MenuExpand(m, mi,
mi->x,
mi->y hLbl m->bPad - 1);
}
AG_Redraw(m);
break;
}
}
< at >< at > -411,7 380,6 < at >< at >
AG_Widget *pwid = AG_SENDER();
AG_Window *pwin;
-/* Adjust the top padding of the parent window if any. */
if ((pwin = AG_ParentWindow(pwid)) != NULL)
AG_WindowSetPadding(pwin, -1, -1, 0, pwin->bPad);
}
< at >< at > -425,6 393,7 < at >< at >
mi = Malloc(sizeof(AG_MenuItem));
mi->parent = miParent;
mi->stateFn = NULL;
if (miParent != NULL) {
m = mi->pmenu = miParent->pmenu;
< at >< at > -1072,7 1041,7 < at >< at >
if (mi->poll != NULL) {
InvalidateLabelSurfaces(mi);
AG_MenuItemFreeChildren(mi);
-AG_PostEvent(mi, m, mi->poll->name, NULL);
AG_PostEventByPtr(mi, m, mi->poll, NULL);
}
AG_ObjectUnlock(m);
}
< at >< at > -1115,12 1084,13 < at >< at >
AG_PushClipRect(m, m->r);
TAILQ_FOREACH(mi, &m->root->subItems, items) {
-if (mi->state) {
int activeState = mi->stateFn ? mi->stateFn->fn.fnInt(mi->stateFn) :
mi->state;
if (activeState) {
if (mi->lblMenu[1] == -1) {
AG_TextColor(WCOLOR(m,TEXT_COLOR));
mi->lblMenu[1] = (mi->text == NULL) ? -1 :
- AG_WidgetMapSurface(m,
- AG_TextRender(mi->text));
AG_WidgetMapSurface(m, AG_TextRender(mi->text));
}
lbl = mi->lblMenu[1];
} else {
< at >< at > -1127,8 1097,7 < at >< at >
if (mi->lblMenu[0] == -1) {
AG_TextColor(WCOLOR_DIS(m,TEXT_COLOR));
mi->lblMenu[0] = (mi->text == NULL) ? -1 :
- AG_WidgetMapSurface(m,
- AG_TextRender(mi->text));
AG_WidgetMapSurface(m, AG_TextRender(mi->text));
}
lbl = mi->lblMenu[0];
}
< at >< at > -1254,14 1223,12 < at >< at >
pm->widget = wid;
pm->menu = AG_MenuNew(NULL, 0);
pm->menu->style = AG_MENU_POPUP;
-WIDGET(pm->menu)->window = wid->window;/* For AG_MenuExpand() */
-pm->item = AG_MenuNode(pm->menu->root, NULL, NULL);
-pm->menu->itemSel = pm->item;
pm->root = AG_MenuNode(pm->menu->root, NULL, NULL);
pm->menu->itemSel = pm->root;
pm->win = NULL;
-
-AG_ObjectLock(wid);
-SLIST_INSERT_HEAD(&wid->menus, pm, menus);
-AG_ObjectUnlock(wid);
#ifdef AG_LEGACY
pm->item = pm->root;
#endif
return (pm);
}
< at >< at > -1270,12 1237,10 < at >< at >
{
AG_Driver *drv;
AG_Window *winParent;
-int x, y;
int x = 0, y = 0;
AG_LockVFS(pm->widget);
-if (pm->win != NULL) {
-AG_PopupHide(pm);
-}
if ((drv = WIDGET(pm->widget)->drv) != NULL &&
(winParent = AG_ParentWindow(pm->widget)) != NULL) {
x = drv->mouse->x;
< at >< at > -1284,8 1249,11 < at >< at >
x -= WIDGET(winParent)->x;
y -= WIDGET(winParent)->y;
}
-pm->win = AG_MenuExpand(winParent, pm->item, x, y);
AG_ObjectLock(pm->menu);
pm->win = AG_MenuExpand(winParent, pm->root, x, y);
AG_ObjectUnlock(pm->menu);
}
AG_UnlockVFS(pm->widget);
}
< at >< at > -1293,39 1261,36 < at >< at >
AG_PopupShowAt(AG_PopupMenu *pm, int x, int y)
{
AG_LockVFS(pm->widget);
-if (pm->win != NULL) {
-AG_PopupHide(pm);
-}
-pm->win = AG_MenuExpand(pm->widget, pm->item, x, y);
AG_ObjectLock(pm->menu);
pm->win = AG_MenuExpand(pm->widget, pm->root, x, y);
AG_ObjectUnlock(pm->menu);
AG_UnlockVFS(pm->widget);
}
static void
PopupHideAll(AG_MenuItem *mi)
{
AG_MenuItem *miSub;
if (mi->view != NULL) {
AG_WindowHide(WIDGET(mi->view)->window);
}
TAILQ_FOREACH(miSub, &mi->subItems, items)
PopupHideAll(miSub);
}
void
AG_PopupHide(AG_PopupMenu *pm)
{
AG_ObjectLock(pm->menu);
-if (pm->win != NULL) {
-AG_MenuCollapse(pm->item);
-pm->win = NULL;
-}
PopupHideAll(pm->root);
AG_ObjectUnlock(pm->menu);
}
void
-AG_PopupDestroy(void *obj, AG_PopupMenu *pm)
AG_PopupDestroy(AG_PopupMenu *pm)
{
-if (obj != NULL) {
-AG_ObjectLock(obj);
-SLIST_REMOVE(&WIDGET(obj)->menus, pm, ag_popup_menu, menus);
-AG_ObjectUnlock(obj);
-}
-if (pm->menu != NULL) {
-AG_MenuCollapse(pm->item);
-AG_ObjectDestroy(pm->menu);
-}
-pm->menu = NULL;
-pm->item = NULL;
-pm->win = NULL;
AG_ObjectDestroy(pm->menu);
free(pm);
}
Modified: trunk/gui/menu.h
===================================================================
--- trunk/gui/menu.h2015-09-12 03:09:52 UTC (rev 9827)
trunk/gui/menu.h2015-09-12 10:59:44 UTC (rev 9828)
< at >< at > -22,8 22,10 < at >< at >
int icon;/* Icon surface mapping */
AG_Surface *iconSrc;/* Icon surface source */
int value;/* Default bool value binding */
-int state;/* Default state flag binding */
int state;/* State flag */
AG_Function *stateFn;/* State function (overrides flag) */
AG_KeySym key_equiv;/* Key shortcut */
AG_KeyMod key_mod;
int x, y;/* Position in parent view */
< at >< at > -72,7 74,6 < at >< at >
#define AG_MENU_HFILL 0x01
#define AG_MENU_VFILL 0x02
#define AG_MENU_EXPAND (AG_MENU_HFILL|AG_MENU_VFILL)
-#define AG_MENU_MODALCLOSED0x08/* Last closed by modal click */
enum ag_menu_style style;/* Menu style */
AG_MenuItem *root;/* Root menu item */
int selecting;/* Selection in progress */
< at >< at > -89,11 90,13 < at >< at >
} AG_Menu;
typedef struct ag_popup_menu {
-AG_Widget *widget;/* Parent widget */
-AG_Menu *menu;/* Menu (allocated) */
-AG_MenuItem *item;/* Root item (allocated) */
-AG_Window *win;/* Expanded window */
-AG_SLIST_ENTRY(ag_popup_menu) menus;
AG_Widget *widget;/* Parent widget */
AG_Menu *menu;/* Menu (allocated) */
AG_MenuItem *root;/* Alias for menu->root */
AG_Window *win;/* Expanded window */
#ifdef AG_LEGACY
AG_MenuItem *item;
#endif
} AG_PopupMenu;
typedef struct ag_menu_view {
< at >< at > -125,7 128,7 < at >< at >
void AG_PopupShow(AG_PopupMenu *);
void AG_PopupShowAt(AG_PopupMenu *, int, int);
void AG_PopupHide(AG_PopupMenu *);
-void AG_PopupDestroy(void *, AG_PopupMenu *);
void AG_PopupDestroy(AG_PopupMenu *);
void AG_MenuDel(AG_MenuItem *);
void AG_MenuItemFree(AG_MenuItem *);
< at >< at > -227,7 230,6 < at >< at >
AG_MenuSetIntBoolMp((mi),(p),(fl),(inv),(mtx))
void AG_MenuSetIntFlagsMp(AG_MenuItem *, int *, int, int, AG_Mutex *);
-
#ifdef AG_LEGACY
# define AG_MenuAddItem(m,lbl) AG_MenuNode((m)->root,(lbl),NULL)
#endif /* AG_LEGACY */
Modified: trunk/gui/menu_view.c
===================================================================
--- trunk/gui/menu_view.c2015-09-12 03:09:52 UTC (rev 9827)
trunk/gui/menu_view.c2015-09-12 10:59:44 UTC (rev 9828)
< at >< at > -189,7 189,7 < at >< at >
MouseButtonUp(AG_Event *event)
{
AG_MenuView *mview = AG_SELF();
-AG_MenuItem *mi = mview->pitem, *miSub;
AG_MenuItem *miRoot = mview->pitem, *mi;
AG_Menu *m = mview->pmenu;
int mx = AG_INT(2);
int my = AG_INT(3);
< at >< at > -199,23 199,25 < at >< at >
my < 0 || my >= HEIGHT(mview)) {
return;
}
-TAILQ_FOREACH(miSub, &mi->subItems, items) {
-AG_MenuUpdateItem(miSub);
TAILQ_FOREACH(mi, &miRoot->subItems, items) {
AG_MenuUpdateItem(mi);
y = m->itemh;
if (my < y && mx >= 0 && mx <= WIDTH(mview)) {
-if (miSub->state == 0) {
int activeState = mi->stateFn ? mi->stateFn->fn.fnInt(mi->stateFn) :
mi->state;
if (!activeState) {
/* Nothing to do */
-} else if (miSub->clickFn != NULL) {
} else if (mi->clickFn != NULL) {
AG_MenuCollapseAll(m);
-AG_ExecEventFn(m, miSub->clickFn);
-} else if (miSub->bind_type != AG_MENU_NO_BINDING) {
-if (miSub->bind_lock != NULL) {
-AG_MutexLock(miSub->bind_lock);
mi->clickFn->fn.fnVoid(mi->clickFn);
} else if (mi->bind_type != AG_MENU_NO_BINDING) {
if (mi->bind_lock != NULL) {
AG_MutexLock(mi->bind_lock);
}
-SetItemBoolValue(miSub);
-if (miSub->bind_lock != NULL) {
-AG_MutexUnlock(miSub->bind_lock);
SetItemBoolValue(mi);
if (mi->bind_lock != NULL) {
AG_MutexUnlock(mi->bind_lock);
}
AG_MenuCollapseAll(m);
}
< at >< at > -283,50 285,49 < at >< at >
static void
Draw(void *obj)
{
-AG_MenuView *mview = obj;
-AG_MenuItem *mi = mview->pitem, *item;
-AG_Menu *m = mview->pmenu;
-AG_Font *font = WIDGET(mview)->font;
AG_MenuView *mv = obj;
AG_MenuItem *miRoot = mv->pitem, *mi;
AG_Menu *m = mv->pmenu;
AG_Font *font = WIDGET(mv)->font;
AG_Rect r;
r.x = 0;
-r.y = mview->tPad;
-r.w = WIDTH(mview);
r.y = mv->tPad;
r.w = WIDTH(mv);
r.h = m->itemh;
-TAILQ_FOREACH(item, &mi->subItems, items) {
-int x = mview->lPad;
TAILQ_FOREACH(mi, &miRoot->subItems, items) {
int x = mv->lPad;
AG_Color C;
int boolState;
int activeState = mi->stateFn ? mi->stateFn->fn.fnInt(mi->stateFn) :
mi->state;
/* Update dynamic item if needed. */
-AG_MenuUpdateItem(item);
AG_MenuUpdateItem(mi);
/* Indicate active item selection */
-if (item == mi->sel_subitem && item->state == 1)
-AG_DrawRect(mview, r, WCOLOR_SEL(m,0));
if (mi == miRoot->sel_subitem && activeState)
AG_DrawRect(mv, r, WCOLOR_SEL(mv,0));
/* Render the menu item's icon */
-if (item->icon == -1 &&
- item->iconSrc != NULL) {
-item->icon = AG_WidgetMapSurface(mview,
- AG_SurfaceDup(item->iconSrc));
if (mi->icon == -1 && mi->iconSrc != NULL) {
mi->icon = AG_WidgetMapSurface(mv, AG_SurfaceDup(mi->iconSrc));
}
-if (item->icon != -1) {
-AG_WidgetBlitSurface(mview, item->icon,
- x (r.h/2 - item->iconSrc->w/2),
- r.y (r.h/2 - item->iconSrc->h/2) 1);
if (mi->icon != -1) {
AG_WidgetBlitSurface(mv, mi->icon,
x (r.h/2 - mi->iconSrc->w/2),
r.y (r.h/2 - mi->iconSrc->h/2) 1);
/* Indicate boolean state */
-boolState = (item->value != -1) ? item->value :
- GetItemBoolValue(item);
boolState = (mi->value != -1) ? mi->value : GetItemBoolValue(mi);
if (boolState) {
C = AG_ColorRGB(223,207,128);
-AG_DrawFrame(mview,
AG_DrawFrame(mv,
AG_RECT(x, r.y 2, r.h, r.h-2),
1, C);
C.a = 64;
-AG_DrawRectBlended(mview,
AG_DrawRectBlended(mv,
AG_RECT(x, r.y 2, r.h, r.h-2),
C, AG_ALPHA_SRC);
}
< at >< at > -333,53 334,52 < at >< at >
}
/* Keep columns aligned if there are icons. */
-if (mi->flags & AG_MENU_ITEM_ICONS)
-x = m->itemh mview->spIconLbl;
if (miRoot->flags & AG_MENU_ITEM_ICONS)
x = m->itemh mv->spIconLbl;
-if (item->flags & AG_MENU_ITEM_SEPARATOR) {
-int x1 = mview->lPad;
-int x2 = WIDTH(mview) - mview->rPad - 1;
if (mi->flags & AG_MENU_ITEM_SEPARATOR) {
int x1 = mv->lPad;
int x2 = WIDTH(mv) - mv->rPad - 1;
AG_Color c[2];
-c[0] = AG_ColorShift(WCOLOR(mview,0), agLowColorShift);
-c[1] = AG_ColorShift(WCOLOR(mview,0), agHighColorShift);
c[0] = AG_ColorShift(WCOLOR(mv,0), agLowColorShift);
c[1] = AG_ColorShift(WCOLOR(mv,0), agHighColorShift);
-AG_DrawLineH(mview, x1, x2, (r.y m->itemh/2 - 1), c[0]);
-AG_DrawLineH(mview, x1, x2, (r.y m->itemh/2), c[1]);
AG_DrawLineH(mv, x1, x2, (r.y m->itemh/2 - 1), c[0]);
AG_DrawLineH(mv, x1, x2, (r.y m->itemh/2), c[1]);
} else {
-int lbl = item->state ? item->lblView[1] :
- item->lblView[0];
int lbl = activeState ? mi->lblView[1] : mi->lblView[0];
/* Render the menu item's text string */
-if (item->state == 1) {
-if (item->lblView[1] == -1) {
-AG_TextColor(WCOLOR(m,TEXT_COLOR));
-item->lblView[1] =
- (item->text == NULL) ? -1 :
- AG_WidgetMapSurface(mview,
- AG_TextRender(item->text));
if (activeState) {
if (mi->lblView[1] == -1) {
AG_TextColor(WCOLOR(mv,TEXT_COLOR));
mi->lblView[1] =
(mi->text == NULL) ? -1 :
AG_WidgetMapSurface(mv,
AG_TextRender(mi->text));
}
-lbl = item->lblView[1];
lbl = mi->lblView[1];
} else {
-if (item->lblView[0] == -1) {
-AG_TextColor(WCOLOR_DIS(m,TEXT_COLOR));
-item->lblView[0] =
- (item->text == NULL) ? -1 :
- AG_WidgetMapSurface(mview,
- AG_TextRender(item->text));
if (mi->lblView[0] == -1) {
AG_TextColor(WCOLOR_DIS(mv,TEXT_COLOR));
mi->lblView[0] =
(mi->text == NULL) ? -1 :
AG_WidgetMapSurface(mv,
AG_TextRender(mi->text));
}
-lbl = item->lblView[0];
lbl = mi->lblView[0];
}
-AG_WidgetBlitSurface(mview, lbl,
AG_WidgetBlitSurface(mv, lbl,
x,
r.y m->itemh/2 - font->height/2 1);
-x = WSURFACE(mview,lbl)->w;
x = WSURFACE(mv,lbl)->w;
}
/* Render the submenu arrow. */
-if (item->nSubItems > 0) {
-x = mview->spLblArrow;
-AG_WidgetBlitSurface(mview, mview->arrowRight,
if (mi->nSubItems > 0) {
x = mv->spLblArrow;
AG_WidgetBlitSurface(mv, mv->arrowRight,
x,
r.y m->itemh/2 - agIconSmallArrowRight.s->h/2 -1);
}
Modified: trunk/gui/widget.c
===================================================================
--- trunk/gui/widget.c2015-09-12 03:09:52 UTC (rev 9827)
trunk/gui/widget.c2015-09-12 10:59:44 UTC (rev 9828)
< at >< at > -32,7 32,6 < at >< at >
#include <agar/gui/widget.h>
#include <agar/gui/window.h>
#include <agar/gui/cursors.h>
-#include <agar/gui/menu.h>
#include <agar/gui/primitive.h>
#include <agar/gui/gui_math.h>
#include <agar/gui/opengl.h>
< at >< at > -315,7 314,6 < at >< at >
wid->y = -1;
wid->w = -1;
wid->h = -1;
-SLIST_INIT(&wid->menus);
wid->focusFwd = NULL;
wid->window = NULL;
wid->drv = NULL;
< at >< at > -681,7 679,7 < at >< at >
switch (a->type) {
case AG_ACTION_FN:
if (a->fn != NULL) {
-AG_ExecEventFn(obj, a->fn);
a->fn->fn.fnVoid(a->fn);
return (1);
}
return (0);
< at >< at > -740,8 738,8 < at >< at >
return (0);
}
if (a->fn != NULL) {
-AG_PostEvent(NULL, wid, a->fn->name, "%i,%i,%i",
- button, xCurs, yCurs);
AG_PostEventByPtr(NULL, wid, a->fn, "%i,%i,%i", button,
xCurs, yCurs);
return (1);
}
return (0);
< at >< at > -928,7 926,6 < at >< at >
{
AG_Widget *wid = obj;
AG_CursorArea *ca, *caNext;
-AG_PopupMenu *pm, *pmNext;
AG_RedrawTie *rt, *rtNext;
AG_ActionTie *at, *atNext;
AG_Variable *V;
< at >< at > -940,12 937,6 < at >< at >
caNext = TAILQ_NEXT(ca, cursorAreas);
free(ca);
}
-for (pm = SLIST_FIRST(&wid->menus);
- pm != SLIST_END(&wid->menus);
- pm = pmNext) {
-pmNext = SLIST_NEXT(pm, menus);
-AG_PopupDestroy(NULL, pm);
-}
for (rt = TAILQ_FIRST(&wid->redrawTies);
rt != TAILQ_END(&wid->redrawTies);
rt = rtNext) {
Modified: trunk/gui/widget.h
===================================================================
--- trunk/gui/widget.h2015-09-12 03:09:52 UTC (rev 9827)
trunk/gui/widget.h2015-09-12 10:59:44 UTC (rev 9828)
< at >< at > -160,7 160,6 < at >< at >
#define AG_WCOLOR_SEL(wid,which) AGWIDGET(wid)->pal.c[AG_SELECTED_STATE][which]
struct ag_font;
-struct ag_popup_menu;
/* Widget instance structure */
typedef struct ag_widget {
< at >< at > -202,7 201,6 < at >< at >
Uint *textures;/* Cached textures (driver-specific) */
AG_TexCoord *texcoords;/* Cached texture coordinates */
-AG_SLIST_HEAD_(ag_popup_menu) menus;/* Managed menus */
struct ag_widget *focusFwd;/* For ForwardFocus() */
struct ag_window *window;/* Back ptr to parent window */
struct ag_driver *drv;/* Back ptr to driver */
[Less]
|
Posted
almost 9 years
ago
by
Agar-SVN
Author: vedge
Date: 2015-09-11 23:09:52 -0400 (Fri, 11 Sep 2015)
New Revision: 9827
Modified:
trunk/gui/dir_dlg.c
trunk/gui/glview.c
trunk/gui/scrollbar.c
trunk/gui/socket.c
trunk/gui/table.c
trunk/gui/tlist.c
Log:
handle
... [More]
user-specified callbacks more efficiently with AG_PostEventByPtr()..
Modified: trunk/gui/dir_dlg.c
===================================================================
--- trunk/gui/dir_dlg.c2015-09-12 03:08:04 UTC (rev 9826)
trunk/gui/dir_dlg.c2015-09-12 03:09:52 UTC (rev 9827)
< at >< at > -359,7 359,7 < at >< at >
AG_ObjectLock(dd);
if (dd->okAction != NULL) {
-AG_PostEvent(NULL, dd, dd->okAction->name, "%s", dd->cwd);
AG_PostEventByPtr(NULL, dd, dd->okAction, "%s", dd->cwd);
} else {
CheckAccessAndChoose(dd);
}
< at >< at > -574,7 574,7 < at >< at >
AG_ObjectLock(dd);
if (dd->cancelAction != NULL) {
-AG_PostEvent(NULL, dd, dd->cancelAction->name, NULL);
AG_PostEventByPtr(NULL, dd, dd->cancelAction, NULL);
} else if (dd->flags & AG_DIRDLG_CLOSEWIN) {
if ((pwin = AG_ParentWindow(dd)) != NULL) {
/*AG_PostEvent(NULL, pwin, "window-close", NULL); */
Modified: trunk/gui/glview.c
===================================================================
--- trunk/gui/glview.c2015-09-12 03:08:04 UTC (rev 9826)
trunk/gui/glview.c2015-09-12 03:09:52 UTC (rev 9827)
< at >< at > -235,7 235,7 < at >< at >
glMatrixMode(GL_PROJECTION);glPushMatrix(); glLoadIdentity();
if (glv->scale_ev != NULL) {
-glv->scale_ev->handler(glv->scale_ev);
glv->scale_ev->fn.fnVoid(glv->scale_ev);
}
glGetFloatv(GL_PROJECTION_MATRIX, glv->mProjection);
glGetFloatv(GL_MODELVIEW_MATRIX, glv->mModelview);
< at >< at > -288,7 288,7 < at >< at >
glv->bgColor);
}
if (glv->underlay_ev != NULL)
-glv->underlay_ev->handler(glv->underlay_ev);
glv->underlay_ev->fn.fnVoid(glv->underlay_ev);
glPushAttrib(GL_TRANSFORM_BIT | GL_VIEWPORT_BIT);
< at >< at > -330,7 330,7 < at >< at >
glDisable(GL_CLIP_PLANE3);
if (glv->draw_ev != NULL)
-glv->draw_ev->handler(glv->draw_ev);
glv->draw_ev->fn.fnVoid(glv->draw_ev);
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
< at >< at > -344,7 344,7 < at >< at >
if (glv->overlay_ev != NULL) {
glPushAttrib(GL_TRANSFORM_BIT);
-glv->overlay_ev->handler(glv->overlay_ev);
glv->overlay_ev->fn.fnVoid(glv->overlay_ev);
glPopAttrib();
}
}
Modified: trunk/gui/scrollbar.c
===================================================================
--- trunk/gui/scrollbar.c2015-09-12 03:08:04 UTC (rev 9826)
trunk/gui/scrollbar.c2015-09-12 03:09:52 UTC (rev 9827)
< at >< at > -344,10 344,10 < at >< at >
AG_DelTimer(sb, &sb->moveTo);
if (sb->curBtn == AG_SCROLLBAR_BUTTON_DEC && sb->buttonDecFn != NULL) {
-AG_PostEvent(NULL, sb, sb->buttonDecFn->name, "%i", 0);
AG_PostEventByPtr(NULL, sb, sb->buttonDecFn, "%i", 0);
}
if (sb->curBtn == AG_SCROLLBAR_BUTTON_INC && sb->buttonIncFn != NULL) {
-AG_PostEvent(NULL, sb, sb->buttonIncFn->name, "%i", 0);
AG_PostEventByPtr(NULL, sb, sb->buttonIncFn, "%i", 0);
}
if (sb->curBtn != AG_SCROLLBAR_BUTTON_NONE) {
< at >< at > -418,7 418,7 < at >< at >
if (x < 0) {/* Decrement */
sb->curBtn = AG_SCROLLBAR_BUTTON_DEC;
if (sb->buttonDecFn != NULL) {
-AG_PostEvent(NULL, sb, sb->buttonDecFn->name, "%i", 1);
AG_PostEventByPtr(NULL, sb, sb->buttonDecFn, "%i", 1);
} else {
if (Decrement(sb) != 1) {
sb->xSeek = -1;
< at >< at > -429,7 429,7 < at >< at >
} else if (x > totsize - sb->width*2) {/* Increment */
sb->curBtn = AG_SCROLLBAR_BUTTON_INC;
if (sb->buttonIncFn != NULL) {
-AG_PostEvent(NULL, sb, sb->buttonIncFn->name, "%i", 1);
AG_PostEventByPtr(NULL, sb, sb->buttonIncFn, "%i", 1);
} else {
if (Increment(sb) != 1) {
sb->xSeek = -1;
Modified: trunk/gui/socket.c
===================================================================
--- trunk/gui/socket.c2015-09-12 03:08:04 UTC (rev 9826)
trunk/gui/socket.c2015-09-12 03:09:52 UTC (rev 9827)
< at >< at > -134,10 134,7 < at >< at >
AG_SocketOverlayFn(AG_Socket *sock, AG_EventFn fn, const char *fmt, ...)
{
AG_ObjectLock(sock);
-if (sock->overlayFn != NULL) {
-AG_UnsetEvent(sock->overlayFn, sock->overlayFn->name);
-}
-sock->overlayFn = AG_SetEvent(sock, NULL, fn, NULL);
sock->overlayFn = AG_SetVoidFn(sock, fn, NULL);
AG_EVENT_GET_ARGS(sock->overlayFn, fmt);
AG_ObjectUnlock(sock);
}
< at >< at > -261,8 258,7 < at >< at >
AGWIDGET_OPS(sock->icon)->draw(sock->icon);
}
if (sock->overlayFn != NULL) {
-AG_PostEvent(NULL, sock->overlayFn, sock->overlayFn->name,
- NULL);
AG_PostEventByPtr(NULL, sock, sock->overlayFn, NULL);
} else {
switch (sock->bgType) {
case AG_SOCKET_PIXMAP:
Modified: trunk/gui/table.c
===================================================================
--- trunk/gui/table.c2015-09-12 03:08:04 UTC (rev 9826)
trunk/gui/table.c2015-09-12 03:09:52 UTC (rev 9827)
< at >< at > -57,7 57,7 < at >< at >
{
AG_Table *t = AG_SELF();
-t->poll_ev->handler(t->poll_ev);
t->poll_ev->fn.fnVoid(t->poll_ev);
if (t->mOffs t->mVis >= t->m) {
t->mOffs = MAX(0, t->m - t->mVis);
}
Modified: trunk/gui/tlist.c
===================================================================
--- trunk/gui/tlist.c2015-09-12 03:08:04 UTC (rev 9826)
trunk/gui/tlist.c2015-09-12 03:09:52 UTC (rev 9827)
< at >< at > -911,7 911,7 < at >< at >
if (!it->selected) {
it->selected = 1;
if (tl->changedEv != NULL) {
-AG_PostEvent(NULL, tl, tl->changedEv->name, "%p,%i",
AG_PostEventByPtr(NULL, tl, tl->changedEv, "%p,%i",
it, 1);
}
AG_PostEvent(NULL, tl, "tlist-changed", "%p, %i", it, 1);
< at >< at > -933,7 933,7 < at >< at >
if (it->selected) {
it->selected = 0;
if (tl->changedEv != NULL) {
-AG_PostEvent(NULL, tl, tl->changedEv->name, "%p,%i",
AG_PostEventByPtr(NULL, tl, tl->changedEv, "%p,%i",
it, 0);
}
AG_PostEvent(NULL, tl, "tlist-changed", "%p, %i", it, 0);
< at >< at > -1075,7 1075,7 < at >< at >
if (tl->dblClicked != NULL && tl->dblClicked == ti->p1) {
AG_DelTimer(tl, &tl->dblClickTo);
if (tl->dblClickEv != NULL) {
-AG_PostEvent(NULL, tl, tl->dblClickEv->name,
AG_PostEventByPtr(NULL, tl, tl->dblClickEv,
"%p", ti);
}
AG_PostEvent(NULL, tl, "tlist-dblclick", "%p", ti);
< at >< at > -1091,7 1091,7 < at >< at >
return;
}
if (tl->popupEv != NULL) {
-AG_PostEvent(NULL, tl, tl->popupEv->name, NULL);
AG_PostEventByPtr(NULL, tl, tl->popupEv, NULL);
} else if (ti->cat != NULL) {
AG_TlistPopup *tp;
< at >< at > -1380,29 1380,28 < at >< at >
}
void
-AG_TlistSetDblClickFn(AG_Tlist *tl, void (*ev)(AG_Event *), const char *fmt,
- ...)
AG_TlistSetDblClickFn(AG_Tlist *tl, AG_EventFn fn, const char *fmt, ...)
{
AG_ObjectLock(tl);
-tl->dblClickEv = AG_SetEvent(tl, NULL, ev, NULL);
tl->dblClickEv = AG_SetVoidFn(tl, fn, NULL);
AG_EVENT_GET_ARGS(tl->dblClickEv, fmt);
AG_ObjectUnlock(tl);
}
void
-AG_TlistSetPopupFn(AG_Tlist *tl, void (*ev)(AG_Event *), const char *fmt, ...)
AG_TlistSetPopupFn(AG_Tlist *tl, AG_EventFn fn, const char *fmt, ...)
{
AG_ObjectLock(tl);
-tl->popupEv = AG_SetEvent(tl, NULL, ev, NULL);
tl->popupEv = AG_SetVoidFn(tl, fn, NULL);
AG_EVENT_GET_ARGS(tl->popupEv, fmt);
AG_ObjectUnlock(tl);
}
void
-AG_TlistSetChangedFn(AG_Tlist *tl, void (*ev)(AG_Event *), const char *fmt, ...)
AG_TlistSetChangedFn(AG_Tlist *tl, AG_EventFn fn, const char *fmt, ...)
{
AG_ObjectLock(tl);
-tl->changedEv = AG_SetEvent(tl, NULL, ev, NULL);
tl->changedEv = AG_SetVoidFn(tl, fn, NULL);
AG_EVENT_GET_ARGS(tl->changedEv, fmt);
AG_ObjectUnlock(tl);
}
[Less]
|
Posted
almost 9 years
ago
by
Agar-SVN
Author: vedge
Date: 2015-09-11 23:06:06 -0400 (Fri, 11 Sep 2015)
New Revision: 9825
Modified:
trunk/gui/AG_Window.3
trunk/gui/window.c
trunk/gui/window.h
Log:
when AG_WindowProcessDetachQueue() encounters visible windows, allow an
extra
... [More]
event cycle between implicit Hide and ultimate Detach/Destroy.
Modified: trunk/gui/AG_Window.3
===================================================================
--- trunk/gui/AG_Window.32015-09-12 02:56:18 UTC (rev 9824)
trunk/gui/AG_Window.32015-09-12 03:06:06 UTC (rev 9825)
< at >< at > -556,9 556,6 < at >< at >
.Ft int
.Fn AG_WindowIsVisible "AG_Window *win"
.Pp
-.Ft int
-.Fn AG_WindowIntersect "AG_DriverSw *drv" "int x" "int y"
-.Pp
.nr nS 0
Newly created windows are invisible by default.
The
< at >< at > -577,14 574,6 < at >< at >
.Fn AG_WindowIsVisible
returns the current visibility status of a window.
A value of 0 means the window is invisible, 1 means it is visible.
-.Pp
-The
-.Fn AG_WindowIntersect
-function tests whether the specified display coordinates intersect one
-or more Agar windows.
-The function returns the number of overlapping windows at the given
-coordinates.
-This function is only useful with single-window drivers.
.Sh FOCUS STATE
The focus state controls the default filtering of events as well as the
behavior and cosmetic appearance of some widgets.
Modified: trunk/gui/window.c
===================================================================
--- trunk/gui/window.c2015-09-12 02:56:18 UTC (rev 9824)
trunk/gui/window.c2015-09-12 03:06:06 UTC (rev 9825)
< at >< at > -24,6 24,7 < at >< at >
*/
#include <agar/core/core.h>
#include <agar/gui/gui.h>
#include <agar/gui/window.h>
#include <agar/gui/titlebar.h>
< at >< at > -33,6 34,8 < at >< at >
#include <agar/gui/cursors.h>
#include <agar/gui/label.h>
#include <agar/config/ag_debug_gui.h>
#include <string.h>
#include <stdarg.h>
< at >< at > -246,20 249,16 < at >< at >
if (AGDRIVER_SINGLE(drv)) {
/*
- * Initialize the built-in window titlebar and icon now that
- * we have an attached driver. We could not do this earlier
- * because surface operations are involved.
* Initialize the built-in AG_Titlebar and dekstop AG_Icon now
* that we have an attached driver (we could not do this
* earlier because surface operations are involved).
*/
-if (win->tbar == NULL &&
- !(win->flags & AG_WINDOW_NOTITLE)) {
if (win->tbar == NULL && !(win->flags & AG_WINDOW_NOTITLE)) {
Uint titlebarFlags = 0;
-if (win->flags & AG_WINDOW_NOCLOSE)
-titlebarFlags |= AG_TITLEBAR_NO_CLOSE;
-if (win->flags & AG_WINDOW_NOMINIMIZE)
-titlebarFlags |= AG_TITLEBAR_NO_MINIMIZE;
-if (win->flags & AG_WINDOW_NOMAXIMIZE)
-titlebarFlags |= AG_TITLEBAR_NO_MAXIMIZE;
if (win->flags & AG_WINDOW_NOCLOSE) { titlebarFlags |= AG_TITLEBAR_NO_CLOSE; }
if (win->flags & AG_WINDOW_NOMINIMIZE) { titlebarFlags |= AG_TITLEBAR_NO_MINIMIZE; }
if (win->flags & AG_WINDOW_NOMAXIMIZE) { titlebarFlags |= AG_TITLEBAR_NO_MAXIMIZE; }
win->tbar = AG_TitlebarNew(win, titlebarFlags);
}
< at >< at > -269,8 268,7 < at >< at >
WIDGET(win->icon)->drv = drv;
WIDGET(win->icon)->drvOps = AGDRIVER_CLASS(drv);
AG_IconSetSurfaceNODUP(win->icon, agIconWindow.s);
-AG_IconSetBackgroundFill(win->icon, 1,
- AGDRIVER_SW(drv)->bgColor);
AG_IconSetBackgroundFill(win->icon, 1, AGDRIVER_SW(drv)->bgColor);
AG_SetStyle(win->icon, "font-size", "80%");
AG_WidgetCompileStyle(win->icon);
}
< at >< at > -287,7 285,12 < at >< at >
AG_Driver *drv;
AG_Window *other, *subwin;
AG_Timer *to, *toNext;
-
#ifdef AG_DEBUG_GUI
Debug(NULL, "AG_ObjectDetach(Window %s, \"%s\")\n", OBJECT(win)->name,
win->caption);
#endif
AG_LockVFS(&agDrivers);
/* Mark window detach in progress */
< at >< at > -333,8 336,21 < at >< at >
* context, we must defer the actual window hide / detach operation
* until the end of the current event processing cycle.
*/
-TAILQ_INSERT_TAIL(&agWindowHideQ, win, visibility);
TAILQ_INSERT_TAIL(&agWindowDetachQ, win, detach);
/* Queued Show/Hide operations would be redundant. */
TAILQ_FOREACH(other, &agWindowHideQ, visibility) {
if (other == win) {
TAILQ_REMOVE(&agWindowHideQ, win, visibility);
break;
}
}
TAILQ_FOREACH(other, &agWindowShowQ, visibility) {
if (other == win) {
TAILQ_REMOVE(&agWindowShowQ, win, visibility);
break;
}
}
AG_UnlockVFS(&agDrivers);
}
< at >< at > -535,8 551,7 < at >< at >
AG_ObjectLock(winParent);
if (AGDRIVER_MULTIPLE(drv) &&
AGDRIVER_MW_CLASS(drv)->setTransientFor != NULL) {
-AGDRIVER_MW_CLASS(drv)->setTransientFor(winParent,
- winTrans);
AGDRIVER_MW_CLASS(drv)->setTransientFor(winParent, winTrans);
}
winTrans->transientFor = winParent;
AG_ObjectUnlock(winParent);
< at >< at > -2032,14 2047,46 < at >< at >
{
AG_Window *win, *winNext;
AG_Driver *drv;
-int closedMain = 0;
int closedMain = 0, nHidden = 0;
#ifdef AG_DEBUG_GUI
Debug(NULL, "AG_WindowProcessDetachQueue() Begin\n");
#endif
TAILQ_FOREACH(win, &agWindowDetachQ, detach) {
if (!win->visible) {
continue;
}
#ifdef AG_DEBUG_GUI
Debug(NULL, "Hiding: %s (\"%s\")\n", OBJECT(win)->name, win->caption);
#endif
/*
* Note: `widget-hidden' event handlers may cause new windows
* to be added to agWindowDetachQ.
*/
AG_PostEvent(NULL, win, "widget-hidden", NULL);
nHidden ;
}
if (nHidden > 0) {
/*
* Windows were hidden - defer detach operation until the next
* event cycle, just in case the underlying WM cannot hide and
* unmap a window in the same event cycle.
*/
#ifdef AG_DEBUG_GUI
Debug(NULL, "Defer Detach (%d windows hidden)\n", nHidden);
#endif
return;
}
for (win = TAILQ_FIRST(&agWindowDetachQ);
win != TAILQ_END(&agWindowDetachQ);
win = winNext) {
winNext = TAILQ_NEXT(win, detach);
drv = WIDGET(win)->drv;
-
#ifdef AG_DEBUG_GUI
Debug(NULL, "Detach: %s (\"%s\")\n", OBJECT(win)->name, win->caption);
#endif
/* Notify all widgets of the window detach. */
AG_PostEvent(drv, win, "detached", NULL);
< at >< at > -2052,30 2099,33 < at >< at >
AGDRIVER_MW(drv)->flags &= ~(AG_DRIVER_MW_OPEN);
}
} else {
-AG_DriverSw *dsw = (AG_DriverSw *)drv;
-
-dsw->flags |= AG_DRIVER_SW_REDRAW;
-win->tbar = NULL;/* No longer safe */
-win->icon = NULL;
win->tbar = NULL;
if (win->icon != NULL) {
AG_ObjectDestroy(win->icon);
win->icon = NULL;
}
AGDRIVER_SW(drv)->flags |= AG_DRIVER_SW_REDRAW;
}
-/* We can now perform the standard AG_ObjectDetach(). */
/* Do a standard AG_ObjectDetach(). */
AG_ObjectSetDetachFn(win, NULL, NULL);
AG_ObjectDetach(win);
if (AGDRIVER_MULTIPLE(drv)) {
/* Destroy the AG_Driver object. */
AG_UnlockVFS(&agDrivers);
-AG_DriverClose(drv);/* Free this driver instance */
AG_DriverClose(drv);
AG_LockVFS(&agDrivers);
}
if (win->flags & AG_WINDOW_MAIN) {
closedMain ;
}
-AG_PostEvent(drv, win, "window-detached", NULL);
AG_PostEvent(NULL, win, "window-detached", NULL);
AG_ObjectDestroy(win);
}
TAILQ_INIT(&agWindowDetachQ);
-
/* Terminate if the last AG_WINDOW_MAIN window was closed. */
if (closedMain > 0) {
AGOBJECT_FOREACH_CHILD(drv, &agDrivers, ag_driver) {
AG_FOREACH_WINDOW(win, drv) {
< at >< at > -2085,26 2135,22 < at >< at >
if (win != NULL)
break;
}
-if (drv == NULL) { /* Last "main" window was closed */
if (drv == NULL) {
#ifdef AG_DEBUG_GUI
Debug(NULL, "AG_WindowProcessDetachQueue() Exit Normally\n");
#endif
AG_Terminate(0);
}
#ifdef AG_DEBUG_GUI
Debug(NULL, "AG_WindowProcessDetachQueue() End (MAIN window remains)\n");
#endif
} else {
#ifdef AG_DEBUG_GUI
Debug(NULL, "AG_WindowProcessDetachQueue() End\n");
#endif
}
}
-int
-AG_WindowIntersect(AG_DriverSw *drv, int x, int y)
-{
-AG_Window *win;
-int rv = 0;
-
-AG_FOREACH_WINDOW(win, drv) {
-if (win->visible &&
- AG_WidgetArea(win, x, y))
-rv ;
-}
-return (rv);
-}
-
/*
* Configure a new cursor-change area with a specified cursor. The provided
* cursor will be freed automatically on window detach.
< at >< at > -2317,7 2363,6 < at >< at >
{
AG_ObjectDetach(win);
}
-
void
AG_WindowSetVisibility(AG_Window *win, int flag)
{
< at >< at > -2329,6 2374,19 < at >< at >
}
AG_ObjectUnlock(win);
}
int
AG_WindowIntersect(AG_DriverSw *drv, int x, int y)
{
AG_Window *win;
int rv = 0;
AG_FOREACH_WINDOW(win, drv) {
if (win->visible &&
AG_WidgetArea(win, x, y))
rv ;
}
return (rv);
}
#endif /* AG_LEGACY */
AG_WidgetClass agWindowClass = {
Modified: trunk/gui/window.h
===================================================================
--- trunk/gui/window.h2015-09-12 02:56:18 UTC (rev 9824)
trunk/gui/window.h2015-09-12 03:06:06 UTC (rev 9825)
< at >< at > -224,7 224,6 < at >< at >
void AG_WindowDetachGenEv(AG_Event *);
void AG_WindowHideGenEv(AG_Event *);
void AG_WindowCloseGenEv(AG_Event *);
-int AG_WindowIntersect(AG_DriverSw *, int, int);
void AG_CloseFocusedWindow(void);
< at >< at > -415,7 414,6 < at >< at >
}
}
-
/*
* Process synchronous window operations. This includes focus changes,
* visibility changes and the detach operation. Called from custom event
< at >< at > -436,10 434,11 < at >< at >
#define AG_WINDOW_POPUP 0x01000000
#define AG_WINDOW_DIALOG 0x02000000
#define AG_WINDOW_CASCADE AG_WINDOW_TILING
-void AG_WindowSetVisibility(AG_Window *, int) DEPRECATED_ATTRIBUTE;
-AG_Window *AG_FindWindow(const char *) DEPRECATED_ATTRIBUTE;
-void AG_ViewAttach(AG_Window *) DEPRECATED_ATTRIBUTE;
-void AG_ViewDetach(AG_Window *) DEPRECATED_ATTRIBUTE;
AG_Window *AG_FindWindow(const char *)DEPRECATED_ATTRIBUTE;
void AG_ViewAttach(AG_Window *)DEPRECATED_ATTRIBUTE;
void AG_ViewDetach(AG_Window *)DEPRECATED_ATTRIBUTE;
void AG_WindowSetVisibility(AG_Window *, int)DEPRECATED_ATTRIBUTE;
int AG_WindowIntersect(AG_DriverSw *, int, int)DEPRECATED_ATTRIBUTE;
#endif /* AG_LEGACY */
__END_DECLS
[Less]
|
Posted
almost 9 years
ago
by
Agar-SVN
Author: vedge
Date: 2015-09-11 22:56:18 -0400 (Fri, 11 Sep 2015)
New Revision: 9824
Modified:
trunk/gui/gui.c
Log:
- in AG_DestroyGUI(), destroy remaining windows gracefully (i.e., normal
detach followed by AG_WindowProcessDetachQueue()). also
... [More]
AG_DriverClose()
any possibly remaining driver instance.
Modified: trunk/gui/gui.c
===================================================================
--- trunk/gui/gui.c2015-09-12 02:50:56 UTC (rev 9823)
trunk/gui/gui.c2015-09-12 02:56:18 UTC (rev 9824)
< at >< at > -31,6 31,7 < at >< at >
#include <agar/core/config.h>
#include <agar/config/have_opengl.h>
#include <agar/config/ag_debug_gui.h>
#include <agar/gui/gui.h>
#include <agar/gui/box.h>
< at >< at > -231,7 232,9 < at >< at >
agRenderingContext = 0;
AG_ObjectInitStatic(&agDrivers, &agObjectClass);
AG_ObjectSetName(&agDrivers, "agDrivers");
AG_ObjectInitStatic(&agInputDevices, &agObjectClass);
AG_ObjectSetName(&agInputDevices, "agInputDevices");
cfg = AG_ConfigObject();
for (i = 0; i < agGUIOptionCount; i )
< at >< at > -310,19 313,40 < at >< at >
AG_DestroyGUI(void)
{
void **ops;
-AG_Driver *drv;
AG_Object *drv, *drvNext;
AG_Window *win;
AG_LockVFS(&agDrivers);
-OBJECT_FOREACH_CHILD(drv, &agDrivers, ag_driver) {
-AG_ObjectFreeChildren(drv);
/* Destroy all windows */
#ifdef AG_DEBUG_GUI
Debug(NULL, "AG_DestroyGUI()\n");
#endif
OBJECT_FOREACH_CHILD(drv, &agDrivers, ag_object) {
OBJECT_FOREACH_CHILD(win, drv, ag_window) {
#ifdef AG_DEBUG_GUI
Debug(drv, "Freeing Window %s (\"%s\")\n", OBJECT(win)->name, win->caption);
#endif
AG_ObjectDetach(win);
}
}
-rescan:
-OBJECT_FOREACH_CHILD(drv, &agDrivers, ag_driver) {
-AG_DriverClose(drv);
-if (drv == (AG_Driver *)agDriverSw) { agDriverSw = NULL; }
-if (drv == (AG_Driver *)agDriverMw) { agDriverMw = NULL; }
-goto rescan;
while (!TAILQ_EMPTY(&agWindowDetachQ)) {
AG_WindowProcessDetachQueue();
}
for (drv = TAILQ_FIRST(&agDrivers.children);
drv != TAILQ_END(&agDrivers.children);
drv = drvNext) {
drvNext = TAILQ_NEXT(drv, cobjs);
#ifdef AG_DEBUG_GUI
Debug(drv, "Freeing Driver %s\n", OBJECT(drv)->name);
#endif
TAILQ_INIT(&drv->children);
AG_DriverClose((AG_Driver *)drv);
}
agDriverSw = NULL;
agDriverMw = NULL;
agDriverOps = NULL;
AG_UnlockVFS(&agDrivers);
< at >< at > -459,7 483,7 < at >< at >
if ((ep = strrchr(sOpts, ')')) != NULL) {
*ep = '\0';
} else {
-Verbose(_("Syntax error in driver options: %s"), sOpts);
Verbose(_("Syntax error in driver options: %s\n"), sOpts);
}
while ((tok = AG_Strsep(&sOpts, ":")) != NULL) {
if ((key = AG_Strsep(&tok, "=")) != NULL) {
[Less]
|
Posted
almost 9 years
ago
by
Agar-SVN
Author: vedge
Date: 2015-09-11 22:50:56 -0400 (Fri, 11 Sep 2015)
New Revision: 9823
Modified:
trunk/gui/style_data.h
trunk/gui/stylesheet.c
trunk/gui/stylesheet.h
Log:
define agStyleDefault data as string
Modified: trunk/gui/style_data.h
... [More]
===================================================================
--- trunk/gui/style_data.h2015-09-12 02:50:21 UTC (rev 9822)
+++ trunk/gui/style_data.h2015-09-12 02:50:56 UTC (rev 9823)
< at >< at > -1,8 +1,68 < at >< at >
-/* File generated by bundlecss */
-const Uint8 agStyleDefault_Data[1186] = {
-35,10,35,32,83,97,109,112,108,101,32,65,103,97,114,32,71,85,73,32,115,116,121,108,101,115,104,101,101,116,10,35,32,82,101,102,101,114,32,116,111,32,65,71,95,83,116,121,108,101,83,104,101,101,116,40,51,41,46,10,35,10,10,65,71,95,87,105,100,103,101,116,32,123,10,9,99,111,108,111,114,58,32,114,103,98,40,49,50,53,44,49,50,53,44,49,50,53,41,59,10,9,99,111,108,111,114,35,102,111,99,117,115,101,100,58,32,114,103,98,40,50,48,48,44,48,44,48,41,59,10,9,99,111,108,111,114,35,100,105,115,97,98,108,101,100,58,32,114,103,98,40,49,54,48,44,49,54,48,44,49,54,48,41,59,10,9,99,111,108,111,114,35,104,111,118,101,114,58,32,114,103,98,40,49,51,48,44,49,51,48,44,49,51,48,41,59,10,9,99,111,108,111,114,35,115,101,108,101,99,116,101,100,58,32,114,103,98,40,53,48,44,53,48,44,49,50,48,41,59,10,9,116,101,120,116,45,
99,111,108,111,114,58,32,114,103,98,40,50,53,48,44,50,53,48,44,50,53,48,41,59,10,9,108,105,110,101,45,99,111,108,111,114,58,32,114,103,98,40,53,48,44,53,48,44,53,48,41,59,10,9,108,105,110,101,45,99,
111,108,111,114,35,104,111,118,101,114,58,32,114,103,98,40,55,48,44,55,48,44,55,48,41,59,10,9,115,104,97,112,101,45,99,111,108,111,114,58,32,114,103,98,40,49,48,48,44,49,48,48,44,49,48,48,41,59,10,125,10,65,71,95,87,105,110,100,111,119,32,123,10,9,98,111,114,100,101,114,45,99,111,108,111,114,58,32,114,103,98,40,49,48,48,44,49,48,48,44,49,48,48,41,59,10,125,10,65,71,95,84,105,116,108,101,98,97,114,32,123,10,9,99,111,108,111,114,58,32,114,103,98,40,52,48,44,53,48,44,54,48,41,59,10,9,99,111,108,111,114,35,100,105,115,97,98,108,101,100,58,32,114,103,98,40,51,53,44,51,53,44,51,53,41,59,10,125,10,65,71,95,77,101,110,117,32,123,10,9,99,111,108,111,114,58,32,114,103,98,40,55,48,44,55,48,44,55,48,41,59,10,9,99,111,108,111,114,35,115,101,108,101,99,116,101,100,58,32,114,103,98,40,52,48,44,52,48,44,
49,49,48,41,59,10,9,99,111,108,111,114,35,100,105,115,97,98,108,101,100,58,32,114,103,98,40,52,48,44,52,48,44,49,49,48,41,59,10,9,116,101,120,116,45,99,111,108,111,114,35,115,101,108,101,99,116,101,
100,58,32,114,103,98,40,50,51,48,44,50,51,48,44,50,51,48,41,59,10,9,116,101,120,116,45,99,111,108,111,114,35,100,105,115,97,98,108,101,100,58,32,114,103,98,40,49,55,48,44,49,55,48,44,49,55,48,41,59,10,125,10,65,71,95,78,111,116,101,98,111,111,107,32,123,10,9,99,111,108,111,114,35,115,101,108,101,99,116,101,100,58,32,114,103,98,40,49,49,55,44,49,49,55,44,49,49,55,41,59,10,125,10,65,71,95,69,100,105,116,97,98,108,101,32,123,10,9,99,111,108,111,114,35,115,101,108,101,99,116,101,100,58,32,114,103,98,40,48,44,48,44,49,48,48,41,59,10,125,10,65,71,95,84,108,105,115,116,32,123,10,9,99,111,108,111,114,58,32,114,103,98,40,49,50,53,44,49,50,53,44,49,50,53,41,59,10,9,99,111,108,111,114,35,115,101,108,101,99,116,101,100,58,32,114,103,98,40,53,48,44,53,48,44,49,50,48,41,59,10,9,116,101,120,116,45,99,11
1,108,111,114,35,115,101,108,101,99,116,101,100,58,32,114,103,98,40,50,53,53,44,50,53,53,44,50,48,48,41,59,10,125,10,65,71,95,67,111,110,115,111,108,101,32,123,10,9,99,111,108,111,114,58,32,114,103,
98,40,48,44,48,44,51,48,41,59,10,9,99,111,108,111,114,35,104,111,118,101,114,58,32,114,103,98,40,48,44,48,44,51,48,41,59,10,9,99,111,108,111,114,35,102,111,99,117,115,101,100,58,32,114,103,98,40,49,48,44,49,48,44,50,56,41,59,10,9,99,111,108,111,114,35,115,101,108,101,99,116,101,100,58,32,114,103,98,40,48,44,49,53,44,56,48,41,59,10,9,116,101,120,116,45,99,111,108,111,114,58,32,114,103,98,40,50,52,48,44,50,52,48,44,50,52,48,41,59,10,125,10,65,71,95,80,114,111,103,114,101,115,115,66,97,114,32,123,10,9,99,111,108,111,114,35,115,101,108,101,99,116,101,100,58,32,114,103,98,40,53,48,44,53,48,44,49,50,48,41,59,10,9,116,101,120,116,45,99,111,108,111,114,35,115,101,108,101,99,116,101,100,58,32,114,103,98,40,50,53,53,44,50,53,53,44,50,53,53,41,59,10,125,10,65,71,95,70,105,120,101,100,80,108,111,116,
116,101,114,32,123,10,9,99,111,108,111,114,58,32,114,103,98,40,53,48,44,53,48,44,53,48,41,59,10,9,108,105,110,101,45,99,111,108,111,114,58,32,114,103,98,40,55,48,44,55,48,44,55,48,41,59,10,125,10,};
+/* File generated by agar bundlecss */
+const char *agStyleDefault_Data =
+"AG_Widget {\n"
+"color: rgb(125,125,125);\n"
+"color#focused: rgb(200,0,0);\n"
+"color#disabled: rgb(160,160,160);\n"
+"color#hover: rgb(130,130,130);\n"
+"color#selected: rgb(50,50,120);\n"
+"text-color: rgb(250,250,250);\n"
+"line-color: rgb(50,50,50);\n"
+"line-color#hover: rgb(70,70,70);\n"
+"shape-color: rgb(100,100,100);\n"
+"}\n"
+"AG_Window {\n"
+"border-color: rgb(100,100,100);\n"
+"}\n"
+"AG_Titlebar {\n"
+"color: rgb(40,50,60);\n"
+"color#disabled: rgb(35,35,35);\n"
+"}\n"
+"AG_Menu {\n"
+"color: rgb(70,70,70);\n"
+"color#selected: rgb(40,40,110);\n"
+"color#disabled: rgb(40,40,110);\n"
+"text-color#selected: rgb(230,230,230);\n"
+"text-color#disabled: rgb(170,170,170);\n"
+"}\n"
+"AG_MenuView {\n"
+"color: rgb(70,70,70);\n"
+"color#selected: rgb(40,40,110);\n"
+"color#disabled: rgb(40,40,110);\n"
+"text-color#selected: rgb(230,230,230);\n"
+"text-color#disabled: rgb(170,170,170);\n"
+"}\n"
+"AG_Notebook {\n"
+"color#selected: rgb(117,117,117);\n"
+"}\n"
+"AG_Editable {\n"
+"color#selected: rgb(0,0,100);\n"
+"}\n"
+"AG_Tlist {\n"
+"color: rgb(125,125,125);\n"
+"color#selected: rgb(50,50,120);\n"
+"text-color#selected: rgb(255,255,200);\n"
+"}\n"
+"AG_Console {\n"
+"color: rgb(0,0,30);\n"
+"color#hover: rgb(0,0,30);\n"
+"color#focused: rgb(10,10,28);\n"
+"color#selected: rgb(0,15,80);\n"
+"text-color: rgb(240,240,240);\n"
+"}\n"
+"AG_ProgressBar {\n"
+"color#selected: rgb(50,50,120);\n"
+"text-color#selected: rgb(255,255,255);\n"
+"}\n"
+"AG_FixedPlotter {\n"
+"color: rgb(50,50,50);\n"
+"line-color: rgb(70,70,70);\n"
+"}\n"
+"";
+
AG_StaticCSS agStyleDefault = {
-"agStyleDefault",
-1186,
-agStyleDefault_Data,
+"agStyleDefault",
+1272,
+&agStyleDefault_Data,
+NULL
};
Modified: trunk/gui/stylesheet.c
===================================================================
--- trunk/gui/stylesheet.c2015-09-12 02:50:21 UTC (rev 9822)
+++ trunk/gui/stylesheet.c2015-09-12 02:50:56 UTC (rev 9823)
< at >< at > -105,7 +105,7 < at >< at >
goto fail;
}
builtin = agBuiltinStyles[i];
-if ((ds = AG_OpenConstCore(builtin->data, builtin->size)) == NULL) {
+if ((ds = AG_OpenConstCore(*builtin->data, builtin->size)) == NULL) {
goto fail;
}
builtin->css = css;
Modified: trunk/gui/stylesheet.h
===================================================================
--- trunk/gui/stylesheet.h2015-09-12 02:50:21 UTC (rev 9822)
+++ trunk/gui/stylesheet.h2015-09-12 02:50:56 UTC (rev 9823)
< at >< at > -26,7 +26,7 < at >< at >
typedef struct ag_static_css {
const char *name;/* Identifier */
Uint32 size;/* Size in bytes */
-const Uint8 *data;/* CSS data */
+const char **data;/* CSS data */
AG_StyleSheet *css;/* Initialized stylesheet */
} AG_StaticCSS;
[Less]
|
Posted
almost 9 years
ago
by
Agar-SVN
Author: vedge
Date: 2015-09-11 22:50:21 -0400 (Fri, 11 Sep 2015)
New Revision: 9822
Modified:
trunk/gui/style.css
Log:
add missing definition for AG_MenuView
Modified: trunk/gui/style.css
... [More]
===================================================================
--- trunk/gui/style.css2015-09-12 02:45:25 UTC (rev 9821)
+++ trunk/gui/style.css2015-09-12 02:50:21 UTC (rev 9822)
< at >< at > -28,6 +28,13 < at >< at >
text-color#selected: rgb(230,230,230);
text-color#disabled: rgb(170,170,170);
}
+AG_MenuView {
+color: rgb(70,70,70);
+color#selected: rgb(40,40,110);
+color#disabled: rgb(40,40,110);
+text-color#selected: rgb(230,230,230);
+text-color#disabled: rgb(170,170,170);
+}
AG_Notebook {
color#selected: rgb(117,117,117);
}
[Less]
|
Posted
almost 9 years
ago
by
Agar-SVN
Author: vedge
Date: 2015-09-11 22:45:25 -0400 (Fri, 11 Sep 2015)
New Revision: 9821
Modified:
trunk/dev/browser.c
trunk/dev/config.c
Log:
AG_FileDlgAddType() now takes an AG_IntFn function.
Modified: trunk/dev/browser.c
... [More]
===================================================================
--- trunk/dev/browser.c2015-09-12 02:43:45 UTC (rev 9820)
trunk/dev/browser.c2015-09-12 02:45:25 UTC (rev 9821)
< at >< at > -254,7 254,7 < at >< at >
return;
}
-static void
static int
SaveObjectToFile(AG_Event *event)
{
AG_Object *ob = AG_PTR(1);
< at >< at > -261,31 261,28 < at >< at >
char *path = AG_STRING(3);
int loadedTmp = 0;
int dataFound;
int rv = 0;
/* Load the object temporarily if it is non-resident. */
if (!OBJECT_RESIDENT(ob)) {
if (AG_ObjectLoadData(ob, &dataFound) == -1) {
-if (dataFound) {
-AG_TextMsg(AG_MSG_ERROR,
- _("%s: Loading failed (non-resident): %s"),
- ob->name, AG_GetError());
-return;
-}
if (dataFound)
return (-1);
}
AG_PostEvent(NULL, ob, "edit-post-load", NULL);
loadedTmp = 1;
}
if (AG_ObjectSaveToFile(ob, path) == -1) {
-AG_TextMsg(AG_MSG_ERROR, "%s: %s", ob->name, AG_GetError());
-} else {
-AG_TextTmsg(AG_MSG_INFO, 1000,
- _("Object `%s' was exported successfully."), ob->name);
AG_SetError("%s: %s", ob->name, AG_GetError());
rv = -1;
}
-if (loadedTmp)
if (loadedTmp) {
AG_ObjectFreeDataset(ob);
}
return (rv);
}
-static void
static int
ImportObject(AG_Event *event)
{
AG_Object *ob = AG_PTR(1);
< at >< at > -292,28 289,25 < at >< at >
char *path = AG_STRING(3);
int loadedTmp = 0;
int dataFound;
int rv = 0;
/* Load the object temporarily if it is non-resident. */
if (!OBJECT_RESIDENT(ob)) {
if (AG_ObjectLoadData(ob, &dataFound) == -1) {
-if (dataFound) {
-AG_TextMsg(AG_MSG_ERROR,
- _("%s: Loading failed (non-resident): %s"),
- ob->name, AG_GetError());
-return;
-}
if (dataFound)
return (-1);
}
loadedTmp = 1;
AG_PostEvent(NULL, ob, "edit-post-load", NULL);
}
if (AG_ObjectLoadFromFile(ob, path) == -1) {
-AG_TextMsg(AG_MSG_ERROR, "%s: %s", ob->name, AG_GetError());
-} else {
-AG_TextTmsg(AG_MSG_INFO, 1000,
- _("Object `%s' was imported successfully."), ob->name);
AG_SetError("%s: %s", ob->name, AG_GetError());
rv = -1;
}
-if (loadedTmp)
if (loadedTmp) {
AG_ObjectFreeDataset(ob);
}
return (0);
}
AG_Window *
Modified: trunk/dev/config.c
===================================================================
--- trunk/dev/config.c2015-09-12 02:43:45 UTC (rev 9820)
trunk/dev/config.c2015-09-12 02:45:25 UTC (rev 9821)
< at >< at > -113,17 113,12 < at >< at >
}
#if 0
-static void
static int
LoadColorSchemeFromACS(AG_Event *event)
{
char *file = AG_STRING(1);
-if (AG_ColorsLoad(file) == 0) {
-AG_TextTmsg(AG_MSG_INFO, 1000,
- _("Color scheme loaded from %s."), file);
-} else {
-AG_TextMsgFromError();
-}
return AG_ColorsLoad(file);
}
static void
< at >< at > -131,12 126,7 < at >< at >
{
char *file = AG_STRING(1);
-if (AG_ColorsSave(file) == 0) {
-AG_TextTmsg(AG_MSG_INFO, 1000, _("Color scheme saved to %s."),
- file);
-} else {
-AG_TextMsgFromError();
-}
return AG_ColorsSave(file);
}
static void
[Less]
|
Posted
almost 9 years
ago
by
Agar-SVN
Author: vedge
Date: 2015-09-10 23:33:39 -0400 (Thu, 10 Sep 2015)
New Revision: 9819
Modified:
trunk/gui/drv_sdlgl.c
Log:
fix memleak when using sdlgl with capture option disabled.
Modified: trunk/gui/drv_sdlgl.c
... [More]
===================================================================
--- trunk/gui/drv_sdlgl.c2015-09-10 10:05:27 UTC (rev 9818)
trunk/gui/drv_sdlgl.c2015-09-11 03:33:39 UTC (rev 9819)
< at >< at > -172,10 172,9 < at >< at >
AG_ObjectDelete(drv->mouse); drv->mouse = NULL;
AG_ObjectDelete(drv->kbd); drv->kbd = NULL;
-if (sgl->outMode != AG_SDLGL_OUT_NONE) {
-Free(sgl->outBuf);
if (sgl->outBuf != NULL) {
free(sgl->outBuf);
sgl->outBuf = NULL;
-sgl->outMode = AG_SDLGL_OUT_NONE;
}
nDrivers = 0;
< at >< at > -383,7 382,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(_("SDLGL: Enabling hardware palette"));
Verbose(_("SDLGL: Using hardware palette\n"));
sFlags |= SDL_HWPALETTE;
}
if ((sgl->s = SDL_SetVideoMode((int)w, (int)h, newDepth, sFlags))
< at >< at > -420,9 419,11 < at >< at >
/* Initialize the output capture buffer. */
Free(sgl->outBuf);
-if ((sgl->outBuf = AG_TryMalloc(dsw->w*dsw->h*4)) == NULL) {
-Verbose("SDLGL: Out of memory; disabling capture\n");
-sgl->outMode = AG_SDLGL_OUT_NONE;
if (sgl->outMode != AG_SDLGL_OUT_NONE) {
if ((sgl->outBuf = AG_TryMalloc(dsw->w*dsw->h*4)) == NULL) {
Verbose("SDLGL: Out of memory; disabling capture\n");
sgl->outMode = AG_SDLGL_OUT_NONE;
}
}
if (flags & AG_VIDEO_FULLSCREEN) {
< at >< at > -535,7 536,7 < at >< at >
/* Resize the output capture buffer. */
if (sgl->outBuf != NULL) {
-Free(sgl->outBuf);
free(sgl->outBuf);
if ((sgl->outBuf = AG_TryMalloc(dsw->w*dsw->h*4)) == NULL) {
Verbose("SDLGL: Out of memory; disabling capture\n");
sgl->outMode = AG_SDLGL_OUT_NONE;
[Less]
|