diff --git a/desmume/src/gtk-glade/callbacks.c b/desmume/src/gtk-glade/callbacks.c index 9434131bb..cb754a73e 100755 --- a/desmume/src/gtk-glade/callbacks.c +++ b/desmume/src/gtk-glade/callbacks.c @@ -47,7 +47,7 @@ void enable_rom_features() { void MAINWINDOW_RESIZE() { GtkWidget * spacer1 = glade_xml_get_widget(xml, "misc_sep3"); GtkWidget * spacer2 = glade_xml_get_widget(xml, "misc_sep4"); - int dim = 66 * ScreenCoeff_Size; + int dim = 66 * ScreenCoeff_Size[0]; /* sees whether we want a gap */ if (!ScreenGap) dim = -1; @@ -195,22 +195,23 @@ void on_fs9_activate (GtkMenuItem *menuitem,gpointer user_data) { Frameskip = /* SUBMENU SIZE ***** ***** ***** ***** */ int H=192, W=256; -void resize (int Size) { +void resize (float Size1, float Size2) { + // not ready yet to handle different zoom factors + Size2 = Size1; /* we want to scale drawing areas by a factor (1x,2x or 3x) */ - gtk_drawing_area_size(GTK_DRAWING_AREA(pDrawingArea), W * Size, H * Size); - gtk_widget_set_usize (pDrawingArea, W * Size, H * Size); - gtk_drawing_area_size(GTK_DRAWING_AREA(pDrawingArea2), W * Size, H * Size); - gtk_widget_set_usize (pDrawingArea2, W * Size, H * Size); - ScreenCoeff_Size = Size; + gtk_widget_set_size_request (pDrawingArea, W * Size1, H * Size1); + gtk_widget_set_size_request (pDrawingArea2, W * Size2, H * Size2); + ScreenCoeff_Size[0] = Size1; + ScreenCoeff_Size[1] = Size2; /* remove artifacts */ black_screen(); /* pack the window */ MAINWINDOW_RESIZE(); } -void on_size1x_activate (GtkMenuItem *menuitem, gpointer user_data) { resize(1); } -void on_size2x_activate (GtkMenuItem *menuitem, gpointer user_data) { resize(2); } -void on_size3x_activate (GtkMenuItem *menuitem, gpointer user_data) { resize(3); } +void on_size1x_activate (GtkMenuItem *menuitem, gpointer user_data) { resize(1.0,1.0); } +void on_size2x_activate (GtkMenuItem *menuitem, gpointer user_data) { resize(2.0,2.0); } +void on_size3x_activate (GtkMenuItem *menuitem, gpointer user_data) { resize(3.0,3.0); } /* MENU CONFIG ***** ***** ***** ***** */ @@ -303,7 +304,7 @@ void on_menu_rotatescreen_activate (GtkMenuItem *menuitem, gpointer user_data) } else { W=256; H=192; } - resize(ScreenCoeff_Size); + resize(ScreenCoeff_Size[0],ScreenCoeff_Size[1]); } /* MENU TOOLS ***** ***** ***** ***** */ diff --git a/desmume/src/gtk-glade/callbacks_IO.c b/desmume/src/gtk-glade/callbacks_IO.c index 9a9824f3c..c24e44d60 100755 --- a/desmume/src/gtk-glade/callbacks_IO.c +++ b/desmume/src/gtk-glade/callbacks_IO.c @@ -23,8 +23,7 @@ #include "callbacks_IO.h" static u16 Cur_Keypad = 0; -int ScreenCoeff_Size=1; -float fScreenCoeff_Size=1.0; +float ScreenCoeff_Size[2]={1.0,1.0}; gboolean ScreenRotate=FALSE; gboolean Boost=FALSE; int BoostFS=20; @@ -84,7 +83,8 @@ void init_pix_col_map() { u32 on_screen_image32[RAW_W*RAW_H*2*MAX_SIZE*MAX_SIZE]; int inline screen_size() { - return RAW_W*RAW_H*2*ScreenCoeff_Size*ScreenCoeff_Size*sizeof(u32); + int sz = ScreenCoeff_Size[0]; + return RAW_W*RAW_H*2*sz*sz*sizeof(u32); } int inline offset_pixels_lower_screen() { return screen_size()/2; @@ -111,17 +111,17 @@ void decode_screen () { } } #define LOOP(a,b,c,d,e,f) \ - L=W*ScreenCoeff_Size; \ + L=W*ScreenCoeff_Size[0]; \ BL=L*sizeof(u32); \ for (a; b; c) { \ for (d; e; f) { \ pix = image[y][x]; \ - for (m=0; mwindow, widget->style->fg_gc[widget->state],0,0, - W*ScreenCoeff_Size, H*ScreenCoeff_Size, + W*ScreenCoeff_Size[0], H*ScreenCoeff_Size[0], GDK_RGB_DITHER_NONE,((guchar*)on_screen_image32)+off,L); return TRUE; } @@ -204,8 +204,8 @@ gboolean on_wDraw_Sub_configure_event(GtkWidget *widget, GdkEventConfigure *eve void set_touch_pos (int x, int y) { s32 EmuX, EmuY; - x /= ScreenCoeff_Size; - y /= ScreenCoeff_Size; + x /= ScreenCoeff_Size[1]; + y /= ScreenCoeff_Size[1]; EmuX = x; EmuY = y; if (ScreenRotate) { EmuX = 256-y; EmuY = x; } if(EmuX<0) EmuX = 0; else if(EmuX>255) EmuX = 255; @@ -213,18 +213,39 @@ void set_touch_pos (int x, int y) { NDS_setTouchPos(EmuX, EmuY); } +gboolean on_wDraw_Main_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { + switch (event->button) { + case 1: break; + case 3: break; + case 2: ScreenCoeff_Size[0]=1.0; + resize(ScreenCoeff_Size[0],ScreenCoeff_Size[1]); break; + } + return TRUE; +} + +gboolean on_wDraw_Main_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { + return TRUE; +} + gboolean on_wDraw_Sub_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { GdkModifierType state; gint x,y; - if(desmume_running()) - if(event->button == 1) - { - click = TRUE; - gdk_window_get_pointer(widget->window, &x, &y, &state); - if (state & GDK_BUTTON1_MASK) - set_touch_pos(x,y); - } + switch (event->button) { + case 1: + if(desmume_running()) { + click = TRUE; + gdk_window_get_pointer(widget->window, &x, &y, &state); + if (state & GDK_BUTTON1_MASK) + set_touch_pos(x,y); + } + break; + case 3: break; + case 2: + ScreenCoeff_Size[0]=1.0; + //ScreenCoeff_Size[1]=1.0; // separate zoom factors + resize(ScreenCoeff_Size[0],ScreenCoeff_Size[1]); break; + } return TRUE; } @@ -234,6 +255,35 @@ gboolean on_wDraw_Sub_button_release_event (GtkWidget *widget, GdkEventButton return TRUE; } +static void resize_incremental(int i, GdkEventScroll *event) { +#ifdef HAVE_LIBGDKGLEXT_X11_1_0 + float zoom_inc=.125, zoom_min=0.25, zoom_max=5.0; +#else + float zoom_inc=1.0, zoom_min=1.0, zoom_max=3.0; +#endif + switch (event->direction) { + case GDK_SCROLL_UP: + ScreenCoeff_Size[i]=MIN(ScreenCoeff_Size[i]+zoom_inc,zoom_max); break; + case GDK_SCROLL_DOWN: + ScreenCoeff_Size[i]=MAX(ScreenCoeff_Size[i]-zoom_inc,zoom_min); break; + case GDK_SCROLL_LEFT: + case GDK_SCROLL_RIGHT: + return; + } + resize(ScreenCoeff_Size[0],ScreenCoeff_Size[1]); +} + +gboolean on_wDraw_Main_scroll_event (GtkWidget *widget, GdkEvent *event, gpointer user_data) { + resize_incremental(0,event); +} +gboolean on_wDraw_Sub_scroll_event (GtkWidget *widget, GdkEvent *event, gpointer user_data) { + // using separate zoom factors is bad for now + resize_incremental(0,event); +// resize_incremental(1,event); +} + + + gboolean on_wDraw_Sub_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, gpointer user_data) { GdkModifierType state; gint x,y; diff --git a/desmume/src/gtk-glade/callbacks_IO.h b/desmume/src/gtk-glade/callbacks_IO.h index c86d54090..57494443d 100755 --- a/desmume/src/gtk-glade/callbacks_IO.h +++ b/desmume/src/gtk-glade/callbacks_IO.h @@ -31,16 +31,20 @@ G_MODULE_EXPORT void on_wDraw_Main_realize (GtkWidget *widget, gpoint G_MODULE_EXPORT gboolean on_wDraw_Main_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data); G_MODULE_EXPORT gboolean on_wDraw_Main_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data); - /* OUTPUT LOWER SCREEN */ G_MODULE_EXPORT void on_wDraw_Sub_realize (GtkWidget *widget, gpointer user_data); G_MODULE_EXPORT gboolean on_wDraw_Sub_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data); G_MODULE_EXPORT gboolean on_wDraw_Sub_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data); /* INPUT STYLUS / MOUSE */ +G_MODULE_EXPORT gboolean on_wDraw_Sub_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, gpointer user_data); + +G_MODULE_EXPORT gboolean on_wDraw_Main_button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer user_data); +G_MODULE_EXPORT gboolean on_wDraw_Main_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data); G_MODULE_EXPORT gboolean on_wDraw_Sub_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data); G_MODULE_EXPORT gboolean on_wDraw_Sub_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data); -G_MODULE_EXPORT gboolean on_wDraw_Sub_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, gpointer user_data); +G_MODULE_EXPORT gboolean on_wDraw_Main_scroll_event (GtkWidget *widget, GdkEvent *event, gpointer user_data); +G_MODULE_EXPORT gboolean on_wDraw_Sub_scroll_event (GtkWidget *widget, GdkEvent *event, gpointer user_data); diff --git a/desmume/src/gtk-glade/glade/DeSmuMe.glade b/desmume/src/gtk-glade/glade/DeSmuMe.glade index b2efbf49f..bea9d4906 100755 --- a/desmume/src/gtk-glade/glade/DeSmuMe.glade +++ b/desmume/src/gtk-glade/glade/DeSmuMe.glade @@ -329,6 +329,7 @@ + True @@ -339,6 +340,7 @@ + True @@ -349,6 +351,7 @@ + True @@ -359,28 +362,28 @@ + True TYPE: FLASH (256KB) True - savetype1 False + savetype1 + True TYPE: FRAM (2MB) True - savetype1 False + savetype1 - - @@ -587,6 +590,7 @@ + True @@ -597,6 +601,7 @@ + True @@ -818,7 +823,6 @@ - True GTK_ORIENTATION_HORIZONTAL GTK_TOOLBAR_BOTH True @@ -1051,10 +1055,12 @@ 256 192 - False - GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK + GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK + + + 0 @@ -1215,13 +1221,13 @@ 256 192 - False GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK + 0 @@ -2175,4 +2181,109 @@ + + + + + True + gtk-media-pause + True + + + + + + + True + Right Screen + True + + + + + + + True + True Gap + True + + + + + + + True + + + + + + True + Rotate 0 + True + + + + + + + True + Rotate 90 + True + + + + + + + True + Rotate 180 + True + + + + + + + True + Rotate 270 + True + + + + + + + True + + + + + + True + gtk-zoom-100 + True + + + + + + + True + gtk-zoom-in + True + + + + + + + True + gtk-zoom-out + True + + + + + diff --git a/desmume/src/gtk-glade/globals.h b/desmume/src/gtk-glade/globals.h index e3b1f1e36..bce84a5b7 100755 --- a/desmume/src/gtk-glade/globals.h +++ b/desmume/src/gtk-glade/globals.h @@ -85,9 +85,10 @@ void unregister_Tool(VoidFunPtr fun); /* callbacks.c */ void enable_rom_features(); +void resize (float Size1, float Size2); /* callbacks_IO.c */ -int ScreenCoeff_Size; +float ScreenCoeff_Size[2]; gboolean ScreenRotate; gboolean ScreenRight; gboolean ScreenGap;