Merge pull request #529 from jarnik/master

settable lime.ui.Window.title, SDL only
This commit is contained in:
Joshua Granick
2015-07-31 20:46:26 -07:00
8 changed files with 65 additions and 0 deletions

View File

@@ -95,5 +95,12 @@ class FlashWindow {
} }
public function setTitle (value:String):String {
// not implemented
return "";
}
} }

View File

@@ -424,5 +424,13 @@ class HTML5Window {
} }
public function setTitle (value:String):String {
// not implemented
return "";
}
} }

View File

@@ -204,6 +204,18 @@ class NativeWindow {
} }
public function setTitle (value:String):String {
if (handle != null) {
return lime_window_set_title (handle, value);
}
return value;
}
private static var lime_window_close = System.load ("lime", "lime_window_close", 1); private static var lime_window_close = System.load ("lime", "lime_window_close", 1);
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);
@@ -218,6 +230,7 @@ class NativeWindow {
private static var lime_window_set_fullscreen = System.load ("lime", "lime_window_set_fullscreen", 2); private static var lime_window_set_fullscreen = System.load ("lime", "lime_window_set_fullscreen", 2);
private static var lime_window_set_icon = System.load ("lime", "lime_window_set_icon", 2); private static var lime_window_set_icon = System.load ("lime", "lime_window_set_icon", 2);
private static var lime_window_set_minimized = System.load ("lime", "lime_window_set_minimized", 2); private static var lime_window_set_minimized = System.load ("lime", "lime_window_set_minimized", 2);
private static var lime_window_set_title = System.load ("lime", "lime_window_set_title", 2);
} }

View File

@@ -51,6 +51,7 @@ class Window {
public var width (get, set):Int; public var width (get, set):Int;
public var x (get, set):Int; public var x (get, set):Int;
public var y (get, set):Int; public var y (get, set):Int;
public var title (get, set):String;
@:noCompletion private var backend:WindowBackend; @:noCompletion private var backend:WindowBackend;
@:noCompletion private var __fullscreen:Bool; @:noCompletion private var __fullscreen:Bool;
@@ -59,6 +60,7 @@ class Window {
@:noCompletion private var __width:Int; @:noCompletion private var __width:Int;
@:noCompletion private var __x:Int; @:noCompletion private var __x:Int;
@:noCompletion private var __y:Int; @:noCompletion private var __y:Int;
@:noCompletion private var __title:String;
public function new (config:Config = null) { public function new (config:Config = null) {
@@ -70,6 +72,7 @@ class Window {
__fullscreen = false; __fullscreen = false;
__x = 0; __x = 0;
__y = 0; __y = 0;
__title = "";
if (config != null) { if (config != null) {
@@ -78,6 +81,7 @@ class Window {
if (Reflect.hasField (config, "width")) __width = config.width; if (Reflect.hasField (config, "width")) __width = config.width;
if (Reflect.hasField (config, "height")) __height = config.height; if (Reflect.hasField (config, "height")) __height = config.height;
if (Reflect.hasField (config, "fullscreen")) __fullscreen = config.fullscreen; if (Reflect.hasField (config, "fullscreen")) __fullscreen = config.fullscreen;
if (Reflect.hasField (config, "title")) __title = config.title;
} }
@@ -369,6 +373,21 @@ class Window {
} }
@:noCompletion private inline function get_title ():String {
return __title;
}
@:noCompletion private function set_title (value:String):String {
__title = value;
backend.setTitle(__title);
return __title;
}
} }

View File

@@ -30,6 +30,7 @@ namespace lime {
virtual bool SetFullscreen (bool fullscreen) = 0; virtual bool SetFullscreen (bool fullscreen) = 0;
virtual void SetIcon (ImageBuffer *imageBuffer) = 0; virtual void SetIcon (ImageBuffer *imageBuffer) = 0;
virtual bool SetMinimized (bool minimized) = 0; virtual bool SetMinimized (bool minimized) = 0;
virtual const char* SetTitle (const char* title) = 0;
Application* currentApplication; Application* currentApplication;
int flags; int flags;

View File

@@ -1159,6 +1159,13 @@ namespace lime {
} }
value lime_window_set_title (value window, value title) {
Window* targetWindow = (Window*)(intptr_t)val_float (window);
return alloc_string (targetWindow->SetTitle (val_string (title)));
}
DEFINE_PRIM (lime_application_create, 1); DEFINE_PRIM (lime_application_create, 1);
DEFINE_PRIM (lime_application_exec, 1); DEFINE_PRIM (lime_application_exec, 1);
@@ -1251,6 +1258,7 @@ namespace lime {
DEFINE_PRIM (lime_window_set_fullscreen, 2); DEFINE_PRIM (lime_window_set_fullscreen, 2);
DEFINE_PRIM (lime_window_set_icon, 2); DEFINE_PRIM (lime_window_set_icon, 2);
DEFINE_PRIM (lime_window_set_minimized, 2); DEFINE_PRIM (lime_window_set_minimized, 2);
DEFINE_PRIM (lime_window_set_title, 2);
} }

View File

@@ -247,6 +247,14 @@ namespace lime {
} }
const char* SDLWindow::SetTitle (const char* title) {
SDL_SetWindowTitle(sdlWindow, title);
return title;
}
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) {

View File

@@ -29,6 +29,7 @@ namespace lime {
virtual bool SetFullscreen (bool fullscreen); virtual bool SetFullscreen (bool fullscreen);
virtual void SetIcon (ImageBuffer *imageBuffer); virtual void SetIcon (ImageBuffer *imageBuffer);
virtual bool SetMinimized (bool minimized); virtual bool SetMinimized (bool minimized);
virtual const char* SetTitle (const char* title);
SDL_Window* sdlWindow; SDL_Window* sdlWindow;