From 83fcb82cce0c42118364eb312b431442e6fbef90 Mon Sep 17 00:00:00 2001 From: Jarnik Date: Fri, 31 Jul 2015 08:08:12 +0200 Subject: [PATCH 1/2] settable lime.ui.Window.titlem, SDL only --- lime/_backend/native/NativeWindow.hx | 13 +++++++++++++ lime/ui/Window.hx | 19 +++++++++++++++++++ project/include/ui/Window.h | 1 + project/src/ExternalInterface.cpp | 8 ++++++++ project/src/backend/sdl/SDLWindow.cpp | 8 ++++++++ project/src/backend/sdl/SDLWindow.h | 1 + 6 files changed, 50 insertions(+) diff --git a/lime/_backend/native/NativeWindow.hx b/lime/_backend/native/NativeWindow.hx index e898e6d2c..ea9ad5ded 100644 --- a/lime/_backend/native/NativeWindow.hx +++ b/lime/_backend/native/NativeWindow.hx @@ -179,6 +179,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); @@ -193,6 +205,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 e83ec2634..45f0e61cf 100644 --- a/lime/ui/Window.hx +++ b/lime/ui/Window.hx @@ -49,6 +49,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; @@ -57,6 +58,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) { @@ -68,6 +70,7 @@ class Window { __fullscreen = false; __x = 0; __y = 0; + __title = ""; if (config != null) { @@ -76,6 +79,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; } @@ -360,6 +364,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 64dbb50a9..61ba9e88d 100644 --- a/project/src/ExternalInterface.cpp +++ b/project/src/ExternalInterface.cpp @@ -1145,6 +1145,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); @@ -1235,6 +1242,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; From b4efea23dde39e6f00a9e69a60073d322da02ad5 Mon Sep 17 00:00:00 2001 From: Jarnik Date: Fri, 31 Jul 2015 08:29:46 +0200 Subject: [PATCH 2/2] lime.ui.Window.title dummy functions for flash and html5 --- lime/_backend/flash/FlashWindow.hx | 7 +++++++ lime/_backend/html5/HTML5Window.hx | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/lime/_backend/flash/FlashWindow.hx b/lime/_backend/flash/FlashWindow.hx index 4e5a28146..83941bca8 100644 --- a/lime/_backend/flash/FlashWindow.hx +++ b/lime/_backend/flash/FlashWindow.hx @@ -86,5 +86,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 3ebde5693..8844c5103 100644 --- a/lime/_backend/html5/HTML5Window.hx +++ b/lime/_backend/html5/HTML5Window.hx @@ -415,5 +415,13 @@ class HTML5Window { } + public function setTitle (value:String):String { + + // not implemented + + return ""; + + } + } \ No newline at end of file