AG_Window * RG_FillEdit(void *p, RG_Tileview *tv) { struct rg_fill_feature *f = p; AG_Window *win; AG_Box *box; win = AG_WindowNew(0); AG_WindowSetCaptionS(win, _("Fill/gradient")); { static const char *modes[] = { N_("Solid"), N_("Horizontal gradient"), N_("Vertical gradient"), N_("Circular gradient"), N_("Pixmap pattern"), NULL }; AG_RadioNewUint(win, AG_RADIO_HFILL, modes, &f->type); } box = AG_BoxNew(win, AG_BOX_VERT, AG_BOX_HFILL|AG_BOX_VFILL); { AG_HSVPal *hsv1, *hsv2; AG_Numerical *num; AG_Notebook *nb; AG_NotebookTab *ntab; nb = AG_NotebookNew(box, AG_NOTEBOOK_HFILL|AG_NOTEBOOK_VFILL); ntab = AG_NotebookAddTab(nb, _("Color A"), AG_BOX_VERT); { hsv1 = AG_HSVPalNew(ntab, AG_HSVPAL_EXPAND); AG_BindUint8(hsv1, "RGBAv", (Uint8 *)&f->f_gradient.c1); } ntab = AG_NotebookAddTab(nb, _("Color B"), AG_BOX_VERT); { hsv2 = AG_HSVPalNew(ntab, AG_HSVPAL_EXPAND); AG_BindUint8(hsv2, "RGBAv", (Uint8 *)&f->f_gradient.c2); } num = AG_NumericalNewUint8R(box, 0, NULL, _("Overall alpha: "), &f->alpha, 0, 255); AG_NumericalSetIncrement(num, 5); } return (win); }
/* Edition routine. */ static void * Edit(void *obj) { Mammal *mammal = obj; AG_Window *win, *winSuper; AG_HSVPal *pal; AG_ObjectClass *super; win = AG_WindowNew(0); AG_WindowSetCaption(win, "Mammal: %s", AGOBJECT(mammal)->name); /* Invoke the "edit" operation of the superclass. */ super = AG_ObjectSuperclass(mammal); if (super->edit != NULL) { winSuper = super->edit(mammal); AG_WindowSetPosition(winSuper, AG_WINDOW_UPPER_CENTER, 0); AG_WindowShow(winSuper); } /* Allow user to edit paramters specific to this class. */ AG_LabelNew(win, 0, "Hair color:"); pal = AG_HSVPalNew(win, AG_HSVPAL_EXPAND); AG_BindFloat(pal, "hue", &mammal->hairColor.h); AG_BindFloat(pal, "saturation", &mammal->hairColor.s); AG_BindFloat(pal, "value", &mammal->hairColor.v); return (win); }
static AG_Window * DEV_ConfigWindow(AG_Config *cfg) { char path[AG_PATHNAME_MAX]; AG_Window *win; AG_Box *hb; AG_Textbox *tbox; /* AG_Checkbox *cb; */ AG_Notebook *nb; AG_NotebookTab *tab; if ((win = AG_WindowNewNamedS(0, "DEV_Config")) == NULL) { return (NULL); } AG_WindowSetCaptionS(win, _("Agar settings")); AG_WindowSetCloseAction(win, AG_WINDOW_DETACH); nb = AG_NotebookNew(win, AG_NOTEBOOK_HFILL|AG_NOTEBOOK_VFILL); tab = AG_NotebookAdd(nb, _("Video"), AG_BOX_VERT); { AG_NumericalNewIntR(tab, 0, "%", _("Screenshot quality: "), &agScreenshotQuality, 1, 100); } tab = AG_NotebookAdd(nb, _("GUI"), AG_BOX_VERT); { AG_CheckboxNewInt(tab, 0, _("Built-in key composition"), &agTextComposition); AG_CheckboxNewInt(tab, 0, _("Bidirectional"), &agTextBidi); AG_SeparatorNewHoriz(tab); AG_LabelNewS(tab, 0, _("Timer settings (milliseconds):")); AG_NumericalNewIntR(tab, 0, NULL, _("Double click delay: "), &agMouseDblclickDelay, 1, 10000); AG_NumericalNewIntR(tab, 0, NULL, _("Cursor spin delay: "), &agMouseSpinDelay, 1, 10000); AG_NumericalNewIntR(tab, 0, NULL, _("Cursor spin interval: "), &agMouseSpinIval, 1, 10000); AG_NumericalNewIntR(tab, 0, NULL, _("Key repeat delay: "), &agKbdDelay, 1, 1000); AG_NumericalNewIntR(tab, 0, NULL, _("Key repeat interval: "), &agKbdRepeat, 1, 500); } tab = AG_NotebookAdd(nb, _("Directories"), AG_BOX_VERT); { hb = AG_BoxNewHoriz(tab, AG_BOX_HFILL); tbox = AG_TextboxNewS(hb, AG_TEXTBOX_HFILL, _("Temporary file directory: ")); AG_GetString(agConfig, "tmp-path", path, sizeof(path)); AG_TextboxSetString(tbox, path); AG_SetEvent(tbox, "textbox-return", SetPath, "%s", "tmp-path"); AG_TextboxSizeHint(tbox, "XXXXXXXXXXXXXXXXXXXX"); AG_ButtonNewFn(hb, 0, "...", SelectPath, "%s,%p", "tmp-path", tbox); hb = AG_BoxNewHoriz(tab, AG_BOX_HFILL); tbox = AG_TextboxNewS(hb, AG_TEXTBOX_HFILL, _("Dataset save directory: ")); AG_GetString(agConfig, "save-path", path, sizeof(path)); AG_TextboxSetString(tbox, path); AG_SetEvent(tbox, "textbox-return", SetPath, "%s", "save-path"); AG_ButtonNewFn(hb, 0, "...", SelectPath, "%s,%p", "save-path", tbox); hb = AG_BoxNewHoriz(tab, AG_BOX_HFILL); tbox = AG_TextboxNewS(hb, AG_TEXTBOX_HFILL, _("Dataset search path: ")); AG_GetString(agConfig, "load-path", path, sizeof(path)); AG_TextboxSetString(tbox, path); AG_SetEvent(tbox, "textbox-return", SetPath, "%s", "load-path"); hb = AG_BoxNewHoriz(tab, AG_BOX_HFILL); tbox = AG_TextboxNewS(hb, AG_TEXTBOX_HFILL, _("Font search path: ")); AG_GetString(agConfig, "font-path", path, sizeof(path)); AG_TextboxSetString(tbox, path); AG_SetEvent(tbox, "textbox-return", SetPath, "%s", "font-path"); } #if 0 tab = AG_NotebookAdd(nb, _("Colors"), AG_BOX_VERT); { AG_Pane *hPane; AG_HSVPal *hsv; AG_Tlist *tl; AG_TlistItem *it; AG_Label *lbl; int i; hPane = AG_PaneNew(tab, AG_PANE_HORIZ, AG_PANE_EXPAND); { tl = AG_TlistNew(hPane->div[0], AG_TLIST_EXPAND); AG_TlistSizeHint(tl, "Tileview text background", 10); for (i = 0; i < LAST_COLOR; i++) { it = AG_TlistAdd(tl, NULL, _(agColorNames[i])); it->p1 = &agColors[i]; } hsv = AG_HSVPalNew(hPane->div[1], AG_HSVPAL_EXPAND); AG_SetEvent(hsv, "h-changed", SetColor, "%p", tl); AG_SetEvent(hsv, "sv-changed", SetColor, "%p", tl); AG_SetEvent(tl, "tlist-selected", BindSelectedColor, "%p", hsv); } lbl = AG_LabelNew(tab, 0, _("Warning: Some color changes will not " "take effect until %s is restarted."), agProgName); AG_LabelSetPaddingLeft(lbl, 10); AG_LabelSetPaddingRight(lbl, 10); hb = AG_BoxNewHoriz(tab, AG_BOX_HOMOGENOUS|AG_BOX_HFILL); { AG_ButtonNewFn(hb, 0, _("Load scheme"), LoadColorSchemeDlg, NULL); AG_ButtonNewFn(hb, 0, _("Save scheme"), SaveColorSchemeDlg, NULL); } } #endif #ifdef AG_DEBUG tab = AG_NotebookAdd(nb, _("Debug"), AG_BOX_VERT); { AG_NumericalNewIntR(tab, 0, NULL, _("Debug level: "), &agDebugLvl, 0, 255); } #endif hb = AG_BoxNewHoriz(win, AG_BOX_HOMOGENOUS|AG_BOX_HFILL); { AG_ButtonNewFn(hb, 0, _("Close"), AGWINDETACH(win)); AG_ButtonNewFn(hb, 0, _("Save"), SaveConfig, NULL); } return (win); }