libui/GTK: start catching up. atleast now it runs without exploding (mostly).

This commit is contained in:
StapleButter 2017-10-03 00:28:41 +02:00
parent 04e8bbaca3
commit 7f05bf24ad
5 changed files with 70 additions and 2 deletions

View File

@ -8,6 +8,8 @@ PROJECT(${PROJECT_WX})
SET(SOURCES
src/libui_sdl/main.cpp
src/libui_sdl/Platform.cpp
src/libui_sdl/DlgEmuSettings.cpp
src/libui_sdl/DlgInputConfig.cpp
src/ARM.cpp
src/ARMInterpreter.cpp
src/ARMInterpreter_ALU.cpp

View File

@ -80,6 +80,11 @@ _UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gbool
{ \
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.
#define uiUnixControlDefaultSetContainer(type) \
static void type ## SetContainer(uiUnixControl *c, GtkContainer *container, gboolean remove) \
@ -106,6 +111,7 @@ _UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gbool
uiUnixControlDefaultEnabled(type) \
uiUnixControlDefaultEnable(type) \
uiUnixControlDefaultDisable(type) \
uiUnixControlDefaultSetFocus(type) \
uiUnixControlDefaultSetContainer(type)
#define uiUnixControlAllDefaults(type) \
@ -126,6 +132,7 @@ _UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gbool
uiControl(var)->Enabled = type ## Enabled; \
uiControl(var)->Enable = type ## Enable; \
uiControl(var)->Disable = type ## Disable; \
uiControl(var)->SetFocus = type ## SetFocus; \
uiUnixControl(var)->SetContainer = type ## SetContainer;
// TODO document
_UI_EXTERN uiUnixControl *uiUnixAllocControl(size_t n, uint32_t typesig, const char *typenamestr);

View File

@ -439,6 +439,11 @@ static gboolean areaWidget_key_release_event(GtkWidget *w, GdkEventKey *e)
return GDK_EVENT_PROPAGATE;
}
char* uiKeyName(int scancode)
{
return "TODO";
}
enum {
pArea = 1,
nProps,

View File

@ -4,7 +4,7 @@
// 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
#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)
{

View File

@ -24,6 +24,13 @@ struct uiWindow {
void *onClosingData;
void (*onContentSizeChanged)(uiWindow *, void *);
void *onContentSizeChangedData;
void (*onDropFile)(uiWindow *, char *, void *);
void *onDropFileData;
void (*onGetFocus)(uiWindow *, void *);
void *onGetFocusData;
void (*onLoseFocus)(uiWindow *, void *);
void *onLoseFocusData;
gboolean fullscreen;
};
@ -46,6 +53,20 @@ static void onSizeAllocate(GtkWidget *widget, GdkRectangle *allocation, gpointer
(*(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)
{
return 0;
@ -112,6 +133,7 @@ uiUnixControlDefaultHide(uiWindow)
uiUnixControlDefaultEnabled(uiWindow)
uiUnixControlDefaultEnable(uiWindow)
uiUnixControlDefaultDisable(uiWindow)
uiUnixControlDefaultSetFocus(uiWindow)
// TODO?
uiUnixControlDefaultSetContainer(uiWindow)
@ -194,6 +216,24 @@ void uiWindowOnClosing(uiWindow *w, int (*f)(uiWindow *, void *), void *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)
{
return gtk_window_get_decorated(w->window) == FALSE;
@ -229,7 +269,12 @@ void uiWindowSetMargined(uiWindow *w, int 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;
@ -272,12 +317,21 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
// and connect our events
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->widget, "focus-in-event", G_CALLBACK(onGetFocus), w);
g_signal_connect(w->widget, "focus-out-event", G_CALLBACK(onLoseFocus), w);
uiWindowOnClosing(w, defaultOnClosing, 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
// TODO we really need to clean this up, especially since see uiWindowDestroy() above
g_object_ref(w->widget);
gtk_window_set_resizable(w->window, resizable?TRUE:FALSE);
return w;
}