From 53541c69d48444bf8a502b35dcd4370c30058fb6 Mon Sep 17 00:00:00 2001 From: Guilherme Felipe Date: Wed, 13 May 2015 23:19:15 -0300 Subject: Fix for scroll_to_line and search functions, fix #1897 The function scroll_to_line(0) should return ERR_FAIL_INDEX because the first line is 1. --- scene/gui/rich_text_label.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 6b2e5aea78..bf719e671a 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -1486,10 +1486,10 @@ Error RichTextLabel::append_bbcode(const String& p_bbcode) { void RichTextLabel::scroll_to_line(int p_line) { + p_line -= 1; ERR_FAIL_INDEX(p_line,lines.size()); _validate_line_caches(); - vscroll->set_val(lines[p_line].height_accum_cache); - + vscroll->set_val(lines[p_line].height_accum_cache-lines[p_line].height_cache); } @@ -1552,27 +1552,23 @@ bool RichTextLabel::search(const String& p_string,bool p_from_selection) { it=_get_next_item(it); } - if (!it) - line=lines.size()-1; } - scroll_to_line(line-2); + if (line > 1) { + line-=1; + } + + scroll_to_line(line); return true; } - } else if (it->type==ITEM_NEWLINE) { - - line=static_cast(it)->line; } - it=_get_next_item(it); charidx=0; } - - return false; } -- cgit v1.2.3 From 4a56f72f5be6cd34c96a082e3697f4eecd744e75 Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Sun, 24 May 2015 23:22:51 +0300 Subject: Haiku: Initial support. --- platform/haiku/SCsub | 10 ++++++++++ platform/haiku/detect.py | 42 +++++++++++++++++++++++++++++++++++++++ platform/haiku/godot_haiku.cpp | 19 ++++++++++++++++++ platform/haiku/logo.png | Bin 0 -> 2055 bytes platform/haiku/os_haiku.cpp | 0 platform/haiku/os_haiku.h | 42 +++++++++++++++++++++++++++++++++++++++ platform/haiku/platform_config.h | 1 + 7 files changed, 114 insertions(+) create mode 100644 platform/haiku/SCsub create mode 100644 platform/haiku/detect.py create mode 100644 platform/haiku/godot_haiku.cpp create mode 100644 platform/haiku/logo.png create mode 100644 platform/haiku/os_haiku.cpp create mode 100644 platform/haiku/os_haiku.h create mode 100644 platform/haiku/platform_config.h diff --git a/platform/haiku/SCsub b/platform/haiku/SCsub new file mode 100644 index 0000000000..8ae489cf54 --- /dev/null +++ b/platform/haiku/SCsub @@ -0,0 +1,10 @@ +Import('env') + +common_haiku = [ + 'os_haiku.cpp' +] + +env.Program( + '#bin/godot', + ['godot_haiku.cpp'] + common_haiku +) diff --git a/platform/haiku/detect.py b/platform/haiku/detect.py new file mode 100644 index 0000000000..992c73ee79 --- /dev/null +++ b/platform/haiku/detect.py @@ -0,0 +1,42 @@ +import os +import sys + +def is_active(): + return True + +def get_name(): + return "Haiku" + +def can_build(): + if (os.name != "posix"): + return False + + if (sys.platform == "darwin"): + return False + + return True + +def get_opts(): + return [] + +def get_flags(): + return [ + ('builtin_zlib', 'no') + ] + +def configure(env): + is64=sys.maxsize > 2**32 + + if (env["bits"]=="default"): + if (is64): + env["bits"]="64" + else: + env["bits"]="32" + + env.Append(CPPPATH = ['#platform/haiku']) + env["CC"] = "gcc-x86" + env["CXX"] = "g++-x86" + env.Append(CPPFLAGS = ['-DDEBUG_METHODS_ENABLED']) + + env.Append(CPPFLAGS = ['-DUNIX_ENABLED']) + #env.Append(LIBS = ['be']) diff --git a/platform/haiku/godot_haiku.cpp b/platform/haiku/godot_haiku.cpp new file mode 100644 index 0000000000..b4e5e50891 --- /dev/null +++ b/platform/haiku/godot_haiku.cpp @@ -0,0 +1,19 @@ +#include "main/main.h" +#include "os_haiku.h" + +int main(int argc, char* argv[]) { + OS_Haiku os; + + Error error = Main::setup(argv[0], argc-1, &argv[1]); + if (error != OK) { + return 255; + } + + if (Main::start()) { + os.run(); + } + + Main::cleanup(); + + return os.get_exit_code(); +} diff --git a/platform/haiku/logo.png b/platform/haiku/logo.png new file mode 100644 index 0000000000..c40214d6de Binary files /dev/null and b/platform/haiku/logo.png differ diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h new file mode 100644 index 0000000000..ee1283f018 --- /dev/null +++ b/platform/haiku/os_haiku.h @@ -0,0 +1,42 @@ +#ifndef OS_HAIKU_H +#define OS_HAIKU_H + +#include "drivers/unix/os_unix.h" + + +class OS_Haiku : public OS_Unix { +private: + virtual void delete_main_loop(); + +protected: + virtual int get_video_driver_count() const; + virtual const char* get_video_driver_name(int p_driver) const; + virtual VideoMode get_default_video_mode() const; + + virtual void initialize(const VideoMode& p_desired, int p_video_driver, int p_audio_driver); + virtual void finalize(); + + virtual void set_main_loop(MainLoop* p_main_loop); + +public: + OS_Haiku(); + void run(); + + virtual String get_name(); + + virtual MainLoop *get_main_loop() const; + virtual bool can_draw() const; + + virtual Point2 get_mouse_pos() const; + virtual int get_mouse_button_state() const; + virtual void set_cursor_shape(CursorShape p_shape); + + virtual void set_window_title(const String& p_title); + virtual Size2 get_window_size() const; + + virtual void set_video_mode(const VideoMode& p_video_mode, int p_screen=0); + virtual VideoMode get_video_mode(int p_screen=0) const; + virtual void get_fullscreen_mode_list(List *p_list, int p_screen=0) const; +}; + +#endif diff --git a/platform/haiku/platform_config.h b/platform/haiku/platform_config.h new file mode 100644 index 0000000000..dad24432a5 --- /dev/null +++ b/platform/haiku/platform_config.h @@ -0,0 +1 @@ +#include -- cgit v1.2.3 From 4e07a2dea8c94337702d35d0d02d4b7234f86e29 Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Mon, 25 May 2015 03:49:24 +0300 Subject: Haiku: fix building with UNIX_ENABLED. --- drivers/unix/packet_peer_udp_posix.cpp | 6 +++++- drivers/unix/stream_peer_tcp_posix.cpp | 9 +++++++-- drivers/unix/tcp_server_posix.cpp | 6 +++++- platform/haiku/detect.py | 6 ++++-- platform/haiku/os_haiku.cpp | 5 +++++ 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/drivers/unix/packet_peer_udp_posix.cpp b/drivers/unix/packet_peer_udp_posix.cpp index 26a0b29228..94b4c35923 100644 --- a/drivers/unix/packet_peer_udp_posix.cpp +++ b/drivers/unix/packet_peer_udp_posix.cpp @@ -13,7 +13,11 @@ #include #ifndef NO_FCNTL -#include + #ifdef __HAIKU__ + #include + #else + #include + #endif #else #include #endif diff --git a/drivers/unix/stream_peer_tcp_posix.cpp b/drivers/unix/stream_peer_tcp_posix.cpp index 2301d8b6c4..2db7d9f6ec 100644 --- a/drivers/unix/stream_peer_tcp_posix.cpp +++ b/drivers/unix/stream_peer_tcp_posix.cpp @@ -39,7 +39,11 @@ #include #include #ifndef NO_FCNTL -#include + #ifdef __HAIKU__ + #include + #else + #include + #endif #else #include #endif @@ -202,7 +206,8 @@ Error StreamPeerTCPPosix::write(const uint8_t* p_data,int p_bytes, int &r_sent, while (data_to_send) { - int sent_amount = send(sockfd, offset, data_to_send, MSG_NOSIGNAL); + // TODO: handle MSG_NOSIGNAL on __HAIKU__ + int sent_amount = send(sockfd, offset, data_to_send, 0); //printf("Sent TCP data of %d bytes, errno %d\n", sent_amount, errno); if (sent_amount == -1) { diff --git a/drivers/unix/tcp_server_posix.cpp b/drivers/unix/tcp_server_posix.cpp index 4f9ee62cde..aaca0fe0d8 100644 --- a/drivers/unix/tcp_server_posix.cpp +++ b/drivers/unix/tcp_server_posix.cpp @@ -41,7 +41,11 @@ #include #include #ifndef NO_FCNTL -#include + #ifdef __HAIKU__ + #include + #else + #include + #endif #else #include #endif diff --git a/platform/haiku/detect.py b/platform/haiku/detect.py index 992c73ee79..5dad2af033 100644 --- a/platform/haiku/detect.py +++ b/platform/haiku/detect.py @@ -34,9 +34,11 @@ def configure(env): env["bits"]="32" env.Append(CPPPATH = ['#platform/haiku']) + + # TODO: add clang and try gcc2 too env["CC"] = "gcc-x86" env["CXX"] = "g++-x86" - env.Append(CPPFLAGS = ['-DDEBUG_METHODS_ENABLED']) + env.Append(CPPFLAGS = ['-DDEBUG_METHODS_ENABLED']) env.Append(CPPFLAGS = ['-DUNIX_ENABLED']) - #env.Append(LIBS = ['be']) + env.Append(LIBS = ['be']) diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp index e69de29bb2..8841306b7a 100644 --- a/platform/haiku/os_haiku.cpp +++ b/platform/haiku/os_haiku.cpp @@ -0,0 +1,5 @@ +#include "os_haiku.h" + +String OS_Haiku::get_name() { + return "Haiku"; +} -- cgit v1.2.3 From 826f8af1ef3311ddcc0fab27629f7a5fcfa1b024 Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Mon, 25 May 2015 06:02:55 +0300 Subject: Haiku: link with the haiku libs, stub the OS_Haiku class. --- drivers/unix/stream_peer_tcp_posix.cpp | 8 +++- platform/haiku/detect.py | 2 +- platform/haiku/os_haiku.cpp | 76 ++++++++++++++++++++++++++++++++++ platform/haiku/os_haiku.h | 3 +- 4 files changed, 85 insertions(+), 4 deletions(-) diff --git a/drivers/unix/stream_peer_tcp_posix.cpp b/drivers/unix/stream_peer_tcp_posix.cpp index 2db7d9f6ec..f65eb694d6 100644 --- a/drivers/unix/stream_peer_tcp_posix.cpp +++ b/drivers/unix/stream_peer_tcp_posix.cpp @@ -206,8 +206,12 @@ Error StreamPeerTCPPosix::write(const uint8_t* p_data,int p_bytes, int &r_sent, while (data_to_send) { - // TODO: handle MSG_NOSIGNAL on __HAIKU__ - int sent_amount = send(sockfd, offset, data_to_send, 0); + // TODO: haiku does not have MSG_NOSIGNAL +#ifdef __HAIKU__ + int sent_amount = send(sockfd, offset, data_to_send, 0); +#else + int sent_amount = send(sockfd, offset, data_to_send, MSG_NOSIGNAL); +#endif //printf("Sent TCP data of %d bytes, errno %d\n", sent_amount, errno); if (sent_amount == -1) { diff --git a/platform/haiku/detect.py b/platform/haiku/detect.py index 5dad2af033..b443469d8d 100644 --- a/platform/haiku/detect.py +++ b/platform/haiku/detect.py @@ -41,4 +41,4 @@ def configure(env): env.Append(CPPFLAGS = ['-DDEBUG_METHODS_ENABLED']) env.Append(CPPFLAGS = ['-DUNIX_ENABLED']) - env.Append(LIBS = ['be']) + env.Append(LIBS = ['be', 'z', 'network', 'bnetapi']) diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp index 8841306b7a..4d45bb3333 100644 --- a/platform/haiku/os_haiku.cpp +++ b/platform/haiku/os_haiku.cpp @@ -1,5 +1,81 @@ #include "os_haiku.h" +OS_Haiku::OS_Haiku() { + +}; + +void OS_Haiku::run() { + +} + String OS_Haiku::get_name() { return "Haiku"; } + +void OS_Haiku::delete_main_loop() { + +} + +int OS_Haiku::get_video_driver_count() const { + +} + +const char* OS_Haiku::get_video_driver_name(int p_driver) const { + +} + +OS::VideoMode OS_Haiku::get_default_video_mode() const { + +} + +void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_audio_driver) { + +} + +void OS_Haiku::finalize() { + +} + +void OS_Haiku::set_main_loop(MainLoop* p_main_loop) { + +} + +MainLoop* OS_Haiku::get_main_loop() const { + +} + +bool OS_Haiku::can_draw() const { + +} + +Point2 OS_Haiku::get_mouse_pos() const { + +} + +int OS_Haiku::get_mouse_button_state() const { + +} + +void OS_Haiku::set_cursor_shape(CursorShape p_shape) { + +} + +void OS_Haiku::set_window_title(const String& p_title) { + +} + +Size2 OS_Haiku::get_window_size() const { + +} + +void OS_Haiku::set_video_mode(const VideoMode& p_video_mode, int p_screen) { + +} + +OS::VideoMode OS_Haiku::get_video_mode(int p_screen) const { + +} + +void OS_Haiku::get_fullscreen_mode_list(List *p_list, int p_screen) const { + +} diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h index ee1283f018..7e3cf84579 100644 --- a/platform/haiku/os_haiku.h +++ b/platform/haiku/os_haiku.h @@ -1,6 +1,7 @@ #ifndef OS_HAIKU_H #define OS_HAIKU_H +#include "os/os.h" #include "drivers/unix/os_unix.h" @@ -24,7 +25,7 @@ public: virtual String get_name(); - virtual MainLoop *get_main_loop() const; + virtual MainLoop* get_main_loop() const; virtual bool can_draw() const; virtual Point2 get_mouse_pos() const; -- cgit v1.2.3 From a5533270436e51c660d2c196e2a6a8f9e21d6420 Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Mon, 25 May 2015 06:34:16 +0300 Subject: Haiku: some small fixes --- drivers/unix/stream_peer_tcp_posix.cpp | 5 ++--- platform/haiku/os_haiku.cpp | 4 ++++ platform/haiku/os_haiku.h | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/unix/stream_peer_tcp_posix.cpp b/drivers/unix/stream_peer_tcp_posix.cpp index f65eb694d6..6e19647933 100644 --- a/drivers/unix/stream_peer_tcp_posix.cpp +++ b/drivers/unix/stream_peer_tcp_posix.cpp @@ -206,11 +206,10 @@ Error StreamPeerTCPPosix::write(const uint8_t* p_data,int p_bytes, int &r_sent, while (data_to_send) { - // TODO: haiku does not have MSG_NOSIGNAL #ifdef __HAIKU__ - int sent_amount = send(sockfd, offset, data_to_send, 0); + int sent_amount = send(sockfd, offset, data_to_send, 0); #else - int sent_amount = send(sockfd, offset, data_to_send, MSG_NOSIGNAL); + int sent_amount = send(sockfd, offset, data_to_send, MSG_NOSIGNAL); #endif //printf("Sent TCP data of %d bytes, errno %d\n", sent_amount, errno); diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp index 4d45bb3333..7c207f265b 100644 --- a/platform/haiku/os_haiku.cpp +++ b/platform/haiku/os_haiku.cpp @@ -79,3 +79,7 @@ OS::VideoMode OS_Haiku::get_video_mode(int p_screen) const { void OS_Haiku::get_fullscreen_mode_list(List *p_list, int p_screen) const { } + +String OS_Haiku::get_executable_path() const { + return OS::get_executable_path(); +} diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h index 7e3cf84579..8740a738cc 100644 --- a/platform/haiku/os_haiku.h +++ b/platform/haiku/os_haiku.h @@ -1,7 +1,6 @@ #ifndef OS_HAIKU_H #define OS_HAIKU_H -#include "os/os.h" #include "drivers/unix/os_unix.h" @@ -38,6 +37,7 @@ public: virtual void set_video_mode(const VideoMode& p_video_mode, int p_screen=0); virtual VideoMode get_video_mode(int p_screen=0) const; virtual void get_fullscreen_mode_list(List *p_list, int p_screen=0) const; + virtual String get_executable_path() const; }; #endif -- cgit v1.2.3 From 8dd674d6399b5543f589d3b770c97209e3e31c3b Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Thu, 28 May 2015 00:59:41 +0300 Subject: Haiku: enable debug support --- platform/haiku/detect.py | 12 +++++++++++- platform/haiku/platform_config.h | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/platform/haiku/detect.py b/platform/haiku/detect.py index b443469d8d..0c4d091824 100644 --- a/platform/haiku/detect.py +++ b/platform/haiku/detect.py @@ -39,6 +39,16 @@ def configure(env): env["CC"] = "gcc-x86" env["CXX"] = "g++-x86" - env.Append(CPPFLAGS = ['-DDEBUG_METHODS_ENABLED']) + if (env["target"]=="release"): + if (env["debug_release"]=="yes"): + env.Append(CCFLAGS=['-g2','-fomit-frame-pointer']) + else: + env.Append(CCFLAGS=['-O2','-ffast-math','-fomit-frame-pointer']) + elif (env["target"]=="release_debug"): + env.Append(CCFLAGS=['-O2','-ffast-math','-DDEBUG_ENABLED']) + elif (env["target"]=="debug"): + env.Append(CCFLAGS=['-g2', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) + + #env.Append(CPPFLAGS = ['-DDEBUG_METHODS_ENABLED']) env.Append(CPPFLAGS = ['-DUNIX_ENABLED']) env.Append(LIBS = ['be', 'z', 'network', 'bnetapi']) diff --git a/platform/haiku/platform_config.h b/platform/haiku/platform_config.h index dad24432a5..d37873ca8b 100644 --- a/platform/haiku/platform_config.h +++ b/platform/haiku/platform_config.h @@ -1 +1,4 @@ #include + +// for ifaddrs.h needed in drivers/unix/ip_unix.cpp +#define _BSD_SOURCE 1 -- cgit v1.2.3 From 513d509783678d1a6c9fd47d7e2e822d886f2c84 Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Thu, 28 May 2015 03:42:40 +0300 Subject: Haiku: enable building with GLES --- platform/haiku/detect.py | 5 +++-- platform/haiku/os_haiku.cpp | 46 +++++++++++++++++++++++++++++++++------- platform/haiku/os_haiku.h | 7 +++++- platform/haiku/platform_config.h | 2 ++ 4 files changed, 49 insertions(+), 11 deletions(-) diff --git a/platform/haiku/detect.py b/platform/haiku/detect.py index 0c4d091824..bb123c6aa0 100644 --- a/platform/haiku/detect.py +++ b/platform/haiku/detect.py @@ -49,6 +49,7 @@ def configure(env): elif (env["target"]=="debug"): env.Append(CCFLAGS=['-g2', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) - #env.Append(CPPFLAGS = ['-DDEBUG_METHODS_ENABLED']) - env.Append(CPPFLAGS = ['-DUNIX_ENABLED']) + #env.Append(CCFLAGS=['-DFREETYPE_ENABLED']) + env.Append(CPPFLAGS = ['-DOPENGL_ENABLED', '-DGLEW_ENABLED']) + env.Append(CPPFLAGS = ['-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DGLES_OVER_GL']) env.Append(LIBS = ['be', 'z', 'network', 'bnetapi']) diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp index 7c207f265b..103b1ac748 100644 --- a/platform/haiku/os_haiku.cpp +++ b/platform/haiku/os_haiku.cpp @@ -1,3 +1,5 @@ +#include "servers/visual/visual_server_raster.h" +#include "drivers/gles2/rasterizer_gles2.h" #include "os_haiku.h" OS_Haiku::OS_Haiku() { @@ -5,17 +7,13 @@ OS_Haiku::OS_Haiku() { }; void OS_Haiku::run() { - + } String OS_Haiku::get_name() { return "Haiku"; } -void OS_Haiku::delete_main_loop() { - -} - int OS_Haiku::get_video_driver_count() const { } @@ -29,19 +27,51 @@ OS::VideoMode OS_Haiku::get_default_video_mode() const { } void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_audio_driver) { - + main_loop = NULL; + +#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED) + //context_gl = memnew( ContextGL_X11( x11_display, x11_window,current_videomode, false ) ); + //context_gl->initialize(); + + rasterizer = memnew(RasterizerGLES2); +#endif + + visual_server = memnew(VisualServerRaster(rasterizer)); + + if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) { + visual_server = memnew(VisualServerWrapMT(visual_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD)); + } } void OS_Haiku::finalize() { - + if (main_loop) { + memdelete(main_loop); + } + + main_loop = NULL; + + visual_server->finish(); + memdelete(visual_server); + memdelete(rasterizer); } void OS_Haiku::set_main_loop(MainLoop* p_main_loop) { + main_loop = p_main_loop; + // TODO: enable + //input->set_main_loop(p_main_loop); } MainLoop* OS_Haiku::get_main_loop() const { - + return main_loop; +} + +void OS_Haiku::delete_main_loop() { + if (main_loop) { + memdelete(main_loop); + } + + main_loop = NULL; } bool OS_Haiku::can_draw() const { diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h index 8740a738cc..67faff5e96 100644 --- a/platform/haiku/os_haiku.h +++ b/platform/haiku/os_haiku.h @@ -2,10 +2,15 @@ #define OS_HAIKU_H #include "drivers/unix/os_unix.h" - +#include "servers/visual_server.h" +#include "servers/visual/rasterizer.h" class OS_Haiku : public OS_Unix { private: + MainLoop* main_loop; + Rasterizer* rasterizer; + VisualServer* visual_server; + virtual void delete_main_loop(); protected: diff --git a/platform/haiku/platform_config.h b/platform/haiku/platform_config.h index d37873ca8b..b63b600fc1 100644 --- a/platform/haiku/platform_config.h +++ b/platform/haiku/platform_config.h @@ -2,3 +2,5 @@ // for ifaddrs.h needed in drivers/unix/ip_unix.cpp #define _BSD_SOURCE 1 + +#define GLES2_INCLUDE_H "gl_context/glew.h" -- cgit v1.2.3 From db459fba1db908b21d6ea3e99c6e75d65c6cc6b0 Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Fri, 29 May 2015 23:36:48 +0300 Subject: Haiku: fix build, link with libGL and libGLEW --- platform/haiku/detect.py | 9 +++++++-- platform/haiku/os_haiku.cpp | 1 + platform/haiku/platform_config.h | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/platform/haiku/detect.py b/platform/haiku/detect.py index bb123c6aa0..2c15720a92 100644 --- a/platform/haiku/detect.py +++ b/platform/haiku/detect.py @@ -50,6 +50,11 @@ def configure(env): env.Append(CCFLAGS=['-g2', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) #env.Append(CCFLAGS=['-DFREETYPE_ENABLED']) - env.Append(CPPFLAGS = ['-DOPENGL_ENABLED', '-DGLEW_ENABLED']) + env.Append(CPPFLAGS = ['-DOPENGL_ENABLED']) env.Append(CPPFLAGS = ['-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DGLES_OVER_GL']) - env.Append(LIBS = ['be', 'z', 'network', 'bnetapi']) + env.Append(LIBS = ['be', 'GL', 'GLEW', 'z', 'network', 'bnetapi']) + + import methods + env.Append(BUILDERS = {'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl')}) + env.Append(BUILDERS = {'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl')}) + env.Append(BUILDERS = {'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl')}) diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp index 103b1ac748..dc3419b09e 100644 --- a/platform/haiku/os_haiku.cpp +++ b/platform/haiku/os_haiku.cpp @@ -1,4 +1,5 @@ #include "servers/visual/visual_server_raster.h" +#include "servers/visual/visual_server_wrap_mt.h" #include "drivers/gles2/rasterizer_gles2.h" #include "os_haiku.h" diff --git a/platform/haiku/platform_config.h b/platform/haiku/platform_config.h index b63b600fc1..691bdbdb9c 100644 --- a/platform/haiku/platform_config.h +++ b/platform/haiku/platform_config.h @@ -3,4 +3,4 @@ // for ifaddrs.h needed in drivers/unix/ip_unix.cpp #define _BSD_SOURCE 1 -#define GLES2_INCLUDE_H "gl_context/glew.h" +#define GLES2_INCLUDE_H -- cgit v1.2.3 From 8130707e018757d9270d8b3d94241eaecc82b896 Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Sat, 30 May 2015 00:57:07 +0300 Subject: Haiku: start implementing the os-dependant stuff --- platform/haiku/os_haiku.cpp | 29 ++++++++++++++++------------- platform/haiku/os_haiku.h | 1 + 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp index dc3419b09e..fb06413478 100644 --- a/platform/haiku/os_haiku.cpp +++ b/platform/haiku/os_haiku.cpp @@ -8,7 +8,7 @@ OS_Haiku::OS_Haiku() { }; void OS_Haiku::run() { - + ERR_PRINT("run() NOT IMPLEMENTED"); } String OS_Haiku::get_name() { @@ -16,19 +16,20 @@ String OS_Haiku::get_name() { } int OS_Haiku::get_video_driver_count() const { - + return 1; } const char* OS_Haiku::get_video_driver_name(int p_driver) const { - + return "GLES2"; } OS::VideoMode OS_Haiku::get_default_video_mode() const { - + return OS::VideoMode(800, 600, false); } void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_audio_driver) { main_loop = NULL; + current_video_mode = p_desired; #if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED) //context_gl = memnew( ContextGL_X11( x11_display, x11_window,current_videomode, false ) ); @@ -42,6 +43,8 @@ void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_ if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) { visual_server = memnew(VisualServerWrapMT(visual_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD)); } + + visual_server->init(); } void OS_Haiku::finalize() { @@ -76,39 +79,39 @@ void OS_Haiku::delete_main_loop() { } bool OS_Haiku::can_draw() const { - + ERR_PRINT("can_draw() NOT IMPLEMENTED"); } Point2 OS_Haiku::get_mouse_pos() const { - + ERR_PRINT("get_mouse_pos() NOT IMPLEMENTED"); } int OS_Haiku::get_mouse_button_state() const { - + ERR_PRINT("get_mouse_button_state() NOT IMPLEMENTED"); } void OS_Haiku::set_cursor_shape(CursorShape p_shape) { - + ERR_PRINT("set_cursor_shape() NOT IMPLEMENTED"); } void OS_Haiku::set_window_title(const String& p_title) { - + ERR_PRINT("set_window_title() NOT IMPLEMENTED"); } Size2 OS_Haiku::get_window_size() const { - + ERR_PRINT("get_window_size() NOT IMPLEMENTED"); } void OS_Haiku::set_video_mode(const VideoMode& p_video_mode, int p_screen) { - + ERR_PRINT("set_video_mode() NOT IMPLEMENTED"); } OS::VideoMode OS_Haiku::get_video_mode(int p_screen) const { - + return current_video_mode; } void OS_Haiku::get_fullscreen_mode_list(List *p_list, int p_screen) const { - + ERR_PRINT("get_fullscreen_mode_list() NOT IMPLEMENTED"); } String OS_Haiku::get_executable_path() const { diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h index 67faff5e96..dfe559c969 100644 --- a/platform/haiku/os_haiku.h +++ b/platform/haiku/os_haiku.h @@ -10,6 +10,7 @@ private: MainLoop* main_loop; Rasterizer* rasterizer; VisualServer* visual_server; + VideoMode current_video_mode; virtual void delete_main_loop(); -- cgit v1.2.3 From 310f061a4a9ef2325d40cd5f194fe22d54094a31 Mon Sep 17 00:00:00 2001 From: Rodolfo Ribeiro Gomes Date: Mon, 8 Jun 2015 23:19:52 -0300 Subject: Small fix for Import Game dialog labels --- tools/editor/project_manager.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/editor/project_manager.cpp b/tools/editor/project_manager.cpp index 00956919b7..43e8d48dd9 100644 --- a/tools/editor/project_manager.cpp +++ b/tools/editor/project_manager.cpp @@ -245,7 +245,8 @@ public: project_name->clear(); if (import_mode) { - set_title("Import Existing Project:"); + set_title("Import Existing Project"); + get_ok()->set_text("Import"); pp->set_text("Project Path: (Must exist)"); pn->set_text("Project Name:"); pn->hide(); @@ -254,7 +255,8 @@ public: popup_centered(Size2(500,125)); } else { - set_title("Create New Project:"); + set_title("Create New Project"); + get_ok()->set_text("Create"); pp->set_text("Project Path:"); pn->set_text("Project Name:"); pn->show(); @@ -313,7 +315,6 @@ public: l->add_color_override("font_color",Color(1,0.4,0.3,0.8)); l->set_align(Label::ALIGN_CENTER); - get_ok()->set_text("Create"); DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); project_path->set_text(d->get_current_dir()); memdelete(d); -- cgit v1.2.3 From f99b72c04f484c39ae728bc175114544a26d7bca Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Wed, 10 Jun 2015 21:18:39 +0300 Subject: Haiku: remove an #ifdef as the platform now supports MSG_NOSIGNAL --- drivers/unix/stream_peer_tcp_posix.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/unix/stream_peer_tcp_posix.cpp b/drivers/unix/stream_peer_tcp_posix.cpp index 6e19647933..5aa3915893 100644 --- a/drivers/unix/stream_peer_tcp_posix.cpp +++ b/drivers/unix/stream_peer_tcp_posix.cpp @@ -206,11 +206,7 @@ Error StreamPeerTCPPosix::write(const uint8_t* p_data,int p_bytes, int &r_sent, while (data_to_send) { -#ifdef __HAIKU__ - int sent_amount = send(sockfd, offset, data_to_send, 0); -#else int sent_amount = send(sockfd, offset, data_to_send, MSG_NOSIGNAL); -#endif //printf("Sent TCP data of %d bytes, errno %d\n", sent_amount, errno); if (sent_amount == -1) { -- cgit v1.2.3 From 8df3e30abd06ce8d51e6b1ad696aabf97ea9f178 Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Thu, 11 Jun 2015 22:57:41 +0300 Subject: Haiku: create a GL context and initialize the audio and physics servers --- drivers/gl_context/glew.c | 2 +- platform/haiku/SCsub | 6 ++- platform/haiku/context_gl_haiku.cpp | 55 ++++++++++++++++++++ platform/haiku/context_gl_haiku.h | 31 ++++++++++++ platform/haiku/detect.py | 3 +- platform/haiku/haiku_application.cpp | 7 +++ platform/haiku/haiku_application.h | 15 ++++++ platform/haiku/haiku_direct_window.cpp | 45 ++++++++++++++++ platform/haiku/haiku_direct_window.h | 27 ++++++++++ platform/haiku/haiku_gl_view.cpp | 54 ++++++++++++++++++++ platform/haiku/haiku_gl_view.h | 27 ++++++++++ platform/haiku/os_haiku.cpp | 93 +++++++++++++++++++++++++++++++--- platform/haiku/os_haiku.h | 30 +++++++++++ 13 files changed, 386 insertions(+), 9 deletions(-) create mode 100644 platform/haiku/context_gl_haiku.cpp create mode 100644 platform/haiku/context_gl_haiku.h create mode 100644 platform/haiku/haiku_application.cpp create mode 100644 platform/haiku/haiku_application.h create mode 100644 platform/haiku/haiku_direct_window.cpp create mode 100644 platform/haiku/haiku_direct_window.h create mode 100644 platform/haiku/haiku_gl_view.cpp create mode 100644 platform/haiku/haiku_gl_view.h diff --git a/drivers/gl_context/glew.c b/drivers/gl_context/glew.c index fc0aa28a72..e38942de4f 100644 --- a/drivers/gl_context/glew.c +++ b/drivers/gl_context/glew.c @@ -1,4 +1,4 @@ -#ifdef GLEW_ENABLED +#ifndef GLEW_ENABLED /* ** The OpenGL Extension Wrangler Library ** Copyright (C) 2002-2008, Milan Ikits diff --git a/platform/haiku/SCsub b/platform/haiku/SCsub index 8ae489cf54..18fa2e2b15 100644 --- a/platform/haiku/SCsub +++ b/platform/haiku/SCsub @@ -1,7 +1,11 @@ Import('env') common_haiku = [ - 'os_haiku.cpp' + 'os_haiku.cpp', + 'context_gl_haiku.cpp', + 'haiku_application.cpp', + 'haiku_direct_window.cpp', + 'haiku_gl_view.cpp' ] env.Program( diff --git a/platform/haiku/context_gl_haiku.cpp b/platform/haiku/context_gl_haiku.cpp new file mode 100644 index 0000000000..5c82b187b3 --- /dev/null +++ b/platform/haiku/context_gl_haiku.cpp @@ -0,0 +1,55 @@ +#include "context_gl_haiku.h" + +#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED) + +ContextGL_Haiku::ContextGL_Haiku(HaikuDirectWindow** p_window, OS::VideoMode& p_default_video_mode) { + video_mode = p_default_video_mode; + + uint32 type = BGL_RGB|BGL_DOUBLE|BGL_DEPTH; + + BRect windowRect; + windowRect.Set(50, 50, 800, 600); + + window = new HaikuDirectWindow(windowRect); + view = new HaikuGLView(window->Bounds(), type); + + *p_window = window; +} + +ContextGL_Haiku::~ContextGL_Haiku() { + delete view; +} + +Error ContextGL_Haiku::initialize() { + window->AddChild(view); + view->LockGL(); + window->SetHaikuGLView(view); + window->InitMessageRunner(); + window->Show(); + + return OK; +} + +void ContextGL_Haiku::release_current() { + ERR_PRINT("release_current() NOT IMPLEMENTED"); +} + +void ContextGL_Haiku::make_current() { + ERR_PRINT("make_current() NOT IMPLEMENTED"); +} + +void ContextGL_Haiku::swap_buffers() { + view->SwapBuffers(); +} + +int ContextGL_Haiku::get_window_width() { + // TODO: implement + return 800; +} + +int ContextGL_Haiku::get_window_height() { + // TODO: implement + return 600; +} + +#endif diff --git a/platform/haiku/context_gl_haiku.h b/platform/haiku/context_gl_haiku.h new file mode 100644 index 0000000000..16efa8f61d --- /dev/null +++ b/platform/haiku/context_gl_haiku.h @@ -0,0 +1,31 @@ +#ifndef CONTEXT_GL_HAIKU_H +#define CONTEXT_GL_HAIKU_H + +#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED) + +#include "os/os.h" +#include "drivers/gl_context/context_gl.h" + +#include "haiku_direct_window.h" +#include "haiku_gl_view.h" + +class ContextGL_Haiku : public ContextGL { +private: + HaikuGLView* view; + HaikuDirectWindow* window; + OS::VideoMode video_mode; + +public: + ContextGL_Haiku(HaikuDirectWindow** p_window, OS::VideoMode& default_video_mode); + ~ContextGL_Haiku(); + + virtual Error initialize(); + virtual void release_current(); + virtual void make_current(); + virtual void swap_buffers(); + virtual int get_window_width(); + virtual int get_window_height(); +}; + +#endif +#endif diff --git a/platform/haiku/detect.py b/platform/haiku/detect.py index 2c15720a92..587148838f 100644 --- a/platform/haiku/detect.py +++ b/platform/haiku/detect.py @@ -50,9 +50,10 @@ def configure(env): env.Append(CCFLAGS=['-g2', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) #env.Append(CCFLAGS=['-DFREETYPE_ENABLED']) + env.Append(CPPFLAGS = ['-DGLEW_ENABLED']) env.Append(CPPFLAGS = ['-DOPENGL_ENABLED']) env.Append(CPPFLAGS = ['-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DGLES_OVER_GL']) - env.Append(LIBS = ['be', 'GL', 'GLEW', 'z', 'network', 'bnetapi']) + env.Append(LIBS = ['be', 'game', 'GL', 'GLEW', 'z', 'network', 'bnetapi']) import methods env.Append(BUILDERS = {'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl')}) diff --git a/platform/haiku/haiku_application.cpp b/platform/haiku/haiku_application.cpp new file mode 100644 index 0000000000..56024f605d --- /dev/null +++ b/platform/haiku/haiku_application.cpp @@ -0,0 +1,7 @@ +#include "haiku_application.h" + +HaikuApplication::HaikuApplication() + : BApplication("application/x-vnd.Haiku-GLDirectMode") +{ + +} diff --git a/platform/haiku/haiku_application.h b/platform/haiku/haiku_application.h new file mode 100644 index 0000000000..995a917d62 --- /dev/null +++ b/platform/haiku/haiku_application.h @@ -0,0 +1,15 @@ +#ifndef HAIKU_APPLICATION_H +#define HAIKU_APPLICATION_H + +#include // needed for image_id +#include + +class HaikuApplication : public BApplication +{ +public: + HaikuApplication(); +//private: +// HaikuDirectWindow* window; +}; + +#endif diff --git a/platform/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp new file mode 100644 index 0000000000..e7f2718278 --- /dev/null +++ b/platform/haiku/haiku_direct_window.cpp @@ -0,0 +1,45 @@ +#include "haiku_direct_window.h" + +HaikuDirectWindow::HaikuDirectWindow(BRect p_frame) + : BDirectWindow(p_frame, "Godot", B_TITLED_WINDOW, 0) +{ + // TODO: formatting + float minWidth = 0.0f; + float maxWidth = 0.0f; + float minHeight = 0.0f; + float maxHeight = 0.0f; + + GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight); + SetSizeLimits(50.0f, maxWidth, 50.0f, maxHeight); +} + + +HaikuDirectWindow::~HaikuDirectWindow() +{ + delete update_runner; +} + +void HaikuDirectWindow::SetHaikuGLView(HaikuGLView* p_view) { + view = p_view; +} + +void HaikuDirectWindow::InitMessageRunner() { + update_runner = new BMessageRunner(BMessenger(view), + new BMessage(REDRAW_MSG), 1000000/60 /* 60 fps */); +} + + +bool HaikuDirectWindow::QuitRequested() +{ + view->EnableDirectMode(false); + be_app->PostMessage(B_QUIT_REQUESTED); + return true; +} + + +void HaikuDirectWindow::DirectConnected(direct_buffer_info *info) +{ + view->DirectConnected(info); + view->EnableDirectMode(true); +} + diff --git a/platform/haiku/haiku_direct_window.h b/platform/haiku/haiku_direct_window.h new file mode 100644 index 0000000000..450ea64296 --- /dev/null +++ b/platform/haiku/haiku_direct_window.h @@ -0,0 +1,27 @@ +#ifndef HAIKU_DIRECT_WINDOW_H +#define HAIKU_DIRECT_WINDOW_H + +#include // needed for image_id +#include + +#include "haiku_gl_view.h" + +#define REDRAW_MSG 'rdrw' + +class HaikuDirectWindow : public BDirectWindow +{ +public: + HaikuDirectWindow(BRect p_frame); + ~HaikuDirectWindow(); + + void SetHaikuGLView(HaikuGLView* p_view); + void InitMessageRunner(); + virtual bool QuitRequested(); + virtual void DirectConnected(direct_buffer_info *info); + +private: + HaikuGLView* view; + BMessageRunner* update_runner; +}; + +#endif diff --git a/platform/haiku/haiku_gl_view.cpp b/platform/haiku/haiku_gl_view.cpp new file mode 100644 index 0000000000..61a0120656 --- /dev/null +++ b/platform/haiku/haiku_gl_view.cpp @@ -0,0 +1,54 @@ +#include "haiku_gl_view.h" + +HaikuGLView::HaikuGLView(BRect frame, uint32 type) + : BGLView(frame, "SampleGLView", B_FOLLOW_ALL_SIDES, 0, type), rotate(0) +{ + width = frame.right-frame.left; + height = frame.bottom-frame.top; +} + +void HaikuGLView::AttachedToWindow(void) +{ + LockGL(); + BGLView::AttachedToWindow(); + UnlockGL(); + MakeFocus(); +} + +void HaikuGLView::FrameResized(float newWidth, float newHeight) +{ +} + +void HaikuGLView::gDraw(float rotation) +{ +} + +void HaikuGLView::gReshape(int width, int height) +{ +} + +void HaikuGLView::Render(void) +{ + LockGL(); + SwapBuffers(); + UnlockGL(); +} + +void HaikuGLView::MessageReceived(BMessage * msg) +{ + switch (msg->what) { + case 'rdrw': + Render(); + /* Rotate a bit more */ + rotate++; + break; + + default: + BGLView::MessageReceived(msg); + } +} + +void HaikuGLView::KeyDown(const char *bytes, int32 numBytes) +{ + +} diff --git a/platform/haiku/haiku_gl_view.h b/platform/haiku/haiku_gl_view.h new file mode 100644 index 0000000000..44d05fa27f --- /dev/null +++ b/platform/haiku/haiku_gl_view.h @@ -0,0 +1,27 @@ +#ifndef HAIKU_GL_VIEW_H +#define HAIKU_GL_VIEW_H + +#include // needed for image_id +#include + +class HaikuGLView : public BGLView +{ +public: + HaikuGLView(BRect frame, uint32 type); + virtual void AttachedToWindow(void); + virtual void FrameResized(float newWidth, float newHeight); + virtual void MessageReceived(BMessage * msg); + virtual void KeyDown(const char* bytes, int32 numBytes); + + void Render(void); + +private: + void gDraw(float rotation = 0); + void gReshape(int width, int height); + + float width; + float height; + float rotate; +}; + +#endif diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp index fb06413478..bf96cf1716 100644 --- a/platform/haiku/os_haiku.cpp +++ b/platform/haiku/os_haiku.cpp @@ -1,14 +1,37 @@ #include "servers/visual/visual_server_raster.h" #include "servers/visual/visual_server_wrap_mt.h" #include "drivers/gles2/rasterizer_gles2.h" +#include "servers/physics/physics_server_sw.h" +#include "main/main.h" + #include "os_haiku.h" + OS_Haiku::OS_Haiku() { - + AudioDriverManagerSW::add_driver(&driver_dummy); }; void OS_Haiku::run() { - ERR_PRINT("run() NOT IMPLEMENTED"); + if (!main_loop) { + return; + } + + main_loop->init(); + + /* + while (true) { + // TODO: process events + + if (Main::iteration() == true) { + break; + } + } + */ + + app->Run(); + delete app; + + main_loop->finish(); } String OS_Haiku::get_name() { @@ -31,20 +54,44 @@ void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_ main_loop = NULL; current_video_mode = p_desired; + app = new HaikuApplication(); + #if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED) - //context_gl = memnew( ContextGL_X11( x11_display, x11_window,current_videomode, false ) ); - //context_gl->initialize(); + context_gl = memnew(ContextGL_Haiku(&window, current_video_mode)); + context_gl->initialize(); rasterizer = memnew(RasterizerGLES2); #endif visual_server = memnew(VisualServerRaster(rasterizer)); + ERR_FAIL_COND(!visual_server); + if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) { visual_server = memnew(VisualServerWrapMT(visual_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD)); } visual_server->init(); + + physics_server = memnew(PhysicsServerSW); + physics_server->init(); + physics_2d_server = memnew(Physics2DServerSW); + physics_2d_server->init(); + + AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton(); + + if (AudioDriverManagerSW::get_driver(p_audio_driver)->init() != OK) { + ERR_PRINT("Initializing audio failed."); + } + + sample_manager = memnew(SampleManagerMallocSW); + audio_server = memnew(AudioServerSW(sample_manager)); + audio_server->init(); + + spatial_sound_server = memnew(SpatialSoundServerSW); + spatial_sound_server->init(); + spatial_sound_2d_server = memnew(SpatialSound2DServerSW); + spatial_sound_2d_server->init(); } void OS_Haiku::finalize() { @@ -54,9 +101,29 @@ void OS_Haiku::finalize() { main_loop = NULL; + spatial_sound_server->finish(); + memdelete(spatial_sound_server); + + spatial_sound_2d_server->finish(); + memdelete(spatial_sound_2d_server); + + audio_server->finish(); + memdelete(audio_server); + memdelete(sample_manager); + visual_server->finish(); memdelete(visual_server); memdelete(rasterizer); + + physics_server->finish(); + memdelete(physics_server); + + physics_2d_server->finish(); + memdelete(physics_2d_server); + +#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED) + memdelete(context_gl); +#endif } void OS_Haiku::set_main_loop(MainLoop* p_main_loop) { @@ -78,8 +145,21 @@ void OS_Haiku::delete_main_loop() { main_loop = NULL; } +void OS_Haiku::release_rendering_thread() { + ERR_PRINT("release_rendering_thread() NOT IMPLEMENTED"); +} + +void OS_Haiku::make_rendering_thread() { + ERR_PRINT("make_rendering_thread() NOT IMPLEMENTED"); +} + bool OS_Haiku::can_draw() const { - ERR_PRINT("can_draw() NOT IMPLEMENTED"); + // TODO: implement + return true; +} + +void OS_Haiku::swap_buffers() { + context_gl->swap_buffers(); } Point2 OS_Haiku::get_mouse_pos() const { @@ -95,7 +175,8 @@ void OS_Haiku::set_cursor_shape(CursorShape p_shape) { } void OS_Haiku::set_window_title(const String& p_title) { - ERR_PRINT("set_window_title() NOT IMPLEMENTED"); + //ERR_PRINT("set_window_title() NOT IMPLEMENTED"); + window->SetTitle(p_title.utf8().get_data()); } Size2 OS_Haiku::get_window_size() const { diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h index dfe559c969..938983347c 100644 --- a/platform/haiku/os_haiku.h +++ b/platform/haiku/os_haiku.h @@ -4,13 +4,39 @@ #include "drivers/unix/os_unix.h" #include "servers/visual_server.h" #include "servers/visual/rasterizer.h" +#include "servers/physics_server.h" +#include "servers/physics_2d/physics_2d_server_sw.h" +#include "servers/audio/audio_server_sw.h" +#include "servers/audio/sample_manager_sw.h" +#include "servers/spatial_sound/spatial_sound_server_sw.h" +#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" +#include "servers/audio/audio_driver_dummy.h" + +#include "context_gl_haiku.h" +#include "haiku_application.h" +#include "haiku_direct_window.h" + class OS_Haiku : public OS_Unix { private: + HaikuApplication* app; + HaikuDirectWindow* window; MainLoop* main_loop; Rasterizer* rasterizer; VisualServer* visual_server; VideoMode current_video_mode; + PhysicsServer* physics_server; + Physics2DServer* physics_2d_server; + AudioServerSW* audio_server; + SampleManagerMallocSW* sample_manager; + SpatialSoundServerSW* spatial_sound_server; + SpatialSound2DServerSW* spatial_sound_2d_server; + + AudioDriverDummy driver_dummy; // TODO: use a real driver + +#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED) + ContextGL_Haiku* context_gl; +#endif virtual void delete_main_loop(); @@ -31,7 +57,11 @@ public: virtual String get_name(); virtual MainLoop* get_main_loop() const; + virtual bool can_draw() const; + virtual void release_rendering_thread(); + virtual void make_rendering_thread(); + virtual void swap_buffers(); virtual Point2 get_mouse_pos() const; virtual int get_mouse_button_state() const; -- cgit v1.2.3 From 1505d65ac9ec9f44195e961f0089343aabe3de79 Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Tue, 16 Jun 2015 21:52:24 +0300 Subject: Haiku: handle mouse movement and click events --- platform/haiku/context_gl_haiku.cpp | 27 ++--- platform/haiku/context_gl_haiku.h | 4 +- platform/haiku/haiku_direct_window.cpp | 177 +++++++++++++++++++++++++++++---- platform/haiku/haiku_direct_window.h | 26 +++-- platform/haiku/haiku_gl_view.cpp | 45 ++------- platform/haiku/haiku_gl_view.h | 20 +--- platform/haiku/os_haiku.cpp | 29 ++++-- platform/haiku/os_haiku.h | 2 + 8 files changed, 227 insertions(+), 103 deletions(-) diff --git a/platform/haiku/context_gl_haiku.cpp b/platform/haiku/context_gl_haiku.cpp index 5c82b187b3..8cb1adc360 100644 --- a/platform/haiku/context_gl_haiku.cpp +++ b/platform/haiku/context_gl_haiku.cpp @@ -2,18 +2,11 @@ #if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED) -ContextGL_Haiku::ContextGL_Haiku(HaikuDirectWindow** p_window, OS::VideoMode& p_default_video_mode) { - video_mode = p_default_video_mode; - - uint32 type = BGL_RGB|BGL_DOUBLE|BGL_DEPTH; +ContextGL_Haiku::ContextGL_Haiku(HaikuDirectWindow* p_window) { + window = p_window; - BRect windowRect; - windowRect.Set(50, 50, 800, 600); - - window = new HaikuDirectWindow(windowRect); + uint32 type = BGL_RGB | BGL_DOUBLE | BGL_DEPTH; view = new HaikuGLView(window->Bounds(), type); - - *p_window = window; } ContextGL_Haiku::~ContextGL_Haiku() { @@ -24,18 +17,18 @@ Error ContextGL_Haiku::initialize() { window->AddChild(view); view->LockGL(); window->SetHaikuGLView(view); - window->InitMessageRunner(); - window->Show(); return OK; } void ContextGL_Haiku::release_current() { - ERR_PRINT("release_current() NOT IMPLEMENTED"); + //ERR_PRINT("release_current() NOT IMPLEMENTED"); + view->UnlockGL(); } void ContextGL_Haiku::make_current() { - ERR_PRINT("make_current() NOT IMPLEMENTED"); + view->LockGL(); + //ERR_PRINT("make_current() NOT IMPLEMENTED"); } void ContextGL_Haiku::swap_buffers() { @@ -43,13 +36,11 @@ void ContextGL_Haiku::swap_buffers() { } int ContextGL_Haiku::get_window_width() { - // TODO: implement - return 800; + return window->Bounds().IntegerWidth(); } int ContextGL_Haiku::get_window_height() { - // TODO: implement - return 600; + return window->Bounds().IntegerHeight(); } #endif diff --git a/platform/haiku/context_gl_haiku.h b/platform/haiku/context_gl_haiku.h index 16efa8f61d..e37fe14970 100644 --- a/platform/haiku/context_gl_haiku.h +++ b/platform/haiku/context_gl_haiku.h @@ -3,7 +3,6 @@ #if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED) -#include "os/os.h" #include "drivers/gl_context/context_gl.h" #include "haiku_direct_window.h" @@ -13,10 +12,9 @@ class ContextGL_Haiku : public ContextGL { private: HaikuGLView* view; HaikuDirectWindow* window; - OS::VideoMode video_mode; public: - ContextGL_Haiku(HaikuDirectWindow** p_window, OS::VideoMode& default_video_mode); + ContextGL_Haiku(HaikuDirectWindow* p_window); ~ContextGL_Haiku(); virtual Error initialize(); diff --git a/platform/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp index e7f2718278..9c0696bc42 100644 --- a/platform/haiku/haiku_direct_window.cpp +++ b/platform/haiku/haiku_direct_window.cpp @@ -1,45 +1,186 @@ +#include "main/main.h" #include "haiku_direct_window.h" HaikuDirectWindow::HaikuDirectWindow(BRect p_frame) : BDirectWindow(p_frame, "Godot", B_TITLED_WINDOW, 0) { - // TODO: formatting - float minWidth = 0.0f; - float maxWidth = 0.0f; - float minHeight = 0.0f; - float maxHeight = 0.0f; - - GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight); - SetSizeLimits(50.0f, maxWidth, 50.0f, maxHeight); + last_mouse_pos_valid = false; + last_buttons_state = 0; } -HaikuDirectWindow::~HaikuDirectWindow() -{ - delete update_runner; +HaikuDirectWindow::~HaikuDirectWindow() { + if (update_runner) { + delete update_runner; + } } void HaikuDirectWindow::SetHaikuGLView(HaikuGLView* p_view) { view = p_view; } -void HaikuDirectWindow::InitMessageRunner() { - update_runner = new BMessageRunner(BMessenger(view), +void HaikuDirectWindow::StartMessageRunner() { + update_runner = new BMessageRunner(BMessenger(this), new BMessage(REDRAW_MSG), 1000000/60 /* 60 fps */); } +void HaikuDirectWindow::StopMessageRunner() { + delete update_runner; +} -bool HaikuDirectWindow::QuitRequested() -{ +void HaikuDirectWindow::SetInput(InputDefault* p_input) { + input = p_input; +} + +bool HaikuDirectWindow::QuitRequested() { view->EnableDirectMode(false); be_app->PostMessage(B_QUIT_REQUESTED); return true; } - -void HaikuDirectWindow::DirectConnected(direct_buffer_info *info) -{ +void HaikuDirectWindow::DirectConnected(direct_buffer_info* info) { view->DirectConnected(info); view->EnableDirectMode(true); } +void HaikuDirectWindow::MessageReceived(BMessage* message) +{ + switch (message->what) { + case REDRAW_MSG: + //ERR_PRINT("iteration 1"); + Main::iteration(); + + //if (NeedsUpdate()) { + // ERR_PRINT("NEEDS UPDATE"); + // Main::force_redraw(); + //} + + //ERR_PRINT("iteration 2"); + break; + + case B_INVALIDATE: + ERR_PRINT("WINDOW B_INVALIDATE"); + //Main::force_redraw(); + break; + + default: + BDirectWindow::MessageReceived(message); + } +} + +void HaikuDirectWindow::DispatchMessage(BMessage* message, BHandler* handler) { + switch (message->what) { + case B_MOUSE_DOWN: + case B_MOUSE_UP: + DispatchMouseButton(message); + break; + + case B_MOUSE_MOVED: + DispatchMouseMoved(message); + break; + + default: + BDirectWindow::DispatchMessage(message, handler); + } +} + +void HaikuDirectWindow::DispatchMouseButton(BMessage* message) { + message->PrintToStream(); + + BPoint where; + if (message->FindPoint("where", &where) != B_OK) { + return; + } + + uint32 buttons = message->FindInt32("buttons"); + uint32 button = buttons ^ last_buttons_state; + last_buttons_state = buttons; + + // TODO: implement the mouse_mode checks + //if (mouse_mode == MOUSE_MODE_CAPTURED) { + // event.xbutton.x=last_mouse_pos.x; + // event.xbutton.y=last_mouse_pos.y; + //} + + InputEvent mouse_event; + mouse_event.ID = ++event_id; + mouse_event.type = InputEvent::MOUSE_BUTTON; + mouse_event.device = 0; + + // TODO: implement the modifier state getters + //mouse_event.mouse_button.mod = get_key_modifier_state(event.xbutton.state); + //mouse_event.mouse_button.button_mask = get_mouse_button_state(event.xbutton.state); + mouse_event.mouse_button.x = where.x; + mouse_event.mouse_button.y = where.y; + mouse_event.mouse_button.global_x = where.x; + mouse_event.mouse_button.global_y = where.y; + + switch (button) { + default: + case B_PRIMARY_MOUSE_BUTTON: + ERR_PRINT("PRIMARY"); + mouse_event.mouse_button.button_index = 1; + break; + + case B_SECONDARY_MOUSE_BUTTON: + ERR_PRINT("SECONDARY"); + mouse_event.mouse_button.button_index = 2; + break; + + case B_TERTIARY_MOUSE_BUTTON: + ERR_PRINT("MIDDLE"); + mouse_event.mouse_button.button_index = 3; + break; + } + + mouse_event.mouse_button.pressed = (message->what == B_MOUSE_DOWN); + + if (message->what == B_MOUSE_DOWN && mouse_event.mouse_button.button_index == 1) { + int32 clicks = message->FindInt32("clicks"); + + if (clicks > 1) { + mouse_event.mouse_button.doubleclick=true; + } + } + + input->parse_input_event(mouse_event); +} + +void HaikuDirectWindow::DispatchMouseMoved(BMessage* message) { + BPoint where; + if (message->FindPoint("where", &where) != B_OK) { + return; + } + + Point2i pos(where.x, where.y); + + if (!last_mouse_pos_valid) { + last_mouse_pos=pos; + last_mouse_pos_valid=true; + } + + Point2i rel = pos - last_mouse_pos; + + InputEvent motion_event; + motion_event.ID = ++event_id; + motion_event.type = InputEvent::MOUSE_MOTION; + motion_event.device = 0; + + // TODO: implement the modifier state getters + //motion_event.mouse_motion.mod = get_key_modifier_state(event.xmotion.state); + //motion_event.mouse_motion.button_mask = get_mouse_button_state(event.xmotion.state); + motion_event.mouse_motion.x = pos.x; + motion_event.mouse_motion.y = pos.y; + input->set_mouse_pos(pos); + motion_event.mouse_motion.global_x = pos.x; + motion_event.mouse_motion.global_y = pos.y; + motion_event.mouse_motion.speed_x = input->get_mouse_speed().x; + motion_event.mouse_motion.speed_y = input->get_mouse_speed().y; + + motion_event.mouse_motion.relative_x = rel.x; + motion_event.mouse_motion.relative_y = rel.y; + + last_mouse_pos=pos; + + input->parse_input_event(motion_event); +} diff --git a/platform/haiku/haiku_direct_window.h b/platform/haiku/haiku_direct_window.h index 450ea64296..19ea987e76 100644 --- a/platform/haiku/haiku_direct_window.h +++ b/platform/haiku/haiku_direct_window.h @@ -4,24 +4,38 @@ #include // needed for image_id #include +#include "os/input.h" #include "haiku_gl_view.h" #define REDRAW_MSG 'rdrw' class HaikuDirectWindow : public BDirectWindow { +private: + unsigned int event_id; + Point2i last_mouse_pos; + bool last_mouse_pos_valid; + uint32 last_buttons_state; + + InputDefault* input; + HaikuGLView* view; + BMessageRunner* update_runner; + + void DispatchMouseButton(BMessage* message); + void DispatchMouseMoved(BMessage* message); + public: HaikuDirectWindow(BRect p_frame); ~HaikuDirectWindow(); void SetHaikuGLView(HaikuGLView* p_view); - void InitMessageRunner(); + void StartMessageRunner(); + void StopMessageRunner(); + void SetInput(InputDefault* p_input); virtual bool QuitRequested(); - virtual void DirectConnected(direct_buffer_info *info); - -private: - HaikuGLView* view; - BMessageRunner* update_runner; + virtual void DirectConnected(direct_buffer_info* info); + virtual void MessageReceived(BMessage* message); + virtual void DispatchMessage(BMessage* message, BHandler* handler); }; #endif diff --git a/platform/haiku/haiku_gl_view.cpp b/platform/haiku/haiku_gl_view.cpp index 61a0120656..8adab96a87 100644 --- a/platform/haiku/haiku_gl_view.cpp +++ b/platform/haiku/haiku_gl_view.cpp @@ -1,54 +1,31 @@ +#include "main/main.h" #include "haiku_gl_view.h" HaikuGLView::HaikuGLView(BRect frame, uint32 type) - : BGLView(frame, "SampleGLView", B_FOLLOW_ALL_SIDES, 0, type), rotate(0) + : BGLView(frame, "SampleGLView", B_FOLLOW_ALL_SIDES, 0, type) { - width = frame.right-frame.left; - height = frame.bottom-frame.top; } -void HaikuGLView::AttachedToWindow(void) -{ +void HaikuGLView::AttachedToWindow(void) { LockGL(); BGLView::AttachedToWindow(); UnlockGL(); MakeFocus(); } -void HaikuGLView::FrameResized(float newWidth, float newHeight) -{ -} - -void HaikuGLView::gDraw(float rotation) -{ -} - -void HaikuGLView::gReshape(int width, int height) -{ -} - -void HaikuGLView::Render(void) -{ - LockGL(); - SwapBuffers(); - UnlockGL(); +void HaikuGLView::Draw(BRect updateRect) { + Main::force_redraw(); } -void HaikuGLView::MessageReceived(BMessage * msg) +void HaikuGLView::MessageReceived(BMessage* msg) { + // TODO: remove if not needed switch (msg->what) { - case 'rdrw': - Render(); - /* Rotate a bit more */ - rotate++; - break; - - default: - BGLView::MessageReceived(msg); + default: + BGLView::MessageReceived(msg); } } -void HaikuGLView::KeyDown(const char *bytes, int32 numBytes) -{ - +void HaikuGLView::MouseMoved (BPoint where, uint32 code, const BMessage *dragMessage) { + ERR_PRINT("MouseMoved()"); } diff --git a/platform/haiku/haiku_gl_view.h b/platform/haiku/haiku_gl_view.h index 44d05fa27f..78ebb513a8 100644 --- a/platform/haiku/haiku_gl_view.h +++ b/platform/haiku/haiku_gl_view.h @@ -7,21 +7,11 @@ class HaikuGLView : public BGLView { public: - HaikuGLView(BRect frame, uint32 type); - virtual void AttachedToWindow(void); - virtual void FrameResized(float newWidth, float newHeight); - virtual void MessageReceived(BMessage * msg); - virtual void KeyDown(const char* bytes, int32 numBytes); - - void Render(void); - -private: - void gDraw(float rotation = 0); - void gReshape(int width, int height); - - float width; - float height; - float rotate; + HaikuGLView(BRect frame, uint32 type); + virtual void AttachedToWindow(void); + virtual void MessageReceived(BMessage* msg); + virtual void MouseMoved (BPoint where, uint32 code, const BMessage *dragMessage); + virtual void Draw(BRect updateRect); }; #endif diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp index bf96cf1716..193927238d 100644 --- a/platform/haiku/os_haiku.cpp +++ b/platform/haiku/os_haiku.cpp @@ -17,6 +17,8 @@ void OS_Haiku::run() { } main_loop->init(); + window->Show(); + window->StartMessageRunner(); /* while (true) { @@ -29,6 +31,7 @@ void OS_Haiku::run() { */ app->Run(); + window->StopMessageRunner(); delete app; main_loop->finish(); @@ -56,8 +59,13 @@ void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_ app = new HaikuApplication(); + BRect frame; + frame.Set(50, 50, 50 + current_video_mode.width - 1, 50 + current_video_mode.height - 1); + + window = new HaikuDirectWindow(frame); + #if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED) - context_gl = memnew(ContextGL_Haiku(&window, current_video_mode)); + context_gl = memnew(ContextGL_Haiku(window)); context_gl->initialize(); rasterizer = memnew(RasterizerGLES2); @@ -67,9 +75,9 @@ void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_ ERR_FAIL_COND(!visual_server); - if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) { - visual_server = memnew(VisualServerWrapMT(visual_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD)); - } + //if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) { + // visual_server = memnew(VisualServerWrapMT(visual_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD)); + //} visual_server->init(); @@ -92,6 +100,9 @@ void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_ spatial_sound_server->init(); spatial_sound_2d_server = memnew(SpatialSound2DServerSW); spatial_sound_2d_server->init(); + + input = memnew(InputDefault); + window->SetInput(input); } void OS_Haiku::finalize() { @@ -121,6 +132,8 @@ void OS_Haiku::finalize() { physics_2d_server->finish(); memdelete(physics_2d_server); + memdelete(input); + #if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED) memdelete(context_gl); #endif @@ -128,9 +141,7 @@ void OS_Haiku::finalize() { void OS_Haiku::set_main_loop(MainLoop* p_main_loop) { main_loop = p_main_loop; - - // TODO: enable - //input->set_main_loop(p_main_loop); + input->set_main_loop(p_main_loop); } MainLoop* OS_Haiku::get_main_loop() const { @@ -146,11 +157,11 @@ void OS_Haiku::delete_main_loop() { } void OS_Haiku::release_rendering_thread() { - ERR_PRINT("release_rendering_thread() NOT IMPLEMENTED"); + context_gl->release_current(); } void OS_Haiku::make_rendering_thread() { - ERR_PRINT("make_rendering_thread() NOT IMPLEMENTED"); + context_gl->make_current(); } bool OS_Haiku::can_draw() const { diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h index 938983347c..b741ae7da0 100644 --- a/platform/haiku/os_haiku.h +++ b/platform/haiku/os_haiku.h @@ -1,6 +1,7 @@ #ifndef OS_HAIKU_H #define OS_HAIKU_H +#include "os/input.h" #include "drivers/unix/os_unix.h" #include "servers/visual_server.h" #include "servers/visual/rasterizer.h" @@ -22,6 +23,7 @@ private: HaikuApplication* app; HaikuDirectWindow* window; MainLoop* main_loop; + InputDefault* input; Rasterizer* rasterizer; VisualServer* visual_server; VideoMode current_video_mode; -- cgit v1.2.3 From 2102d35e9c18a0cede87e7e45d375153702b3ea5 Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Wed, 17 Jun 2015 22:27:45 +0300 Subject: Haiku: read the status of the key modifiers and mouse buttons --- platform/haiku/haiku_direct_window.cpp | 71 +++++++++++++++++++++++----------- platform/haiku/haiku_direct_window.h | 2 + 2 files changed, 51 insertions(+), 22 deletions(-) diff --git a/platform/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp index 9c0696bc42..6ff4369087 100644 --- a/platform/haiku/haiku_direct_window.cpp +++ b/platform/haiku/haiku_direct_window.cpp @@ -39,7 +39,7 @@ bool HaikuDirectWindow::QuitRequested() { } void HaikuDirectWindow::DirectConnected(direct_buffer_info* info) { - view->DirectConnected(info); + view->DirectConnected(info); view->EnableDirectMode(true); } @@ -49,21 +49,21 @@ void HaikuDirectWindow::MessageReceived(BMessage* message) case REDRAW_MSG: //ERR_PRINT("iteration 1"); Main::iteration(); - + //if (NeedsUpdate()) { // ERR_PRINT("NEEDS UPDATE"); // Main::force_redraw(); //} - + //ERR_PRINT("iteration 2"); break; - + case B_INVALIDATE: ERR_PRINT("WINDOW B_INVALIDATE"); //Main::force_redraw(); break; - default: + default: BDirectWindow::MessageReceived(message); } } @@ -92,6 +92,7 @@ void HaikuDirectWindow::DispatchMouseButton(BMessage* message) { return; } + uint32 modifiers = message->FindInt32("modifiers"); uint32 buttons = message->FindInt32("buttons"); uint32 button = buttons ^ last_buttons_state; last_buttons_state = buttons; @@ -101,15 +102,14 @@ void HaikuDirectWindow::DispatchMouseButton(BMessage* message) { // event.xbutton.x=last_mouse_pos.x; // event.xbutton.y=last_mouse_pos.y; //} - + InputEvent mouse_event; mouse_event.ID = ++event_id; mouse_event.type = InputEvent::MOUSE_BUTTON; mouse_event.device = 0; - // TODO: implement the modifier state getters - //mouse_event.mouse_button.mod = get_key_modifier_state(event.xbutton.state); - //mouse_event.mouse_button.button_mask = get_mouse_button_state(event.xbutton.state); + mouse_event.mouse_button.mod = GetKeyModifierState(modifiers); + mouse_event.mouse_button.button_mask = GetMouseButtonState(buttons); mouse_event.mouse_button.x = where.x; mouse_event.mouse_button.y = where.y; mouse_event.mouse_button.global_x = where.x; @@ -118,30 +118,27 @@ void HaikuDirectWindow::DispatchMouseButton(BMessage* message) { switch (button) { default: case B_PRIMARY_MOUSE_BUTTON: - ERR_PRINT("PRIMARY"); mouse_event.mouse_button.button_index = 1; break; case B_SECONDARY_MOUSE_BUTTON: - ERR_PRINT("SECONDARY"); mouse_event.mouse_button.button_index = 2; break; case B_TERTIARY_MOUSE_BUTTON: - ERR_PRINT("MIDDLE"); mouse_event.mouse_button.button_index = 3; break; } - + mouse_event.mouse_button.pressed = (message->what == B_MOUSE_DOWN); if (message->what == B_MOUSE_DOWN && mouse_event.mouse_button.button_index == 1) { int32 clicks = message->FindInt32("clicks"); - + if (clicks > 1) { mouse_event.mouse_button.doubleclick=true; } - } + } input->parse_input_event(mouse_event); } @@ -151,12 +148,14 @@ void HaikuDirectWindow::DispatchMouseMoved(BMessage* message) { if (message->FindPoint("where", &where) != B_OK) { return; } - + Point2i pos(where.x, where.y); - + uint32 modifiers = message->FindInt32("modifiers"); + uint32 buttons = message->FindInt32("buttons"); + if (!last_mouse_pos_valid) { - last_mouse_pos=pos; - last_mouse_pos_valid=true; + last_mouse_pos = pos; + last_mouse_pos_valid = true; } Point2i rel = pos - last_mouse_pos; @@ -166,9 +165,8 @@ void HaikuDirectWindow::DispatchMouseMoved(BMessage* message) { motion_event.type = InputEvent::MOUSE_MOTION; motion_event.device = 0; - // TODO: implement the modifier state getters - //motion_event.mouse_motion.mod = get_key_modifier_state(event.xmotion.state); - //motion_event.mouse_motion.button_mask = get_mouse_button_state(event.xmotion.state); + motion_event.mouse_motion.mod = GetKeyModifierState(modifiers); + motion_event.mouse_motion.button_mask = GetMouseButtonState(buttons); motion_event.mouse_motion.x = pos.x; motion_event.mouse_motion.y = pos.y; input->set_mouse_pos(pos); @@ -184,3 +182,32 @@ void HaikuDirectWindow::DispatchMouseMoved(BMessage* message) { input->parse_input_event(motion_event); } + +inline InputModifierState HaikuDirectWindow::GetKeyModifierState(uint32 p_state) { + InputModifierState state; + + state.shift = (p_state & B_SHIFT_KEY) != 0; + state.control = (p_state & B_CONTROL_KEY) != 0; + state.alt = (p_state & B_OPTION_KEY) != 0; + state.meta = (p_state & B_COMMAND_KEY) != 0; + + return state; +} + +inline unsigned int HaikuDirectWindow::GetMouseButtonState(uint32 p_state) { + unsigned int state = 0; + + if (p_state & B_PRIMARY_MOUSE_BUTTON) { + state |= 1 << 0; + } + + if (p_state & B_SECONDARY_MOUSE_BUTTON) { + state |= 1 << 1; + } + + if (p_state & B_TERTIARY_MOUSE_BUTTON) { + state |= 1 << 2; + } + + return state; +} diff --git a/platform/haiku/haiku_direct_window.h b/platform/haiku/haiku_direct_window.h index 19ea987e76..bb0ef43da0 100644 --- a/platform/haiku/haiku_direct_window.h +++ b/platform/haiku/haiku_direct_window.h @@ -23,6 +23,8 @@ private: void DispatchMouseButton(BMessage* message); void DispatchMouseMoved(BMessage* message); + inline InputModifierState GetKeyModifierState(uint32 p_state); + inline unsigned int GetMouseButtonState(uint32 p_state); public: HaikuDirectWindow(BRect p_frame); -- cgit v1.2.3 From f10eb8ffa1a7f6bee9b5228ea1204fd93844e4cc Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Thu, 18 Jun 2015 22:41:33 +0300 Subject: Haiku: implement get_mouse_pos() and get_mouse_button_state() --- platform/haiku/haiku_direct_window.cpp | 13 ++++++++----- platform/haiku/haiku_direct_window.h | 8 ++++++-- platform/haiku/os_haiku.cpp | 7 +++---- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/platform/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp index 6ff4369087..62231565a9 100644 --- a/platform/haiku/haiku_direct_window.cpp +++ b/platform/haiku/haiku_direct_window.cpp @@ -6,6 +6,7 @@ HaikuDirectWindow::HaikuDirectWindow(BRect p_frame) { last_mouse_pos_valid = false; last_buttons_state = 0; + last_button_mask = 0; } @@ -154,11 +155,11 @@ void HaikuDirectWindow::DispatchMouseMoved(BMessage* message) { uint32 buttons = message->FindInt32("buttons"); if (!last_mouse_pos_valid) { - last_mouse_pos = pos; + last_mouse_position = pos; last_mouse_pos_valid = true; } - Point2i rel = pos - last_mouse_pos; + Point2i rel = pos - last_mouse_position; InputEvent motion_event; motion_event.ID = ++event_id; @@ -178,7 +179,7 @@ void HaikuDirectWindow::DispatchMouseMoved(BMessage* message) { motion_event.mouse_motion.relative_x = rel.x; motion_event.mouse_motion.relative_y = rel.y; - last_mouse_pos=pos; + last_mouse_position = pos; input->parse_input_event(motion_event); } @@ -194,8 +195,8 @@ inline InputModifierState HaikuDirectWindow::GetKeyModifierState(uint32 p_state) return state; } -inline unsigned int HaikuDirectWindow::GetMouseButtonState(uint32 p_state) { - unsigned int state = 0; +inline int HaikuDirectWindow::GetMouseButtonState(uint32 p_state) { + int state = 0; if (p_state & B_PRIMARY_MOUSE_BUTTON) { state |= 1 << 0; @@ -209,5 +210,7 @@ inline unsigned int HaikuDirectWindow::GetMouseButtonState(uint32 p_state) { state |= 1 << 2; } + last_button_mask = state; + return state; } diff --git a/platform/haiku/haiku_direct_window.h b/platform/haiku/haiku_direct_window.h index bb0ef43da0..be4dcd9e94 100644 --- a/platform/haiku/haiku_direct_window.h +++ b/platform/haiku/haiku_direct_window.h @@ -13,9 +13,10 @@ class HaikuDirectWindow : public BDirectWindow { private: unsigned int event_id; - Point2i last_mouse_pos; + Point2i last_mouse_position; bool last_mouse_pos_valid; uint32 last_buttons_state; + int last_button_mask; InputDefault* input; HaikuGLView* view; @@ -24,7 +25,7 @@ private: void DispatchMouseButton(BMessage* message); void DispatchMouseMoved(BMessage* message); inline InputModifierState GetKeyModifierState(uint32 p_state); - inline unsigned int GetMouseButtonState(uint32 p_state); + inline int GetMouseButtonState(uint32 p_state); public: HaikuDirectWindow(BRect p_frame); @@ -38,6 +39,9 @@ public: virtual void DirectConnected(direct_buffer_info* info); virtual void MessageReceived(BMessage* message); virtual void DispatchMessage(BMessage* message, BHandler* handler); + + inline Point2i GetLastMousePosition() { return last_mouse_position; }; + inline int GetLastButtonMask() { return last_button_mask; }; }; #endif diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp index 193927238d..3694244e0a 100644 --- a/platform/haiku/os_haiku.cpp +++ b/platform/haiku/os_haiku.cpp @@ -174,19 +174,18 @@ void OS_Haiku::swap_buffers() { } Point2 OS_Haiku::get_mouse_pos() const { - ERR_PRINT("get_mouse_pos() NOT IMPLEMENTED"); + return window->GetLastMousePosition(); } int OS_Haiku::get_mouse_button_state() const { - ERR_PRINT("get_mouse_button_state() NOT IMPLEMENTED"); + return window->GetLastButtonMask(); } void OS_Haiku::set_cursor_shape(CursorShape p_shape) { - ERR_PRINT("set_cursor_shape() NOT IMPLEMENTED"); + //ERR_PRINT("set_cursor_shape() NOT IMPLEMENTED"); } void OS_Haiku::set_window_title(const String& p_title) { - //ERR_PRINT("set_window_title() NOT IMPLEMENTED"); window->SetTitle(p_title.utf8().get_data()); } -- cgit v1.2.3 From 93ac4ace0a0d84fdd7003fcaa02296d55ad5b2ad Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Sat, 20 Jun 2015 01:59:32 +0300 Subject: Haiku: handle the quit request message --- platform/haiku/haiku_direct_window.cpp | 32 +++++++++++++------------------- platform/haiku/haiku_direct_window.h | 2 ++ platform/haiku/os_haiku.cpp | 3 +++ 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/platform/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp index 62231565a9..3fccab10dd 100644 --- a/platform/haiku/haiku_direct_window.cpp +++ b/platform/haiku/haiku_direct_window.cpp @@ -2,7 +2,7 @@ #include "haiku_direct_window.h" HaikuDirectWindow::HaikuDirectWindow(BRect p_frame) - : BDirectWindow(p_frame, "Godot", B_TITLED_WINDOW, 0) + : BDirectWindow(p_frame, "Godot", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE) { last_mouse_pos_valid = false; last_buttons_state = 0; @@ -33,10 +33,13 @@ void HaikuDirectWindow::SetInput(InputDefault* p_input) { input = p_input; } +void HaikuDirectWindow::SetMainLoop(MainLoop* p_main_loop) { + main_loop = p_main_loop; +} + bool HaikuDirectWindow::QuitRequested() { - view->EnableDirectMode(false); - be_app->PostMessage(B_QUIT_REQUESTED); - return true; + main_loop->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST); + return false; } void HaikuDirectWindow::DirectConnected(direct_buffer_info* info) { @@ -44,24 +47,15 @@ void HaikuDirectWindow::DirectConnected(direct_buffer_info* info) { view->EnableDirectMode(true); } -void HaikuDirectWindow::MessageReceived(BMessage* message) -{ +void HaikuDirectWindow::MessageReceived(BMessage* message) { switch (message->what) { case REDRAW_MSG: - //ERR_PRINT("iteration 1"); - Main::iteration(); - - //if (NeedsUpdate()) { - // ERR_PRINT("NEEDS UPDATE"); - // Main::force_redraw(); - //} - - //ERR_PRINT("iteration 2"); - break; + Sync(); - case B_INVALIDATE: - ERR_PRINT("WINDOW B_INVALIDATE"); - //Main::force_redraw(); + if (Main::iteration() == true) { + view->EnableDirectMode(false); + Quit(); + } break; default: diff --git a/platform/haiku/haiku_direct_window.h b/platform/haiku/haiku_direct_window.h index be4dcd9e94..c985cdc5d6 100644 --- a/platform/haiku/haiku_direct_window.h +++ b/platform/haiku/haiku_direct_window.h @@ -18,6 +18,7 @@ private: uint32 last_buttons_state; int last_button_mask; + MainLoop* main_loop; InputDefault* input; HaikuGLView* view; BMessageRunner* update_runner; @@ -35,6 +36,7 @@ public: void StartMessageRunner(); void StopMessageRunner(); void SetInput(InputDefault* p_input); + void SetMainLoop(MainLoop* p_main_loop); virtual bool QuitRequested(); virtual void DirectConnected(direct_buffer_info* info); virtual void MessageReceived(BMessage* message); diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp index 3694244e0a..699b0ba1ce 100644 --- a/platform/haiku/os_haiku.cpp +++ b/platform/haiku/os_haiku.cpp @@ -29,6 +29,7 @@ void OS_Haiku::run() { } } */ + app->Run(); window->StopMessageRunner(); @@ -142,6 +143,7 @@ void OS_Haiku::finalize() { void OS_Haiku::set_main_loop(MainLoop* p_main_loop) { main_loop = p_main_loop; input->set_main_loop(p_main_loop); + window->SetMainLoop(p_main_loop); } MainLoop* OS_Haiku::get_main_loop() const { @@ -154,6 +156,7 @@ void OS_Haiku::delete_main_loop() { } main_loop = NULL; + window->SetMainLoop(NULL); } void OS_Haiku::release_rendering_thread() { -- cgit v1.2.3 From d44dfc244099eafe40ff0d48abbcefd4271d029b Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Sat, 20 Jun 2015 03:43:11 +0300 Subject: Haiku: cleanup, add TODOs --- platform/haiku/os_haiku.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp index 699b0ba1ce..7e4bb83177 100644 --- a/platform/haiku/os_haiku.cpp +++ b/platform/haiku/os_haiku.cpp @@ -2,6 +2,7 @@ #include "servers/visual/visual_server_wrap_mt.h" #include "drivers/gles2/rasterizer_gles2.h" #include "servers/physics/physics_server_sw.h" +//#include "servers/physics_2d/physics_2d_server_wrap_mt.h" #include "main/main.h" #include "os_haiku.h" @@ -19,22 +20,10 @@ void OS_Haiku::run() { main_loop->init(); window->Show(); window->StartMessageRunner(); - - /* - while (true) { - // TODO: process events - - if (Main::iteration() == true) { - break; - } - } - */ - - app->Run(); window->StopMessageRunner(); - delete app; + delete app; main_loop->finish(); } @@ -76,6 +65,7 @@ void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_ ERR_FAIL_COND(!visual_server); + // TODO: enable multithreaded VS //if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) { // visual_server = memnew(VisualServerWrapMT(visual_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD)); //} @@ -85,6 +75,8 @@ void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_ physics_server = memnew(PhysicsServerSW); physics_server->init(); physics_2d_server = memnew(Physics2DServerSW); + // TODO: enable multithreaded PS + //physics_2d_server = Physics2DServerWrapMT::init_server(); physics_2d_server->init(); AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton(); -- cgit v1.2.3 From b59e95ce1c9905af8c7d44b74082ac489520e9b2 Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Sat, 20 Jun 2015 15:35:54 +0300 Subject: Haiku: implemet get_widow_size() get/set_window_position() --- platform/haiku/os_haiku.cpp | 13 ++++++++++++- platform/haiku/os_haiku.h | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp index 7e4bb83177..1dc16f7e1c 100644 --- a/platform/haiku/os_haiku.cpp +++ b/platform/haiku/os_haiku.cpp @@ -185,7 +185,18 @@ void OS_Haiku::set_window_title(const String& p_title) { } Size2 OS_Haiku::get_window_size() const { - ERR_PRINT("get_window_size() NOT IMPLEMENTED"); + BSize size = window->Size(); + return Size2i(size.IntegerWidth(), size.IntegerHeight()); +} + +Point2 OS_Haiku::get_window_position() const { + BPoint point(0, 0); + window->ConvertToScreen(&point); + return Point2i(point.x, point.y); +} + +void OS_Haiku::set_window_position(const Point2& p_position) { + window->MoveTo(p_position.x, p_position.y); } void OS_Haiku::set_video_mode(const VideoMode& p_video_mode, int p_screen) { diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h index b741ae7da0..59f47fa11f 100644 --- a/platform/haiku/os_haiku.h +++ b/platform/haiku/os_haiku.h @@ -71,6 +71,8 @@ public: virtual void set_window_title(const String& p_title); virtual Size2 get_window_size() const; + virtual Point2 get_window_position() const; + virtual void set_window_position(const Point2& p_position); virtual void set_video_mode(const VideoMode& p_video_mode, int p_screen=0); virtual VideoMode get_video_mode(int p_screen=0) const; -- cgit v1.2.3 From 6f48ddc61db9a06e0751356e712fc87ded9ae3c3 Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Sun, 21 Jun 2015 02:08:31 +0300 Subject: Haiku: add some screen and window-related methods --- platform/haiku/os_haiku.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++- platform/haiku/os_haiku.h | 8 ++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp index 1dc16f7e1c..230340f325 100644 --- a/platform/haiku/os_haiku.cpp +++ b/platform/haiku/os_haiku.cpp @@ -1,3 +1,5 @@ +#include + #include "servers/visual/visual_server_raster.h" #include "servers/visual/visual_server_wrap_mt.h" #include "drivers/gles2/rasterizer_gles2.h" @@ -180,13 +182,48 @@ void OS_Haiku::set_cursor_shape(CursorShape p_shape) { //ERR_PRINT("set_cursor_shape() NOT IMPLEMENTED"); } +int OS_Haiku::get_screen_count() const { + // TODO: implement get_screen_count() + return 1; +} + +int OS_Haiku::get_current_screen() const { + // TODO: implement get_current_screen() + return 0; +} + +void OS_Haiku::set_current_screen(int p_screen) { + // TODO: implement set_current_screen() +} + +Point2 OS_Haiku::get_screen_position(int p_screen) const { + // TODO: make this work with the p_screen parameter + BScreen* screen = new BScreen(window); + BRect frame = screen->Frame(); + delete screen; + return Point2i(frame.left, frame.top); +} + +Size2 OS_Haiku::get_screen_size(int p_screen) const { + // TODO: make this work with the p_screen parameter + BScreen* screen = new BScreen(window); + BRect frame = screen->Frame(); + delete screen; + return Size2i(frame.IntegerWidth() + 1, frame.IntegerHeight() + 1); +} + void OS_Haiku::set_window_title(const String& p_title) { window->SetTitle(p_title.utf8().get_data()); } Size2 OS_Haiku::get_window_size() const { BSize size = window->Size(); - return Size2i(size.IntegerWidth(), size.IntegerHeight()); + return Size2i(size.IntegerWidth() + 1, size.IntegerHeight() + 1); +} + +void OS_Haiku::set_window_size(const Size2 p_size) { + // TODO: why does it stop redrawing after this is called? + window->ResizeTo(p_size.x, p_size.y); } Point2 OS_Haiku::get_window_position() const { @@ -199,6 +236,16 @@ void OS_Haiku::set_window_position(const Point2& p_position) { window->MoveTo(p_position.x, p_position.y); } +void OS_Haiku::set_window_fullscreen(bool p_enabled) { + window->SetFullScreen(p_enabled); + current_video_mode.fullscreen = p_enabled; + visual_server->init(); +} + +bool OS_Haiku::is_window_fullscreen() const { + return current_video_mode.fullscreen; +} + void OS_Haiku::set_video_mode(const VideoMode& p_video_mode, int p_screen) { ERR_PRINT("set_video_mode() NOT IMPLEMENTED"); } diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h index 59f47fa11f..983fbc33a9 100644 --- a/platform/haiku/os_haiku.h +++ b/platform/haiku/os_haiku.h @@ -69,10 +69,18 @@ public: virtual int get_mouse_button_state() const; virtual void set_cursor_shape(CursorShape p_shape); + virtual int get_screen_count() const; + virtual int get_current_screen() const; + virtual void set_current_screen(int p_screen); + virtual Point2 get_screen_position(int p_screen=0) const; + virtual Size2 get_screen_size(int p_screen=0) const; virtual void set_window_title(const String& p_title); virtual Size2 get_window_size() const; + virtual void set_window_size(const Size2 p_size); virtual Point2 get_window_position() const; virtual void set_window_position(const Point2& p_position); + virtual void set_window_fullscreen(bool p_enabled); + virtual bool is_window_fullscreen() const; virtual void set_video_mode(const VideoMode& p_video_mode, int p_screen=0); virtual VideoMode get_video_mode(int p_screen=0) const; -- cgit v1.2.3 From 174df9a276b26eb6594e3387f71e3fe8c1706253 Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Sun, 21 Jun 2015 22:18:27 +0300 Subject: Haiku: add support for mouse wheel --- platform/haiku/haiku_direct_window.cpp | 33 +++++++++++++++++++++++++++++++++ platform/haiku/haiku_direct_window.h | 2 ++ 2 files changed, 35 insertions(+) diff --git a/platform/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp index 3fccab10dd..8c8069af49 100644 --- a/platform/haiku/haiku_direct_window.cpp +++ b/platform/haiku/haiku_direct_window.cpp @@ -7,6 +7,7 @@ HaikuDirectWindow::HaikuDirectWindow(BRect p_frame) last_mouse_pos_valid = false; last_buttons_state = 0; last_button_mask = 0; + last_key_modifier_state = 0; } @@ -74,6 +75,10 @@ void HaikuDirectWindow::DispatchMessage(BMessage* message, BHandler* handler) { DispatchMouseMoved(message); break; + case B_MOUSE_WHEEL_CHANGED: + DispatchMouseWheelChanged(message); + break; + default: BDirectWindow::DispatchMessage(message, handler); } @@ -178,7 +183,35 @@ void HaikuDirectWindow::DispatchMouseMoved(BMessage* message) { input->parse_input_event(motion_event); } +void HaikuDirectWindow::DispatchMouseWheelChanged(BMessage* message) { + float wheel_delta_y = 0; + if (message->FindFloat("be:wheel_delta_y", &wheel_delta_y) != B_OK) { + return; + } + + InputEvent mouse_event; + mouse_event.ID = ++event_id; + mouse_event.type = InputEvent::MOUSE_BUTTON; + mouse_event.device = 0; + + mouse_event.mouse_button.button_index = wheel_delta_y < 0 ? 4 : 5; + mouse_event.mouse_button.mod = GetKeyModifierState(last_key_modifier_state); + mouse_event.mouse_button.button_mask = last_button_mask; + mouse_event.mouse_button.x = last_mouse_position.x; + mouse_event.mouse_button.y = last_mouse_position.y; + mouse_event.mouse_button.global_x = last_mouse_position.x; + mouse_event.mouse_button.global_y = last_mouse_position.y; + + mouse_event.mouse_button.pressed = true; + input->parse_input_event(mouse_event); + + mouse_event.ID = ++event_id; + mouse_event.mouse_button.pressed = false; + input->parse_input_event(mouse_event); +} + inline InputModifierState HaikuDirectWindow::GetKeyModifierState(uint32 p_state) { + last_key_modifier_state = p_state; InputModifierState state; state.shift = (p_state & B_SHIFT_KEY) != 0; diff --git a/platform/haiku/haiku_direct_window.h b/platform/haiku/haiku_direct_window.h index c985cdc5d6..5355ab4dd4 100644 --- a/platform/haiku/haiku_direct_window.h +++ b/platform/haiku/haiku_direct_window.h @@ -16,6 +16,7 @@ private: Point2i last_mouse_position; bool last_mouse_pos_valid; uint32 last_buttons_state; + uint32 last_key_modifier_state; int last_button_mask; MainLoop* main_loop; @@ -25,6 +26,7 @@ private: void DispatchMouseButton(BMessage* message); void DispatchMouseMoved(BMessage* message); + void DispatchMouseWheelChanged(BMessage* message); inline InputModifierState GetKeyModifierState(uint32 p_state); inline int GetMouseButtonState(uint32 p_state); -- cgit v1.2.3 From 7ad89c7e8383144292609f857803a4c57f852259 Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Tue, 23 Jun 2015 21:22:12 +0300 Subject: Haiku: implement some more window-related methods --- platform/haiku/os_haiku.cpp | 44 +++++++++++++++++++++++++++++++++++++++++++- platform/haiku/os_haiku.h | 6 ++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp index 230340f325..b4b7877038 100644 --- a/platform/haiku/os_haiku.cpp +++ b/platform/haiku/os_haiku.cpp @@ -20,7 +20,6 @@ void OS_Haiku::run() { } main_loop->init(); - window->Show(); window->StartMessageRunner(); app->Run(); window->StopMessageRunner(); @@ -56,6 +55,16 @@ void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_ window = new HaikuDirectWindow(frame); + if (current_video_mode.fullscreen) { + window->SetFullScreen(true); + } + + if (!current_video_mode.resizable) { + uint32 flags = window->Flags(); + flags |= B_NOT_RESIZABLE; + window->SetFlags(flags); + } + #if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED) context_gl = memnew(ContextGL_Haiku(window)); context_gl->initialize(); @@ -98,6 +107,7 @@ void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_ input = memnew(InputDefault); window->SetInput(input); + window->Show(); } void OS_Haiku::finalize() { @@ -246,6 +256,38 @@ bool OS_Haiku::is_window_fullscreen() const { return current_video_mode.fullscreen; } +void OS_Haiku::set_window_resizable(bool p_enabled) { + uint32 flags = window->Flags(); + + if (p_enabled) { + flags &= ~(B_NOT_RESIZABLE); + } else { + flags |= B_NOT_RESIZABLE; + } + + window->SetFlags(flags); +} + +bool OS_Haiku::is_window_resizable() const { + return !(window->Flags() & B_NOT_RESIZABLE); +} + +void OS_Haiku::set_window_minimized(bool p_enabled) { + window->Minimize(p_enabled); +} + +bool OS_Haiku::is_window_minimized() const { + return window->IsMinimized(); +} + +void OS_Haiku::set_window_maximized(bool p_enabled) { + window->Minimize(!p_enabled); +} + +bool OS_Haiku::is_window_maximized() const { + return !window->IsMinimized(); +} + void OS_Haiku::set_video_mode(const VideoMode& p_video_mode, int p_screen) { ERR_PRINT("set_video_mode() NOT IMPLEMENTED"); } diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h index 983fbc33a9..a7a8bee522 100644 --- a/platform/haiku/os_haiku.h +++ b/platform/haiku/os_haiku.h @@ -81,6 +81,12 @@ public: virtual void set_window_position(const Point2& p_position); virtual void set_window_fullscreen(bool p_enabled); virtual bool is_window_fullscreen() const; + virtual void set_window_resizable(bool p_enabled); + virtual bool is_window_resizable() const; + virtual void set_window_minimized(bool p_enabled); + virtual bool is_window_minimized() const; + virtual void set_window_maximized(bool p_enabled); + virtual bool is_window_maximized() const; virtual void set_video_mode(const VideoMode& p_video_mode, int p_screen=0); virtual VideoMode get_video_mode(int p_screen=0) const; -- cgit v1.2.3 From f61eb5fd8e13642c82364f8ee66a0f6c791a4511 Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Fri, 26 Jun 2015 21:32:57 +0300 Subject: Haiku: fix the glew.c hack --- drivers/gl_context/glew.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gl_context/glew.c b/drivers/gl_context/glew.c index e38942de4f..962e82b657 100644 --- a/drivers/gl_context/glew.c +++ b/drivers/gl_context/glew.c @@ -1,4 +1,8 @@ -#ifndef GLEW_ENABLED +#ifdef __HAIKU__ + #undef GLEW_ENABLED +#endif + +#ifdef GLEW_ENABLED /* ** The OpenGL Extension Wrangler Library ** Copyright (C) 2002-2008, Milan Ikits -- cgit v1.2.3 From 903e6b37c0ed94cd0b3447dd3ff471abbfaa4460 Mon Sep 17 00:00:00 2001 From: volzhs Date: Mon, 29 Jun 2015 02:56:38 +0900 Subject: fix crash by payments when run on android 5.1.1 device. (http://stackoverflow.com/questions/24480069/google-in-app-billing-illegalargumentexception-service-intent-must-be-explicit) --- .../android/java/src/com/android/godot/payments/PaymentsManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/android/java/src/com/android/godot/payments/PaymentsManager.java b/platform/android/java/src/com/android/godot/payments/PaymentsManager.java index fd1a62738a..5bf86d0b69 100644 --- a/platform/android/java/src/com/android/godot/payments/PaymentsManager.java +++ b/platform/android/java/src/com/android/godot/payments/PaymentsManager.java @@ -47,8 +47,10 @@ public class PaymentsManager { } public PaymentsManager initService(){ + Intent intent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); + intent.setPackage("com.android.vending"); activity.bindService( - new Intent("com.android.vending.billing.InAppBillingService.BIND"), + intent, mServiceConn, Context.BIND_AUTO_CREATE); return this; -- cgit v1.2.3 From 77e78cdb200b08a079b9d4047ea99227874ff3e1 Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Thu, 2 Jul 2015 18:41:32 +0300 Subject: Haiku: gl context locking --- platform/haiku/context_gl_haiku.cpp | 3 --- platform/haiku/haiku_direct_window.cpp | 42 ++++++++++++++++++++++++++++------ platform/haiku/haiku_direct_window.h | 12 +++++++--- platform/haiku/os_haiku.cpp | 23 +++++++++++++++---- 4 files changed, 62 insertions(+), 18 deletions(-) diff --git a/platform/haiku/context_gl_haiku.cpp b/platform/haiku/context_gl_haiku.cpp index 8cb1adc360..21107a52a4 100644 --- a/platform/haiku/context_gl_haiku.cpp +++ b/platform/haiku/context_gl_haiku.cpp @@ -15,20 +15,17 @@ ContextGL_Haiku::~ContextGL_Haiku() { Error ContextGL_Haiku::initialize() { window->AddChild(view); - view->LockGL(); window->SetHaikuGLView(view); return OK; } void ContextGL_Haiku::release_current() { - //ERR_PRINT("release_current() NOT IMPLEMENTED"); view->UnlockGL(); } void ContextGL_Haiku::make_current() { view->LockGL(); - //ERR_PRINT("make_current() NOT IMPLEMENTED"); } void ContextGL_Haiku::swap_buffers() { diff --git a/platform/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp index 8c8069af49..e400d70108 100644 --- a/platform/haiku/haiku_direct_window.cpp +++ b/platform/haiku/haiku_direct_window.cpp @@ -23,7 +23,7 @@ void HaikuDirectWindow::SetHaikuGLView(HaikuGLView* p_view) { void HaikuDirectWindow::StartMessageRunner() { update_runner = new BMessageRunner(BMessenger(this), - new BMessage(REDRAW_MSG), 1000000/60 /* 60 fps */); + new BMessage(REDRAW_MSG), 1000000/30 /* 30 fps */); } void HaikuDirectWindow::StopMessageRunner() { @@ -68,15 +68,31 @@ void HaikuDirectWindow::DispatchMessage(BMessage* message, BHandler* handler) { switch (message->what) { case B_MOUSE_DOWN: case B_MOUSE_UP: - DispatchMouseButton(message); + HandleMouseButton(message); break; case B_MOUSE_MOVED: - DispatchMouseMoved(message); + HandleMouseMoved(message); break; case B_MOUSE_WHEEL_CHANGED: - DispatchMouseWheelChanged(message); + HandleMouseWheelChanged(message); + break; + + case B_WINDOW_RESIZED: + HandleWindowResized(message); + //view->UnlockGL(); + //BDirectWindow::DispatchMessage(message, handler); + //view->LockGL(); + break; + + case LOCKGL_MSG: + ERR_PRINT("LOCKGL"); + view->LockGL(); + break; + + case UNLOCKGL_MSG: + view->UnlockGL(); break; default: @@ -84,7 +100,7 @@ void HaikuDirectWindow::DispatchMessage(BMessage* message, BHandler* handler) { } } -void HaikuDirectWindow::DispatchMouseButton(BMessage* message) { +void HaikuDirectWindow::HandleMouseButton(BMessage* message) { message->PrintToStream(); BPoint where; @@ -143,7 +159,7 @@ void HaikuDirectWindow::DispatchMouseButton(BMessage* message) { input->parse_input_event(mouse_event); } -void HaikuDirectWindow::DispatchMouseMoved(BMessage* message) { +void HaikuDirectWindow::HandleMouseMoved(BMessage* message) { BPoint where; if (message->FindPoint("where", &where) != B_OK) { return; @@ -183,7 +199,7 @@ void HaikuDirectWindow::DispatchMouseMoved(BMessage* message) { input->parse_input_event(motion_event); } -void HaikuDirectWindow::DispatchMouseWheelChanged(BMessage* message) { +void HaikuDirectWindow::HandleMouseWheelChanged(BMessage* message) { float wheel_delta_y = 0; if (message->FindFloat("be:wheel_delta_y", &wheel_delta_y) != B_OK) { return; @@ -210,6 +226,18 @@ void HaikuDirectWindow::DispatchMouseWheelChanged(BMessage* message) { input->parse_input_event(mouse_event); } +void HaikuDirectWindow::HandleWindowResized(BMessage* message) { + int32 width = 0; + int32 height = 0; + + if ((message->FindInt32("width", &width) != B_OK) || (message->FindInt32("height", &height) != B_OK)) { + return; + } + + current_video_mode->width = width; + current_video_mode->height = height; +} + inline InputModifierState HaikuDirectWindow::GetKeyModifierState(uint32 p_state) { last_key_modifier_state = p_state; InputModifierState state; diff --git a/platform/haiku/haiku_direct_window.h b/platform/haiku/haiku_direct_window.h index 5355ab4dd4..3667eb24d1 100644 --- a/platform/haiku/haiku_direct_window.h +++ b/platform/haiku/haiku_direct_window.h @@ -5,9 +5,12 @@ #include #include "os/input.h" +#include "core/os/os.h" #include "haiku_gl_view.h" #define REDRAW_MSG 'rdrw' +#define LOCKGL_MSG 'glck' +#define UNLOCKGL_MSG 'ulck' class HaikuDirectWindow : public BDirectWindow { @@ -18,15 +21,17 @@ private: uint32 last_buttons_state; uint32 last_key_modifier_state; int last_button_mask; + OS::VideoMode* current_video_mode; MainLoop* main_loop; InputDefault* input; HaikuGLView* view; BMessageRunner* update_runner; - void DispatchMouseButton(BMessage* message); - void DispatchMouseMoved(BMessage* message); - void DispatchMouseWheelChanged(BMessage* message); + void HandleMouseButton(BMessage* message); + void HandleMouseMoved(BMessage* message); + void HandleMouseWheelChanged(BMessage* message); + void HandleWindowResized(BMessage* message); inline InputModifierState GetKeyModifierState(uint32 p_state); inline int GetMouseButtonState(uint32 p_state); @@ -39,6 +44,7 @@ public: void StopMessageRunner(); void SetInput(InputDefault* p_input); void SetMainLoop(MainLoop* p_main_loop); + inline void SetVideoMode(OS::VideoMode* video_mode) { current_video_mode = video_mode; }; virtual bool QuitRequested(); virtual void DirectConnected(direct_buffer_info* info); virtual void MessageReceived(BMessage* message); diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp index b4b7877038..2c29260281 100644 --- a/platform/haiku/os_haiku.cpp +++ b/platform/haiku/os_haiku.cpp @@ -20,11 +20,21 @@ void OS_Haiku::run() { } main_loop->init(); + context_gl->release_current(); + + // TODO: clean up + BMessenger* bms = new BMessenger(window); + BMessage* msg = new BMessage(); + bms->SendMessage(LOCKGL_MSG, msg); + window->StartMessageRunner(); app->Run(); window->StopMessageRunner(); delete app; + + delete bms; + delete msg; main_loop->finish(); } @@ -54,6 +64,7 @@ void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_ frame.Set(50, 50, 50 + current_video_mode.width - 1, 50 + current_video_mode.height - 1); window = new HaikuDirectWindow(frame); + window->SetVideoMode(¤t_video_mode); if (current_video_mode.fullscreen) { window->SetFullScreen(true); @@ -68,6 +79,7 @@ void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_ #if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED) context_gl = memnew(ContextGL_Haiku(window)); context_gl->initialize(); + context_gl->make_current(); rasterizer = memnew(RasterizerGLES2); #endif @@ -81,6 +93,10 @@ void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_ // visual_server = memnew(VisualServerWrapMT(visual_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD)); //} + input = memnew(InputDefault); + window->SetInput(input); + + window->Show(); visual_server->init(); physics_server = memnew(PhysicsServerSW); @@ -104,10 +120,6 @@ void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_ spatial_sound_server->init(); spatial_sound_2d_server = memnew(SpatialSound2DServerSW); spatial_sound_2d_server->init(); - - input = memnew(InputDefault); - window->SetInput(input); - window->Show(); } void OS_Haiku::finalize() { @@ -266,10 +278,11 @@ void OS_Haiku::set_window_resizable(bool p_enabled) { } window->SetFlags(flags); + current_video_mode.resizable = p_enabled; } bool OS_Haiku::is_window_resizable() const { - return !(window->Flags() & B_NOT_RESIZABLE); + return current_video_mode.resizable; } void OS_Haiku::set_window_minimized(bool p_enabled) { -- cgit v1.2.3 From a009fadfff40d6339031a70c760103c76edfdce7 Mon Sep 17 00:00:00 2001 From: Peace Sells Date: Thu, 9 Jul 2015 20:51:49 -0600 Subject: Added GridMap settings which allows the user to enter a pick distance. --- modules/gridmap/grid_map_editor_plugin.cpp | 24 ++++++++++++++++++++++-- modules/gridmap/grid_map_editor_plugin.h | 7 +++++-- tools/editor/editor_settings.cpp | 1 + 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index 3d56b04cac..e4559ca100 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -220,7 +220,9 @@ void GridMapEditor::_menu_option(int p_option) { } break; - + case MENU_OPTION_GRIDMAP_SETTINGS: { + settings_dialog->popup_centered(settings_vbc->get_combined_minimum_size() + Size2(50, 50)); + } break; } } @@ -304,7 +306,7 @@ bool GridMapEditor::do_input_action(Camera* p_camera,const Point2& p_point,bool p.d=edit_floor[edit_axis]*node->get_cell_size(); Vector3 inters; - if (!p.intersects_segment(from,from+normal*500,&inters)) + if (!p.intersects_segment(from, from + normal * settings_pick_distance->get_val(), &inters)) return false; @@ -1249,6 +1251,24 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { //options->get_popup()->add_separator(); //options->get_popup()->add_item("Configure",MENU_OPTION_CONFIGURE); + options->get_popup()->add_separator(); + options->get_popup()->add_item("Settings", MENU_OPTION_GRIDMAP_SETTINGS); + + settings_dialog = memnew(ConfirmationDialog); + settings_dialog->set_title("GridMap Settings"); + add_child(settings_dialog); + settings_vbc = memnew(VBoxContainer); + settings_vbc->set_custom_minimum_size(Size2(200, 0)); + settings_dialog->add_child(settings_vbc); + settings_dialog->set_child_rect(settings_vbc); + + settings_pick_distance = memnew(SpinBox); + settings_pick_distance->set_max(10000.0f); + settings_pick_distance->set_min(500.0f); + settings_pick_distance->set_step(1.0f); + settings_pick_distance->set_val(EDITOR_DEF("gridmap_editor/pick_distance", 5000.0)); + settings_vbc->add_margin_child("Pick Distance:", settings_pick_distance); + clip_mode=CLIP_DISABLED; options->get_popup()->connect("item_pressed", this,"_menu_option"); diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h index 26fe8f20dc..03b2d4226e 100644 --- a/modules/gridmap/grid_map_editor_plugin.h +++ b/modules/gridmap/grid_map_editor_plugin.h @@ -78,6 +78,9 @@ class GridMapEditor : public VBoxContainer { ToolButton *mode_thumbnail; ToolButton *mode_list; HBoxContainer *spatial_editor_hb; + ConfirmationDialog *settings_dialog; + VBoxContainer *settings_vbc; + SpinBox *settings_pick_distance; struct SetItem { @@ -165,8 +168,8 @@ class GridMapEditor : public VBoxContainer { MENU_OPTION_SELECTION_MAKE_AREA, MENU_OPTION_SELECTION_MAKE_EXTERIOR_CONNECTOR, MENU_OPTION_SELECTION_CLEAR, - MENU_OPTION_REMOVE_AREA - + MENU_OPTION_REMOVE_AREA, + MENU_OPTION_GRIDMAP_SETTINGS }; diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp index 0df9fcadef..f16f7c2992 100644 --- a/tools/editor/editor_settings.cpp +++ b/tools/editor/editor_settings.cpp @@ -443,6 +443,7 @@ void EditorSettings::_load_defaults() { set("scenetree_editor/duplicate_node_name_num_separator",0); hints["scenetree_editor/duplicate_node_name_num_separator"]=PropertyInfo(Variant::INT,"scenetree_editor/duplicate_node_name_num_separator",PROPERTY_HINT_ENUM, "None,Space,Underscore,Dash"); + set("gridmap_editor/pick_distance", 5000.0); set("3d_editor/default_fov",45.0); set("3d_editor/default_z_near",0.1); -- cgit v1.2.3 From db440a2a58a9f783322ffc528fe50e832f5ae50c Mon Sep 17 00:00:00 2001 From: sheepandshepherd Date: Fri, 10 Jul 2015 21:33:44 +0200 Subject: Fix List::move_before for front and back elements --- core/list.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/list.h b/core/list.h index 6deb150ef6..018abca940 100644 --- a/core/list.h +++ b/core/list.h @@ -518,10 +518,16 @@ public: if (value->prev_ptr) { value->prev_ptr->next_ptr = value->next_ptr; - }; + } + else { + _data->first = value->next_ptr; + } if (value->next_ptr) { value->next_ptr->prev_ptr = value->prev_ptr; - }; + } + else { + _data->last = value->prev_ptr; + } value->next_ptr = where; if (!where) { -- cgit v1.2.3 From 07e76a3f2ce85c996ddddce8e4e5180c7b948490 Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Sun, 12 Jul 2015 00:52:47 +0300 Subject: Haiku: add keyboard support --- platform/haiku/SCsub | 3 +- platform/haiku/haiku_direct_window.cpp | 84 ++++++++++++++ platform/haiku/haiku_direct_window.h | 2 + platform/haiku/key_mapping_haiku.cpp | 193 +++++++++++++++++++++++++++++++++ platform/haiku/key_mapping_haiku.h | 13 +++ 5 files changed, 294 insertions(+), 1 deletion(-) create mode 100644 platform/haiku/key_mapping_haiku.cpp create mode 100644 platform/haiku/key_mapping_haiku.h diff --git a/platform/haiku/SCsub b/platform/haiku/SCsub index 18fa2e2b15..88c9b8b464 100644 --- a/platform/haiku/SCsub +++ b/platform/haiku/SCsub @@ -5,7 +5,8 @@ common_haiku = [ 'context_gl_haiku.cpp', 'haiku_application.cpp', 'haiku_direct_window.cpp', - 'haiku_gl_view.cpp' + 'haiku_gl_view.cpp', + 'key_mapping_haiku.cpp' ] env.Program( diff --git a/platform/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp index e400d70108..e7577602ca 100644 --- a/platform/haiku/haiku_direct_window.cpp +++ b/platform/haiku/haiku_direct_window.cpp @@ -1,5 +1,9 @@ +#include + #include "main/main.h" +#include "os/keyboard.h" #include "haiku_direct_window.h" +#include "key_mapping_haiku.h" HaikuDirectWindow::HaikuDirectWindow(BRect p_frame) : BDirectWindow(p_frame, "Godot", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE) @@ -79,6 +83,15 @@ void HaikuDirectWindow::DispatchMessage(BMessage* message, BHandler* handler) { HandleMouseWheelChanged(message); break; + case B_KEY_DOWN: + case B_KEY_UP: + HandleKeyboardEvent(message); + break; + + case B_MODIFIERS_CHANGED: + HandleKeyboardModifierEvent(message); + break; + case B_WINDOW_RESIZED: HandleWindowResized(message); //view->UnlockGL(); @@ -226,6 +239,77 @@ void HaikuDirectWindow::HandleMouseWheelChanged(BMessage* message) { input->parse_input_event(mouse_event); } +void HaikuDirectWindow::HandleKeyboardEvent(BMessage* message) { + message->PrintToStream(); + int32 raw_char = 0; + int32 key = 0; + int32 modifiers = 0; + + if (message->FindInt32("raw_char", &raw_char) != B_OK) { + return; + } + + if (message->FindInt32("key", &key) != B_OK) { + return; + } + + if (message->FindInt32("modifiers", &modifiers) != B_OK) { + return; + } + + InputEvent event; + event.ID = ++event_id; + event.type = InputEvent::KEY; + event.device = 0; + event.key.mod = GetKeyModifierState(modifiers); + event.key.pressed = (message->what == B_KEY_DOWN); + event.key.scancode = KeyMappingHaiku::get_keysym(raw_char, key); + event.key.echo = message->HasInt32("be:key_repeat"); + event.key.unicode = 0; + + const char* bytes = NULL; + if (message->FindString("bytes", &bytes) == B_OK) { + event.key.unicode = BUnicodeChar::FromUTF8(&bytes); + } + + //make it consistent accross platforms. + if (event.key.scancode==KEY_BACKTAB) { + event.key.scancode=KEY_TAB; + event.key.mod.shift=true; + } + + input->parse_input_event(event); +} + +void HaikuDirectWindow::HandleKeyboardModifierEvent(BMessage* message) { + message->PrintToStream(); + + int32 old_modifiers = 0; + int32 modifiers = 0; + + if (message->FindInt32("be:old_modifiers", &old_modifiers) != B_OK) { + return; + } + + if (message->FindInt32("modifiers", &modifiers) != B_OK) { + return; + } + + int32 key = old_modifiers ^ modifiers; + + InputEvent event; + event.ID = ++event_id; + event.type = InputEvent::KEY; + event.device = 0; + event.key.mod = GetKeyModifierState(modifiers); + event.key.pressed = ((modifiers & key) != 0); + event.key.scancode = KeyMappingHaiku::get_modifier_keysym(key); + event.key.echo = false; + event.key.unicode = 0; + + input->parse_input_event(event); +} + void HaikuDirectWindow::HandleWindowResized(BMessage* message) { int32 width = 0; int32 height = 0; diff --git a/platform/haiku/haiku_direct_window.h b/platform/haiku/haiku_direct_window.h index 3667eb24d1..7b1fd851fa 100644 --- a/platform/haiku/haiku_direct_window.h +++ b/platform/haiku/haiku_direct_window.h @@ -32,6 +32,8 @@ private: void HandleMouseMoved(BMessage* message); void HandleMouseWheelChanged(BMessage* message); void HandleWindowResized(BMessage* message); + void HandleKeyboardEvent(BMessage* message); + void HandleKeyboardModifierEvent(BMessage* message); inline InputModifierState GetKeyModifierState(uint32 p_state); inline int GetMouseButtonState(uint32 p_state); diff --git a/platform/haiku/key_mapping_haiku.cpp b/platform/haiku/key_mapping_haiku.cpp new file mode 100644 index 0000000000..d7bde9a727 --- /dev/null +++ b/platform/haiku/key_mapping_haiku.cpp @@ -0,0 +1,193 @@ +#include + +#include "key_mapping_haiku.h" +#include "os/keyboard.h" + +struct _HaikuTranslatePair { + unsigned int keysym; + int32 keycode; +}; + +static _HaikuTranslatePair _mod_to_keycode[] = { + { KEY_SHIFT, B_SHIFT_KEY }, + { KEY_ALT, B_COMMAND_KEY }, + { KEY_CONTROL, B_CONTROL_KEY }, + { KEY_CAPSLOCK, B_CAPS_LOCK }, + { KEY_SCROLLLOCK, B_SCROLL_LOCK }, + { KEY_NUMLOCK, B_NUM_LOCK }, + { KEY_SUPER_L, B_OPTION_KEY }, + { KEY_MENU, B_MENU_KEY }, + { KEY_SHIFT, B_LEFT_SHIFT_KEY }, + { KEY_SHIFT, B_RIGHT_SHIFT_KEY }, + { KEY_ALT, B_LEFT_COMMAND_KEY }, + { KEY_ALT, B_RIGHT_COMMAND_KEY }, + { KEY_CONTROL, B_LEFT_CONTROL_KEY }, + { KEY_CONTROL, B_RIGHT_CONTROL_KEY }, + { KEY_SUPER_L, B_LEFT_OPTION_KEY }, + { KEY_SUPER_R, B_RIGHT_OPTION_KEY }, + { KEY_UNKNOWN, 0 } +}; + +static _HaikuTranslatePair _fn_to_keycode[] = { + { KEY_F1, B_F1_KEY }, + { KEY_F2, B_F2_KEY }, + { KEY_F3, B_F3_KEY }, + { KEY_F4, B_F4_KEY }, + { KEY_F5, B_F5_KEY }, + { KEY_F6, B_F6_KEY }, + { KEY_F7, B_F7_KEY }, + { KEY_F8, B_F8_KEY }, + { KEY_F9, B_F9_KEY }, + { KEY_F10, B_F10_KEY }, + { KEY_F11, B_F11_KEY }, + { KEY_F12, B_F12_KEY }, + //{ KEY_F13, ? }, + //{ KEY_F14, ? }, + //{ KEY_F15, ? }, + //{ KEY_F16, ? }, + { KEY_PRINT, B_PRINT_KEY }, + { KEY_SCROLLLOCK, B_SCROLL_KEY }, + { KEY_PAUSE, B_PAUSE_KEY }, + { KEY_UNKNOWN, 0 } +}; + +static _HaikuTranslatePair _hb_to_keycode[] = { + { KEY_BACKSPACE, B_BACKSPACE }, + { KEY_TAB, B_TAB }, + { KEY_RETURN, B_RETURN }, + { KEY_CAPSLOCK, B_CAPS_LOCK }, + { KEY_ESCAPE, B_ESCAPE }, + { KEY_SPACE, B_SPACE }, + { KEY_PAGEUP, B_PAGE_UP }, + { KEY_PAGEDOWN, B_PAGE_DOWN }, + { KEY_END, B_END }, + { KEY_HOME, B_HOME }, + { KEY_LEFT, B_LEFT_ARROW }, + { KEY_UP, B_UP_ARROW }, + { KEY_RIGHT, B_RIGHT_ARROW }, + { KEY_DOWN, B_DOWN_ARROW }, + { KEY_PRINT, B_PRINT_KEY }, + { KEY_INSERT, B_INSERT }, + { KEY_DELETE, B_DELETE }, + // { KEY_HELP, ??? }, + + { KEY_0, (0x30) }, + { KEY_1, (0x31) }, + { KEY_2, (0x32) }, + { KEY_3, (0x33) }, + { KEY_4, (0x34) }, + { KEY_5, (0x35) }, + { KEY_6, (0x36) }, + { KEY_7, (0x37) }, + { KEY_8, (0x38) }, + { KEY_9, (0x39) }, + { KEY_A, (0x61) }, + { KEY_B, (0x62) }, + { KEY_C, (0x63) }, + { KEY_D, (0x64) }, + { KEY_E, (0x65) }, + { KEY_F, (0x66) }, + { KEY_G, (0x67) }, + { KEY_H, (0x68) }, + { KEY_I, (0x69) }, + { KEY_J, (0x6A) }, + { KEY_K, (0x6B) }, + { KEY_L, (0x6C) }, + { KEY_M, (0x6D) }, + { KEY_N, (0x6E) }, + { KEY_O, (0x6F) }, + { KEY_P, (0x70) }, + { KEY_Q, (0x71) }, + { KEY_R, (0x72) }, + { KEY_S, (0x73) }, + { KEY_T, (0x74) }, + { KEY_U, (0x75) }, + { KEY_V, (0x76) }, + { KEY_W, (0x77) }, + { KEY_X, (0x78) }, + { KEY_Y, (0x79) }, + { KEY_Z, (0x7A) }, + +/* +{ KEY_PLAY, VK_PLAY},// (0xFA) +{ KEY_STANDBY,VK_SLEEP },//(0x5F) +{ KEY_BACK,VK_BROWSER_BACK},// (0xA6) +{ KEY_FORWARD,VK_BROWSER_FORWARD},// (0xA7) +{ KEY_REFRESH,VK_BROWSER_REFRESH},// (0xA8) +{ KEY_STOP,VK_BROWSER_STOP},// (0xA9) +{ KEY_SEARCH,VK_BROWSER_SEARCH},// (0xAA) +{ KEY_FAVORITES, VK_BROWSER_FAVORITES},// (0xAB) +{ KEY_HOMEPAGE,VK_BROWSER_HOME},// (0xAC) +{ KEY_VOLUMEMUTE,VK_VOLUME_MUTE},// (0xAD) +{ KEY_VOLUMEDOWN,VK_VOLUME_DOWN},// (0xAE) +{ KEY_VOLUMEUP,VK_VOLUME_UP},// (0xAF) +{ KEY_MEDIANEXT,VK_MEDIA_NEXT_TRACK},// (0xB0) +{ KEY_MEDIAPREVIOUS,VK_MEDIA_PREV_TRACK},// (0xB1) +{ KEY_MEDIASTOP,VK_MEDIA_STOP},// (0xB2) +{ KEY_LAUNCHMAIL, VK_LAUNCH_MAIL},// (0xB4) +{ KEY_LAUNCHMEDIA,VK_LAUNCH_MEDIA_SELECT},// (0xB5) +{ KEY_LAUNCH0,VK_LAUNCH_APP1},// (0xB6) +{ KEY_LAUNCH1,VK_LAUNCH_APP2},// (0xB7) +*/ + + { KEY_SEMICOLON, 0x3B }, + { KEY_EQUAL, 0x3D }, + { KEY_COLON, 0x2C }, + { KEY_MINUS, 0x2D }, + { KEY_PERIOD, 0x2E }, + { KEY_SLASH, 0x2F }, + { KEY_KP_MULTIPLY, 0x2A }, + { KEY_KP_ADD, 0x2B }, + + { KEY_QUOTELEFT, 0x60 }, + { KEY_BRACKETLEFT, 0x5B }, + { KEY_BACKSLASH, 0x5C }, + { KEY_BRACKETRIGHT, 0x5D }, + { KEY_APOSTROPHE, 0x27 }, + + { KEY_UNKNOWN, 0 } +}; + +unsigned int KeyMappingHaiku::get_keysym(int32 raw_char, int32 key) { + if (raw_char == B_INSERT && key == 0x64) { return KEY_KP_0; } + if (raw_char == B_END && key == 0x58) { return KEY_KP_1; } + if (raw_char == B_DOWN_ARROW && key == 0x59) { return KEY_KP_2; } + if (raw_char == B_PAGE_DOWN && key == 0x5A) { return KEY_KP_3; } + if (raw_char == B_LEFT_ARROW && key == 0x48) { return KEY_KP_4; } + if (raw_char == 0x35 && key == 0x49) { return KEY_KP_5; } + if (raw_char == B_RIGHT_ARROW && key == 0x4A) { return KEY_KP_6; } + if (raw_char == B_HOME && key == 0x37) { return KEY_KP_7; } + if (raw_char == B_UP_ARROW && key == 0x38) { return KEY_KP_8; } + if (raw_char == B_PAGE_UP && key == 0x39) { return KEY_KP_9; } + if (raw_char == 0x2F && key == 0x23) { return KEY_KP_DIVIDE; } + if (raw_char == 0x2D && key == 0x25) { return KEY_KP_SUBSTRACT; } + if (raw_char == B_DELETE && key == 0x65) { return KEY_KP_PERIOD; } + + if (raw_char == 0x10) { + for(int i = 0; _fn_to_keycode[i].keysym != KEY_UNKNOWN; i++) { + if (_fn_to_keycode[i].keycode == key) { + return _fn_to_keycode[i].keysym; + } + } + + return KEY_UNKNOWN; + } + + for(int i = 0; _hb_to_keycode[i].keysym != KEY_UNKNOWN; i++) { + if (_hb_to_keycode[i].keycode == raw_char) { + return _hb_to_keycode[i].keysym; + } + } + + return KEY_UNKNOWN; +} + +unsigned int KeyMappingHaiku::get_modifier_keysym(int32 key) { + for(int i = 0; _mod_to_keycode[i].keysym != KEY_UNKNOWN; i++) { + if ((_mod_to_keycode[i].keycode & key) != 0) { + return _mod_to_keycode[i].keysym; + } + } + + return KEY_UNKNOWN; +} diff --git a/platform/haiku/key_mapping_haiku.h b/platform/haiku/key_mapping_haiku.h new file mode 100644 index 0000000000..e2864678a8 --- /dev/null +++ b/platform/haiku/key_mapping_haiku.h @@ -0,0 +1,13 @@ +#ifndef KEY_MAPPING_HAIKU_H +#define KEY_MAPPING_HAIKU_H + +class KeyMappingHaiku +{ + KeyMappingHaiku() {}; + +public: + static unsigned int get_keysym(int32 raw_char, int32 key); + static unsigned int get_modifier_keysym(int32 key); +}; + +#endif -- cgit v1.2.3 From ec11762006e80105d24f3b1075b657e58f95e2ed Mon Sep 17 00:00:00 2001 From: MrGreenTea Date: Wed, 15 Jul 2015 01:59:35 +0200 Subject: added floor() and ceil() to Vector3 --- core/math/vector3.h | 30 +++++++++++++++++++++--------- core/variant_call.cpp | 18 ++++++++---------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/core/math/vector3.h b/core/math/vector3.h index d27b611379..8a3cca8f33 100644 --- a/core/math/vector3.h +++ b/core/math/vector3.h @@ -40,11 +40,11 @@ struct Vector3 { enum Axis { AXIS_X, AXIS_Y, - AXIS_Z, + AXIS_Z, }; union { - + #ifdef USE_QUAD_VECTORS struct { @@ -52,7 +52,7 @@ struct Vector3 { real_t y; real_t z; real_t _unused; - }; + }; real_t coord[4]; #else @@ -61,18 +61,18 @@ struct Vector3 { real_t y; real_t z; }; - + real_t coord[3]; #endif }; _FORCE_INLINE_ const real_t& operator[](int p_axis) const { - + return coord[p_axis]; } _FORCE_INLINE_ real_t& operator[](int p_axis) { - + return coord[p_axis]; } @@ -84,7 +84,7 @@ struct Vector3 { _FORCE_INLINE_ real_t length() const; _FORCE_INLINE_ real_t length_squared() const; - + _FORCE_INLINE_ void normalize(); _FORCE_INLINE_ Vector3 normalized() const; _FORCE_INLINE_ Vector3 inverse() const; @@ -107,6 +107,8 @@ struct Vector3 { _FORCE_INLINE_ real_t dot(const Vector3& p_b) const; _FORCE_INLINE_ Vector3 abs() const; + _FORCE_INLINE_ Vector3 floor() const; + _FORCE_INLINE_ Vector3 ceil() const; _FORCE_INLINE_ real_t distance_to(const Vector3& p_b) const; _FORCE_INLINE_ real_t distance_squared_to(const Vector3& p_b) const; @@ -172,7 +174,17 @@ real_t Vector3::dot(const Vector3& p_b) const { Vector3 Vector3::abs() const { return Vector3( Math::abs(x), Math::abs(y), Math::abs(z) ); -} +} + +Vector3 Vector3::floor() const { + + return Vector3( Math::floor(x), Math::floor(y), Math::floor(z) ); +} + +Vector3 Vector3::ceil() const { + + return Vector3( Math::ceil(x), Math::ceil(y), Math::ceil(z) ); +} Vector3 Vector3::linear_interpolate(const Vector3& p_b,float p_t) const { @@ -301,7 +313,7 @@ bool Vector3::operator<(const Vector3& p_v) const { return y *p_list) const { if (fd.returns) ret.name="ret"; mi.return_val=ret; -#endif +#endif p_list->push_back(mi); } @@ -1336,6 +1338,8 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC1(VECTOR3,REAL,Vector3,dot,VECTOR3,"b",varray()); ADDFUNC1(VECTOR3,VECTOR3,Vector3,cross,VECTOR3,"b",varray()); ADDFUNC0(VECTOR3,VECTOR3,Vector3,abs,varray()); + ADDFUNC0(VECTOR3,VECTOR3,Vector3,floor,varray()); + ADDFUNC0(VECTOR3,VECTOR3,Vector3,ceil,varray()); ADDFUNC1(VECTOR3,REAL,Vector3,distance_to,VECTOR3,"b",varray()); ADDFUNC1(VECTOR3,REAL,Vector3,distance_squared_to,VECTOR3,"b",varray()); ADDFUNC1(VECTOR3,VECTOR3,Vector3,slide,VECTOR3,"by",varray()); @@ -1535,10 +1539,10 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC1(TRANSFORM,NIL,Transform,xform,NIL,"v",varray()); ADDFUNC1(TRANSFORM,NIL,Transform,xform_inv,NIL,"v",varray()); -#ifdef DEBUG_ENABLED +#ifdef DEBUG_ENABLED _VariantCall::type_funcs[Variant::TRANSFORM].functions["xform"].returns=true; _VariantCall::type_funcs[Variant::TRANSFORM].functions["xform_inv"].returns=true; -#endif +#endif ADDFUNC0(INPUT_EVENT,BOOL,InputEvent,is_pressed,varray()); ADDFUNC1(INPUT_EVENT,BOOL,InputEvent,is_action,STRING,"action",varray()); @@ -1635,9 +1639,3 @@ void unregister_variant_methods() { } - - - - - - -- cgit v1.2.3 From f8db8b72155ef904b9399295d3c40737e265e2ad Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Mon, 20 Jul 2015 22:45:22 +0300 Subject: Haiku: update detect.py --- platform/haiku/detect.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/platform/haiku/detect.py b/platform/haiku/detect.py index 587148838f..d219850bb4 100644 --- a/platform/haiku/detect.py +++ b/platform/haiku/detect.py @@ -17,7 +17,9 @@ def can_build(): return True def get_opts(): - return [] + return [ + ('debug_release', 'Add debug symbols to release version','no') + ] def get_flags(): return [ @@ -41,9 +43,9 @@ def configure(env): if (env["target"]=="release"): if (env["debug_release"]=="yes"): - env.Append(CCFLAGS=['-g2','-fomit-frame-pointer']) + env.Append(CCFLAGS=['-g2']) else: - env.Append(CCFLAGS=['-O2','-ffast-math','-fomit-frame-pointer']) + env.Append(CCFLAGS=['-O3','-ffast-math']) elif (env["target"]=="release_debug"): env.Append(CCFLAGS=['-O2','-ffast-math','-DDEBUG_ENABLED']) elif (env["target"]=="debug"): -- cgit v1.2.3 From f5bfd497aab7e24a6f4dc0315e9e9333504067a0 Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Sun, 26 Jul 2015 02:18:32 +0300 Subject: Haiku: add sound support --- drivers/SCsub | 1 + drivers/media_kit/SCsub | 5 + drivers/media_kit/audio_driver_media_kit.cpp | 143 +++++++++++++++++++++++++++ drivers/media_kit/audio_driver_media_kit.h | 72 ++++++++++++++ platform/haiku/detect.py | 5 +- platform/haiku/os_haiku.cpp | 4 +- platform/haiku/os_haiku.h | 6 +- 7 files changed, 230 insertions(+), 6 deletions(-) create mode 100644 drivers/media_kit/SCsub create mode 100644 drivers/media_kit/audio_driver_media_kit.cpp create mode 100644 drivers/media_kit/audio_driver_media_kit.h diff --git a/drivers/SCsub b/drivers/SCsub index 6ab0973625..2bb2d4966c 100644 --- a/drivers/SCsub +++ b/drivers/SCsub @@ -12,6 +12,7 @@ SConscript('windows/SCsub'); SConscript('gles2/SCsub'); SConscript('gl_context/SCsub'); SConscript('openssl/SCsub'); +SConscript('media_kit/SCsub'); if (env["png"]=="yes"): SConscript("png/SCsub"); diff --git a/drivers/media_kit/SCsub b/drivers/media_kit/SCsub new file mode 100644 index 0000000000..9fbb467baa --- /dev/null +++ b/drivers/media_kit/SCsub @@ -0,0 +1,5 @@ +Import('env') + +env.add_source_files(env.drivers_sources,"*.cpp") + +Export('env') diff --git a/drivers/media_kit/audio_driver_media_kit.cpp b/drivers/media_kit/audio_driver_media_kit.cpp new file mode 100644 index 0000000000..3fabe4f96f --- /dev/null +++ b/drivers/media_kit/audio_driver_media_kit.cpp @@ -0,0 +1,143 @@ +/*************************************************************************/ +/* audio_driver_media_kit.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "audio_driver_media_kit.h" + +#ifdef MEDIA_KIT_ENABLED + +#include "globals.h" + +int32_t* AudioDriverMediaKit::samples_in = NULL; + +Error AudioDriverMediaKit::init() { + active = false; + + mix_rate = 44100; + output_format = OUTPUT_STEREO; + channels = 2; + + int latency = GLOBAL_DEF("audio/output_latency", 25); + buffer_size = nearest_power_of_2(latency * mix_rate / 1000); + samples_in = memnew_arr(int32_t, buffer_size * channels); + + media_raw_audio_format format; + format = media_raw_audio_format::wildcard; + format.frame_rate = mix_rate; + format.channel_count = channels; + format.format = media_raw_audio_format::B_AUDIO_INT; + format.byte_order = B_MEDIA_LITTLE_ENDIAN; + format.buffer_size = buffer_size * sizeof(int32_t) * channels; + + player = new BSoundPlayer( + &format, + "godot_sound_server", + AudioDriverMediaKit::PlayBuffer, + NULL, + this + ); + + if (player->InitCheck() != B_OK) { + fprintf(stderr, "MediaKit ERR: can not create a BSoundPlayer instance\n"); + ERR_FAIL_COND_V(player == NULL, ERR_CANT_OPEN); + } + + mutex = Mutex::create(); + player->Start(); + + return OK; +} + +void AudioDriverMediaKit::PlayBuffer(void* cookie, void* buffer, size_t size, const media_raw_audio_format& format) { + AudioDriverMediaKit* ad = (AudioDriverMediaKit*) cookie; + int32_t* buf = (int32_t*) buffer; + + if (!ad->active) { + for (unsigned int i = 0; i < ad->buffer_size * ad->channels; i++) { + AudioDriverMediaKit::samples_in[i] = 0; + } + } else { + ad->lock(); + ad->audio_server_process(ad->buffer_size, AudioDriverMediaKit::samples_in); + ad->unlock(); + } + + for (unsigned int i = 0; i < ad->buffer_size * ad->channels; i++) { + buf[i] = AudioDriverMediaKit::samples_in[i]; + } +} + +void AudioDriverMediaKit::start() { + active = true; +} + +int AudioDriverMediaKit::get_mix_rate() const { + return mix_rate; +} + +AudioDriverSW::OutputFormat AudioDriverMediaKit::get_output_format() const { + return output_format; +} + +void AudioDriverMediaKit::lock() { + if (!mutex) + return; + + mutex->lock(); +} + +void AudioDriverMediaKit::unlock() { + if (!mutex) + return; + + mutex->unlock(); +} + +void AudioDriverMediaKit::finish() { + if (player) + delete player; + + if (samples_in) { + memdelete_arr(samples_in); + }; + + if (mutex) { + memdelete(mutex); + mutex = NULL; + } +} + +AudioDriverMediaKit::AudioDriverMediaKit() { + mutex = NULL; + player = NULL; +} + +AudioDriverMediaKit::~AudioDriverMediaKit() { + +} + +#endif diff --git a/drivers/media_kit/audio_driver_media_kit.h b/drivers/media_kit/audio_driver_media_kit.h new file mode 100644 index 0000000000..a23ec447f1 --- /dev/null +++ b/drivers/media_kit/audio_driver_media_kit.h @@ -0,0 +1,72 @@ +/*************************************************************************/ +/* audio_driver_media_kit.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "servers/audio/audio_server_sw.h" + +#ifdef MEDIA_KIT_ENABLED + +#include "core/os/thread.h" +#include "core/os/mutex.h" + +#include // needed for image_id +#include + +class AudioDriverMediaKit : public AudioDriverSW { + Mutex* mutex; + + BSoundPlayer* player; + static int32_t* samples_in; + + static void PlayBuffer(void* cookie, void* buffer, size_t size, const media_raw_audio_format& format); + + unsigned int mix_rate; + OutputFormat output_format; + unsigned int buffer_size; + int channels; + + bool active; + +public: + + const char* get_name() const { + return "MediaKit"; + }; + + virtual Error init(); + virtual void start(); + virtual int get_mix_rate() const; + virtual OutputFormat get_output_format() const; + virtual void lock(); + virtual void unlock(); + virtual void finish(); + + AudioDriverMediaKit(); + ~AudioDriverMediaKit(); +}; + +#endif diff --git a/platform/haiku/detect.py b/platform/haiku/detect.py index d219850bb4..f4198e50cd 100644 --- a/platform/haiku/detect.py +++ b/platform/haiku/detect.py @@ -52,10 +52,9 @@ def configure(env): env.Append(CCFLAGS=['-g2', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) #env.Append(CCFLAGS=['-DFREETYPE_ENABLED']) - env.Append(CPPFLAGS = ['-DGLEW_ENABLED']) - env.Append(CPPFLAGS = ['-DOPENGL_ENABLED']) + env.Append(CPPFLAGS = ['-DGLEW_ENABLED', '-DOPENGL_ENABLED', '-DMEDIA_KIT_ENABLED']) env.Append(CPPFLAGS = ['-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DGLES_OVER_GL']) - env.Append(LIBS = ['be', 'game', 'GL', 'GLEW', 'z', 'network', 'bnetapi']) + env.Append(LIBS = ['be', 'game', 'media', 'network', 'bnetapi', 'z', 'GL', 'GLEW']) import methods env.Append(BUILDERS = {'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl')}) diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp index 2c29260281..1edb23d504 100644 --- a/platform/haiku/os_haiku.cpp +++ b/platform/haiku/os_haiku.cpp @@ -11,7 +11,9 @@ OS_Haiku::OS_Haiku() { - AudioDriverManagerSW::add_driver(&driver_dummy); +#ifdef MEDIA_KIT_ENABLED + AudioDriverManagerSW::add_driver(&driver_media_kit); +#endif }; void OS_Haiku::run() { diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h index a7a8bee522..f88b8182f8 100644 --- a/platform/haiku/os_haiku.h +++ b/platform/haiku/os_haiku.h @@ -11,7 +11,7 @@ #include "servers/audio/sample_manager_sw.h" #include "servers/spatial_sound/spatial_sound_server_sw.h" #include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" -#include "servers/audio/audio_driver_dummy.h" +#include "drivers/media_kit/audio_driver_media_kit.h" #include "context_gl_haiku.h" #include "haiku_application.h" @@ -34,7 +34,9 @@ private: SpatialSoundServerSW* spatial_sound_server; SpatialSound2DServerSW* spatial_sound_2d_server; - AudioDriverDummy driver_dummy; // TODO: use a real driver +#ifdef MEDIA_KIT_ENABLED + AudioDriverMediaKit driver_media_kit; +#endif #if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED) ContextGL_Haiku* context_gl; -- cgit v1.2.3 From 7a516d13e259e0d26d09521188443bf1eab893df Mon Sep 17 00:00:00 2001 From: Federico Pacheco Date: Tue, 4 Aug 2015 01:44:38 -0300 Subject: ParallaxBackground: added option to ignore camera zoom --- scene/2d/parallax_background.cpp | 20 +++++++++++++++++++- scene/2d/parallax_background.h | 4 ++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/scene/2d/parallax_background.cpp b/scene/2d/parallax_background.cpp index 109546bde3..8bb4eb55ba 100644 --- a/scene/2d/parallax_background.cpp +++ b/scene/2d/parallax_background.cpp @@ -110,7 +110,10 @@ void ParallaxBackground::_update_scroll() { if (!l) continue; - l->set_base_offset_and_scale(ofs,scale); + if (ignore_camera_zoom) + l->set_base_offset_and_scale(ofs, 1.0); + else + l->set_base_offset_and_scale(ofs, scale); } } @@ -165,6 +168,18 @@ Point2 ParallaxBackground::get_limit_end() const { return limit_end; } +void ParallaxBackground::set_ignore_camera_zoom(bool ignore){ + + ignore_camera_zoom = ignore; + +} + +bool ParallaxBackground::is_ignore_camera_zoom(){ + + return ignore_camera_zoom; + +} + void ParallaxBackground::_bind_methods() { ObjectTypeDB::bind_method(_MD("_camera_moved"),&ParallaxBackground::_camera_moved); @@ -178,6 +193,8 @@ void ParallaxBackground::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_limit_begin"),&ParallaxBackground::get_limit_begin); ObjectTypeDB::bind_method(_MD("set_limit_end","ofs"),&ParallaxBackground::set_limit_end); ObjectTypeDB::bind_method(_MD("get_limit_end"),&ParallaxBackground::get_limit_end); + ObjectTypeDB::bind_method(_MD("set_ignore_camera_zoom"), &ParallaxBackground::set_ignore_camera_zoom); + ObjectTypeDB::bind_method(_MD("is_ignore_camera_zoom"), &ParallaxBackground::is_ignore_camera_zoom); ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/offset"),_SCS("set_scroll_offset"),_SCS("get_scroll_offset")); @@ -185,6 +202,7 @@ void ParallaxBackground::_bind_methods() { ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/base_scale"),_SCS("set_scroll_base_scale"),_SCS("get_scroll_base_scale")); ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/limit_begin"),_SCS("set_limit_begin"),_SCS("get_limit_begin")); ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/limit_end"),_SCS("set_limit_end"),_SCS("get_limit_end")); + ADD_PROPERTY( PropertyInfo(Variant::BOOL, "scroll/ignore_camera_zoom"), _SCS("set_ignore_camera_zoom"), _SCS("is_ignore_camera_zoom")); } diff --git a/scene/2d/parallax_background.h b/scene/2d/parallax_background.h index 363236b2ad..8dede07a16 100644 --- a/scene/2d/parallax_background.h +++ b/scene/2d/parallax_background.h @@ -44,6 +44,7 @@ class ParallaxBackground : public CanvasLayer { String group_name; Point2 limit_begin; Point2 limit_end; + bool ignore_camera_zoom; void _update_scroll(); protected: @@ -72,6 +73,9 @@ public: void set_limit_end(const Point2& p_ofs); Point2 get_limit_end() const; + void set_ignore_camera_zoom(bool ignore); + bool is_ignore_camera_zoom(); + ParallaxBackground(); }; -- cgit v1.2.3 From 80943d77a4318822f888ea81e87d77c53d6047d7 Mon Sep 17 00:00:00 2001 From: volzhs Date: Tue, 11 Aug 2015 22:39:59 +0900 Subject: prevent to change tool mode when control or shift key is pressed --- tools/editor/plugins/canvas_item_editor_plugin.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp index f2738f0a62..9469b79ea0 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.cpp +++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp @@ -144,6 +144,9 @@ void CanvasItemEditor::_unhandled_key_input(const InputEvent& p_ev) { if (!is_visible()) return; + if (p_ev.key.mod.control || p_ev.key.mod.shift) + // prevent to change tool mode when control or shift key is pressed + return; if (p_ev.key.pressed && !p_ev.key.echo && p_ev.key.scancode==KEY_Q) _tool_select(TOOL_SELECT); if (p_ev.key.pressed && !p_ev.key.echo && p_ev.key.scancode==KEY_W) -- cgit v1.2.3 From edabbcd064372ff036e01735f6b236f472d80c93 Mon Sep 17 00:00:00 2001 From: volzhs Date: Tue, 11 Aug 2015 22:52:43 +0900 Subject: remove shift key check because shift + v in use with tool mode --- tools/editor/plugins/canvas_item_editor_plugin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp index 9469b79ea0..e2f39b85ab 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.cpp +++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp @@ -144,8 +144,8 @@ void CanvasItemEditor::_unhandled_key_input(const InputEvent& p_ev) { if (!is_visible()) return; - if (p_ev.key.mod.control || p_ev.key.mod.shift) - // prevent to change tool mode when control or shift key is pressed + if (p_ev.key.mod.control) + // prevent to change tool mode when control key is pressed return; if (p_ev.key.pressed && !p_ev.key.echo && p_ev.key.scancode==KEY_Q) _tool_select(TOOL_SELECT); -- cgit v1.2.3 From f48ce8901ab4fb74dd1a2de15b75895d0cb08fd8 Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Wed, 12 Aug 2015 21:40:45 +0300 Subject: Haiku: remove unneeded code --- platform/haiku/haiku_direct_window.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/platform/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp index e7577602ca..2097ace497 100644 --- a/platform/haiku/haiku_direct_window.cpp +++ b/platform/haiku/haiku_direct_window.cpp @@ -94,13 +94,9 @@ void HaikuDirectWindow::DispatchMessage(BMessage* message, BHandler* handler) { case B_WINDOW_RESIZED: HandleWindowResized(message); - //view->UnlockGL(); - //BDirectWindow::DispatchMessage(message, handler); - //view->LockGL(); break; case LOCKGL_MSG: - ERR_PRINT("LOCKGL"); view->LockGL(); break; -- cgit v1.2.3 From ced44b45d3590e6c2149fd83792dbf702321aff5 Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Wed, 12 Aug 2015 22:14:40 +0300 Subject: Haiku: remove unneeded code --- platform/haiku/detect.py | 2 +- platform/haiku/haiku_application.cpp | 2 +- platform/haiku/haiku_application.h | 2 -- platform/haiku/haiku_direct_window.cpp | 7 ------- platform/haiku/haiku_gl_view.cpp | 15 +-------------- platform/haiku/haiku_gl_view.h | 2 -- 6 files changed, 3 insertions(+), 27 deletions(-) diff --git a/platform/haiku/detect.py b/platform/haiku/detect.py index f4198e50cd..19fe2f79fb 100644 --- a/platform/haiku/detect.py +++ b/platform/haiku/detect.py @@ -27,7 +27,7 @@ def get_flags(): ] def configure(env): - is64=sys.maxsize > 2**32 + is64 = sys.maxsize > 2**32 if (env["bits"]=="default"): if (is64): diff --git a/platform/haiku/haiku_application.cpp b/platform/haiku/haiku_application.cpp index 56024f605d..ea20d73729 100644 --- a/platform/haiku/haiku_application.cpp +++ b/platform/haiku/haiku_application.cpp @@ -1,7 +1,7 @@ #include "haiku_application.h" HaikuApplication::HaikuApplication() - : BApplication("application/x-vnd.Haiku-GLDirectMode") + : BApplication("application/x-vnd.Godot") { } diff --git a/platform/haiku/haiku_application.h b/platform/haiku/haiku_application.h index 995a917d62..a64b01c94d 100644 --- a/platform/haiku/haiku_application.h +++ b/platform/haiku/haiku_application.h @@ -8,8 +8,6 @@ class HaikuApplication : public BApplication { public: HaikuApplication(); -//private: -// HaikuDirectWindow* window; }; #endif diff --git a/platform/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp index 2097ace497..3914ee272a 100644 --- a/platform/haiku/haiku_direct_window.cpp +++ b/platform/haiku/haiku_direct_window.cpp @@ -55,8 +55,6 @@ void HaikuDirectWindow::DirectConnected(direct_buffer_info* info) { void HaikuDirectWindow::MessageReceived(BMessage* message) { switch (message->what) { case REDRAW_MSG: - Sync(); - if (Main::iteration() == true) { view->EnableDirectMode(false); Quit(); @@ -110,8 +108,6 @@ void HaikuDirectWindow::DispatchMessage(BMessage* message, BHandler* handler) { } void HaikuDirectWindow::HandleMouseButton(BMessage* message) { - message->PrintToStream(); - BPoint where; if (message->FindPoint("where", &where) != B_OK) { return; @@ -236,7 +232,6 @@ void HaikuDirectWindow::HandleMouseWheelChanged(BMessage* message) { } void HaikuDirectWindow::HandleKeyboardEvent(BMessage* message) { - message->PrintToStream(); int32 raw_char = 0; int32 key = 0; int32 modifiers = 0; @@ -278,8 +273,6 @@ void HaikuDirectWindow::HandleKeyboardEvent(BMessage* message) { } void HaikuDirectWindow::HandleKeyboardModifierEvent(BMessage* message) { - message->PrintToStream(); - int32 old_modifiers = 0; int32 modifiers = 0; diff --git a/platform/haiku/haiku_gl_view.cpp b/platform/haiku/haiku_gl_view.cpp index 8adab96a87..481d6098a7 100644 --- a/platform/haiku/haiku_gl_view.cpp +++ b/platform/haiku/haiku_gl_view.cpp @@ -2,7 +2,7 @@ #include "haiku_gl_view.h" HaikuGLView::HaikuGLView(BRect frame, uint32 type) - : BGLView(frame, "SampleGLView", B_FOLLOW_ALL_SIDES, 0, type) + : BGLView(frame, "GodotGLView", B_FOLLOW_ALL_SIDES, 0, type) { } @@ -16,16 +16,3 @@ void HaikuGLView::AttachedToWindow(void) { void HaikuGLView::Draw(BRect updateRect) { Main::force_redraw(); } - -void HaikuGLView::MessageReceived(BMessage* msg) -{ - // TODO: remove if not needed - switch (msg->what) { - default: - BGLView::MessageReceived(msg); - } -} - -void HaikuGLView::MouseMoved (BPoint where, uint32 code, const BMessage *dragMessage) { - ERR_PRINT("MouseMoved()"); -} diff --git a/platform/haiku/haiku_gl_view.h b/platform/haiku/haiku_gl_view.h index 78ebb513a8..f44b6d4325 100644 --- a/platform/haiku/haiku_gl_view.h +++ b/platform/haiku/haiku_gl_view.h @@ -9,8 +9,6 @@ class HaikuGLView : public BGLView public: HaikuGLView(BRect frame, uint32 type); virtual void AttachedToWindow(void); - virtual void MessageReceived(BMessage* msg); - virtual void MouseMoved (BPoint where, uint32 code, const BMessage *dragMessage); virtual void Draw(BRect updateRect); }; -- cgit v1.2.3 From cff2509ecd06967c0d214dc0cf3d31c392091c99 Mon Sep 17 00:00:00 2001 From: Alexander Holland Date: Wed, 12 Aug 2015 22:24:21 +0200 Subject: close all parent PopupMenus fix --- scene/gui/popup_menu.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index e706053592..275965b372 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -738,10 +738,18 @@ int PopupMenu::find_item_by_accelerator(uint32_t p_accel) const { void PopupMenu::activate_item(int p_item) { - ERR_FAIL_INDEX(p_item,items.size()); ERR_FAIL_COND(items[p_item].separator); emit_signal("item_pressed",items[p_item].ID); + + //hide all parent PopupMenue's + Node *next = get_parent(); + PopupMenu *pop = next->cast_to(); + while (pop) { + pop->hide(); + next = next->get_parent(); + pop = next->cast_to(); + } hide(); } -- cgit v1.2.3 From f6eff87793a3200e728bcc4dc33dc9c612d73036 Mon Sep 17 00:00:00 2001 From: Alexander Holland Date: Wed, 12 Aug 2015 22:35:37 +0200 Subject: update scene tabs on save - fix --- tools/editor/editor_node.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index b0a2c568de..f51c4e8214 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -918,6 +918,7 @@ void EditorNode::_save_scene(String p_file) { //EditorFileSystem::get_singleton()->update_file(p_file,sdata->get_type()); set_current_version(editor_data.get_undo_redo().get_version()); _update_title(); + _update_scene_tabs(); } else { _dialog_display_file_error(p_file,err); @@ -1323,7 +1324,6 @@ void EditorNode::_dialog_action(String p_file) { default: { //save scene? - if (file->get_mode()==FileDialog::MODE_SAVE_FILE) { //_save_scene(p_file); -- cgit v1.2.3 From 69710055f0af99838d669b2e3fa3f1ae8bf6683d Mon Sep 17 00:00:00 2001 From: Mavhod Date: Thu, 13 Aug 2015 14:09:21 +0700 Subject: get_date on Linux tm_mon is 0-11 --- drivers/unix/os_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 314e13cee4..ba151b0f44 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -242,7 +242,7 @@ OS::Date OS_Unix::get_date(bool utc) const { lt=localtime(&t); Date ret; ret.year=1900+lt->tm_year; - ret.month=(Month)lt->tm_mon; + ret.month=(Month)lt->tm_mon + 1; ret.day=lt->tm_mday; ret.weekday=(Weekday)lt->tm_wday; ret.dst=lt->tm_isdst; -- cgit v1.2.3 From 3942117bbf1b669fb81628bb401d16ad83f1f2bb Mon Sep 17 00:00:00 2001 From: Mavhod Date: Thu, 13 Aug 2015 18:56:13 +0700 Subject: add () Sorry, firt time I put it but had no compiled for check. --- drivers/unix/os_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index ba151b0f44..975affbb82 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -242,7 +242,7 @@ OS::Date OS_Unix::get_date(bool utc) const { lt=localtime(&t); Date ret; ret.year=1900+lt->tm_year; - ret.month=(Month)lt->tm_mon + 1; + ret.month=(Month)(lt->tm_mon + 1); ret.day=lt->tm_mday; ret.weekday=(Weekday)lt->tm_wday; ret.dst=lt->tm_isdst; -- cgit v1.2.3 From b038a2c3c21b7be4cc1db0aca6c84ddaf57132cf Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Thu, 13 Aug 2015 22:36:43 +0300 Subject: Haiku: update logo.png --- platform/haiku/logo.png | Bin 2055 -> 1361 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/platform/haiku/logo.png b/platform/haiku/logo.png index c40214d6de..42d7728da8 100644 Binary files a/platform/haiku/logo.png and b/platform/haiku/logo.png differ -- cgit v1.2.3 From 2a757a6ad4ef4e7767b7d3ef7e177ec6613ef6d1 Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Fri, 14 Aug 2015 22:52:28 +0300 Subject: Haiku: move the audio driver to platform/haiku --- drivers/SCsub | 1 - drivers/media_kit/SCsub | 5 - drivers/media_kit/audio_driver_media_kit.cpp | 143 --------------------------- drivers/media_kit/audio_driver_media_kit.h | 72 -------------- platform/haiku/SCsub | 3 +- platform/haiku/audio_driver_media_kit.cpp | 143 +++++++++++++++++++++++++++ platform/haiku/audio_driver_media_kit.h | 72 ++++++++++++++ platform/haiku/os_haiku.h | 2 +- 8 files changed, 218 insertions(+), 223 deletions(-) delete mode 100644 drivers/media_kit/SCsub delete mode 100644 drivers/media_kit/audio_driver_media_kit.cpp delete mode 100644 drivers/media_kit/audio_driver_media_kit.h create mode 100644 platform/haiku/audio_driver_media_kit.cpp create mode 100644 platform/haiku/audio_driver_media_kit.h diff --git a/drivers/SCsub b/drivers/SCsub index bed1f22a64..3028139f50 100644 --- a/drivers/SCsub +++ b/drivers/SCsub @@ -12,7 +12,6 @@ SConscript('windows/SCsub'); SConscript('gles2/SCsub'); SConscript('gl_context/SCsub'); SConscript('openssl/SCsub'); -SConscript('media_kit/SCsub'); if (env["png"]=="yes"): SConscript("png/SCsub"); diff --git a/drivers/media_kit/SCsub b/drivers/media_kit/SCsub deleted file mode 100644 index 9fbb467baa..0000000000 --- a/drivers/media_kit/SCsub +++ /dev/null @@ -1,5 +0,0 @@ -Import('env') - -env.add_source_files(env.drivers_sources,"*.cpp") - -Export('env') diff --git a/drivers/media_kit/audio_driver_media_kit.cpp b/drivers/media_kit/audio_driver_media_kit.cpp deleted file mode 100644 index 3fabe4f96f..0000000000 --- a/drivers/media_kit/audio_driver_media_kit.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/*************************************************************************/ -/* audio_driver_media_kit.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#include "audio_driver_media_kit.h" - -#ifdef MEDIA_KIT_ENABLED - -#include "globals.h" - -int32_t* AudioDriverMediaKit::samples_in = NULL; - -Error AudioDriverMediaKit::init() { - active = false; - - mix_rate = 44100; - output_format = OUTPUT_STEREO; - channels = 2; - - int latency = GLOBAL_DEF("audio/output_latency", 25); - buffer_size = nearest_power_of_2(latency * mix_rate / 1000); - samples_in = memnew_arr(int32_t, buffer_size * channels); - - media_raw_audio_format format; - format = media_raw_audio_format::wildcard; - format.frame_rate = mix_rate; - format.channel_count = channels; - format.format = media_raw_audio_format::B_AUDIO_INT; - format.byte_order = B_MEDIA_LITTLE_ENDIAN; - format.buffer_size = buffer_size * sizeof(int32_t) * channels; - - player = new BSoundPlayer( - &format, - "godot_sound_server", - AudioDriverMediaKit::PlayBuffer, - NULL, - this - ); - - if (player->InitCheck() != B_OK) { - fprintf(stderr, "MediaKit ERR: can not create a BSoundPlayer instance\n"); - ERR_FAIL_COND_V(player == NULL, ERR_CANT_OPEN); - } - - mutex = Mutex::create(); - player->Start(); - - return OK; -} - -void AudioDriverMediaKit::PlayBuffer(void* cookie, void* buffer, size_t size, const media_raw_audio_format& format) { - AudioDriverMediaKit* ad = (AudioDriverMediaKit*) cookie; - int32_t* buf = (int32_t*) buffer; - - if (!ad->active) { - for (unsigned int i = 0; i < ad->buffer_size * ad->channels; i++) { - AudioDriverMediaKit::samples_in[i] = 0; - } - } else { - ad->lock(); - ad->audio_server_process(ad->buffer_size, AudioDriverMediaKit::samples_in); - ad->unlock(); - } - - for (unsigned int i = 0; i < ad->buffer_size * ad->channels; i++) { - buf[i] = AudioDriverMediaKit::samples_in[i]; - } -} - -void AudioDriverMediaKit::start() { - active = true; -} - -int AudioDriverMediaKit::get_mix_rate() const { - return mix_rate; -} - -AudioDriverSW::OutputFormat AudioDriverMediaKit::get_output_format() const { - return output_format; -} - -void AudioDriverMediaKit::lock() { - if (!mutex) - return; - - mutex->lock(); -} - -void AudioDriverMediaKit::unlock() { - if (!mutex) - return; - - mutex->unlock(); -} - -void AudioDriverMediaKit::finish() { - if (player) - delete player; - - if (samples_in) { - memdelete_arr(samples_in); - }; - - if (mutex) { - memdelete(mutex); - mutex = NULL; - } -} - -AudioDriverMediaKit::AudioDriverMediaKit() { - mutex = NULL; - player = NULL; -} - -AudioDriverMediaKit::~AudioDriverMediaKit() { - -} - -#endif diff --git a/drivers/media_kit/audio_driver_media_kit.h b/drivers/media_kit/audio_driver_media_kit.h deleted file mode 100644 index a23ec447f1..0000000000 --- a/drivers/media_kit/audio_driver_media_kit.h +++ /dev/null @@ -1,72 +0,0 @@ -/*************************************************************************/ -/* audio_driver_media_kit.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#include "servers/audio/audio_server_sw.h" - -#ifdef MEDIA_KIT_ENABLED - -#include "core/os/thread.h" -#include "core/os/mutex.h" - -#include // needed for image_id -#include - -class AudioDriverMediaKit : public AudioDriverSW { - Mutex* mutex; - - BSoundPlayer* player; - static int32_t* samples_in; - - static void PlayBuffer(void* cookie, void* buffer, size_t size, const media_raw_audio_format& format); - - unsigned int mix_rate; - OutputFormat output_format; - unsigned int buffer_size; - int channels; - - bool active; - -public: - - const char* get_name() const { - return "MediaKit"; - }; - - virtual Error init(); - virtual void start(); - virtual int get_mix_rate() const; - virtual OutputFormat get_output_format() const; - virtual void lock(); - virtual void unlock(); - virtual void finish(); - - AudioDriverMediaKit(); - ~AudioDriverMediaKit(); -}; - -#endif diff --git a/platform/haiku/SCsub b/platform/haiku/SCsub index 88c9b8b464..859095fa5a 100644 --- a/platform/haiku/SCsub +++ b/platform/haiku/SCsub @@ -6,7 +6,8 @@ common_haiku = [ 'haiku_application.cpp', 'haiku_direct_window.cpp', 'haiku_gl_view.cpp', - 'key_mapping_haiku.cpp' + 'key_mapping_haiku.cpp', + 'audio_driver_media_kit.cpp' ] env.Program( diff --git a/platform/haiku/audio_driver_media_kit.cpp b/platform/haiku/audio_driver_media_kit.cpp new file mode 100644 index 0000000000..3fabe4f96f --- /dev/null +++ b/platform/haiku/audio_driver_media_kit.cpp @@ -0,0 +1,143 @@ +/*************************************************************************/ +/* audio_driver_media_kit.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "audio_driver_media_kit.h" + +#ifdef MEDIA_KIT_ENABLED + +#include "globals.h" + +int32_t* AudioDriverMediaKit::samples_in = NULL; + +Error AudioDriverMediaKit::init() { + active = false; + + mix_rate = 44100; + output_format = OUTPUT_STEREO; + channels = 2; + + int latency = GLOBAL_DEF("audio/output_latency", 25); + buffer_size = nearest_power_of_2(latency * mix_rate / 1000); + samples_in = memnew_arr(int32_t, buffer_size * channels); + + media_raw_audio_format format; + format = media_raw_audio_format::wildcard; + format.frame_rate = mix_rate; + format.channel_count = channels; + format.format = media_raw_audio_format::B_AUDIO_INT; + format.byte_order = B_MEDIA_LITTLE_ENDIAN; + format.buffer_size = buffer_size * sizeof(int32_t) * channels; + + player = new BSoundPlayer( + &format, + "godot_sound_server", + AudioDriverMediaKit::PlayBuffer, + NULL, + this + ); + + if (player->InitCheck() != B_OK) { + fprintf(stderr, "MediaKit ERR: can not create a BSoundPlayer instance\n"); + ERR_FAIL_COND_V(player == NULL, ERR_CANT_OPEN); + } + + mutex = Mutex::create(); + player->Start(); + + return OK; +} + +void AudioDriverMediaKit::PlayBuffer(void* cookie, void* buffer, size_t size, const media_raw_audio_format& format) { + AudioDriverMediaKit* ad = (AudioDriverMediaKit*) cookie; + int32_t* buf = (int32_t*) buffer; + + if (!ad->active) { + for (unsigned int i = 0; i < ad->buffer_size * ad->channels; i++) { + AudioDriverMediaKit::samples_in[i] = 0; + } + } else { + ad->lock(); + ad->audio_server_process(ad->buffer_size, AudioDriverMediaKit::samples_in); + ad->unlock(); + } + + for (unsigned int i = 0; i < ad->buffer_size * ad->channels; i++) { + buf[i] = AudioDriverMediaKit::samples_in[i]; + } +} + +void AudioDriverMediaKit::start() { + active = true; +} + +int AudioDriverMediaKit::get_mix_rate() const { + return mix_rate; +} + +AudioDriverSW::OutputFormat AudioDriverMediaKit::get_output_format() const { + return output_format; +} + +void AudioDriverMediaKit::lock() { + if (!mutex) + return; + + mutex->lock(); +} + +void AudioDriverMediaKit::unlock() { + if (!mutex) + return; + + mutex->unlock(); +} + +void AudioDriverMediaKit::finish() { + if (player) + delete player; + + if (samples_in) { + memdelete_arr(samples_in); + }; + + if (mutex) { + memdelete(mutex); + mutex = NULL; + } +} + +AudioDriverMediaKit::AudioDriverMediaKit() { + mutex = NULL; + player = NULL; +} + +AudioDriverMediaKit::~AudioDriverMediaKit() { + +} + +#endif diff --git a/platform/haiku/audio_driver_media_kit.h b/platform/haiku/audio_driver_media_kit.h new file mode 100644 index 0000000000..a23ec447f1 --- /dev/null +++ b/platform/haiku/audio_driver_media_kit.h @@ -0,0 +1,72 @@ +/*************************************************************************/ +/* audio_driver_media_kit.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "servers/audio/audio_server_sw.h" + +#ifdef MEDIA_KIT_ENABLED + +#include "core/os/thread.h" +#include "core/os/mutex.h" + +#include // needed for image_id +#include + +class AudioDriverMediaKit : public AudioDriverSW { + Mutex* mutex; + + BSoundPlayer* player; + static int32_t* samples_in; + + static void PlayBuffer(void* cookie, void* buffer, size_t size, const media_raw_audio_format& format); + + unsigned int mix_rate; + OutputFormat output_format; + unsigned int buffer_size; + int channels; + + bool active; + +public: + + const char* get_name() const { + return "MediaKit"; + }; + + virtual Error init(); + virtual void start(); + virtual int get_mix_rate() const; + virtual OutputFormat get_output_format() const; + virtual void lock(); + virtual void unlock(); + virtual void finish(); + + AudioDriverMediaKit(); + ~AudioDriverMediaKit(); +}; + +#endif diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h index f88b8182f8..57b72df3cf 100644 --- a/platform/haiku/os_haiku.h +++ b/platform/haiku/os_haiku.h @@ -11,8 +11,8 @@ #include "servers/audio/sample_manager_sw.h" #include "servers/spatial_sound/spatial_sound_server_sw.h" #include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" -#include "drivers/media_kit/audio_driver_media_kit.h" +#include "audio_driver_media_kit.h" #include "context_gl_haiku.h" #include "haiku_application.h" #include "haiku_direct_window.h" -- cgit v1.2.3 From 17fbd2067385aa3bcbfd676192cb57a9735596cf Mon Sep 17 00:00:00 2001 From: Julian Murgia - StraToN Date: Tue, 18 Aug 2015 20:27:01 +0200 Subject: Added close button to tab. Added 4 display policies for this close button (show always, show never, show active tab only, show hover). Set the scene tabs in editor to follow the hover policy. --- scene/gui/tabs.cpp | 250 +++++++++++++++++++++++++++++++++++++++++-- scene/gui/tabs.h | 20 ++++ tools/editor/editor_node.cpp | 15 +++ tools/editor/editor_node.h | 1 + 4 files changed, 280 insertions(+), 6 deletions(-) diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp index a849d3ae72..6d84f028b3 100644 --- a/scene/gui/tabs.cpp +++ b/scene/gui/tabs.cpp @@ -64,6 +64,15 @@ Size2 Tabs::get_minimum_size() const { ms.width+=bms.width; ms.height=MAX(bms.height+tab_bg->get_minimum_size().height,ms.height); } + + if (tabs[i].close_button.is_valid()) { + Ref cb=tabs[i].close_button; + Size2 bms = cb->get_size()+get_stylebox("button")->get_minimum_size(); + bms.width+=get_constant("hseparation"); + + ms.width+=bms.width; + ms.height=MAX(bms.height+tab_bg->get_minimum_size().height,ms.height); + } } return ms; @@ -77,22 +86,48 @@ void Tabs::_input_event(const InputEvent& p_event) { Point2 pos( p_event.mouse_motion.x, p_event.mouse_motion.y ); - int hover=-1; + int hover_buttons=-1; + hover=-1; for(int i=0;i=tabs[i].ofs_cache && pos.x=tabs[i].ofs_cache && pos.xget_string_size(s).width;; + int slen=font->get_string_size(s).width; lsize+=slen; Ref icon; @@ -211,6 +268,56 @@ void Tabs::_notification(int p_what) { } + // Close button + switch (cb_displaypolicy) { + case SHOW_ALWAYS: { + if (tabs[i].close_button.is_valid()) { + Ref style = get_stylebox("button"); + Ref rb=tabs[i].close_button; + + lsize+=get_constant("hseparation"); + lsize+=style->get_margin(MARGIN_LEFT); + lsize+=rb->get_width(); + lsize+=style->get_margin(MARGIN_RIGHT); + + } + } break; + case SHOW_ACTIVE_ONLY: { + if (i==current) { + if (tabs[i].close_button.is_valid()) { + Ref style = get_stylebox("button"); + Ref rb=tabs[i].close_button; + + lsize+=get_constant("hseparation"); + lsize+=style->get_margin(MARGIN_LEFT); + lsize+=rb->get_width(); + lsize+=style->get_margin(MARGIN_RIGHT); + + } + } + } break; + case SHOW_HOVER: { + if (i==current || i==hover) { + if (tabs[i].close_button.is_valid()) { + Ref style = get_stylebox("button"); + Ref rb=tabs[i].close_button; + + lsize+=get_constant("hseparation"); + lsize+=style->get_margin(MARGIN_LEFT); + lsize+=rb->get_width(); + lsize+=style->get_margin(MARGIN_RIGHT); + + } + } + } break; + case SHOW_NEVER: // by default, never show close button + default: { + // do nothing + } break; + + } + + Ref sb; int va; Color col; @@ -273,6 +380,103 @@ void Tabs::_notification(int p_what) { } + + + + // Close button + switch (cb_displaypolicy) { + case SHOW_ALWAYS: { + if (tabs[i].close_button.is_valid()) { + Ref style = get_stylebox("button"); + Ref cb=tabs[i].close_button; + + w+=get_constant("hseparation"); + + Rect2 cb_rect; + cb_rect.size=style->get_minimum_size()+cb->get_size(); + cb_rect.pos.x=w; + cb_rect.pos.y=sb->get_margin(MARGIN_TOP)+((sb_rect.size.y-sb_ms.y)-(cb_rect.size.y))/2; + + if (cb_hover==i) { + if (cb_pressing) + get_stylebox("button_pressed")->draw(ci,cb_rect); + else + style->draw(ci,cb_rect); + } + + w+=style->get_margin(MARGIN_LEFT); + + cb->draw(ci,Point2i( w,cb_rect.pos.y+style->get_margin(MARGIN_TOP) )); + w+=cb->get_width(); + w+=style->get_margin(MARGIN_RIGHT); + tabs[i].cb_rect=cb_rect; + } + } break; + case SHOW_ACTIVE_ONLY: { + if (current==i) { + if (tabs[i].close_button.is_valid()) { + Ref style = get_stylebox("button"); + Ref cb=tabs[i].close_button; + + w+=get_constant("hseparation"); + + Rect2 cb_rect; + cb_rect.size=style->get_minimum_size()+cb->get_size(); + cb_rect.pos.x=w; + cb_rect.pos.y=sb->get_margin(MARGIN_TOP)+((sb_rect.size.y-sb_ms.y)-(cb_rect.size.y))/2; + + if (cb_hover==i) { + if (cb_pressing) + get_stylebox("button_pressed")->draw(ci,cb_rect); + else + style->draw(ci,cb_rect); + } + + w+=style->get_margin(MARGIN_LEFT); + + cb->draw(ci,Point2i( w,cb_rect.pos.y+style->get_margin(MARGIN_TOP) )); + w+=cb->get_width(); + w+=style->get_margin(MARGIN_RIGHT); + tabs[i].cb_rect=cb_rect; + } + } + } break; + case SHOW_HOVER: { + if (current==i || hover==i) { + if (tabs[i].close_button.is_valid()) { + Ref style = get_stylebox("button"); + Ref cb=tabs[i].close_button; + + w+=get_constant("hseparation"); + + Rect2 cb_rect; + cb_rect.size=style->get_minimum_size()+cb->get_size(); + cb_rect.pos.x=w; + cb_rect.pos.y=sb->get_margin(MARGIN_TOP)+((sb_rect.size.y-sb_ms.y)-(cb_rect.size.y))/2; + + if (cb_hover==i) { + if (cb_pressing) + get_stylebox("button_pressed")->draw(ci,cb_rect); + else + style->draw(ci,cb_rect); + } + + w+=style->get_margin(MARGIN_LEFT); + + cb->draw(ci,Point2i( w,cb_rect.pos.y+style->get_margin(MARGIN_TOP) )); + w+=cb->get_width(); + w+=style->get_margin(MARGIN_RIGHT); + tabs[i].cb_rect=cb_rect; + } + } + } break; + case SHOW_NEVER: + default: { + // show nothing + } break; + + } + w+=sb->get_margin(MARGIN_RIGHT); tabs[i].size_cache=w-tabs[i].ofs_cache; @@ -358,11 +562,29 @@ Ref Tabs::get_tab_right_button(int p_tab) const{ } +void Tabs::set_tab_close_button(int p_tab, const Ref& p_close_button) { + ERR_FAIL_INDEX(p_tab, tabs.size()); + tabs[p_tab].close_button=p_close_button; + update(); + minimum_size_changed(); +} + + +Ref Tabs::get_tab_close_button(int p_tab) const{ + + ERR_FAIL_INDEX_V(p_tab,tabs.size(),Ref()); + return tabs[p_tab].close_button; + +} + void Tabs::add_tab(const String& p_str,const Ref& p_icon) { Tab t; t.text=p_str; t.icon=p_icon; + + t.close_button = get_icon("Close","EditorIcons"); + tabs.push_back(t); update(); @@ -394,6 +616,11 @@ void Tabs::remove_tab(int p_idx) { } +void Tabs::set_tab_close_display_policy(CloseButtonDisplayPolicy p_cb_displaypolicy) { + cb_displaypolicy = p_cb_displaypolicy; +} + + void Tabs::set_tab_align(TabAlign p_align) { tab_align=p_align; @@ -423,14 +650,22 @@ void Tabs::_bind_methods() { ADD_SIGNAL(MethodInfo("tab_changed",PropertyInfo(Variant::INT,"tab"))); ADD_SIGNAL(MethodInfo("right_button_pressed",PropertyInfo(Variant::INT,"tab"))); + ADD_SIGNAL(MethodInfo("tab_close",PropertyInfo(Variant::INT,"tab"))); + ADD_PROPERTY( PropertyInfo(Variant::INT, "current_tab", PROPERTY_HINT_RANGE,"-1,4096,1",PROPERTY_USAGE_EDITOR), _SCS("set_current_tab"), _SCS("get_current_tab") ); BIND_CONSTANT( ALIGN_LEFT ); BIND_CONSTANT( ALIGN_CENTER ); BIND_CONSTANT( ALIGN_RIGHT ); + + BIND_CONSTANT( SHOW_ACTIVE_ONLY ); + BIND_CONSTANT( SHOW_ALWAYS ); + BIND_CONSTANT( SHOW_HOVER ); + BIND_CONSTANT( SHOW_NEVER ); } + Tabs::Tabs() { current=0; @@ -438,4 +673,7 @@ Tabs::Tabs() { rb_hover=-1; rb_pressing=false; + cb_hover=-1; + cb_pressing=false; + cb_displaypolicy = SHOW_NEVER; // Default : no close button } diff --git a/scene/gui/tabs.h b/scene/gui/tabs.h index 5cb0d9e916..1a8352bc93 100644 --- a/scene/gui/tabs.h +++ b/scene/gui/tabs.h @@ -42,6 +42,14 @@ public: ALIGN_CENTER, ALIGN_RIGHT }; + + enum CloseButtonDisplayPolicy { + + SHOW_ALWAYS, + SHOW_ACTIVE_ONLY, + SHOW_HOVER, + SHOW_NEVER + }; private: @@ -53,6 +61,8 @@ private: int size_cache; Ref right_button; Rect2 rb_rect; + Ref close_button; + Rect2 cb_rect; }; Vector tabs; @@ -63,6 +73,12 @@ private: int rb_hover; bool rb_pressing; + int cb_hover; + bool cb_pressing; + CloseButtonDisplayPolicy cb_displaypolicy; + + int hover; // hovered tab + protected: void _input_event(const InputEvent& p_event); @@ -82,6 +98,10 @@ public: void set_tab_right_button(int p_tab,const Ref& p_right_button); Ref get_tab_right_button(int p_tab) const; + void set_tab_close_button(int p_tab, const Ref& p_close_button); + Ref get_tab_close_button(int p_tab) const; + void set_tab_close_display_policy(CloseButtonDisplayPolicy p_cb_displaypolicy); + void set_tab_align(TabAlign p_align); TabAlign get_tab_align() const; diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index b0a2c568de..6321745caa 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -3620,6 +3620,7 @@ void EditorNode::_bind_methods() { ObjectTypeDB::bind_method("set_current_scene",&EditorNode::set_current_scene); ObjectTypeDB::bind_method("set_current_version",&EditorNode::set_current_version); ObjectTypeDB::bind_method("_scene_tab_changed",&EditorNode::_scene_tab_changed); + ObjectTypeDB::bind_method("_scene_tab_closed",&EditorNode::_scene_tab_closed); ObjectTypeDB::bind_method("_scene_tab_script_edited",&EditorNode::_scene_tab_script_edited); ObjectTypeDB::bind_method("_set_main_scene_state",&EditorNode::_set_main_scene_state); ObjectTypeDB::bind_method("_update_scene_tabs",&EditorNode::_update_scene_tabs); @@ -4072,6 +4073,17 @@ void EditorNode::_scene_tab_script_edited(int p_tab) { edit_resource(script); } +void EditorNode::_scene_tab_closed(int p_tab) { + set_current_scene(p_tab); + bool p_confirmed = true; + if (unsaved_cache) + p_confirmed = false; + + _menu_option_confirm(FILE_CLOSE, p_confirmed); + _update_scene_tabs(); +} + + void EditorNode::_scene_tab_changed(int p_tab) { @@ -4225,8 +4237,10 @@ EditorNode::EditorNode() { scene_tabs=memnew( Tabs ); scene_tabs->add_tab("unsaved"); scene_tabs->set_tab_align(Tabs::ALIGN_CENTER); + scene_tabs->set_tab_close_display_policy(Tabs::SHOW_HOVER); scene_tabs->connect("tab_changed",this,"_scene_tab_changed"); scene_tabs->connect("right_button_pressed",this,"_scene_tab_script_edited"); + scene_tabs->connect("tab_close", this, "_scene_tab_closed"); top_dark_vb->add_child(scene_tabs); //left left_l_hsplit = memnew( HSplitContainer ); @@ -4363,6 +4377,7 @@ EditorNode::EditorNode() { main_editor_tabs = memnew( Tabs ); main_editor_tabs->connect("tab_changed",this,"_editor_select"); + main_editor_tabs->set_tab_close_display_policy(Tabs::SHOW_NEVER); HBoxContainer *srth = memnew( HBoxContainer ); srt->add_child( srth ); Control *tec = memnew( Control ); diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index d40658a056..f08f413507 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -473,6 +473,7 @@ class EditorNode : public Node { void _dock_split_dragged(int ofs); void _dock_popup_exit(); void _scene_tab_changed(int p_tab); + void _scene_tab_closed(int p_tab); void _scene_tab_script_edited(int p_tab); Dictionary _get_main_scene_state(); -- cgit v1.2.3 From 32b52e80411d5bf23fc6add0a5ec67a24690c847 Mon Sep 17 00:00:00 2001 From: Joshua Olson <0joshua.olson1@gmail.com> Date: Wed, 26 Aug 2015 14:21:04 -0600 Subject: Fixed misspelled local variable for code clarity Specifically, tar(g)et_fps --- main/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main/main.cpp b/main/main.cpp index 19ee1c115f..acc122233a 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1454,9 +1454,9 @@ bool Main::iteration() { OS::get_singleton()->delay_usec( OS::get_singleton()->get_frame_delay()*1000 ); } - int taret_fps = OS::get_singleton()->get_target_fps(); - if (taret_fps>0) { - uint64_t time_step = 1000000L/taret_fps; + int target_fps = OS::get_singleton()->get_target_fps(); + if (target_fps>0) { + uint64_t time_step = 1000000L/target_fps; target_ticks += time_step; uint64_t current_ticks = OS::get_singleton()->get_ticks_usec(); if (current_ticksdelay_usec(target_ticks-current_ticks); -- cgit v1.2.3 From f0119c2e3c0ddb19cef1fdf6cfebb6697dabd14d Mon Sep 17 00:00:00 2001 From: "Eric R. Monson" Date: Fri, 28 Aug 2015 11:15:31 -0700 Subject: Properly free enemies after death in 3d platformer demo. Previously, they stuck around as invisible physics objects. This fix is much cleaner than my previous attempts, as it uses the ability to call a function from an animation as is done in the 2d platformer demo. --- demos/3d/platformer/enemy.gd | 3 ++- demos/3d/platformer/enemy.scn | Bin 37784 -> 38594 bytes 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/demos/3d/platformer/enemy.gd b/demos/3d/platformer/enemy.gd index cbbb2fe725..9b2e95a96d 100644 --- a/demos/3d/platformer/enemy.gd +++ b/demos/3d/platformer/enemy.gd @@ -91,4 +91,5 @@ func _ready(): # Initalization here pass - +func _die(): + queue_free() diff --git a/demos/3d/platformer/enemy.scn b/demos/3d/platformer/enemy.scn index 06d725061d..083582a85a 100644 Binary files a/demos/3d/platformer/enemy.scn and b/demos/3d/platformer/enemy.scn differ -- cgit v1.2.3 From e8223a90e43fe6315c8f45ce914cab0b6ae6923b Mon Sep 17 00:00:00 2001 From: Cesar Verdes Date: Sun, 6 Sep 2015 12:17:50 -0300 Subject: Ignore some extension of files created by Visual Studio 2013 --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 613eff442a..08213c1e5c 100644 --- a/.gitignore +++ b/.gitignore @@ -73,6 +73,8 @@ platform/android/libs/play_licensing/gen/* *.suo *.user *.sln.docstates +*.sln +*.vcxproj* # Build results [Dd]ebug/ -- cgit v1.2.3 From c925fbce2da5925009d5f78183e017f9252af35f Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Sat, 17 Oct 2015 15:41:01 +0300 Subject: Haiku: fix build --- platform/haiku/detect.py | 19 +++++++++---------- platform/haiku/haiku_direct_window.h | 5 +++-- platform/haiku/os_haiku.h | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/platform/haiku/detect.py b/platform/haiku/detect.py index 19fe2f79fb..b5fd550442 100644 --- a/platform/haiku/detect.py +++ b/platform/haiku/detect.py @@ -10,10 +10,10 @@ def get_name(): def can_build(): if (os.name != "posix"): return False - + if (sys.platform == "darwin"): return False - + return True def get_opts(): @@ -34,13 +34,12 @@ def configure(env): env["bits"]="64" else: env["bits"]="32" - + env.Append(CPPPATH = ['#platform/haiku']) - - # TODO: add clang and try gcc2 too - env["CC"] = "gcc-x86" - env["CXX"] = "g++-x86" - + + env["CC"] = "gcc" + env["CXX"] = "g++" + if (env["target"]=="release"): if (env["debug_release"]=="yes"): env.Append(CCFLAGS=['-g2']) @@ -50,12 +49,12 @@ def configure(env): env.Append(CCFLAGS=['-O2','-ffast-math','-DDEBUG_ENABLED']) elif (env["target"]=="debug"): env.Append(CCFLAGS=['-g2', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) - + #env.Append(CCFLAGS=['-DFREETYPE_ENABLED']) env.Append(CPPFLAGS = ['-DGLEW_ENABLED', '-DOPENGL_ENABLED', '-DMEDIA_KIT_ENABLED']) env.Append(CPPFLAGS = ['-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DGLES_OVER_GL']) env.Append(LIBS = ['be', 'game', 'media', 'network', 'bnetapi', 'z', 'GL', 'GLEW']) - + import methods env.Append(BUILDERS = {'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl')}) env.Append(BUILDERS = {'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl')}) diff --git a/platform/haiku/haiku_direct_window.h b/platform/haiku/haiku_direct_window.h index 7b1fd851fa..f0398df505 100644 --- a/platform/haiku/haiku_direct_window.h +++ b/platform/haiku/haiku_direct_window.h @@ -4,15 +4,16 @@ #include // needed for image_id #include -#include "os/input.h" #include "core/os/os.h" +#include "main/input_default.h" + #include "haiku_gl_view.h" #define REDRAW_MSG 'rdrw' #define LOCKGL_MSG 'glck' #define UNLOCKGL_MSG 'ulck' -class HaikuDirectWindow : public BDirectWindow +class HaikuDirectWindow : public BDirectWindow { private: unsigned int event_id; diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h index 57b72df3cf..e1b0b86cf4 100644 --- a/platform/haiku/os_haiku.h +++ b/platform/haiku/os_haiku.h @@ -1,7 +1,6 @@ #ifndef OS_HAIKU_H #define OS_HAIKU_H -#include "os/input.h" #include "drivers/unix/os_unix.h" #include "servers/visual_server.h" #include "servers/visual/rasterizer.h" @@ -11,6 +10,7 @@ #include "servers/audio/sample_manager_sw.h" #include "servers/spatial_sound/spatial_sound_server_sw.h" #include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" +#include "main/input_default.h" #include "audio_driver_media_kit.h" #include "context_gl_haiku.h" @@ -46,7 +46,7 @@ private: protected: virtual int get_video_driver_count() const; - virtual const char* get_video_driver_name(int p_driver) const; + virtual const char* get_video_driver_name(int p_driver) const; virtual VideoMode get_default_video_mode() const; virtual void initialize(const VideoMode& p_desired, int p_video_driver, int p_audio_driver); -- cgit v1.2.3