Selaa lähdekoodia

API: remove hide_cursor(), use a bool parameter in show_cursor() instead

Daniele Bartolini 12 vuotta sitten
vanhempi
sitoutus
2e15338547

+ 1 - 12
engine/lua/LuaWindow.cpp

@@ -147,17 +147,7 @@ CE_EXPORT int window_show_cursor(lua_State* L)
 {
 	LuaStack stack(L);
 
-	device()->window()->show_cursor();
-
-	return 0;
-}
-
-//-----------------------------------------------------------------------------
-CE_EXPORT int window_hide_cursor(lua_State* L)
-{
-	LuaStack stack(L);
-
-	device()->window()->hide_cursor();
+	device()->window()->show_cursor(stack.get_bool(1));
 
 	return 0;
 }
@@ -228,7 +218,6 @@ void load_window(LuaEnvironment& env)
 	env.load_module_function("Window", "is_resizable",	window_is_resizable);
 	env.load_module_function("Window", "set_resizable",	window_set_resizable);
 	env.load_module_function("Window", "show_cursor",	window_show_cursor);
-	env.load_module_function("Window", "hide_cursor",	window_hide_cursor);
 	env.load_module_function("Window", "get_cursor_xy",	window_get_cursor_xy);
 	env.load_module_function("Window", "set_cursor_xy",	window_set_cursor_xy);
 	env.load_module_function("Window", "title",			window_title);

+ 1 - 6
engine/os/android/OsWindow.cpp

@@ -107,12 +107,7 @@ void OsWindow::set_resizable(bool /*resizeable*/)
 }
 
 //-----------------------------------------------------------------------------
-void OsWindow::show_cursor()
-{
-}
-
-//-----------------------------------------------------------------------------
-void OsWindow::hide_cursor()
+void OsWindow::show_cursor(bool /*show*/)
 {
 }
 

+ 1 - 4
engine/os/android/OsWindow.h

@@ -72,10 +72,7 @@ public:
 	void			set_resizable(bool resizeable);
 
 	/// Stub method, does nothing under Android.
-	void			show_cursor();
-
-	/// Stub method, does nothing under Android.
-	void			hide_cursor();
+	void			show_cursor(bool show);
 
 	/// Stub method, does nothing under Android.
 	void			get_cursor_xy(int32_t& x, int32_t& y);

+ 9 - 8
engine/os/linux/OsWindow.cpp

@@ -249,15 +249,16 @@ void OsWindow::set_resizable(bool resizable)
 }
 
 //-----------------------------------------------------------------------------
-void OsWindow::show_cursor()
+void OsWindow::show_cursor(bool show)
 {
-	XDefineCursor(m_x11_display, m_x11_window, None);
-}
-
-//-----------------------------------------------------------------------------
-void OsWindow::hide_cursor()
-{
-	XDefineCursor(m_x11_display, m_x11_window, m_x11_hidden_cursor);
+	if (show)
+	{
+		XDefineCursor(m_x11_display, m_x11_window, None);
+	}
+	else
+	{
+		XDefineCursor(m_x11_display, m_x11_window, m_x11_hidden_cursor);
+	}
 }
 
 //-----------------------------------------------------------------------------

+ 1 - 2
engine/os/linux/OsWindow.h

@@ -60,8 +60,7 @@ public:
 	bool			is_resizable() const;
 	void			set_resizable(bool resizable);
 
-	void			show_cursor();
-	void			hide_cursor();
+	void			show_cursor(bool show);
 
 	void			get_cursor_xy(int32_t& x, int32_t& y);
 	void			set_cursor_xy(int32_t x, int32_t y);

+ 2 - 8
engine/os/win/OsWindow.cpp

@@ -206,15 +206,9 @@ void OsWindow::move(uint32_t x, uint32_t y)
 }
 
 //-----------------------------------------------------------------------------
-void OsWindow::show_cursor()
+void OsWindow::show_cursor(bool show)
 {
-	ShowCursor(true);
-}
-
-//-----------------------------------------------------------------------------
-void OsWindow::hide_cursor()
-{
-	ShowCursor(false);
+	ShowCursor(show);
 }
 
 //-----------------------------------------------------------------------------

+ 1 - 2
engine/os/win/OsWindow.h

@@ -48,8 +48,7 @@ public:
 	void			resize(uint32_t width, uint32_t height);
 	void			move(uint32_t x, uint32_t y);
 
-	void			show_cursor();
-	void			hide_cursor();
+	void			show_cursor(bool show);
 
 	void			get_cursor_xy(int32_t& x, int32_t& y);
 	void			set_cursor_xy(int32_t x, int32_t y);