GUI2: removed 2010 experimental listbox
This was never finished, is not maintained, suffers from a lack of features the "old" listbox
class now has, and seems (according to the logs) to be have been superceded by the pane widget.
At the very least, the pane widget seems to be what mordante was working with in his early
prototype of a new addon manager, and not this 2010 list class.
(cherry-picked from commit 458dd284b8
)
This commit is contained in:
parent
398165631c
commit
c6e9efde9c
46 changed files with 7 additions and 1042 deletions
|
@ -5,7 +5,6 @@ gui/widgets/drawing.cpp
|
|||
gui/widgets/horizontal_scrollbar.cpp
|
||||
gui/widgets/image.cpp
|
||||
gui/widgets/label.cpp
|
||||
gui/widgets/list.cpp
|
||||
gui/widgets/listbox.cpp
|
||||
gui/widgets/matrix.cpp
|
||||
gui/widgets/menu_button.cpp
|
||||
|
|
|
@ -204,14 +204,7 @@ resolution_definition_ptr get_control(const std::string& control_type, const std
|
|||
const auto& current_types = current_gui->second.widget_types;
|
||||
const auto& default_types = default_gui->second.widget_types;
|
||||
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
const auto widget_definitions = (control_type == "list")
|
||||
? current_types.find("listbox")
|
||||
: current_types.find(control_type);
|
||||
#else
|
||||
const auto widget_definitions
|
||||
= current_types.find(control_type);
|
||||
#endif
|
||||
const auto widget_definitions = current_types.find(control_type);
|
||||
|
||||
gui_definition::widget_definition_map_t::const_iterator control;
|
||||
|
||||
|
@ -226,14 +219,7 @@ resolution_definition_ptr get_control(const std::string& control_type, const std
|
|||
bool found_fallback = false;
|
||||
|
||||
if(current_gui != default_gui) {
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
auto default_widget_definitions = (control_type == "list")
|
||||
? default_types.find("listbox")
|
||||
: default_types.find(control_type);
|
||||
#else
|
||||
auto default_widget_definitions
|
||||
= default_types.find(control_type);
|
||||
#endif
|
||||
auto default_widget_definitions = default_types.find(control_type);
|
||||
|
||||
VALIDATE(widget_definitions != current_types.end(),
|
||||
formatter() << "Type '" << control_type << "' is unknown.");
|
||||
|
|
|
@ -36,11 +36,7 @@
|
|||
#include "gui/widgets/stacked_widget.hpp"
|
||||
#include "gui/widgets/drawing.hpp"
|
||||
#include "gui/widgets/image.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/pane.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/toggle_button.hpp"
|
||||
|
|
|
@ -16,11 +16,7 @@
|
|||
|
||||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/widgets/grid.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/toggle_button.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
|
|
|
@ -22,11 +22,7 @@
|
|||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/auxiliary/old_markup.hpp"
|
||||
#include "preferences/game.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/window.hpp"
|
||||
#include "log.hpp"
|
||||
#include "serialization/string_utils.hpp"
|
||||
|
|
|
@ -19,11 +19,7 @@
|
|||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/image.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/multi_page.hpp"
|
||||
#include "gui/widgets/multimenu_button.hpp"
|
||||
#include "gui/widgets/scroll_label.hpp"
|
||||
|
|
|
@ -18,11 +18,7 @@
|
|||
|
||||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/widgets/button.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/text_box.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
|
|
|
@ -18,11 +18,7 @@
|
|||
|
||||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/widgets/image.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/multi_page.hpp"
|
||||
#include "gui/widgets/scroll_label.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
|
|
|
@ -19,11 +19,7 @@
|
|||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gettext.hpp"
|
||||
|
||||
namespace gui2
|
||||
|
|
|
@ -19,11 +19,7 @@
|
|||
|
||||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/text_box.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
#include "formula/string_utils.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
#include "map/location.hpp"
|
||||
|
|
|
@ -25,11 +25,7 @@
|
|||
#include "gui/dialogs/message.hpp"
|
||||
#include "gui/dialogs/transient_message.hpp"
|
||||
#include "gui/widgets/button.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/text_box.hpp"
|
||||
#include "gui/widgets/toggle_panel.hpp"
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/image.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/minimap.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/text_box.hpp"
|
||||
|
|
|
@ -18,11 +18,7 @@
|
|||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/core/log.hpp"
|
||||
#include "gui/dialogs/message.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/image.hpp"
|
||||
|
|
|
@ -26,11 +26,7 @@
|
|||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/styled_widget.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/selectable_item.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/stacked_widget.hpp"
|
||||
|
|
|
@ -24,12 +24,7 @@
|
|||
|
||||
namespace gui2
|
||||
{
|
||||
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
class list_view;
|
||||
#else
|
||||
class listbox;
|
||||
#endif
|
||||
|
||||
namespace dialogs
|
||||
{
|
||||
|
|
|
@ -23,11 +23,7 @@
|
|||
#include "map/label.hpp"
|
||||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/widgets/styled_widget.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/window.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/toggle_button.hpp"
|
||||
|
|
|
@ -17,11 +17,7 @@
|
|||
#include "gui/dialogs/language_selection.hpp"
|
||||
|
||||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
#include "language.hpp"
|
||||
|
|
|
@ -15,14 +15,11 @@
|
|||
|
||||
#include "gui/dialogs/multiplayer/faction_select.hpp"
|
||||
|
||||
#include "game_config_manager.hpp"
|
||||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/auxiliary/old_markup.hpp"
|
||||
#include "gui/core/log.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/image.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
|
|
|
@ -26,11 +26,7 @@
|
|||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/image.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/menu_button.hpp"
|
||||
#include "gui/widgets/minimap.hpp"
|
||||
#include "gui/widgets/chatbox.hpp"
|
||||
|
@ -392,14 +388,12 @@ void mp_lobby::update_gamelist_diff()
|
|||
|
||||
void mp_lobby::update_gamelist_header()
|
||||
{
|
||||
#ifndef GUI2_EXPERIMENTAL_LISTBOX
|
||||
const std::string games_string = VGETTEXT("Games: showing $num_shown out of $num_total", {
|
||||
{"num_shown", std::to_string(lobby_info_.games_visibility().count())},
|
||||
{"num_total", std::to_string(lobby_info_.games().size())}
|
||||
});
|
||||
|
||||
find_widget<label>(gamelistbox_, "map", false).set_label(games_string);
|
||||
#endif
|
||||
}
|
||||
|
||||
std::map<std::string, string_map> mp_lobby::make_game_row_data(const mp::game_info& game)
|
||||
|
|
|
@ -22,18 +22,13 @@
|
|||
#include "game_initialization/multiplayer.hpp"
|
||||
#include "quit_confirmation.hpp"
|
||||
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#endif
|
||||
class wesnothd_connection;
|
||||
namespace gui2
|
||||
{
|
||||
|
||||
class grid;
|
||||
class label;
|
||||
#ifndef GUI2_EXPERIMENTAL_LISTBOX
|
||||
class listbox;
|
||||
#endif
|
||||
class text_box;
|
||||
class window;
|
||||
class multi_page;
|
||||
|
|
|
@ -25,11 +25,7 @@
|
|||
#include "preferences/credentials.hpp"
|
||||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
#include "log.hpp"
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
#include "gui/auxiliary/field.hpp"
|
||||
#include "gui/dialogs/modal_dialog.hpp"
|
||||
#include "gui/widgets/button.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/settings.hpp"
|
||||
|
||||
#include "utils/functional.hpp"
|
||||
|
|
|
@ -28,11 +28,7 @@
|
|||
#include "gui/widgets/integer_selector.hpp"
|
||||
#include "gui/widgets/menu_button.hpp"
|
||||
#include "preferences/game.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "formatter.hpp"
|
||||
#include "formula/string_utils.hpp"
|
||||
#include "game_config.hpp"
|
||||
|
@ -48,13 +44,8 @@
|
|||
#include "savegame.hpp"
|
||||
#include "settings.hpp"
|
||||
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "utils/functional.hpp"
|
||||
#endif
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
|
||||
static lg::log_domain log_mp_create("mp/create");
|
||||
|
||||
#define DBG_MP LOG_STREAM(debug, log_mp_create)
|
||||
|
|
|
@ -34,11 +34,7 @@
|
|||
#include "gui/widgets/menu_button.hpp"
|
||||
#include "gui/widgets/image.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/tree_view.hpp"
|
||||
#include "gui/widgets/tree_view_node.hpp"
|
||||
|
@ -49,14 +45,12 @@
|
|||
#include "utils/scope_exit.hpp"
|
||||
#include "wesnothd_connection.hpp"
|
||||
|
||||
|
||||
static lg::log_domain log_mp_connect_engine("mp/connect/engine");
|
||||
#define DBG_MP LOG_STREAM(debug, log_mp_connect_engine)
|
||||
#define LOG_MP LOG_STREAM(info, log_mp_connect_engine)
|
||||
#define WRN_MP LOG_STREAM(warn, log_mp_connect_engine)
|
||||
#define ERR_MP LOG_STREAM(err, log_mp_connect_engine)
|
||||
|
||||
|
||||
namespace gui2
|
||||
{
|
||||
namespace dialogs
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
#include "game_initialization/multiplayer.hpp"
|
||||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/widgets/button.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/text_box.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
|
|
|
@ -27,11 +27,7 @@
|
|||
#include "gui/widgets/drawing.hpp"
|
||||
#include "gui/widgets/menu_button.hpp"
|
||||
#include "gui/widgets/image.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/label.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/slider.hpp"
|
||||
|
|
|
@ -49,11 +49,7 @@
|
|||
#include "gui/widgets/grid.hpp"
|
||||
#include "gui/widgets/image.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/scroll_label.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/slider.hpp"
|
||||
|
|
|
@ -19,11 +19,7 @@
|
|||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
|
||||
|
|
|
@ -21,11 +21,7 @@
|
|||
#include "gettext.hpp"
|
||||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/menu_button.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
|
|
|
@ -19,11 +19,7 @@
|
|||
#include "formatter.hpp"
|
||||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
#include "image.hpp"
|
||||
|
|
|
@ -15,11 +15,7 @@
|
|||
#include "gui/dialogs/theme_list.hpp"
|
||||
|
||||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
#include "theme.hpp"
|
||||
|
|
|
@ -19,11 +19,7 @@
|
|||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/image.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/unit_preview_pane.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
|
|
|
@ -22,11 +22,7 @@
|
|||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
#include "gui/widgets/image.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/unit_preview_pane.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
|
|
|
@ -18,11 +18,7 @@
|
|||
|
||||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/core/log.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/image.hpp"
|
||||
|
|
|
@ -19,11 +19,7 @@
|
|||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/core/log.hpp"
|
||||
#include "gui/dialogs/message.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/image.hpp"
|
||||
|
|
|
@ -19,11 +19,7 @@
|
|||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/core/log.hpp"
|
||||
#include "gui/dialogs/message.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/image.hpp"
|
||||
|
|
|
@ -18,11 +18,7 @@
|
|||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/image.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/unit_preview_pane.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
|
|
|
@ -19,11 +19,7 @@
|
|||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/text_box.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
|
|
|
@ -21,11 +21,7 @@
|
|||
|
||||
#include "formatter.hpp"
|
||||
#include "gui/widgets/generator.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/scrollbar_container.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
#include "serialization/string_utils.hpp"
|
||||
|
|
|
@ -1,474 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2010 - 2018 by Mark de Wever <koraq@xs4all.nl>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
|
||||
#define GETTEXT_DOMAIN "wesnoth-lib"
|
||||
|
||||
#include "gui/widgets/list.hpp"
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
|
||||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/core/log.hpp"
|
||||
#include "gui/widgets/detail/register.hpp"
|
||||
#include "gui/widgets/selectable.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
|
||||
#include "utils/functional.hpp"
|
||||
|
||||
#define LOG_SCOPE_HEADER get_control_type() + " [" + id() + "] " + __func__
|
||||
#define LOG_HEADER LOG_SCOPE_HEADER + ':'
|
||||
|
||||
namespace gui2
|
||||
{
|
||||
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
REGISTER_WIDGET(listbox)
|
||||
#endif
|
||||
|
||||
list_view::list_view(const bool has_minimum,
|
||||
const bool has_maximum,
|
||||
const generator_base::tplacement placement,
|
||||
const bool select,
|
||||
const builder_grid_const_ptr list_builder)
|
||||
: container_base()
|
||||
, state_(ENABLED)
|
||||
, generator_(nullptr)
|
||||
, list_builder_(list_builder)
|
||||
, need_layout_(false)
|
||||
{
|
||||
assert(list_builder);
|
||||
|
||||
generator_
|
||||
= generator_base::build(has_minimum, has_maximum, placement, select);
|
||||
assert(generator_);
|
||||
|
||||
connect_signal<event::LEFT_BUTTON_DOWN>(
|
||||
std::bind(&list_view::signal_handler_left_button_down, this, _2),
|
||||
event::dispatcher::back_pre_child);
|
||||
|
||||
connect_signal<event::SDL_KEY_DOWN>(std::bind(
|
||||
&list_view::signal_handler_sdl_key_down, this, _2, _3, _5, _6));
|
||||
|
||||
connect_signal<event::SDL_KEY_DOWN>(
|
||||
std::bind(
|
||||
&list_view::signal_handler_sdl_key_down, this, _2, _3, _5, _6),
|
||||
event::dispatcher::back_pre_child);
|
||||
}
|
||||
|
||||
void list_view::add_row(const string_map& item, const int index)
|
||||
{
|
||||
std::map<std::string, string_map> data;
|
||||
|
||||
data.emplace("", item);
|
||||
add_row(data, index);
|
||||
}
|
||||
|
||||
void
|
||||
list_view::add_row(const std::map<std::string /* widget id */, string_map>& data,
|
||||
const int index)
|
||||
{
|
||||
assert(generator_);
|
||||
grid& grid = generator_->create_item(index, list_builder_, data, nullptr);
|
||||
|
||||
selectable_item* selectable
|
||||
= find_widget<selectable_item>(&grid, "_toggle", false, false);
|
||||
|
||||
if(selectable) {
|
||||
dynamic_cast<widget&>(*selectable)
|
||||
.connect_signal<event::LEFT_BUTTON_CLICK>(
|
||||
std::bind(
|
||||
&list_view::signal_handler_pre_child_left_button_click,
|
||||
this,
|
||||
&grid,
|
||||
_2,
|
||||
_3,
|
||||
_4),
|
||||
event::dispatcher::back_pre_child);
|
||||
|
||||
// Post widget for panel.
|
||||
dynamic_cast<widget&>(*selectable)
|
||||
.connect_signal<event::LEFT_BUTTON_CLICK>(
|
||||
std::bind(&list_view::signal_handler_left_button_click,
|
||||
this,
|
||||
&grid,
|
||||
_2),
|
||||
event::dispatcher::back_post_child);
|
||||
|
||||
// Post widget for button and widgets on the panel.
|
||||
dynamic_cast<widget&>(*selectable)
|
||||
.connect_signal<event::LEFT_BUTTON_CLICK>(
|
||||
std::bind(&list_view::signal_handler_left_button_click,
|
||||
this,
|
||||
&grid,
|
||||
_2),
|
||||
event::dispatcher::back_child);
|
||||
}
|
||||
}
|
||||
|
||||
void list_view::append_rows(const std::vector<string_map>& items)
|
||||
{
|
||||
for(const string_map & item : items)
|
||||
{
|
||||
add_row(item);
|
||||
}
|
||||
}
|
||||
|
||||
void list_view::remove_row(const unsigned row, unsigned count)
|
||||
{
|
||||
assert(generator_);
|
||||
|
||||
if(row >= get_item_count()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!count || count > get_item_count()) {
|
||||
count = get_item_count();
|
||||
}
|
||||
|
||||
unsigned height_reduced = 0;
|
||||
for(; count; --count) {
|
||||
if(generator_->item(row).get_visible() != visibility::invisible) {
|
||||
height_reduced += generator_->item(row).get_height();
|
||||
}
|
||||
generator_->delete_item(row);
|
||||
}
|
||||
|
||||
if(height_reduced != 0) {
|
||||
// resize_content(0, -height_reduced);
|
||||
}
|
||||
}
|
||||
|
||||
void list_view::clear()
|
||||
{
|
||||
// Due to the removing from the linked group, don't use
|
||||
// generator_->clear() directly.
|
||||
remove_row(0, 0);
|
||||
}
|
||||
|
||||
unsigned list_view::get_item_count() const
|
||||
{
|
||||
assert(generator_);
|
||||
return generator_->get_item_count();
|
||||
}
|
||||
|
||||
void list_view::set_row_active(const unsigned row, const bool active)
|
||||
{
|
||||
assert(generator_);
|
||||
generator_->item(row).set_active(active);
|
||||
}
|
||||
|
||||
void list_view::set_row_shown(const unsigned row, const bool shown)
|
||||
{
|
||||
assert(generator_);
|
||||
|
||||
window* window = get_window();
|
||||
assert(window);
|
||||
|
||||
const int selected_row = get_selected_row();
|
||||
|
||||
bool resize_needed = false;
|
||||
{
|
||||
window::invalidate_layout_blocker invalidate_layout_blocker(*window);
|
||||
|
||||
generator_->set_item_shown(row, shown);
|
||||
generator_->place(generator_->get_origin(),
|
||||
generator_->calculate_best_size());
|
||||
// resize_needed = !content_resize_request();
|
||||
}
|
||||
|
||||
if(resize_needed) {
|
||||
window->invalidate_layout();
|
||||
} else {
|
||||
// get_grid().set_visible_rectangle(content_visible_rectangle());
|
||||
set_is_dirty(true);
|
||||
}
|
||||
|
||||
if(selected_row != get_selected_row()) {
|
||||
fire(event::NOTIFY_MODIFIED, *this, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void list_view::set_row_shown(const boost::dynamic_bitset<>& shown)
|
||||
{
|
||||
assert(generator_);
|
||||
assert(shown.size() == get_item_count());
|
||||
|
||||
window* window = get_window();
|
||||
assert(window);
|
||||
|
||||
const int selected_row = get_selected_row();
|
||||
|
||||
bool resize_needed = false;
|
||||
{
|
||||
window::invalidate_layout_blocker invalidate_layout_blocker(*window);
|
||||
|
||||
for(std::size_t i = 0; i < shown.size(); ++i) {
|
||||
generator_->set_item_shown(i, shown[i]);
|
||||
}
|
||||
generator_->place(generator_->get_origin(),
|
||||
generator_->calculate_best_size());
|
||||
// resize_needed = !content_resize_request();
|
||||
}
|
||||
|
||||
if(resize_needed) {
|
||||
window->invalidate_layout();
|
||||
} else {
|
||||
// content_grid_->set_visible_rectangle(content_visible_rectangle());
|
||||
set_is_dirty(true);
|
||||
}
|
||||
|
||||
if(selected_row != get_selected_row()) {
|
||||
fire(event::NOTIFY_MODIFIED, *this, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
const grid* list_view::get_row_grid(const unsigned row) const
|
||||
{
|
||||
assert(generator_);
|
||||
// rename this function and can we return a reference??
|
||||
return &generator_->item(row);
|
||||
}
|
||||
|
||||
grid* list_view::get_row_grid(const unsigned row)
|
||||
{
|
||||
assert(generator_);
|
||||
return &generator_->item(row);
|
||||
}
|
||||
|
||||
bool list_view::select_row(const unsigned row, const bool select)
|
||||
{
|
||||
assert(generator_);
|
||||
|
||||
generator_->select_item(row, select);
|
||||
|
||||
return true; // FIXME test what result should have been!!!
|
||||
}
|
||||
|
||||
int list_view::get_selected_row() const
|
||||
{
|
||||
assert(generator_);
|
||||
|
||||
return generator_->get_selected_item();
|
||||
}
|
||||
|
||||
void list_view::place(const point& origin, const point& size)
|
||||
{
|
||||
// Inherited.
|
||||
container_base::place(origin, size);
|
||||
|
||||
/**
|
||||
* @todo Work-around to set the selected item visible again.
|
||||
*
|
||||
* At the moment the lists and dialogs in general are resized a lot as
|
||||
* work-around for sizing. So this function makes the selected item in view
|
||||
* again. It doesn't work great in all cases but the proper fix is to avoid
|
||||
* resizing dialogs a lot. Need more work later on.
|
||||
*/
|
||||
const int selected_item = generator_->get_selected_item();
|
||||
if(selected_item != -1) {
|
||||
/*
|
||||
const SDL_Rect& visible = content_visible_area();
|
||||
SDL_Rect rect = generator_->item(selected_item).get_rectangle();
|
||||
|
||||
rect.x = visible.x;
|
||||
rect.w = visible.w;
|
||||
|
||||
show_content_rect(rect);
|
||||
*/
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
void list_view::resize_content(
|
||||
const int width_modification
|
||||
, const int height_modification)
|
||||
{
|
||||
DBG_GUI_L << LOG_HEADER << " current size " << content_grid()->get_size()
|
||||
<< " width_modification " << width_modification
|
||||
<< " height_modification " << height_modification
|
||||
<< ".\n";
|
||||
|
||||
if(content_resize_request(width_modification, height_modification)) {
|
||||
|
||||
// Calculate new size.
|
||||
point size = content_grid()->get_size();
|
||||
size.x += width_modification;
|
||||
size.y += height_modification;
|
||||
|
||||
// Set new size.
|
||||
content_grid()->set_size(size);
|
||||
|
||||
// Set status.
|
||||
need_layout_ = true;
|
||||
// If the content grows assume it "overwrites" the old content.
|
||||
if(width_modification < 0 || height_modification < 0) {
|
||||
set_is_dirty(true);
|
||||
}
|
||||
DBG_GUI_L << LOG_HEADER << " succeeded.\n";
|
||||
} else {
|
||||
DBG_GUI_L << LOG_HEADER << " failed.\n";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void list_view::init()
|
||||
{
|
||||
init_grid(cast<listbox_definition::resolution>(config()).grid);
|
||||
|
||||
set_single_child(find_widget<grid>(&get_grid(), "_list_grid", false),
|
||||
generator_);
|
||||
|
||||
/*
|
||||
* These items should be managed by the new listbox class.
|
||||
* So make them invisible for now.
|
||||
*/
|
||||
grid* g = find_widget<grid>(&get_grid(), "_header_grid", false, false);
|
||||
if(g)
|
||||
g->set_visible(widget::visibility::invisible);
|
||||
|
||||
g = find_widget<grid>(&get_grid(), "_footer_grid", false, false);
|
||||
if(g)
|
||||
g->set_visible(widget::visibility::invisible);
|
||||
|
||||
g = find_widget<grid>(&get_grid(), "_vertical_scrollbar_grid", false, false);
|
||||
if(g)
|
||||
g->set_visible(widget::visibility::invisible);
|
||||
|
||||
g = find_widget<grid>(&get_grid(), "_horizontal_scrollbar_grid", false, false);
|
||||
if(g)
|
||||
g->set_visible(widget::visibility::invisible);
|
||||
}
|
||||
|
||||
bool list_view::get_active() const
|
||||
{
|
||||
return state_ != DISABLED;
|
||||
}
|
||||
|
||||
unsigned list_view::get_state() const
|
||||
{
|
||||
return state_;
|
||||
}
|
||||
|
||||
void list_view::layout_children(const bool force)
|
||||
{
|
||||
if(need_layout_ || force) {
|
||||
get_grid().place(get_grid().get_origin(), get_grid().get_size());
|
||||
|
||||
/*
|
||||
get_grid().set_visible_rectangle(content_visible_area_);
|
||||
*/
|
||||
need_layout_ = false;
|
||||
set_is_dirty(true);
|
||||
}
|
||||
}
|
||||
|
||||
void list_view::set_self_active(const bool active)
|
||||
{
|
||||
/* DO NOTHING */
|
||||
}
|
||||
|
||||
void list_view::signal_handler_left_button_down(const event::ui_event event)
|
||||
{
|
||||
DBG_GUI_E << LOG_HEADER << ' ' << event << ".\n";
|
||||
|
||||
assert(get_window());
|
||||
get_window()->keyboard_capture(this);
|
||||
}
|
||||
|
||||
void list_view::signal_handler_pre_child_left_button_click(
|
||||
grid* grid, const event::ui_event event, bool& handled, bool& halt)
|
||||
{
|
||||
DBG_GUI_E << LOG_HEADER << ' ' << event << ".\n";
|
||||
|
||||
assert(grid);
|
||||
assert(generator_);
|
||||
|
||||
for(std::size_t i = 0; i < generator_->get_item_count(); ++i) {
|
||||
if(&generator_->item(i) == grid) {
|
||||
|
||||
/**
|
||||
* @todo Here we should check whether the panel can be toggled.
|
||||
*
|
||||
* NO set halt + handled
|
||||
* YES do nothing
|
||||
*
|
||||
* Then a post to the widget, which if done sets the proper state
|
||||
* in the list.
|
||||
*
|
||||
* For now we simply assume an item can only be selected and not
|
||||
* deselected (which is true at the moment).
|
||||
*/
|
||||
if(generator_->is_selected(i)) {
|
||||
halt = true;
|
||||
handled = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
assert(false);
|
||||
}
|
||||
|
||||
void list_view::signal_handler_left_button_click(grid* grid,
|
||||
const event::ui_event event)
|
||||
{
|
||||
DBG_GUI_E << LOG_HEADER << ' ' << event << ".\n";
|
||||
assert(grid);
|
||||
assert(generator_);
|
||||
|
||||
/** @todo Test the proper state to set. */
|
||||
for(std::size_t i = 0; i < generator_->get_item_count(); ++i) {
|
||||
if(&generator_->item(i) == grid) {
|
||||
generator_->select_item(i);
|
||||
fire(event::NOTIFY_MODIFIED, *this, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void list_view::signal_handler_sdl_key_down(const event::ui_event event,
|
||||
bool& handled,
|
||||
const SDL_Keycode key,
|
||||
SDL_Keymod modifier)
|
||||
{
|
||||
DBG_GUI_E << LOG_HEADER << ' ' << event << ".\n";
|
||||
|
||||
if(handled) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch(key) {
|
||||
case SDLK_UP:
|
||||
generator_->handle_key_up_arrow(modifier, handled);
|
||||
break;
|
||||
case SDLK_DOWN:
|
||||
generator_->handle_key_down_arrow(modifier, handled);
|
||||
break;
|
||||
case SDLK_LEFT:
|
||||
generator_->handle_key_left_arrow(modifier, handled);
|
||||
break;
|
||||
case SDLK_RIGHT:
|
||||
generator_->handle_key_right_arrow(modifier, handled);
|
||||
break;
|
||||
default:
|
||||
;
|
||||
/* Do nothing. */
|
||||
}
|
||||
if(handled) {
|
||||
fire(event::NOTIFY_MODIFIED, *this, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace gui2
|
||||
|
||||
#endif
|
|
@ -1,304 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2010 - 2018 by Mark de Wever <koraq@xs4all.nl>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
|
||||
#include "gui/widgets/generator.hpp"
|
||||
#include "gui/widgets/scrollbar_container.hpp"
|
||||
|
||||
#include <boost/dynamic_bitset.hpp>
|
||||
|
||||
namespace gui2
|
||||
{
|
||||
|
||||
/**
|
||||
* The list class.
|
||||
*
|
||||
* For now it's a generic for all kind of lists, horizontal, vertical etc.
|
||||
* Might be that there will be different types per class, not sure yet.
|
||||
*/
|
||||
class list_view : public container_base
|
||||
{
|
||||
friend class debug_layout_graph;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param has_minimum Does the listbox need to have one item
|
||||
* selected.
|
||||
* @param has_maximum Can the listbox only have one item
|
||||
* selected.
|
||||
* @param placement How are the items placed.
|
||||
* @param select Select an item when selected, if false it
|
||||
* changes the visible state instead.
|
||||
*/
|
||||
list_view(const bool has_minimum,
|
||||
const bool has_maximum,
|
||||
const generator_base::tplacement placement,
|
||||
const bool select,
|
||||
const builder_grid_const_ptr list_builder);
|
||||
|
||||
/***** ***** ***** ***** Row handling. ***** ***** ****** *****/
|
||||
/**
|
||||
* When an item in the list is selected by the user we need to
|
||||
* update the state. We installed a callback handler which
|
||||
* calls us.
|
||||
*
|
||||
* @param item The data send to the set_members of the
|
||||
* widgets.
|
||||
* @param index The item before which to add the new item,
|
||||
* 0 == begin, -1 == end.
|
||||
*/
|
||||
void add_row(const string_map& item, const int index = -1);
|
||||
|
||||
/**
|
||||
* Adds single row to the grid.
|
||||
*
|
||||
* This function expect a row to have multiple widgets (either multiple
|
||||
* columns or one column with multiple widgets).
|
||||
*
|
||||
*
|
||||
* @param data The data to send to the set_members of the
|
||||
* widgets. If the member id is not an empty
|
||||
* string it is only send to the widget that has
|
||||
* the wanted id (if any). If the member id is an
|
||||
* empty string, it is send to all members.
|
||||
* Having both empty and non-empty id's gives
|
||||
* undefined behavior.
|
||||
* @param index The item before which to add the new item,
|
||||
* 0 == begin, -1 == end.
|
||||
*/
|
||||
void add_row(const std::map<std::string /* widget id */, string_map>& data,
|
||||
const int index = -1);
|
||||
|
||||
/**
|
||||
* Appends several rows to the grid.
|
||||
*
|
||||
* @param items The data to send to the set_members of the
|
||||
* widgets.
|
||||
*/
|
||||
void append_rows(const std::vector<string_map>& items);
|
||||
|
||||
/**
|
||||
* Removes a row in the listbox.
|
||||
*
|
||||
* @param row The row to remove, when not in
|
||||
* range the function is ignored.
|
||||
* @param count The number of rows to remove, 0 means all
|
||||
* rows (starting from row).
|
||||
*/
|
||||
void remove_row(const unsigned row, unsigned count = 1);
|
||||
|
||||
/** Removes all the rows in the listbox, clearing it. */
|
||||
void clear();
|
||||
|
||||
/** Returns the number of items in the listbox. */
|
||||
unsigned get_item_count() const;
|
||||
|
||||
/**
|
||||
* Makes a row active or inactive.
|
||||
*
|
||||
* NOTE this doesn't change the select status of the row.
|
||||
*
|
||||
* @param row The row to (de)activate.
|
||||
* @param active true activate, false deactivate.
|
||||
*/
|
||||
void set_row_active(const unsigned row, const bool active);
|
||||
|
||||
/**
|
||||
* Makes a row visible or invisible.
|
||||
*
|
||||
* @param row The row to show or hide.
|
||||
* @param shown true visible, false invisible.
|
||||
*/
|
||||
void set_row_shown(const unsigned row, const bool shown);
|
||||
|
||||
/**
|
||||
* Makes a row visible or invisible.
|
||||
*
|
||||
* Use this version if you want to show hide multiple items since it's
|
||||
* optimized for that purpose, for one it calls the selection changed
|
||||
* callback only once instead of several times.
|
||||
*
|
||||
* @param shown A vector with the show hide status for every
|
||||
* row. The number of items in the vector must
|
||||
* be equal to the number of items in the
|
||||
* listbox.
|
||||
*/
|
||||
void set_row_shown(const boost::dynamic_bitset<>& shown);
|
||||
|
||||
/**
|
||||
* Returns the grid of the wanted row.
|
||||
*
|
||||
* There's only a const version since allowing callers to modify the grid
|
||||
* behind our backs might give problems. We return a pointer instead of a
|
||||
* reference since dynamic casting of pointers is easier (no try catch
|
||||
* needed).
|
||||
*
|
||||
* @param row The row to get the grid from, the caller has
|
||||
* to make sure the row is a valid row.
|
||||
* @returns The grid of the wanted row.
|
||||
*/
|
||||
const grid* get_row_grid(const unsigned row) const;
|
||||
|
||||
/**
|
||||
* The possibly-giving-problems nonconst version of get_row_grid
|
||||
*
|
||||
* @param row The row to get the grid from, the caller has
|
||||
* to make sure the row is a valid row.
|
||||
* @returns The grid of the wanted row.
|
||||
*/
|
||||
grid* get_row_grid(const unsigned row);
|
||||
|
||||
/**
|
||||
* Selectes a row.
|
||||
*
|
||||
* @param row The row to select.
|
||||
* @param select Select or deselect the row.
|
||||
*/
|
||||
bool select_row(const unsigned row, const bool select = true);
|
||||
|
||||
/**
|
||||
* Returns the first selected row
|
||||
*
|
||||
* @returns The first selected row.
|
||||
* @retval -1 No row selected.
|
||||
*/
|
||||
int get_selected_row() const;
|
||||
#if 0
|
||||
/**
|
||||
* Request to update the size of the content after changing the content.
|
||||
*
|
||||
* When a resize is required the container first can try to handle it
|
||||
* itself. If it can't honor the request the function will call @ref
|
||||
* window::invalidate_layout().
|
||||
*
|
||||
* @note Calling this function on a widget with size == (0, 0) results
|
||||
* false but doesn't call invalidate_layout, the engine expects to be in
|
||||
* build up phase with the layout already invalidated.
|
||||
*
|
||||
* @returns True if the resizing succeeded, false
|
||||
* otherwise.
|
||||
*/
|
||||
bool update_content_size();
|
||||
#endif
|
||||
/***** ***** ***** ***** inherited ***** ***** ****** *****/
|
||||
|
||||
/** Inherited from tcontrol_. */
|
||||
void init();
|
||||
|
||||
/** See @ref styled_widget::get_active. */
|
||||
virtual bool get_active() const override;
|
||||
|
||||
/** See @ref styled_widget::get_state. */
|
||||
virtual unsigned get_state() const override;
|
||||
|
||||
/** See @ref widget::place. */
|
||||
virtual void place(const point& origin, const point& size) override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Possible states of the widget.
|
||||
*
|
||||
* Note the order of the states must be the same as defined in settings.hpp.
|
||||
*/
|
||||
enum state_t {
|
||||
ENABLED,
|
||||
DISABLED,
|
||||
};
|
||||
|
||||
/**
|
||||
* Current state of the widget.
|
||||
*
|
||||
* The state of the widget determines what to render and how the widget
|
||||
* reacts to certain 'events'.
|
||||
*/
|
||||
state_t state_;
|
||||
|
||||
/**
|
||||
* Contains a pointer to the generator.
|
||||
*
|
||||
* The pointer is not owned by this class, it's stored in the content_grid_
|
||||
* of the scrollbar_container super class and freed when it's grid is
|
||||
* freed.
|
||||
*/
|
||||
generator_base* generator_;
|
||||
|
||||
/** Contains the builder for the new items. */
|
||||
builder_grid_const_ptr list_builder_;
|
||||
|
||||
bool need_layout_;
|
||||
#if 0
|
||||
/**
|
||||
* Resizes the content.
|
||||
*
|
||||
* The resize either happens due to resizing the content or invalidate the
|
||||
* layout of the window.
|
||||
*
|
||||
* @param width_modification The wanted modification to the width:
|
||||
* * negative values reduce width.
|
||||
* * zero leave width as is.
|
||||
* * positive values increase width.
|
||||
* @param height_modification The wanted modification to the height:
|
||||
* * negative values reduce height.
|
||||
* * zero leave height as is.
|
||||
* * positive values increase height.
|
||||
*/
|
||||
void resize_content(
|
||||
const int width_modification
|
||||
, const int height_modification);
|
||||
#endif
|
||||
/** Layouts the children if needed. */
|
||||
void layout_children(const bool force);
|
||||
#if 0
|
||||
/** Inherited from scrollbar_container. */
|
||||
virtual void set_content_size(const point& origin, const point& size);
|
||||
#endif
|
||||
/** See @ref container_base::set_self_active. */
|
||||
virtual void set_self_active(const bool active) override;
|
||||
|
||||
public:
|
||||
/** Static type getter that does not rely on the widget being constructed. */
|
||||
static const std::string& type();
|
||||
|
||||
private:
|
||||
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
|
||||
virtual const std::string& get_control_type() const override;
|
||||
|
||||
/***** ***** ***** signal handlers ***** ****** *****/
|
||||
|
||||
void signal_handler_left_button_down(const event::ui_event event);
|
||||
|
||||
void signal_handler_pre_child_left_button_click(grid* grid,
|
||||
const event::ui_event event,
|
||||
bool& handled,
|
||||
bool& halt);
|
||||
|
||||
void signal_handler_left_button_click(grid* grid,
|
||||
const event::ui_event event);
|
||||
|
||||
void signal_handler_sdl_key_down(const event::ui_event event,
|
||||
bool& handled,
|
||||
const SDL_Keycode key,
|
||||
SDL_Keymod modifier);
|
||||
};
|
||||
|
||||
typedef list_view listbox;
|
||||
|
||||
} // namespace gui2
|
||||
|
||||
#endif
|
|
@ -12,8 +12,6 @@
|
|||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#ifndef GUI2_EXPERIMENTAL_LISTBOX
|
||||
|
||||
#define GETTEXT_DOMAIN "wesnoth-lib"
|
||||
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
|
@ -973,17 +971,6 @@ builder_listbox::builder_listbox(const config& cfg)
|
|||
|
||||
widget* builder_listbox::build() const
|
||||
{
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
list_view* widget = new list_view(true, true, generator_base::vertical_list, true, list_builder);
|
||||
|
||||
// init_control(widget);
|
||||
if(!list_data.empty()) {
|
||||
widget->append_rows(list_data);
|
||||
}
|
||||
|
||||
return widget;
|
||||
#else
|
||||
|
||||
listbox* widget = new listbox(*this, generator_base::vertical_list, list_builder, has_minimum_, has_maximum_);
|
||||
|
||||
widget->set_vertical_scrollbar_mode(vertical_scrollbar_mode);
|
||||
|
@ -999,7 +986,6 @@ widget* builder_listbox::build() const
|
|||
widget->finalize(header, footer, list_data);
|
||||
|
||||
return widget;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*WIKI_MACRO
|
||||
|
@ -1090,17 +1076,6 @@ builder_horizontal_listbox::builder_horizontal_listbox(const config& cfg)
|
|||
|
||||
widget* builder_horizontal_listbox::build() const
|
||||
{
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
list_view* widget = new list_view(true, true, generator_base::horizontal_list, true, list_builder);
|
||||
|
||||
// init_control(widget);
|
||||
if(!list_data.empty()) {
|
||||
widget->append_rows(list_data);
|
||||
}
|
||||
|
||||
return widget;
|
||||
#else
|
||||
|
||||
listbox* widget = new listbox(*this, generator_base::horizontal_list, list_builder, has_minimum_, has_maximum_);
|
||||
|
||||
widget->set_vertical_scrollbar_mode(vertical_scrollbar_mode);
|
||||
|
@ -1116,7 +1091,6 @@ widget* builder_horizontal_listbox::build() const
|
|||
widget->finalize(nullptr, nullptr, list_data);
|
||||
|
||||
return widget;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*WIKI_MACRO
|
||||
|
@ -1207,17 +1181,6 @@ builder_grid_listbox::builder_grid_listbox(const config& cfg)
|
|||
|
||||
widget* builder_grid_listbox::build() const
|
||||
{
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
list_view* widget = new list_view(true, true, generator_base::grid, true, list_builder);
|
||||
|
||||
// init_control(widget);
|
||||
if(!list_data.empty()) {
|
||||
widget->append_rows(list_data);
|
||||
}
|
||||
|
||||
return widget;
|
||||
#else
|
||||
|
||||
listbox* widget = new listbox(*this, generator_base::table, list_builder, has_minimum_, has_maximum_);
|
||||
|
||||
widget->set_vertical_scrollbar_mode(vertical_scrollbar_mode);
|
||||
|
@ -1233,7 +1196,6 @@ widget* builder_grid_listbox::build() const
|
|||
widget->finalize(nullptr, nullptr, list_data);
|
||||
|
||||
return widget;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
|
@ -1241,5 +1203,3 @@ widget* builder_grid_listbox::build() const
|
|||
// }------------ END --------------
|
||||
|
||||
} // namespace gui2
|
||||
|
||||
#endif
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifndef GUI2_EXPERIMENTAL_LISTBOX
|
||||
|
||||
#include "gui/widgets/generator.hpp"
|
||||
#include "gui/widgets/scrollbar_container.hpp"
|
||||
|
||||
|
@ -526,5 +524,3 @@ struct builder_grid_listbox : public builder_styled_widget
|
|||
// }------------ END --------------
|
||||
|
||||
} // namespace gui2
|
||||
|
||||
#endif
|
||||
|
|
|
@ -43,9 +43,7 @@ class scrollbar_container : public container_base
|
|||
|
||||
friend struct implementation::builder_scroll_label;
|
||||
friend struct implementation::builder_scrollbar_panel;
|
||||
#ifndef GUI2_EXPERIMENTAL_LISTBOX
|
||||
friend class listbox;
|
||||
#endif
|
||||
friend class tree_view;
|
||||
friend struct scrollbar_container_implementation;
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "gui/dialogs/message.hpp"
|
||||
#include "gui/widgets/clickable_item.hpp"
|
||||
#include "gui/widgets/styled_widget.hpp"
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#include "gui/widgets/multi_page.hpp"
|
||||
#include "gui/widgets/multimenu_button.hpp"
|
||||
#include "gui/widgets/progress_bar.hpp"
|
||||
|
@ -40,12 +41,6 @@
|
|||
#include "gui/widgets/widget.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
|
||||
#include "config.hpp"
|
||||
#include "log.hpp"
|
||||
#include "scripting/lua_common.hpp"
|
||||
|
@ -131,11 +126,7 @@ static gui2::widget* find_widget(lua_State* L, int i, bool readonly)
|
|||
gui2::widget* w = scoped_dialog::current->window.get();
|
||||
for(; !lua_isnoneornil(L, i); ++i)
|
||||
{
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
if(gui2::list_view* list = dynamic_cast<gui2::list_view*>(w))
|
||||
#else
|
||||
if(gui2::listbox* list = dynamic_cast<gui2::listbox*>(w))
|
||||
#endif
|
||||
{
|
||||
int v = lua_tointeger(L, i);
|
||||
if(v < 1) {
|
||||
|
@ -463,11 +454,7 @@ int intf_set_dialog_value(lua_State* L)
|
|||
{
|
||||
gui2::widget *w = find_widget(L, 2, false);
|
||||
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
if(gui2::list_view* list = dynamic_cast<gui2::list_view*>(w))
|
||||
#else
|
||||
if(gui2::listbox* list = dynamic_cast<gui2::listbox*>(w))
|
||||
#endif
|
||||
{
|
||||
if(lua_istable(L, 1)) {
|
||||
// Do two passes in case has_minimum is true
|
||||
|
@ -595,11 +582,7 @@ int intf_get_dialog_value(lua_State* L)
|
|||
gui2::widget *w = find_widget(L, 1, true);
|
||||
int num_rets = 1;
|
||||
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
if(gui2::list_view* list = dynamic_cast<gui2::list_view*>(w))
|
||||
#else
|
||||
if(gui2::listbox* list = dynamic_cast<gui2::listbox*>(w))
|
||||
#endif
|
||||
{
|
||||
lua_pushinteger(L, list->get_selected_row() + 1);
|
||||
num_rets = 2;
|
||||
|
@ -691,11 +674,7 @@ int intf_remove_dialog_item(lua_State* L)
|
|||
int number = luaL_checkinteger(L, 2);
|
||||
gui2::widget* w = find_widget(L, 3, true);
|
||||
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
if(gui2::list_view* list = dynamic_cast<gui2::list_view*>(w))
|
||||
#else
|
||||
if(gui2::listbox* list = dynamic_cast<gui2::listbox*>(w))
|
||||
#endif
|
||||
{
|
||||
list->remove_row(pos, number);
|
||||
} else if(gui2::multi_page* multi_page = dynamic_cast<gui2::multi_page*>(w)) {
|
||||
|
@ -773,23 +752,10 @@ int intf_set_dialog_callback(lua_State* L)
|
|||
connect_signal_notify_modified(dynamic_cast<gui2::widget&>(*si), std::bind(dialog_callback, _1));
|
||||
} else if(gui2::integer_selector* is = dynamic_cast<gui2::integer_selector*>(w)) {
|
||||
connect_signal_notify_modified(dynamic_cast<gui2::widget&>(*is), std::bind(dialog_callback, _1));
|
||||
}
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
else if(gui2::list_view* l = dynamic_cast<gui2::list_view*>(w)) {
|
||||
static dialog_callback_wrapper wrapper;
|
||||
connect_signal_notify_modified(*l
|
||||
, std::bind(
|
||||
&dialog_callback_wrapper::forward
|
||||
, wrapper
|
||||
, w));
|
||||
}
|
||||
#else
|
||||
else if(gui2::listbox* l = dynamic_cast<gui2::listbox*>(w)) {
|
||||
} else if(gui2::listbox* l = dynamic_cast<gui2::listbox*>(w)) {
|
||||
static dialog_callback_wrapper wrapper;
|
||||
connect_signal_notify_modified(*l, std::bind(&dialog_callback_wrapper::forward, wrapper, w));
|
||||
}
|
||||
#endif
|
||||
else if(gui2::tree_view* tv = dynamic_cast<gui2::tree_view*>(w)) {
|
||||
} else if(gui2::tree_view* tv = dynamic_cast<gui2::tree_view*>(w)) {
|
||||
tv->set_selection_change_callback(&dialog_callback);
|
||||
} else {
|
||||
return luaL_argerror(L, lua_gettop(L), "unsupported widget");
|
||||
|
|
Loading…
Add table
Reference in a new issue