Add Window move and resize

This commit is contained in:
Joshua Granick
2014-07-09 20:05:36 -07:00
parent 46e62e8dfb
commit 7df3b3adfa
5 changed files with 60 additions and 1 deletions

View File

@@ -333,9 +333,29 @@ class Window {
#end #end
public function move (x:Int, y:Int):Void {
#if (cpp || neko)
lime_window_move (handle, x, y);
#end
}
public function resize (width:Int, height:Int):Void {
#if (cpp || neko)
lime_window_resize (handle, width, height);
#end
}
#if (cpp || neko) #if (cpp || neko)
private static var lime_window_create = System.load ("lime", "lime_window_create", 5); private static var lime_window_create = System.load ("lime", "lime_window_create", 5);
private static var lime_window_event_manager_register = System.load ("lime", "lime_window_event_manager_register", 2); private static var lime_window_event_manager_register = System.load ("lime", "lime_window_event_manager_register", 2);
private static var lime_window_move = System.load ("lime", "lime_window_move", 3);
private static var lime_window_resize = System.load ("lime", "lime_window_resize", 3);
#end #end

View File

@@ -17,8 +17,10 @@ namespace lime {
public: public:
Application* currentApplication; virtual void Move (int x, int y) = 0;
virtual void Resize (int width, int height) = 0;
Application* currentApplication;
int flags; int flags;

View File

@@ -194,6 +194,24 @@ namespace lime {
} }
value lime_window_move (value window, value x, value y) {
Window* targetWindow = (Window*)(intptr_t)val_float (window);
targetWindow->Move (val_int (x), val_int (y));
return alloc_null ();
}
value lime_window_resize (value window, value width, value height) {
Window* targetWindow = (Window*)(intptr_t)val_float (window);
targetWindow->Resize (val_int (width), val_int (height));
return alloc_null ();
}
DEFINE_PRIM (lime_application_create, 1); DEFINE_PRIM (lime_application_create, 1);
DEFINE_PRIM (lime_application_exec, 1); DEFINE_PRIM (lime_application_exec, 1);
DEFINE_PRIM (lime_application_get_ticks, 0); DEFINE_PRIM (lime_application_get_ticks, 0);
@@ -211,6 +229,8 @@ namespace lime {
DEFINE_PRIM (lime_update_event_manager_register, 2); DEFINE_PRIM (lime_update_event_manager_register, 2);
DEFINE_PRIM (lime_window_create, 5); DEFINE_PRIM (lime_window_create, 5);
DEFINE_PRIM (lime_window_event_manager_register, 2); DEFINE_PRIM (lime_window_event_manager_register, 2);
DEFINE_PRIM (lime_window_move, 3);
DEFINE_PRIM (lime_window_resize, 3);
} }

View File

@@ -27,6 +27,20 @@ namespace lime {
} }
void SDLWindow::Move (int x, int y) {
SDL_SetWindowPosition (sdlWindow, x, y);
}
void SDLWindow::Resize (int width, int height) {
SDL_SetWindowSize (sdlWindow, width, height);
}
Window* CreateWindow (Application* application, int width, int height, int flags, const char* title) { Window* CreateWindow (Application* application, int width, int height, int flags, const char* title) {
return new SDLWindow (application, width, height, flags, title); return new SDLWindow (application, width, height, flags, title);

View File

@@ -16,6 +16,9 @@ namespace lime {
SDLWindow (Application* application, int width, int height, int flags, const char* title); SDLWindow (Application* application, int width, int height, int flags, const char* title);
~SDLWindow (); ~SDLWindow ();
virtual void Move (int x, int y);
virtual void Resize (int width, int height);
SDL_Window* sdlWindow; SDL_Window* sdlWindow;
}; };