Add set_droppable

This commit is contained in:
twinaphex 2016-06-04 08:38:38 +02:00
parent 80b194f491
commit 47c7330cc8
7 changed files with 34 additions and 1 deletions

View File

@ -64,7 +64,9 @@ void *glkitview_init(void);
#if defined(HAVE_COCOA)
[self setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[self registerForDraggedTypes:[NSArray arrayWithObjects:NSColorPboardType, NSFilenamesPboardType, nil]];
ui_window_cocoa_t view;
view.data = (CocoaView*)self;
ui_window_cocoa_set_droppable(&view, true);
#elif defined(HAVE_COCOATOUCH)
self.view = (__bridge GLKView*)glkitview_init();

View File

@ -43,6 +43,8 @@ void ui_window_cocoa_destroy(void *data);
void ui_window_cocoa_set_title(void *data, char *buf);
void ui_window_cocoa_set_droppable(void *data, bool droppable);
RETRO_END_DECLS
#endif

View File

@ -55,10 +55,26 @@ void ui_window_cocoa_set_title(void *data, char *buf)
[[cocoa_view window] setTitle:[NSString stringWithCString:text encoding:NSUTF8StringEncoding]];
}
void ui_window_cocoa_set_droppable(void *data, bool droppable)
{
ui_window_cocoa_t *cocoa = (ui_window_cocoa_t*)data;
CocoaView *cocoa_view = (CocoaView*)cocoa->data;
if (droppable)
{
[[cocoa_view window] registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];
}
else
{
[[cocoa_view window] unregisterDraggedTypes];
}
}
const ui_window_t ui_window_cocoa = {
ui_window_cocoa_destroy,
ui_window_cocoa_set_focused,
ui_window_cocoa_set_visible,
ui_window_cocoa_set_title,
ui_window_cocoa_set_droppable,
"cocoa"
};

View File

@ -38,10 +38,15 @@ static void ui_window_null_set_title(void *data, char *buf)
{
}
static void ui_window_null_set_droppable(void *data, bool droppable)
{
}
const ui_window_t ui_window_null = {
ui_window_null_destroy,
ui_window_null_set_focused,
ui_window_null_set_visible,
ui_window_null_set_title,
ui_window_null_set_droppable,
"null"
};

View File

@ -73,10 +73,15 @@ void ui_window_win32_set_title(void *data, char *buf)
SetWindowText(window->hwnd, buf);
}
void ui_window_win32_set_droppable(void *data, bool droppable)
{
}
const ui_window_t ui_window_win32 = {
ui_window_win32_destroy,
ui_window_win32_set_focused,
ui_window_win32_set_visible,
ui_window_win32_set_title,
ui_window_win32_set_droppable,
"win32"
};

View File

@ -46,6 +46,8 @@ void ui_window_win32_destroy(void *data);
void ui_window_win32_set_title(void *data, char *buf);
void ui_window_win32_set_droppable(void *data, bool droppable);
RETRO_END_DECLS
#endif

View File

@ -37,6 +37,7 @@ typedef struct ui_window
void (*set_focused)(void *data);
void (*set_visible)(void *data, bool visible);
void (*set_title)(void *data, char *buf);
void (*set_droppable)(void *data, bool droppable);
const char *ident;
} ui_window_t;