aboutsummaryrefslogtreecommitdiff
path: root/src/libui_sdl/main.cpp
diff options
context:
space:
mode:
authorStapleButter <thetotalworm@gmail.com>2017-09-11 15:56:52 +0200
committerStapleButter <thetotalworm@gmail.com>2017-09-11 15:56:52 +0200
commit62a26977c793acde24ffad1f81647c0a4f68ed09 (patch)
tree17d073431872027c39b9ad7eab8b373b7ef564db /src/libui_sdl/main.cpp
parent08ed0f3229da2a6feb8bc3080b8e871c79c8d392 (diff)
libui: primp file picker dialogs
* support for filters, for Windows (tested) and GTK (theoretical) * add extra parameter for setting the start directory, but not supported yet
Diffstat (limited to 'src/libui_sdl/main.cpp')
-rw-r--r--src/libui_sdl/main.cpp39
1 files changed, 36 insertions, 3 deletions
diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp
index c0992ef..e67ba8a 100644
--- a/src/libui_sdl/main.cpp
+++ b/src/libui_sdl/main.cpp
@@ -21,8 +21,7 @@
#include <stdio.h>
#include <SDL2/SDL.h>
-#include <GL/gl.h>
-#include <GL/glext.h>
+#include "libui/ui.h"
#include "../types.h"
#include "../version.h"
@@ -34,6 +33,14 @@ SDL_GLContext MainGL;
void RunMainWindow();
+void OnOpenFile(uiMenuItem* item, uiWindow* window, void* blarg)
+{
+ char* file = uiOpenFile(window, "DS ROM (*.nds)|*.nds;*.srl|Any file|*.*", NULL);
+ if (!file) return;
+
+ printf("file opened: %s\n", file);
+}
+
int main(int argc, char** argv)
{
srand(time(NULL));
@@ -47,8 +54,34 @@ int main(int argc, char** argv)
return 1;
}
- RunMainWindow();
+ uiInitOptions ui_opt;
+ memset(&ui_opt, 0, sizeof(uiInitOptions));
+ const char* ui_err = uiInit(&ui_opt);
+ if (ui_err != NULL)
+ {
+ printf("libui shat itself :( %s\n", ui_err);
+ uiFreeInitError(ui_err);
+ return 1;
+ }
+
+ //RunMainWindow();
+
+ uiMenu* menu;
+ uiMenuItem* menuitem;
+
+ menu = uiNewMenu("File");
+ menuitem = uiMenuAppendItem(menu, "Open...");
+ uiMenuItemOnClicked(menuitem, OnOpenFile, NULL);
+ uiMenuAppendSeparator(menu);
+ uiMenuAppendItem(menu, "Quit");
+
+ uiWindow* win;
+ win = uiNewWindow("melonDS " MELONDS_VERSION, 256, 384, 1);
+
+ uiControlShow(uiControl(win));
+ uiMain();
+ uiUninit();
SDL_Quit();
return 0;
}