gui2/text_box: Implement I-beam cursor
This cursor is active when the widget has the mouse focus. You know, like textboxes are wont to do anywhere else. Took long enough, although there was an interaction issue with tooltips fixed in the previous commit. I still need to figure out how to make this work with GUI1 textboxes (e.g. in-game console). The colour version of the cursor was kindly provided by LordBob, and the B&W version is my own.
This commit is contained in:
parent
47ddf8877f
commit
d7f2595393
7 changed files with 29 additions and 3 deletions
|
@ -21,7 +21,7 @@
|
|||
### User interface
|
||||
* "Core" type add-ons are now only accessible via hotkey.
|
||||
* Removed "Classic" in-game theme.
|
||||
* Textboxes now have a hover effect.
|
||||
* Textboxes now have a hover effect as well as an I-beam cursor.
|
||||
* Added the Private Replay checkbox to the Multiplayer Create Game screen. This separates
|
||||
whether observers are allowed from whether the replay will be publicly available.
|
||||
### Units
|
||||
|
|
BIN
images/cursors-bw/ibeam.png
Normal file
BIN
images/cursors-bw/ibeam.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 246 B |
BIN
images/cursors/ibeam.png
Normal file
BIN
images/cursors/ibeam.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
|
@ -55,6 +55,7 @@ std::array<cursor_data, cursor::NUM_CURSORS> available_cursors {{
|
|||
#ifdef __APPLE__
|
||||
{ nullptr, boost::indeterminate, "normal.png", "normal.png", 0, 0 },
|
||||
{ nullptr, boost::indeterminate, "wait-alt.png", "wait.png", 0, 0 },
|
||||
{ nullptr, boost::indeterminate, "ibeam.png", "ibeam.png", 0, 0 },
|
||||
{ nullptr, boost::indeterminate, "move.png", "move.png", 0, 0 },
|
||||
{ nullptr, boost::indeterminate, "attack.png", "attack.png", 0, 0 },
|
||||
{ nullptr, boost::indeterminate, "select.png", "select.png", 0, 0 },
|
||||
|
@ -64,6 +65,7 @@ std::array<cursor_data, cursor::NUM_CURSORS> available_cursors {{
|
|||
#else
|
||||
{ nullptr, boost::indeterminate, "normal.png", "normal.png", 0, 0 },
|
||||
{ nullptr, boost::indeterminate, "wait.png", "wait.png", 0, 0 },
|
||||
{ nullptr, boost::indeterminate, "ibeam.png", "ibeam.png", 0, 0 },
|
||||
{ nullptr, boost::indeterminate, "move.png", "move.png", 0, 0 },
|
||||
{ nullptr, boost::indeterminate, "attack.png", "attack.png", 0, 0 },
|
||||
{ nullptr, boost::indeterminate, "select.png", "select.png", 0, 0 },
|
||||
|
@ -80,7 +82,8 @@ bool have_focus = true;
|
|||
|
||||
bool use_color_cursors()
|
||||
{
|
||||
return game_config::editor == false && preferences::use_color_cursors();
|
||||
return false;
|
||||
/*return game_config::editor == false && preferences::use_color_cursors();*/
|
||||
}
|
||||
|
||||
SDL_Cursor* create_cursor(surface surf)
|
||||
|
|
|
@ -27,7 +27,7 @@ struct manager
|
|||
~manager();
|
||||
};
|
||||
|
||||
enum CURSOR_TYPE { NORMAL, WAIT, MOVE, ATTACK, HYPERLINK, MOVE_DRAG, ATTACK_DRAG, NO_CURSOR, NUM_CURSORS };
|
||||
enum CURSOR_TYPE { NORMAL, WAIT, IBEAM, MOVE, ATTACK, HYPERLINK, MOVE_DRAG, ATTACK_DRAG, NO_CURSOR, NUM_CURSORS };
|
||||
|
||||
/**
|
||||
* Use the default parameter to reset cursors.
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "gui/widgets/text_box_base.hpp"
|
||||
|
||||
#include "cursor.hpp"
|
||||
#include "desktop/clipboard.hpp"
|
||||
#include "gui/core/log.hpp"
|
||||
#include "gui/core/timer.hpp"
|
||||
|
@ -72,6 +73,7 @@ text_box_base::text_box_base(const implementation::builder_styled_widget& builde
|
|||
text_box_base::~text_box_base()
|
||||
{
|
||||
toggle_cursor_timer(false);
|
||||
update_mouse_cursor(false);
|
||||
}
|
||||
|
||||
void text_box_base::set_active(const bool active)
|
||||
|
@ -670,6 +672,8 @@ void text_box_base::signal_handler_mouse_enter(const event::ui_event event,
|
|||
set_state(HOVERED);
|
||||
}
|
||||
|
||||
update_mouse_cursor(true);
|
||||
|
||||
handled = true;
|
||||
}
|
||||
|
||||
|
@ -682,6 +686,23 @@ void text_box_base::signal_handler_mouse_leave(const event::ui_event event,
|
|||
set_state(ENABLED);
|
||||
}
|
||||
|
||||
update_mouse_cursor(false);
|
||||
|
||||
handled = true;
|
||||
}
|
||||
|
||||
void text_box_base::update_mouse_cursor(bool enable)
|
||||
{
|
||||
// Someone else may set the mouse cursor for us to something unusual (e.g.
|
||||
// the WAIT cursor) so we ought to mess with that only if it's set to
|
||||
// NORMAL or IBEAM.
|
||||
|
||||
if(enable && cursor::get() == cursor::NORMAL) {
|
||||
cursor::set(cursor::IBEAM);
|
||||
} else if(!enable && cursor::get() == cursor::IBEAM) {
|
||||
cursor::set(cursor::NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace gui2
|
||||
|
|
|
@ -289,6 +289,8 @@ private:
|
|||
|
||||
virtual void reset_cursor_state();
|
||||
|
||||
void update_mouse_cursor(bool enable);
|
||||
|
||||
/**
|
||||
* Current state of the widget.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue