mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-23 06:10:03 -06:00
libui/GTK: start catching up. atleast now it runs without exploding (mostly).
This commit is contained in:
@ -8,6 +8,8 @@ PROJECT(${PROJECT_WX})
|
|||||||
SET(SOURCES
|
SET(SOURCES
|
||||||
src/libui_sdl/main.cpp
|
src/libui_sdl/main.cpp
|
||||||
src/libui_sdl/Platform.cpp
|
src/libui_sdl/Platform.cpp
|
||||||
|
src/libui_sdl/DlgEmuSettings.cpp
|
||||||
|
src/libui_sdl/DlgInputConfig.cpp
|
||||||
src/ARM.cpp
|
src/ARM.cpp
|
||||||
src/ARMInterpreter.cpp
|
src/ARMInterpreter.cpp
|
||||||
src/ARMInterpreter_ALU.cpp
|
src/ARMInterpreter_ALU.cpp
|
||||||
|
@ -80,6 +80,11 @@ _UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gbool
|
|||||||
{ \
|
{ \
|
||||||
gtk_widget_set_sensitive(type(c)->widget, FALSE); \
|
gtk_widget_set_sensitive(type(c)->widget, FALSE); \
|
||||||
}
|
}
|
||||||
|
#define uiUnixControlDefaultSetFocus(type) \
|
||||||
|
static void type ## SetFocus(uiControl *c) \
|
||||||
|
{ \
|
||||||
|
gtk_widget_grab_focus(type(c)->widget); \
|
||||||
|
}
|
||||||
// TODO this whole addedBefore stuff is a MASSIVE HACK.
|
// TODO this whole addedBefore stuff is a MASSIVE HACK.
|
||||||
#define uiUnixControlDefaultSetContainer(type) \
|
#define uiUnixControlDefaultSetContainer(type) \
|
||||||
static void type ## SetContainer(uiUnixControl *c, GtkContainer *container, gboolean remove) \
|
static void type ## SetContainer(uiUnixControl *c, GtkContainer *container, gboolean remove) \
|
||||||
@ -106,6 +111,7 @@ _UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gbool
|
|||||||
uiUnixControlDefaultEnabled(type) \
|
uiUnixControlDefaultEnabled(type) \
|
||||||
uiUnixControlDefaultEnable(type) \
|
uiUnixControlDefaultEnable(type) \
|
||||||
uiUnixControlDefaultDisable(type) \
|
uiUnixControlDefaultDisable(type) \
|
||||||
|
uiUnixControlDefaultSetFocus(type) \
|
||||||
uiUnixControlDefaultSetContainer(type)
|
uiUnixControlDefaultSetContainer(type)
|
||||||
|
|
||||||
#define uiUnixControlAllDefaults(type) \
|
#define uiUnixControlAllDefaults(type) \
|
||||||
@ -126,6 +132,7 @@ _UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gbool
|
|||||||
uiControl(var)->Enabled = type ## Enabled; \
|
uiControl(var)->Enabled = type ## Enabled; \
|
||||||
uiControl(var)->Enable = type ## Enable; \
|
uiControl(var)->Enable = type ## Enable; \
|
||||||
uiControl(var)->Disable = type ## Disable; \
|
uiControl(var)->Disable = type ## Disable; \
|
||||||
|
uiControl(var)->SetFocus = type ## SetFocus; \
|
||||||
uiUnixControl(var)->SetContainer = type ## SetContainer;
|
uiUnixControl(var)->SetContainer = type ## SetContainer;
|
||||||
// TODO document
|
// TODO document
|
||||||
_UI_EXTERN uiUnixControl *uiUnixAllocControl(size_t n, uint32_t typesig, const char *typenamestr);
|
_UI_EXTERN uiUnixControl *uiUnixAllocControl(size_t n, uint32_t typesig, const char *typenamestr);
|
||||||
|
@ -439,6 +439,11 @@ static gboolean areaWidget_key_release_event(GtkWidget *w, GdkEventKey *e)
|
|||||||
return GDK_EVENT_PROPAGATE;
|
return GDK_EVENT_PROPAGATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* uiKeyName(int scancode)
|
||||||
|
{
|
||||||
|
return "TODO";
|
||||||
|
}
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
pArea = 1,
|
pArea = 1,
|
||||||
nProps,
|
nProps,
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
// LONGTERM figure out why, and describe, that this is the desired behavior
|
// LONGTERM figure out why, and describe, that this is the desired behavior
|
||||||
// LONGTERM also point out that font and color buttons also work like this
|
// LONGTERM also point out that font and color buttons also work like this
|
||||||
|
|
||||||
#define windowWindow(w) (GTK_WINDOW(uiControlHandle(uiControl(w))))
|
#define windowWindow(w) ((w)?(GTK_WINDOW(uiControlHandle(uiControl(w)))):NULL)
|
||||||
|
|
||||||
static char *filedialog(GtkWindow *parent, GtkFileChooserAction mode, const gchar *confirm, char* filter, char* initpath)
|
static char *filedialog(GtkWindow *parent, GtkFileChooserAction mode, const gchar *confirm, char* filter, char* initpath)
|
||||||
{
|
{
|
||||||
|
@ -24,6 +24,13 @@ struct uiWindow {
|
|||||||
void *onClosingData;
|
void *onClosingData;
|
||||||
void (*onContentSizeChanged)(uiWindow *, void *);
|
void (*onContentSizeChanged)(uiWindow *, void *);
|
||||||
void *onContentSizeChangedData;
|
void *onContentSizeChangedData;
|
||||||
|
void (*onDropFile)(uiWindow *, char *, void *);
|
||||||
|
void *onDropFileData;
|
||||||
|
void (*onGetFocus)(uiWindow *, void *);
|
||||||
|
void *onGetFocusData;
|
||||||
|
void (*onLoseFocus)(uiWindow *, void *);
|
||||||
|
void *onLoseFocusData;
|
||||||
|
|
||||||
gboolean fullscreen;
|
gboolean fullscreen;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -46,6 +53,20 @@ static void onSizeAllocate(GtkWidget *widget, GdkRectangle *allocation, gpointer
|
|||||||
(*(w->onContentSizeChanged))(w, w->onContentSizeChangedData);
|
(*(w->onContentSizeChanged))(w, w->onContentSizeChangedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean onGetFocus(GtkWidget *win, GdkEvent *e, gpointer data)
|
||||||
|
{
|
||||||
|
uiWindow *w = uiWindow(data);
|
||||||
|
if (w->onGetFocus)
|
||||||
|
w->onGetFocus(w, w->onGetFocusData);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean onLoseFocus(GtkWidget *win, GdkEvent *e, gpointer data)
|
||||||
|
{
|
||||||
|
uiWindow *w = uiWindow(data);
|
||||||
|
if (w->onLoseFocus)
|
||||||
|
w->onLoseFocus(w, w->onLoseFocusData);
|
||||||
|
}
|
||||||
|
|
||||||
static int defaultOnClosing(uiWindow *w, void *data)
|
static int defaultOnClosing(uiWindow *w, void *data)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
@ -112,6 +133,7 @@ uiUnixControlDefaultHide(uiWindow)
|
|||||||
uiUnixControlDefaultEnabled(uiWindow)
|
uiUnixControlDefaultEnabled(uiWindow)
|
||||||
uiUnixControlDefaultEnable(uiWindow)
|
uiUnixControlDefaultEnable(uiWindow)
|
||||||
uiUnixControlDefaultDisable(uiWindow)
|
uiUnixControlDefaultDisable(uiWindow)
|
||||||
|
uiUnixControlDefaultSetFocus(uiWindow)
|
||||||
// TODO?
|
// TODO?
|
||||||
uiUnixControlDefaultSetContainer(uiWindow)
|
uiUnixControlDefaultSetContainer(uiWindow)
|
||||||
|
|
||||||
@ -194,6 +216,24 @@ void uiWindowOnClosing(uiWindow *w, int (*f)(uiWindow *, void *), void *data)
|
|||||||
w->onClosingData = data;
|
w->onClosingData = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uiWindowOnDropFile(uiWindow *w, void (*f)(uiWindow *, char *, void *), void *data)
|
||||||
|
{
|
||||||
|
w->onDropFile = f;
|
||||||
|
w->onDropFileData = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void uiWindowOnGetFocus(uiWindow *w, void (*f)(uiWindow *, void *), void *data)
|
||||||
|
{
|
||||||
|
w->onGetFocus = f;
|
||||||
|
w->onGetFocusData = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void uiWindowOnLoseFocus(uiWindow *w, void (*f)(uiWindow *, void *), void *data)
|
||||||
|
{
|
||||||
|
w->onLoseFocus = f;
|
||||||
|
w->onLoseFocusData = data;
|
||||||
|
}
|
||||||
|
|
||||||
int uiWindowBorderless(uiWindow *w)
|
int uiWindowBorderless(uiWindow *w)
|
||||||
{
|
{
|
||||||
return gtk_window_get_decorated(w->window) == FALSE;
|
return gtk_window_get_decorated(w->window) == FALSE;
|
||||||
@ -229,7 +269,12 @@ void uiWindowSetMargined(uiWindow *w, int margined)
|
|||||||
setMargined(w->childHolderContainer, w->margined);
|
setMargined(w->childHolderContainer, w->margined);
|
||||||
}
|
}
|
||||||
|
|
||||||
uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
void uiWindowSetDropTarget(uiWindow* w, int drop)
|
||||||
|
{
|
||||||
|
printf("DRAG DROP TODO!!!!!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar, int resizable)
|
||||||
{
|
{
|
||||||
uiWindow *w;
|
uiWindow *w;
|
||||||
|
|
||||||
@ -272,12 +317,21 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
|||||||
// and connect our events
|
// and connect our events
|
||||||
g_signal_connect(w->widget, "delete-event", G_CALLBACK(onClosing), w);
|
g_signal_connect(w->widget, "delete-event", G_CALLBACK(onClosing), w);
|
||||||
g_signal_connect(w->childHolderWidget, "size-allocate", G_CALLBACK(onSizeAllocate), w);
|
g_signal_connect(w->childHolderWidget, "size-allocate", G_CALLBACK(onSizeAllocate), w);
|
||||||
|
g_signal_connect(w->widget, "focus-in-event", G_CALLBACK(onGetFocus), w);
|
||||||
|
g_signal_connect(w->widget, "focus-out-event", G_CALLBACK(onLoseFocus), w);
|
||||||
|
|
||||||
uiWindowOnClosing(w, defaultOnClosing, NULL);
|
uiWindowOnClosing(w, defaultOnClosing, NULL);
|
||||||
uiWindowOnContentSizeChanged(w, defaultOnPositionContentSizeChanged, NULL);
|
uiWindowOnContentSizeChanged(w, defaultOnPositionContentSizeChanged, NULL);
|
||||||
|
|
||||||
|
uiWindowOnDropFile(w, NULL, NULL);
|
||||||
|
uiWindowOnGetFocus(w, NULL, NULL);
|
||||||
|
uiWindowOnLoseFocus(w, NULL, NULL);
|
||||||
|
|
||||||
// normally it's SetParent() that does this, but we can't call SetParent() on a uiWindow
|
// normally it's SetParent() that does this, but we can't call SetParent() on a uiWindow
|
||||||
// TODO we really need to clean this up, especially since see uiWindowDestroy() above
|
// TODO we really need to clean this up, especially since see uiWindowDestroy() above
|
||||||
g_object_ref(w->widget);
|
g_object_ref(w->widget);
|
||||||
|
|
||||||
|
gtk_window_set_resizable(w->window, resizable?TRUE:FALSE);
|
||||||
|
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user