Merge pull request #557 from TommyX12/master
Added window flashing alert function under window class
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
#include <hx/CFFI.h>
|
||||
#ifdef HX_WINDOWS
|
||||
#include <SDL_syswm.h>
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
|
||||
// Custom DEFINE_PRIM macro when calls are the same as NME
|
||||
@@ -562,6 +566,29 @@ namespace nme {
|
||||
DEFINE_LIME_LEGACY_PRIM_1(gl_s3d_set_focal_length);
|
||||
#endif
|
||||
|
||||
value lime_window_alert (value count, value speed, value stop_on_forground) {
|
||||
|
||||
#ifdef HX_WINDOWS
|
||||
SDL_SysWMinfo info;
|
||||
SDL_VERSION (&info.version);
|
||||
SDL_GetWindowWMInfo(SDL_GL_GetCurrentWindow(), &info);
|
||||
|
||||
FLASHWINFO fi;
|
||||
fi.cbSize = sizeof(FLASHWINFO);
|
||||
fi.hwnd = info.info.win.window;
|
||||
fi.dwFlags = val_bool (stop_on_forground) ? FLASHW_ALL | FLASHW_TIMERNOFG : FLASHW_ALL | FLASHW_TIMER;
|
||||
fi.uCount = val_int (count);
|
||||
fi.dwTimeout = val_int (speed);
|
||||
FlashWindowEx(&fi);
|
||||
#endif
|
||||
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
DEFINE_PRIM (lime_window_alert, 3);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -572,4 +599,4 @@ extern "C" int lime_legacy_register_prims()
|
||||
{
|
||||
nme_register_prims();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,5 +114,9 @@ class FlashWindow {
|
||||
|
||||
}
|
||||
|
||||
public function alert (count:Int, speed:Int, stopOnForeground:Bool):Void {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -626,5 +626,9 @@ class HTML5Window {
|
||||
|
||||
}
|
||||
|
||||
public function alert (count:Int, speed:Int, stopOnForeground:Bool):Void {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -233,6 +233,16 @@ class NativeWindow {
|
||||
|
||||
}
|
||||
|
||||
public function alert (count:Int, speed:Int, stopOnForeground:Bool):Void {
|
||||
|
||||
if (handle != null) {
|
||||
|
||||
lime_window_alert (handle, count, speed, stopOnForeground);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@:cffi private static function lime_window_close (handle:Float):Void;
|
||||
@:cffi private static function lime_window_create (application:Float, width:Int, height:Int, flags:Int, title:String):Float;
|
||||
@@ -250,6 +260,7 @@ class NativeWindow {
|
||||
@:cffi private static function lime_window_set_icon (handle:Float, buffer:Dynamic):Void;
|
||||
@:cffi private static function lime_window_set_minimized (handle:Float, minimized:Bool):Bool;
|
||||
@:cffi private static function lime_window_set_title (handle:Float, title:String):String;
|
||||
@:cffi private static function lime_window_alert (handle:Float, count:Int, speed:Int, stopOnForeground:Bool):Void;
|
||||
|
||||
|
||||
}
|
||||
@@ -269,4 +280,4 @@ class NativeWindow {
|
||||
var WINDOW_FLAG_DEPTH_BUFFER = 0x00000200;
|
||||
var WINDOW_FLAG_STENCIL_BUFFER = 0x00000400;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,6 +269,12 @@ class Window {
|
||||
|
||||
}
|
||||
|
||||
public function alert (count:Int, speed:Int, stopOnForeground:Bool):Void {
|
||||
|
||||
backend.alert (count, speed, stopOnForeground);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function toString ():String {
|
||||
|
||||
@@ -416,4 +422,4 @@ class Window {
|
||||
@:noCompletion private typedef WindowBackend = lime._backend.html5.HTML5Window;
|
||||
#else
|
||||
@:noCompletion private typedef WindowBackend = lime._backend.native.NativeWindow;
|
||||
#end
|
||||
#end
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace lime {
|
||||
virtual void SetIcon (ImageBuffer *imageBuffer) = 0;
|
||||
virtual bool SetMinimized (bool minimized) = 0;
|
||||
virtual const char* SetTitle (const char* title) = 0;
|
||||
virtual void Alert (int count, int speed, bool stop_on_foreground) = 0;
|
||||
|
||||
Application* currentApplication;
|
||||
int flags;
|
||||
@@ -64,4 +65,4 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1211,6 +1211,13 @@ namespace lime {
|
||||
|
||||
}
|
||||
|
||||
void lime_window_alert (double window, int count, int speed, bool stop_on_forground) {
|
||||
|
||||
Window* targetWindow = (Window*)(intptr_t)window;
|
||||
targetWindow->Alert (count, speed, stop_on_forground);
|
||||
|
||||
}
|
||||
|
||||
|
||||
DEFINE_PRIME1 (lime_application_create);
|
||||
DEFINE_PRIME2v (lime_application_event_manager_register);
|
||||
@@ -1313,6 +1320,7 @@ namespace lime {
|
||||
DEFINE_PRIME2v (lime_window_set_icon);
|
||||
DEFINE_PRIME2 (lime_window_set_minimized);
|
||||
DEFINE_PRIME2 (lime_window_set_title);
|
||||
DEFINE_PRIME4 (lime_window_alert);
|
||||
|
||||
|
||||
}
|
||||
@@ -1322,4 +1330,4 @@ extern "C" int lime_register_prims () {
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,6 +270,22 @@ namespace lime {
|
||||
|
||||
}
|
||||
|
||||
void SDLWindow::Alert (int count, int speed, bool stop_on_foreground) {
|
||||
|
||||
SDL_SysWMinfo info;
|
||||
SDL_VERSION (&info.version);
|
||||
SDL_GetWindowWMInfo(sdlWindow, &info);
|
||||
|
||||
FLASHWINFO fi;
|
||||
fi.cbSize = sizeof(FLASHWINFO);
|
||||
fi.hwnd = info.info.win.window;
|
||||
fi.dwFlags = stop_on_foreground ? FLASHW_ALL | FLASHW_TIMERNOFG : FLASHW_ALL | FLASHW_TIMER;
|
||||
fi.uCount = count;
|
||||
fi.dwTimeout = speed;
|
||||
FlashWindowEx(&fi);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Window* CreateWindow (Application* application, int width, int height, int flags, const char* title) {
|
||||
|
||||
@@ -278,4 +294,4 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace lime {
|
||||
virtual void SetIcon (ImageBuffer *imageBuffer);
|
||||
virtual bool SetMinimized (bool minimized);
|
||||
virtual const char* SetTitle (const char* title);
|
||||
virtual void Alert (int count, int speed, bool stop_on_foreground);
|
||||
|
||||
SDL_Window* sdlWindow;
|
||||
|
||||
@@ -41,4 +42,4 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user