WIP -- set_resizable() + is_resizable added

This commit is contained in:
hurikhan 2015-01-15 22:50:23 +09:00
parent 07b8d9136a
commit d269344bbd
7 changed files with 91 additions and 18 deletions

View File

@ -220,6 +220,14 @@ void _OS::set_fullscreen(bool p_enabled) {
bool _OS::is_fullscreen() const {
return OS::get_singleton()->is_fullscreen();
}
void _OS::set_resizable(bool p_enabled) {
OS::get_singleton()->set_resizable(p_enabled);
}
bool _OS::is_resizable() const {
return OS::get_singleton()->is_resizable();
}
#endif
void _OS::set_use_file_access_save_and_swap(bool p_enable) {
@ -232,7 +240,6 @@ bool _OS::is_video_mode_resizable(int p_screen) const {
OS::VideoMode vm;
vm = OS::get_singleton()->get_video_mode(p_screen);
return vm.resizable;
}
Array _OS::get_fullscreen_mode_list(int p_screen) const {
@ -690,6 +697,8 @@ void _OS::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_window_size"),&_OS::set_window_size);
ObjectTypeDB::bind_method(_MD("set_fullscreen","enabled"),&_OS::set_fullscreen);
ObjectTypeDB::bind_method(_MD("is_fullscreen"),&_OS::is_fullscreen);
ObjectTypeDB::bind_method(_MD("set_resizable","enabled"),&_OS::set_resizable);
ObjectTypeDB::bind_method(_MD("is_resizable"),&_OS::is_resizable);
#endif
ObjectTypeDB::bind_method(_MD("set_iterations_per_second","iterations_per_second"),&_OS::set_iterations_per_second);

View File

@ -120,6 +120,8 @@ public:
virtual void set_window_size(const Size2& p_size);
void set_fullscreen(bool p_enabled);
bool is_fullscreen() const;
void set_resizable(bool p_enabled);
bool is_resizable() const;
#endif
Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track);

View File

@ -162,6 +162,8 @@ public:
virtual void set_window_size(const Size2 p_size)=0;
virtual void set_fullscreen(bool p_enabled)=0;
virtual bool is_fullscreen() const=0;
virtual void set_resizable(bool p_enabled)=0;
virtual bool is_resizable() const=0;
#endif
virtual void set_iterations_per_second(int p_ips);

View File

@ -2,10 +2,18 @@
extends Control
func _fixed_process(delta):
var modetext = "Mode:\n"
if(OS.is_fullscreen()):
get_node("Label_Fullscreen").set_text("Mode:\nFullscreen")
modetext += "Fullscreen\n"
else:
get_node("Label_Fullscreen").set_text("Mode:\nWindowed")
modetext += "Windowed\n"
if(!OS.is_resizable()):
modetext += "FixedSize\n"
get_node("Label_Mode").set_text(modetext)
get_node("Label_Position").set_text( str("Position:\n", OS.get_window_position() ) )
@ -19,6 +27,7 @@ func _fixed_process(delta):
get_node("Label_Screen0_Position").set_text(str("Screen0 Position:\n",OS.get_screen_position()))
if(OS.get_screen_count() > 1):
get_node("Button_Screen1").show()
get_node("Label_Screen1_Resolution").show()
@ -42,6 +51,9 @@ func _fixed_process(delta):
if( Input.is_action_pressed("ui_down")):
OS.set_fullscreen(false)
get_node("Button_FixedSize").set_pressed( !OS.is_resizable() )
func _ready():
set_fixed_process(true)
@ -67,3 +79,15 @@ func _on_Button_Screen0_pressed():
func _on_Button_Screen1_pressed():
OS.set_screen(1)
func _on_Button_FixedSize_pressed():
if(OS.is_resizable()):
OS.set_resizable(false)
else:
OS.set_resizable(true)

View File

@ -223,7 +223,7 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
#endif
}
// disable resizeable window
// disable resizable window
if (!current_videomode.resizable) {
XSizeHints *xsh;
xsh = XAllocSizeHints();
@ -239,7 +239,9 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
xsh->min_height = xwa.height;
xsh->max_height = xwa.height;
XSetWMNormalHints(x11_display, x11_window, xsh);
XFree(xsh);
}
current_videomode.resizable;
AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton();
@ -708,6 +710,9 @@ void OS_X11::set_fullscreen(bool p_enabled) {
if(p_enabled && current_videomode.fullscreen)
return;
if(!current_videomode.resizable)
set_resizable(true);
if(p_enabled) {
window_data.size = get_window_size();
window_data.position = get_window_position();
@ -734,11 +739,37 @@ void OS_X11::set_fullscreen(bool p_enabled) {
}
visual_server->init();
}
bool OS_X11::is_fullscreen() const {
return current_videomode.fullscreen;
}
void OS_X11::set_resizable(bool p_enabled) {
if(!current_videomode.fullscreen) {
XSizeHints *xsh;
xsh = XAllocSizeHints();
xsh->flags = p_enabled ? 0L : PMinSize | PMaxSize;
if(!p_enabled) {
XWindowAttributes xwa;
XGetWindowAttributes(x11_display,x11_window,&xwa);
xsh->min_width = xwa.width;
xsh->max_width = xwa.width;
xsh->min_height = xwa.height;
xsh->max_height = xwa.height;
printf("%d %d\n", xwa.width, xwa.height);
}
XSetWMNormalHints(x11_display, x11_window, xsh);
XFree(xsh);
current_videomode.resizable = p_enabled;
}
}
bool OS_X11::is_resizable() const {
return current_videomode.resizable;
}
#endif
InputModifierState OS_X11::get_key_modifier_state(unsigned int p_x11_state) {
@ -1688,6 +1719,4 @@ OS_X11::OS_X11() {
minimized = false;
xim_style=NULL;
mouse_mode=MOUSE_MODE_VISIBLE;
};

View File

@ -160,10 +160,15 @@ class OS_X11 : public OS_Unix {
Joystick joysticks[JOYSTICKS_MAX];
#ifdef EXPERIMENTAL_WM_API
// This struct saves the values of the window before going fullscreen
// to be able to restore the same state after leaving fullscreen
struct {
bool resizable;
Point2i position;
Size2i size;
} window_data;
bool maximized;
void set_wm_border(bool p_enabled);
void set_wm_fullscreen(bool p_enabled);
#endif
@ -234,6 +239,8 @@ public:
virtual void set_window_size(const Size2 p_size);
virtual void set_fullscreen(bool p_enabled);
virtual bool is_fullscreen() const;
virtual void set_resizable(bool p_enabled);
virtual bool is_resizable() const;
#endif
virtual void move_window_to_foreground();