static void SoundMenu(AG_NotebookTab *parent, struct gui_sound *cfg) { AG_Radio *radio; AG_Checkbox *check; AG_Numerical *num; AG_Label *lbl; AG_Box *box; AG_Box *box2; int i; for(i = 0; i < 6 ; i++) { if(cfg->nSampleRate == SampleRates[i]) break; } if(i > 6) i = 6; box = AG_BoxNewVert(AGWIDGET(parent), AG_BOX_VFILL); { lbl = AG_LabelNew(AGWIDGET(box), 0, "%s", gettext("Sample Rate")); radio = AG_RadioNewFn(AGWIDGET(box), 0, SampleRateName, OnChangeSampleRate, "%p", cfg); AG_SetInt(radio, "value", i); box = AG_BoxNewVert(AGWIDGET(parent), AG_BOX_HFILL); check = AG_CheckboxNewInt(AGWIDGET(box), AG_CHECKBOX_HFILL, gettext("HQ Rendering"), &(cfg->bFMHQmode)); } box = AG_BoxNewVert(AGWIDGET(parent), AG_BOX_VFILL); { num = AG_NumericalNewInt(AGWIDGET(box), AG_NUMERICAL_HFILL, gettext("Per Second") ,gettext("Sound Buffer"), &(cfg->nSoundBuffer)); AG_NumericalSetRangeInt(num, 30, 2000); AG_NumericalSetIncrement(num, 10.0); check = AG_CheckboxNewInt(AGWIDGET(box), AG_CHECKBOX_HFILL, gettext("Force Stereo"), &(cfg->nStereoOut)); check = AG_CheckboxNewInt(AGWIDGET(box), AG_CHECKBOX_HFILL, gettext("FDD Seek & Motor"), &(cfg->bFddSound)); check = AG_CheckboxNewInt(AGWIDGET(box), AG_CHECKBOX_HFILL, gettext("CMT Monitor"), &(cfg->bTapeMon)); } }
ffmpegPlayer * ffmpegPlayerNew(void *parent, int w, int h, int flags, SDL_Surface *screen) { ffmpegPlayer *me; assert(screen != NULL); /* Create a new instance of the class */ me = malloc(sizeof(ffmpegPlayer)); AG_ObjectInit(me, &ffmpegPlayerClass); /* Save the user-requested geometry */ me->w = w; me->h = h; me->flags = flags; me->screen = screen; if (flags & AG_FFMPEGPLAYER_HFILL) AGWIDGET(me)->flags |= AG_WIDGET_HFILL; if (flags & AG_FFMPEGPLAYER_VFILL) AGWIDGET(me)->flags |= AG_WIDGET_VFILL; /* Attach the object to the parent (no-op if parent is NULL) */ AG_ObjectAttach(parent, me); return me; }
static void FileMenu_BootMode(AG_Event *event) { AG_Menu *self = (AG_Menu *)AG_SELF(); AG_MenuItem *item = (AG_MenuItem *)AG_SENDER(); AG_Window *w; AG_Button *btn[3]; AG_Box *box; AG_Box *box2; char *label; AG_Label *lbl; w = AG_WindowNew(AG_WINDOW_NOMINIMIZE | AG_WINDOW_NOMAXIMIZE | FILEDIALOG_WINDOW_DEFAULT); AG_WindowSetMinSize(w, 230, 80); label = gettext("Select mode (Notice: If select , reboot.)"); AG_WindowSetMinSize(w, 230, 80); box = AG_BoxNewHorizNS(w, AG_BOX_HFILL); AG_WidgetSetSize(box, 230, 32); lbl = AG_LabelNew(AGWIDGET(box), AG_LABEL_EXPAND, "%s", label); box = AG_BoxNewVert(w, AG_BOX_HFILL); AG_WidgetSetSize(box, 230, 32); box2 = AG_BoxNewHoriz(box, 0); btn[0] = AG_ButtonNewFn (AGWIDGET(box2), 0, gettext("BASIC"), SetBootMode, "%i", FALSE); box2 = AG_BoxNewVert(box, 0); btn[1] = AG_ButtonNewFn (AGWIDGET(box2), 0, gettext("DOS"), SetBootMode, "%i", TRUE); box2 = AG_BoxNewVert(box, 0); btn[2] = AG_ButtonNewFn (AGWIDGET(box2), 0, gettext("Cancel"), OnPushCancel, NULL); AG_ActionFn(AGWIDGET(w), "window-close", OnPushCancel, NULL); AG_WindowSetCaption(w, gettext("Boot Mode")); AG_WindowShow(w); }
void Create_AGMainBar(AG_Widget *Parent) { AG_MenuItem *item; // MenuBar = AG_MenuNew(Parent, AG_MENU_HFILL); // MenuBar = AG_MenuNewGlobal(AG_MENU_HFILL); if(!MenuBar) return; AG_LockVFS(AGOBJECT(MenuBar)); item = AG_MenuNode(MenuBar->root , gettext("File"), NULL); Create_FileMenu(item); item = AG_MenuNode(MenuBar->root, gettext("Drive 1"), NULL); Create_Drive1Menu(item); item = AG_MenuNode(MenuBar->root, gettext("Drive 0"), NULL); Create_Drive0Menu(item); item = AG_MenuNode(MenuBar->root, gettext("Tape"), NULL); Create_TapeMenu(item); item = AG_MenuNode(MenuBar->root, gettext("Debug"), NULL); Create_DebugMenu(item); item = AG_MenuNode(MenuBar->root, gettext("Tools"), NULL); Create_ToolsMenu(item); item = AG_MenuNode(MenuBar->root, gettext("Help"), NULL); Create_HelpMenu(item); item = AG_MenuNode(MenuBar->root, gettext("About"), NULL); Create_AboutMenu(item); AG_UnlockVFS(AGOBJECT(MenuBar)); // F12 -> Menu 閉じる AG_ActionFn(AGWIDGET(MenuBar), "close-menu", UnraiseMenu, NULL); AG_ActionOnKeyDown(AGWIDGET(MenuBar), AG_KEY_F12, AG_KEYMOD_NONE, "close-menu"); }
/* * ステータスバーの生成 */ void CreateStatus(AG_Widget *parent) { AG_Rect rec; AG_Surface *tmps; AG_PixelFormat fmt; int i; r.r = 255; // r->g r.g = 0; // g->b r.b = 0; // b->r r.a = 255; // a->a b.r = 0; b.g = 0; b.b = 255; b.a = 255; n.r = 255; n.g = 255; n.b = 255; n.a = 255; black.r = 0; black.g = 0; black.b = 0; black.a = 255; // // アルファチャンネル alpha.r = 1; alpha.g = 1; alpha.b = 1; alpha.a = 180; // // Surfaceつくる SetPixelFormat(&fmt); pStatusFont = AG_FetchFont (StatusFont, STAT_PT, 0); // Init Var nFontSize = STAT_PT; if(parent) { AG_VBox *vb; AG_HBox *hb; { hb = (AG_HBox *)parent; InitStatOSD(AGWIDGET(hb)); InitVFD(AGWIDGET(hb)); InitTapeOSD(AGWIDGET(hb)); InitLeds(AGWIDGET(hb)); } } }
static int resizePlayer(ffmpegPlayer *me) { /* resizePlayer may be called before any size allocation */ int widget_w = AGWIDGET(me)->w > 0 ? AGWIDGET(me)->w : me->w; int widget_h = AGWIDGET(me)->h > 0 ? AGWIDGET(me)->h : me->h; if (me->flags & AG_FFMPEGPLAYER_KEEPRATIO) { int film_w, film_h; float aspect; SDL_ffmpegGetVideoSize(me->file, &film_w, &film_h); aspect = (float)film_h / film_w; if (widget_w * aspect > widget_h) { me->disp_w = SCALE_FLOOR((int)(widget_h / aspect)); me->disp_h = SCALE_FLOOR(widget_h); } else { me->disp_w = SCALE_FLOOR(widget_w); me->disp_h = SCALE_FLOOR((int)(widget_w * aspect)); } } else { me->disp_w = SCALE_FLOOR(widget_w); me->disp_h = SCALE_FLOOR(widget_h); } #ifndef USE_OVERLAY for (int i = 0; i < FFMPEGPLAYER_BUFSIZE; i++) { SDL_ffmpegVideoFrame *frame = me->videoFrame[i]; if (frame->surface != NULL) SDL_FreeSurface(frame->surface); frame->surface = SDL_CreateRGBSurface(SDL_HWSURFACE, me->disp_w, me->disp_h, 24, htonl(0xFF000000), htonl(0x00FF0000), htonl(0x0000FF00), 0x0); if (frame->surface == NULL) /* FIXME */ return -1; SDL_ffmpegGetVideoFrame(me->file, frame); } me->curVideoFrame = 0; #endif return 0; }
static void SoundMenu2(AG_NotebookTab *parent, struct gui_sound *cfg) { AG_Radio *radio; AG_Checkbox *check; AG_Numerical *num; AG_Label *lbl; AG_Box *box; AG_Box *box2; int i; box = AG_BoxNewVert(AGWIDGET(parent), AG_BOX_VFILL); { check = AG_CheckboxNewInt(AGWIDGET(box), AG_CHECKBOX_HFILL, gettext("Enable OPN"), &(cfg->bOPNEnable)); check = AG_CheckboxNewInt(AGWIDGET(box), AG_CHECKBOX_HFILL, gettext("Enable WHG"), &(cfg->bWHGEnable)); check = AG_CheckboxNewInt(AGWIDGET(box), AG_CHECKBOX_HFILL, gettext("Enable THG"), &(cfg->bTHGEnable)); } }
/* * Initialization routine. Note that the object system will automatically * invoke the initialization routines of the parent classes first. */ static void Init(void *obj) { formaText *my = (formaText*)obj; /* Allow this widget to grab focus. */ AGWIDGET(my)->flags |= AG_WIDGET_FOCUSABLE; /* * We'll eventually need to create and map a surface, but we cannot * do this from Init(), because it involves texture operations in * GL mode which are thread-unsafe. We wait until Draw() to do that. */ my->mySurface = -1; /* * Map our event handlers. For a list of all meaningful events * we can handle, see AG_Object(3), AG_Widget(3) and AG_Window(3). * * Here we register handlers for the common AG_Window(3) events. */ AG_SetEvent(my, "mouse-button-up", MouseButtonUp, NULL); AG_SetEvent(my, "mouse-button-down", MouseButtonDown, NULL); AG_SetEvent(my, "mouse-motion", MouseMotion, NULL); AG_SetEvent(my, "key-up", KeyUp, NULL); AG_SetEvent(my, "key-down", KeyDown, NULL); }
/* * セレクト */ BOOL SelectDraw(void) { BOOL ret; AG_Color nullcolor; AG_Rect rect; AG_Widget *w; BYTE bold = bMode; int y; if (SelectCheck()) { return TRUE; } rect.h = nDrawWidth; rect.w = nDrawHeight; rect.x = 0; rect.y = 0; DrawSHUTDOWN = FALSE; /* * すべてクリア */ if(!bUseOpenGL) { if(DrawArea != NULL) { AG_ObjectLock(DrawArea); nullcolor.r = 0; nullcolor.g = 0; nullcolor.b = 0; nullcolor.a = 255; AG_FillRect(AGWIDGET(DrawArea)->drv->sRef , &rect, nullcolor); AG_ObjectUnlock(DrawArea); } } else { // OpenGLのとき } /* * すべてクリア */ bOldFullScan = bFullScan; /* * セレクト */ #if XM7_VER >= 3 switch (screen_mode) { case SCR_400LINE: ret = Select400l(); case SCR_262144: ret = Select256k(); case SCR_4096: ret = Select320(); default: ret = Select640(); } #else /* */ if (mode320) { ret = Select320(); } else { ret = Select640(); } } else {
static void ConfigMenuBright(struct gui_disp *cfg, AG_NotebookTab *parent) { AG_Slider *slider; AG_Box *box; AG_Box *vbox; AG_Label *lbl; lbl = AG_LabelNew(AGWIDGET(parent), 0, "%s", gettext("Bright")); // slider = AG_SliderNewFltR(AGWIDGET(parent),AG_SLIDER_HORIZ, AG_SLIDER_HFILL, &fBright0, 0.0f, 1.0f); slider = AG_SliderNew(AGWIDGET(parent), AG_SLIDER_HORIZ, AG_SLIDER_HFILL); AG_SetUint16(slider, "value", cfg->nBrightness); AG_SetUint16(slider, "min", 0); AG_SetUint16(slider, "max", 255); #ifdef USE_OPENGL AG_SetEvent(AGOBJECT(slider), "slider-changed", OnChangeBright, "%p", cfg); #endif /* USE_OPENGL */ box = AG_BoxNewHoriz(AGWIDGET(parent), AG_BOX_HFILL); }
static void ErrorPopup(char *message) { AG_Window *win; win = AG_WindowNew(0); if(win == NULL) { if(message == NULL) return; XM7_DebugLog(XM7_LOG_INFO, "Error: %s.", message); return; } else { AG_VBox *vb; AG_Textbox *tb; XM7_DebugLog(XM7_LOG_INFO, "Error: %s.", message); vb = AG_VBoxNew(AGWIDGET(win), AG_HBOX_HFILL); if(message != NULL) tb = AG_TextboxNew(vb, AG_TEXTBOX_MULTILINE, "%s", message); AG_ButtonNewFn(AGWIDGET(vb), 0, gettext("Close"), OnPushCancel, NULL); AG_WindowShow(win); } }
static void CreateWindow(void) { AG_Window *win; AG_Label *lbl; AG_Console *cons; win = AG_WindowNew(0); AG_WindowSetCaption(win, "Agar keyboard events demo"); lbl = AG_LabelNew(win, AG_LABEL_HFILL, "Agar keyboard events demo"); AG_LabelJustify(lbl, AG_TEXT_CENTER); AG_SeparatorNewHoriz(win); cons = AG_ConsoleNew(win, AG_CONSOLE_EXPAND); AG_ConsoleMsg(cons, "Press any key..."); /* * Attach our event handler function to both keydown and keyup * events of the Window object. Note that we could have used * any other object derived from the Widget class. */ AG_SetEvent(win, "key-down", MyKeyboardHandler, "%p", cons); AG_SetEvent(win, "key-up", MyKeyboardHandler, "%p", cons); /* * Enable reception of keydown/keyup events by the window, regardless * of whether it is currently focused or not. */ AGWIDGET(win)->flags |= AG_WIDGET_UNFOCUSED_KEYUP; AGWIDGET(win)->flags |= AG_WIDGET_UNFOCUSED_KEYDOWN; AG_ButtonNewFn(win, AG_BUTTON_HFILL, "Quit", Quit, NULL); AG_WindowShow(win); AG_WindowSetGeometryAlignedPct(win, AG_WINDOW_MC, 30, 30); }
void OnConfigDisplayMenu(AG_Event *event) { AG_MenuItem *self = (AG_MenuItem *)AG_SELF(); AG_Window *win; AG_Notebook *note; AG_Notebook *note2; AG_NotebookTab *tab; AG_NotebookTab *tab2; AG_Box *box; AG_Button *btn; struct gui_disp *cfg; int i, num; cfg = (struct gui_disp *)malloc(sizeof(struct gui_disp)); if(cfg == NULL) return; { LockVM(); cfg->nDrawFPS = configdat.nDrawFPS; cfg->nEmuFPS = configdat.nEmuFPS; cfg->nBrightness = configdat.nBrightness; cfg->nRenderMethod = configdat.nRenderMethod; cfg->uWidth = configdat.uWidth; cfg->uHeight = configdat.uHeight; cfg->bFullScan = configdat.bFullScan; cfg->bFullScanFS = configdat.bFullScanFS; cfg->bSmoosing = configdat.bSmoosing; cfg->bUseSIMD = configdat.bUseSIMD; #ifdef _USE_OPENCL cfg->bUseOpenCL = configdat.bUseOpenCL; cfg->nCLGlobalWorkThreads = configdat.nCLGlobalWorkThreads; cfg->bCLSparse = configdat.bCLSparse; cfg->nCLDeviceNum = configdat.nCLDeviceNum; cfg->nCLPlatformNum = configdat.nCLPlatformNum; cfg->bCLInteropGL = configdat.bCLInteropGL; for(i = 0; i <= 8; i++) cfg->sDeviceName[i] = NULL; if(cldraw == NULL) { num = 8; } else { num = cldraw->GetDevices(); } if(num >= 8) num = 8; if(num <= 0) num = 0; for(i = 0; i < num; i++) { cfg->sDeviceName[i] = malloc(96 * sizeof(char)); cfg->sDeviceName[i][0] = '\0'; if(cldraw == NULL) { snprintf(cfg->sDeviceName[i], 94, "Processor #%d", i); } else { char sName[64]; char sType[16]; cldraw->GetDeviceName(sName, 64, i); cldraw->GetDeviceType(sType, 16, i); snprintf(cfg->sDeviceName[i], 94, "%s(%s)", sType, sName); } } cfg->sDeviceName[8] = NULL; #endif UnlockVM(); } win= AG_WindowNew(DIALOG_WINDOW_DEFAULT); note = AG_NotebookNew(AGWIDGET(win), AG_NOTEBOOK_HFILL); { tab = AG_NotebookAddTab(note, gettext("Screen"), AG_BOX_HORIZ); OnConfigMenuScreen(cfg, tab); #ifdef USE_OPENGL tab = AG_NotebookAddTab(note, gettext("Display"), AG_BOX_HORIZ); ConfigMenuBright(cfg, tab); #endif /* USE_OPENGL */ #ifdef _USE_OPENCL tab = AG_NotebookAddTab(note, gettext("OpenCL"), AG_BOX_HORIZ); ConfigMenuOpenCL(cfg, tab); #endif /* USE_OPENGL */ } box = AG_BoxNewHoriz(AGWIDGET(win), AG_BOX_HFILL); AG_WidgetSetSize(AGWIDGET(box), 320, 24); { AG_Box *vbox; vbox = AG_BoxNewVert(AGWIDGET(box), AG_BOX_VFILL); btn = AG_ButtonNewFn(AGWIDGET(box), 0, gettext("OK"), OnConfigApplyDisp, "%p", cfg); vbox = AG_BoxNewVert(AGWIDGET(box), AG_BOX_VFILL); AG_WidgetSetSize(AGWIDGET(vbox), 80, 24); vbox = AG_BoxNewVert(AGWIDGET(box), AG_BOX_VFILL); btn = AG_ButtonNewFn(AGWIDGET(box), 0, gettext("Cancel"), OnPushCancel2, "%p", cfg); } AG_SetEvent(win, "window-close", OnPushCancel2, "%p", cfg); AG_WindowSetCaption(win, gettext("Display")); AG_WindowShow(win); }
static void OnConfigMenuScreen(struct gui_disp *cfg, AG_NotebookTab *parent) { AG_Radio *radio; AG_Checkbox *check; AG_Numerical *fps; AG_Box *box; AG_Box *box2; AG_Combo *combo; AG_TlistItem *TlistItem[RENDERING_END]; int i; int limit; box = AG_BoxNewHoriz(AGWIDGET(parent), AG_BOX_VFILL); { radio = AG_RadioNewFn(AGWIDGET(box), 0, ScreenSizeName, OnChangeScreenReso, "%p", cfg); limit = sizeof(ScreenSizeHeight) / sizeof(WORD); for(i = 0; i <= limit; i++){ if((ScreenSizeWidth[i] == cfg->uWidth) && (ScreenSizeHeight[i] == cfg->uHeight)) break; } if(i >= limit) i = 2; AG_SetInt(radio, "value", i); box = AG_BoxNewVert(AGWIDGET(parent), AG_BOX_HFILL); fps = AG_NumericalNewS(AGWIDGET(box), AG_NUMERICAL_HFILL, NULL ,gettext("Display rate")); AG_BindUint16(fps, "value", &(cfg->nDrawFPS)); { AG_SetInt(fps, "min", 2); AG_SetInt(fps, "max", 75); AG_SetInt(fps, "inc", 1); } fps = AG_NumericalNewS(AGWIDGET(box), AG_NUMERICAL_HFILL, NULL ,gettext("Emulation rate")); AG_BindUint16(fps, "value", &(cfg->nEmuFPS)); { AG_SetInt(fps, "min", 2); AG_SetInt(fps, "max", 75); AG_SetInt(fps, "inc", 1); } box2 = AG_BoxNewHoriz(AGWIDGET(box), AG_BOX_HFILL); combo = AG_ComboNewS(AGWIDGET(box2), AG_COMBO_SCROLLTOSEL | AG_COMBO_HFILL, gettext("Rendering Method")); AG_ComboSizeHint(combo, "XXXXXXXXXXXXXX", RENDERING_END); TlistItem[0] = AG_TlistAddPtrHead(combo->list, NULL, gettext("Full Draw"), (void *)&RenderMethodsList[0]); TlistItem[1] = AG_TlistAddPtr(combo->list, NULL, gettext("Diff Block"), (void *)&RenderMethodsList[1]); TlistItem[2] = AG_TlistAddPtr(combo->list, NULL, gettext("Diff Raster"), (void *)&RenderMethodsList[2]); for(i = RENDERING_FULL; i < RENDERING_END; i++) { if(i == cfg->nRenderMethod) { AG_ComboSelect(combo, TlistItem[i]); } } AG_SetEvent(combo, "combo-selected", RenderMethodSelected, "%p", cfg); box2 = AG_BoxNewHoriz(AGWIDGET(box), AG_BOX_HFILL); check = AG_CheckboxNewInt(AGWIDGET(box2), AG_CHECKBOX_HFILL, gettext("Full Scan (15KHz)"), &(cfg->bFullScan)); box2 = AG_BoxNewHoriz(AGWIDGET(box), AG_BOX_HFILL); check = AG_CheckboxNewInt(AGWIDGET(box2), AG_CHECKBOX_HFILL, gettext("SMOOSING"), &(cfg->bSmoosing)); box2 = AG_BoxNewHoriz(AGWIDGET(box), AG_BOX_HFILL); check = AG_CheckboxNewInt(AGWIDGET(box2), AG_CHECKBOX_HFILL, gettext("Use OpenCL(Need REBOOT)"), &(cfg->bUseOpenCL)); box2 = AG_BoxNewHoriz(AGWIDGET(box), AG_BOX_HFILL); check = AG_CheckboxNewInt(AGWIDGET(box2), AG_CHECKBOX_HFILL, gettext("Use SIMD instructions(Need REBOOT)"), &(cfg->bUseSIMD)); } }
static void * drawVideoThread(void *data) { ffmpegPlayer *me = data; AG_ObjectLock(me); for (;;) { SDL_ffmpegVideoFrame *frame = me->videoFrame[me->curVideoFrame]; if (!frame->ready) { DEBUG("Video buffer underrun!"); SDL_ffmpegGetVideoFrame(me->file, frame); } uint64_t sync = getSync(me); uint64_t pts = frame->pts; if (pts >= sync) { AG_ObjectUnlock(me); /* condition variable waiting may be faster, test with 500mhz */ AG_Delay(pts - sync); AG_ObjectLock(me); if (me->file == NULL) { /* FIXME */ break; } if (pts > getSync(me)) continue; #ifdef USE_OVERLAY if (frame->overlay != NULL) { if (AG_WidgetVisible(me)) { int frame_x = (AGWIDGET(me)->w - me->disp_w) / 2; int frame_y = (AGWIDGET(me)->h - me->disp_h) / 2; SDL_Rect rect = { .x = AGWIDGET(me)->rView.x1 + frame_x, .y = AGWIDGET(me)->rView.y1 + frame_y, .w = me->disp_w, .h = me->disp_h }; SDL_DisplayYUVOverlay(frame->overlay, &rect); } } #else if (frame->surface != NULL) { #ifdef USE_SDL_SHADOWSURFACE if (me->surface != NULL) AG_SDL_ShadowSurfaceFree(me->surface); me->surface = AG_SDL_ShadowSurface(frame->surface); #else if (me->surface != NULL) AG_SurfaceFree(me->surface); me->surface = AG_SurfaceFromSDL(frame->surface); #endif if (me->surface == NULL) { /* FIXME */ break; } AG_Redraw(AGWIDGET(me)); } #endif } else { /* frame is skipped */ DEBUG("skip frame: %lums late", sync - frame->pts); } frame->ready = 0; RR_INC(me->curVideoFrame, FFMPEGPLAYER_BUFSIZE); /* wake up buffer-fill thread */ AG_CondSignal(&me->video_cond); }
void RaiseMenu(AG_Event *event) { if(MenuBar != NULL) { AG_WidgetFocus(AGWIDGET(MenuBar)); } }
static void VolumeMenu(AG_NotebookTab *parent, struct gui_sound *cfg) { AG_Slider *slider; AG_Box *box; AG_Box *vbox; AG_Label *lbl; lbl = AG_LabelNew(AGWIDGET(parent), 0, "%s", gettext("Main Volume")); slider = AG_SliderNewIntR(AGWIDGET(parent),AG_SLIDER_HORIZ, AG_SLIDER_HFILL, &(cfg->iTotalVolume), 0, 128); AG_SetEvent(AGOBJECT(slider), "slider-changed", OnChangeTotalVolume, "%p", cfg); box = AG_BoxNewHoriz(AGWIDGET(parent), AG_BOX_HFILL); AG_WidgetSetSize(AGWIDGET(box), 320, 12); lbl = AG_LabelNew(AGWIDGET(parent), 0, "%s", gettext("PSG")); slider = AG_SliderNewIntR(AGWIDGET(parent),AG_SLIDER_HORIZ, AG_SLIDER_HFILL, &(cfg->nPSGVolume), -40, 12); AG_SetEvent(AGOBJECT(slider), "slider-changed", OnChangeVolume, "%p", cfg); lbl = AG_LabelNew(AGWIDGET(parent), 0, "%s", gettext("FM")); slider = AG_SliderNewIntR(AGWIDGET(parent),AG_SLIDER_HORIZ, AG_SLIDER_HFILL, &(cfg->nFMVolume), -40, 12); AG_SetEvent(AGOBJECT(slider), "slider-changed", OnChangeVolume, "%p", cfg); lbl = AG_LabelNew(AGWIDGET(parent), 0, "%s", gettext("BEEP")); slider = AG_SliderNewIntR(AGWIDGET(parent),AG_SLIDER_HORIZ, AG_SLIDER_HFILL, &(cfg->nBeepVolume), -35, 12); AG_SetEvent(AGOBJECT(slider), "slider-changed", OnChangeVolume, "%p", cfg); lbl = AG_LabelNew(AGWIDGET(parent), 0, "%s", gettext("CMT")); slider = AG_SliderNewIntR(AGWIDGET(parent),AG_SLIDER_HORIZ, AG_SLIDER_HFILL, &(cfg->nCMTVolume), -35, 6); AG_SetEvent(AGOBJECT(slider), "slider-changed", OnChangeVolume, "%p", cfg); lbl = AG_LabelNew(AGWIDGET(parent), 0, "%s", gettext("SFX")); slider = AG_SliderNewIntR(AGWIDGET(parent),AG_SLIDER_HORIZ, AG_SLIDER_HFILL, &(cfg->nWaveVolume), -35, 12); AG_SetEvent(AGOBJECT(slider), "slider-changed", OnChangeVolume, "%p", cfg); lbl = AG_LabelNew(AGWIDGET(parent), 0, "%s", gettext("Channel Separation")); slider = AG_SliderNewUint32R(AGWIDGET(parent),AG_SLIDER_HORIZ, AG_SLIDER_HFILL, &(cfg->uChSeparation), 0, 16); AG_SetEvent(AGOBJECT(slider), "slider-changed", OnChangeVolume, "%p", cfg); }
void OnConfigSoundMenu(AG_Event *event) { AG_MenuItem *self = (AG_MenuItem *)AG_SELF(); AG_Window *win; AG_Notebook *note; AG_Notebook *note2; AG_NotebookTab *tab; AG_NotebookTab *tab2; AG_Box *box; AG_Button *btn; struct gui_sound *cfg; cfg = malloc(sizeof(struct gui_sound)); if(cfg == NULL) return; { cfg->iTotalVolume = configdat.iTotalVolume; cfg->nFMVolume = configdat.nFMVolume; cfg->nPSGVolume = configdat.nPSGVolume; cfg->nBeepVolume = configdat.nBeepVolume; cfg->nCMTVolume = configdat.nCMTVolume; cfg->nWaveVolume = configdat.nWaveVolume; cfg->uChSeparation = configdat.uChSeparation; cfg->nSampleRate = configdat.nSampleRate; cfg->nSoundBuffer = configdat.nSoundBuffer; cfg->nBeepFreq = configdat.nBeepFreq; cfg->bFMHQmode = configdat.bFMHQmode; cfg->nStereoOut = configdat.nStereoOut; cfg->bTapeMon = configdat.bTapeMon; cfg->bOPNEnable = configdat.bOPNEnable; cfg->bWHGEnable = configdat.bWHGEnable; cfg->bTHGEnable = configdat.bTHGEnable; #ifdef FDDSND cfg->bFddSound = configdat.bFddSound; #endif } win= AG_WindowNew(DIALOG_WINDOW_DEFAULT); note = AG_NotebookNew(AGWIDGET(win), AG_NOTEBOOK_HFILL); { tab = AG_NotebookAddTab(note, gettext("Volume"), AG_BOX_VERT); VolumeMenu(tab, cfg); tab = AG_NotebookAddTab(note, gettext("Rendering"), AG_BOX_HORIZ); SoundMenu(tab, cfg); tab = AG_NotebookAddTab(note, gettext("Misc"), AG_BOX_HORIZ); SoundMenu2(tab, cfg); } box = AG_BoxNewHoriz(AGWIDGET(win), AG_BOX_HFILL); AG_WidgetSetSize(AGWIDGET(box), 320, 24); { AG_Box *vbox; vbox = AG_BoxNewVert(AGWIDGET(box), AG_BOX_VFILL); btn = AG_ButtonNewFn(AGWIDGET(box), 0, gettext("OK"), OnConfigApplySound, "%p", cfg); vbox = AG_BoxNewVert(AGWIDGET(box), AG_BOX_VFILL); AG_WidgetSetSize(AGWIDGET(vbox), 80, 24); vbox = AG_BoxNewVert(AGWIDGET(box), AG_BOX_VFILL); btn = AG_ButtonNewFn(AGWIDGET(box), 0, gettext("Cancel"), OnPushCancel2, "%p", cfg); } AG_SetEvent(win, "window-close", OnPushCancel2, "%p", cfg); AG_WindowSetCaption(win, gettext("Sound Preferences")); AG_WindowShow(win); }
/* * マウス キャプチャ状態設定 */ void SetMouseCapture(BOOL en) { int x; int y; //SDL_SysWMinfo sdlinfo; /* * キャプチャ停止中/VM停止中/非アクティブ時は強制的に無効 */ if (!mos_capture || stopreq_flag || !run_flag || !bActivate) { en = FALSE; } /* * カーソル表示/消去 */ if (bMouseCursor == en) { if (!en) { #ifdef USE_OPENGL if(GLDrawArea != NULL) { AG_HideCursor(AGDRIVER(GLDrawArea)); } else #endif if (DrawArea != NULL) { AG_HideCursor(AGDRIVER(DrawArea)); } } else { #ifdef USE_OPENGL if(GLDrawArea != NULL) { AG_ShowCursor(AGDRIVER(GLDrawArea)); } else #endif if (DrawArea != NULL) { AG_ShowCursor(AGDRIVER(DrawArea)); } } bMouseCursor = !en; } /* * キャプチャ状態に変化がなければ帰る */ if (bMouseCaptureFlag == en) { return; } if (en) { /* * カーソル位置を保存 */ // gtk_widget_get_pointer(drawArea, &x, &y); GetMousePos(&x, &y); nMouseSX = x; nMouseSY = y; /* * 描画ウィンドウのサイズを求める */ // gdk_window_get_size(drawArea->window, &nDAreaW, &nDAreaH); /* * 中心座標を求める */ /* * カーソルをウィンドウ中央に固定 */ #ifdef USE_OPENGL if(GLDrawArea != NULL) { x = GLDrawArea->wid.w / 2; y = GLDrawArea->wid.h / 2; AG_ExecMouseAction (GLDrawArea, AG_ACTION_ON_BUTTONUP, AG_MOUSE_NONE, x, y); if(AG_UsingSDL(AGDRIVER(GLDrawArea))) SDL_WM_GrabInput(SDL_GRAB_ON); } else #endif if(DrawArea != NULL) { x = AGWIDGET(DrawArea)->w / 2; y = AGWIDGET(DrawArea)->h / 2; AG_ExecMouseAction (DrawArea, AG_ACTION_ON_BUTTONUP, AG_MOUSE_NONE, x, y); if(AG_UsingSDL(AGDRIVER(DrawArea))) SDL_WM_GrabInput(SDL_GRAB_ON); } } else { /* * クリップ解除 */ //gdk_pointer_ungrab(GDK_CURRENT_TIME); // if(SDL_GetWMInfo(&sdlinfo)) { // XUngrabPointer(sdlinfo.info.x11.display, CurrentTime); //} /* * カーソル位置を復元 */ #ifdef USE_OPENGL if(GLDrawArea != NULL) { x = nMouseSX; y = nMouseSY; AG_ExecMouseAction (GLDrawArea, AG_ACTION_ON_BUTTONUP, AG_MOUSE_NONE, x, y); if(AG_UsingSDL(AGDRIVER(GLDrawArea))) SDL_WM_GrabInput(SDL_GRAB_OFF); } else #endif if(DrawArea != NULL) { x = nMouseSX; y = nMouseSY; AG_ExecMouseAction (DrawArea, AG_ACTION_ON_BUTTONUP, AG_MOUSE_NONE, x, y); if(AG_UsingSDL(AGDRIVER(DrawArea))) SDL_WM_GrabInput(SDL_GRAB_OFF); } } /* * キャプチャ状態を保存 */ bMouseCaptureFlag = en; /* * マウス移動距離をクリア */ nMouseX = 0; nMouseY = 0; }
int main(int argc, char *argv[]) { #ifdef HAVE_SDL AG_Window *win; SDL_Surface *screen, *bmp, *tex1, *tex2, *avatar; AG_Surface *agbmp, *agavatar; int c, useGL = 0; Uint32 sdlFlags = 0; char *optArg; Uint32 rmask, gmask, bmask, amask; if (AG_InitCore("agar-sdl-demo", 0) == -1) { fprintf(stderr, "AG_InitCore: %s\n", AG_GetError()); goto fail; } while ((c = AG_Getopt(argc, argv, "?g", &optArg, NULL)) != -1) { switch (c) { case 'g': useGL = 1; break; default: printf("Usage: %s [-g]\n", agProgName); break; } } /* Set up SDL */ if (SDL_Init(SDL_INIT_VIDEO) == -1) { fprintf(stderr, "SDL_Init: %s\n", SDL_GetError()); return (1); } if (useGL) { sdlFlags = SDL_RESIZABLE | SDL_OPENGL; } else { sdlFlags = SDL_RESIZABLE | SDL_SWSURFACE; } if ((screen = SDL_SetVideoMode(320, 240, 32, sdlFlags)) == NULL) { fprintf(stderr, "SDL_SetVideoMode: %s\n", SDL_GetError()); goto fail; } if (useGL) { /* Set up OpenGL viewport and projection. */ AG_GL_InitContext(AG_RECT(0, 0, 320, 240)); } /* Initialize Agar-GUI to reuse display */ if (AG_InitVideoSDL(screen, 0) == -1) { fprintf(stderr, "%s\n", AG_GetError()); AG_Destroy(); goto fail; } AG_BindGlobalKey(AG_KEY_ESCAPE, AG_KEYMOD_ANY, AG_QuitGUI); /* Display some test widgets. */ win = AG_WindowNew(AG_WINDOW_PLAIN); AG_LabelNew(win, 0, "Attached to existing %s display", useGL ? "SDL/OpenGL" : "SDL"); /* Test conversion from SDL_Surface to AG_Surface. */ if ((bmp = SDL_LoadBMP("agar.bmp")) != NULL) { if ((agbmp = AG_SurfaceFromSDL(bmp)) != NULL) { AG_PixmapFromSurface(win, 0, agbmp); } else { AG_LabelNewS(win, 0, AG_GetError()); } } double vDbl = 1.0, minDbl = -1e6, maxDbl = 1e6, visDbl = 0.0; AG_Console *cons; cons = AG_ConsoleNew(win, AG_CONSOLE_EXPAND); AG_SetEvent(win, "key-down", MyKeyboardHandler, "%p", cons); AG_SetEvent(win, "key-up", MyKeyboardHandler, "%p", cons); AGWIDGET(win)->flags |= AG_WIDGET_UNFOCUSED_KEYUP; AGWIDGET(win)->flags |= AG_WIDGET_UNFOCUSED_KEYDOWN; AG_Scrollbar *sb; sb = AG_ScrollbarNewDouble(win, AG_SCROLLBAR_HORIZ, AG_SCROLLBAR_HFILL, &vDbl, &minDbl, &maxDbl, &visDbl); #ifdef HAVE_SDL_IMAGE if ((tex1 = IMG_Load("test1.png")) == NULL || (tex2 = IMG_Load("test2.png")) == NULL) { fprintf(stderr, "IMG_Load() failed\n"); goto fail; } # if SDL_BYTEORDER == SDL_BIG_ENDIAN rmask = 0xff000000; gmask = 0x00ff0000; bmask = 0x0000ff00; amask = 0x000000ff; # else rmask = 0x000000ff; gmask = 0x0000ff00; bmask = 0x00ff0000; amask = 0xff000000; # endif avatar = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA, 64, 128, tex1->format->BitsPerPixel, rmask, gmask, bmask, amask); SDL_SetAlpha(tex1, 0, 0); SDL_BlitSurface(tex1, NULL, avatar, NULL); SDL_SetAlpha(tex2, SDL_SRCALPHA, 0); SDL_BlitSurface(tex2, NULL, avatar, NULL); if ((agavatar = AG_SurfaceFromSDL(avatar)) != NULL) { AG_PixmapFromSurface(win, 0, agavatar); } else { AG_LabelNewS(win, 0, AG_GetError()); } #endif /* HAVE_SDL_IMAGE */ AG_WindowShow(win); AG_EventLoop(); AG_Destroy(); SDL_Quit(); return (0); fail: SDL_Quit(); return (1); #else fprintf(stderr, "Agar was compiled without SDL support\n"); return (1); #endif /* HAVE_SDL */ }