diff --git a/lime/_backend/flash/FlashWindow.hx b/lime/_backend/flash/FlashWindow.hx index 9be0a4deb..576892c87 100644 --- a/lime/_backend/flash/FlashWindow.hx +++ b/lime/_backend/flash/FlashWindow.hx @@ -95,5 +95,12 @@ class FlashWindow { } + public function setTitle (value:String):String { + + // not implemented + + return ""; + + } } \ No newline at end of file diff --git a/lime/_backend/html5/HTML5Window.hx b/lime/_backend/html5/HTML5Window.hx index 4a16cbc4c..b52e7fb50 100644 --- a/lime/_backend/html5/HTML5Window.hx +++ b/lime/_backend/html5/HTML5Window.hx @@ -424,5 +424,13 @@ class HTML5Window { } + public function setTitle (value:String):String { + + // not implemented + + return ""; + + } + } \ No newline at end of file diff --git a/lime/_backend/native/NativeWindow.hx b/lime/_backend/native/NativeWindow.hx index d6ebfe01d..7764aed15 100644 --- a/lime/_backend/native/NativeWindow.hx +++ b/lime/_backend/native/NativeWindow.hx @@ -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_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_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_title = System.load ("lime", "lime_window_set_title", 2); } diff --git a/lime/ui/Window.hx b/lime/ui/Window.hx index 94dc47e3f..53a24b182 100644 --- a/lime/ui/Window.hx +++ b/lime/ui/Window.hx @@ -51,6 +51,7 @@ class Window { public var width (get, set):Int; public var x (get, set):Int; public var y (get, set):Int; + public var title (get, set):String; @:noCompletion private var backend:WindowBackend; @:noCompletion private var __fullscreen:Bool; @@ -59,6 +60,7 @@ class Window { @:noCompletion private var __width:Int; @:noCompletion private var __x:Int; @:noCompletion private var __y:Int; + @:noCompletion private var __title:String; public function new (config:Config = null) { @@ -70,6 +72,7 @@ class Window { __fullscreen = false; __x = 0; __y = 0; + __title = ""; if (config != null) { @@ -78,6 +81,7 @@ class Window { if (Reflect.hasField (config, "width")) __width = config.width; if (Reflect.hasField (config, "height")) __height = config.height; 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; + + } + } diff --git a/project/include/ui/Window.h b/project/include/ui/Window.h index 78c983288..865ae06e2 100644 --- a/project/include/ui/Window.h +++ b/project/include/ui/Window.h @@ -30,6 +30,7 @@ namespace lime { virtual bool SetFullscreen (bool fullscreen) = 0; virtual void SetIcon (ImageBuffer *imageBuffer) = 0; virtual bool SetMinimized (bool minimized) = 0; + virtual const char* SetTitle (const char* title) = 0; Application* currentApplication; int flags; diff --git a/project/src/ExternalInterface.cpp b/project/src/ExternalInterface.cpp index 6c097e029..e9970abcc 100644 --- a/project/src/ExternalInterface.cpp +++ b/project/src/ExternalInterface.cpp @@ -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_exec, 1); @@ -1251,6 +1258,7 @@ namespace lime { DEFINE_PRIM (lime_window_set_fullscreen, 2); DEFINE_PRIM (lime_window_set_icon, 2); DEFINE_PRIM (lime_window_set_minimized, 2); + DEFINE_PRIM (lime_window_set_title, 2); } diff --git a/project/src/backend/sdl/SDLWindow.cpp b/project/src/backend/sdl/SDLWindow.cpp index 2ea362a09..def296dad 100644 --- a/project/src/backend/sdl/SDLWindow.cpp +++ b/project/src/backend/sdl/SDLWindow.cpp @@ -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) { diff --git a/project/src/backend/sdl/SDLWindow.h b/project/src/backend/sdl/SDLWindow.h index 4342166df..7f16f4b36 100644 --- a/project/src/backend/sdl/SDLWindow.h +++ b/project/src/backend/sdl/SDLWindow.h @@ -29,6 +29,7 @@ namespace lime { virtual bool SetFullscreen (bool fullscreen); virtual void SetIcon (ImageBuffer *imageBuffer); virtual bool SetMinimized (bool minimized); + virtual const char* SetTitle (const char* title); SDL_Window* sdlWindow;