mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-24 20:26:23 +00:00
GUI1: Remove CVideo from widget constructor
This commit is contained in:
parent
1fea22a51d
commit
fa3315b520
@ -891,7 +891,7 @@ void display::create_buttons()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto b = std::make_shared<gui::button>(screen_, menu.title(), gui::button::TYPE_PRESS, menu.image(),
|
auto b = std::make_shared<gui::button>(menu.title(), gui::button::TYPE_PRESS, menu.image(),
|
||||||
gui::button::DEFAULT_SPACE, true, menu.overlay(), font::SIZE_BUTTON_SMALL);
|
gui::button::DEFAULT_SPACE, true, menu.overlay(), font::SIZE_BUTTON_SMALL);
|
||||||
|
|
||||||
DBG_DP << "drawing button " << menu.get_id();
|
DBG_DP << "drawing button " << menu.get_id();
|
||||||
@ -909,7 +909,7 @@ void display::create_buttons()
|
|||||||
|
|
||||||
DBG_DP << "creating action buttons...";
|
DBG_DP << "creating action buttons...";
|
||||||
for(const auto& action : theme_.actions()) {
|
for(const auto& action : theme_.actions()) {
|
||||||
auto b = std::make_shared<gui::button>(screen_, action.title(), string_to_button_type(action.type()),
|
auto b = std::make_shared<gui::button>(action.title(), string_to_button_type(action.type()),
|
||||||
action.image(), gui::button::DEFAULT_SPACE, true, action.overlay(), font::SIZE_BUTTON_SMALL);
|
action.image(), gui::button::DEFAULT_SPACE, true, action.overlay(), font::SIZE_BUTTON_SMALL);
|
||||||
|
|
||||||
DBG_DP << "drawing button " << action.get_id();
|
DBG_DP << "drawing button " << action.get_id();
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include "widgets/widget.hpp"
|
#include "widgets/widget.hpp"
|
||||||
|
|
||||||
struct SDL_Rect;
|
struct SDL_Rect;
|
||||||
class CVideo;
|
|
||||||
|
|
||||||
namespace editor {
|
namespace editor {
|
||||||
|
|
||||||
@ -47,7 +46,7 @@ class common_palette : public gui::widget {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
common_palette(CVideo& video) : gui::widget(video, true) {}
|
common_palette() : gui::widget(true) {}
|
||||||
|
|
||||||
virtual ~common_palette() {}
|
virtual ~common_palette() {}
|
||||||
|
|
||||||
@ -91,8 +90,8 @@ public:
|
|||||||
class tristate_palette : public common_palette
|
class tristate_palette : public common_palette
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
tristate_palette(CVideo& video)
|
tristate_palette()
|
||||||
: common_palette(video)
|
: common_palette()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
virtual void select_fg_item(const std::string& item_id) = 0;
|
virtual void select_fg_item(const std::string& item_id) = 0;
|
||||||
|
@ -173,7 +173,7 @@ void editor_palette<Item>::adjust_size(const SDL_Rect& target)
|
|||||||
if(items_fitting > 0) {
|
if(items_fitting > 0) {
|
||||||
const auto buttons_needed = static_cast<std::size_t>(items_fitting);
|
const auto buttons_needed = static_cast<std::size_t>(items_fitting);
|
||||||
if(buttons_.size() != buttons_needed) {
|
if(buttons_.size() != buttons_needed) {
|
||||||
buttons_.resize(buttons_needed, gui::tristate_button(gui_.video(), this));
|
buttons_.resize(buttons_needed, gui::tristate_button(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ public:
|
|||||||
|
|
||||||
editor_palette(editor_display &gui, const game_config_view& /*cfg*/
|
editor_palette(editor_display &gui, const game_config_view& /*cfg*/
|
||||||
, std::size_t item_size, std::size_t columns, editor_toolkit &toolkit)
|
, std::size_t item_size, std::size_t columns, editor_toolkit &toolkit)
|
||||||
: tristate_palette(gui.video())
|
: tristate_palette()
|
||||||
, groups_()
|
, groups_()
|
||||||
, gui_(gui)
|
, gui_(gui)
|
||||||
, item_size_(item_size)
|
, item_size_(item_size)
|
||||||
|
@ -29,7 +29,7 @@ class empty_palette : public common_palette {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
empty_palette(display& gui) :
|
empty_palette(display& gui) :
|
||||||
common_palette(gui.video()),
|
common_palette(),
|
||||||
gui_(gui) {}
|
gui_(gui) {}
|
||||||
|
|
||||||
//event handling
|
//event handling
|
||||||
|
@ -50,8 +50,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
location_palette_item(CVideo& video, editor::location_palette* parent)
|
location_palette_item(editor::location_palette* parent)
|
||||||
: gui::widget(video, true)
|
: gui::widget(true)
|
||||||
, parent_(parent)
|
, parent_(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -137,8 +137,8 @@ private:
|
|||||||
class location_palette_button : public gui::button
|
class location_palette_button : public gui::button
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
location_palette_button(CVideo& video, const SDL_Rect& location, const std::string& text, const std::function<void (void)>& callback)
|
location_palette_button(const SDL_Rect& location, const std::string& text, const std::function<void (void)>& callback)
|
||||||
: gui::button(video, text)
|
: gui::button(text)
|
||||||
, callback_(callback)
|
, callback_(callback)
|
||||||
{
|
{
|
||||||
this->set_location(location.x, location.y);
|
this->set_location(location.x, location.y);
|
||||||
@ -160,7 +160,7 @@ protected:
|
|||||||
namespace editor {
|
namespace editor {
|
||||||
location_palette::location_palette(editor_display &gui, const game_config_view& /*cfg*/,
|
location_palette::location_palette(editor_display &gui, const game_config_view& /*cfg*/,
|
||||||
editor_toolkit &toolkit)
|
editor_toolkit &toolkit)
|
||||||
: common_palette(gui.video())
|
: common_palette()
|
||||||
, item_size_(20)
|
, item_size_(20)
|
||||||
//TODO avoid magic number
|
//TODO avoid magic number
|
||||||
, item_space_(20 + 3)
|
, item_space_(20 + 3)
|
||||||
@ -247,14 +247,14 @@ void location_palette::adjust_size(const SDL_Rect& target)
|
|||||||
const int button_y = 30;
|
const int button_y = 30;
|
||||||
int bottom = target.y + target.h;
|
int bottom = target.y + target.h;
|
||||||
if (!button_goto_) {
|
if (!button_goto_) {
|
||||||
button_goto_.reset(new location_palette_button(video(), SDL_Rect{ target.x , bottom -= button_y, target.w - 10, button_height }, _("Go To"), [this]() {
|
button_goto_.reset(new location_palette_button(SDL_Rect{ target.x , bottom -= button_y, target.w - 10, button_height }, _("Go To"), [this]() {
|
||||||
//static_cast<mouse_action_starting_position&>(toolkit_.get_mouse_action()). ??
|
//static_cast<mouse_action_starting_position&>(toolkit_.get_mouse_action()). ??
|
||||||
map_location pos = disp_.get_map().special_location(selected_item_);
|
map_location pos = disp_.get_map().special_location(selected_item_);
|
||||||
if (pos.valid()) {
|
if (pos.valid()) {
|
||||||
disp_.scroll_to_tile(pos, display::WARP);
|
disp_.scroll_to_tile(pos, display::WARP);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
button_add_.reset(new location_palette_button(video(), SDL_Rect{ target.x , bottom -= button_y, target.w - 10, button_height }, _("Add"), [this]() {
|
button_add_.reset(new location_palette_button(SDL_Rect{ target.x , bottom -= button_y, target.w - 10, button_height }, _("Add"), [this]() {
|
||||||
std::string newid;
|
std::string newid;
|
||||||
if (gui2::dialogs::edit_text::execute(_("New Location Identifier"), "", newid)) {
|
if (gui2::dialogs::edit_text::execute(_("New Location Identifier"), "", newid)) {
|
||||||
static const boost::regex valid_id("[a-zA-Z0-9_]+");
|
static const boost::regex valid_id("[a-zA-Z0-9_]+");
|
||||||
@ -271,7 +271,7 @@ void location_palette::adjust_size(const SDL_Rect& target)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
button_delete_.reset(new location_palette_button(video(), SDL_Rect{ target.x , bottom -= button_y, target.w - 10, button_height }, _("Delete"), nullptr));
|
button_delete_.reset(new location_palette_button(SDL_Rect{ target.x , bottom -= button_y, target.w - 10, button_height }, _("Delete"), nullptr));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
button_goto_->set_location(SDL_Rect{ target.x , bottom -= button_y, target.w - 10, button_height });
|
button_goto_->set_location(SDL_Rect{ target.x , bottom -= button_y, target.w - 10, button_height });
|
||||||
@ -290,7 +290,7 @@ void location_palette::adjust_size(const SDL_Rect& target)
|
|||||||
// This simplifies the scrolling code in add_item.
|
// This simplifies the scrolling code in add_item.
|
||||||
const std::size_t buttons_needed = items_fitting;
|
const std::size_t buttons_needed = items_fitting;
|
||||||
if(buttons_.size() != buttons_needed) {
|
if(buttons_.size() != buttons_needed) {
|
||||||
location_palette_item lpi(disp_.video(), this);
|
location_palette_item lpi(this);
|
||||||
buttons_.resize(buttons_needed, lpi);
|
buttons_.resize(buttons_needed, lpi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ namespace editor {
|
|||||||
|
|
||||||
palette_manager::palette_manager(editor_display& gui, const game_config_view& cfg
|
palette_manager::palette_manager(editor_display& gui, const game_config_view& cfg
|
||||||
, editor_toolkit& toolkit)
|
, editor_toolkit& toolkit)
|
||||||
: gui::widget(gui.video()),
|
: gui::widget(),
|
||||||
gui_(gui),
|
gui_(gui),
|
||||||
palette_start_(0),
|
palette_start_(0),
|
||||||
toolkit_(toolkit),
|
toolkit_(toolkit),
|
||||||
|
@ -23,18 +23,17 @@
|
|||||||
#include "log.hpp"
|
#include "log.hpp"
|
||||||
#include "sdl/rect.hpp"
|
#include "sdl/rect.hpp"
|
||||||
#include "sound.hpp"
|
#include "sound.hpp"
|
||||||
#include "video.hpp" // TODO: highdpi - only needed for widget constructor
|
|
||||||
|
|
||||||
static lg::log_domain log_display("display");
|
static lg::log_domain log_display("display");
|
||||||
#define ERR_DP LOG_STREAM(err, log_display)
|
#define ERR_DP LOG_STREAM(err, log_display)
|
||||||
|
|
||||||
namespace gui {
|
namespace gui {
|
||||||
|
|
||||||
tristate_button::tristate_button(CVideo& video,
|
tristate_button::tristate_button(
|
||||||
editor::tristate_palette* palette,
|
editor::tristate_palette* palette,
|
||||||
std::string button_image_name,
|
std::string button_image_name,
|
||||||
const bool auto_join)
|
const bool auto_join)
|
||||||
: widget(video, auto_join)
|
: widget(auto_join)
|
||||||
, baseImage_()
|
, baseImage_()
|
||||||
, touchedBaseImage_()
|
, touchedBaseImage_()
|
||||||
, activeBaseImage_()
|
, activeBaseImage_()
|
||||||
|
@ -37,7 +37,7 @@ public:
|
|||||||
|
|
||||||
enum PRESSED_STATE { LEFT, RIGHT, BOTH, NONE };
|
enum PRESSED_STATE { LEFT, RIGHT, BOTH, NONE };
|
||||||
|
|
||||||
tristate_button(CVideo& video,
|
tristate_button(
|
||||||
editor::tristate_palette* palette,
|
editor::tristate_palette* palette,
|
||||||
std::string button_image="",
|
std::string button_image="",
|
||||||
const bool auto_join=true);
|
const bool auto_join=true);
|
||||||
|
@ -112,12 +112,12 @@ namespace gui{
|
|||||||
mode_ = mode;
|
mode_ = mode;
|
||||||
|
|
||||||
if(!check_label.empty()) {
|
if(!check_label.empty()) {
|
||||||
check_.reset(new gui::button(gui.video(),check_label,gui::button::TYPE_CHECK));
|
check_.reset(new gui::button(check_label,gui::button::TYPE_CHECK));
|
||||||
check_->set_check(checked);
|
check_->set_check(checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
box_.reset(new gui::textbox(gui.video(),100,"",true,256,font::SIZE_NORMAL,0.8,0.6));
|
box_.reset(new gui::textbox(100,"",true,256,font::SIZE_NORMAL,0.8,0.6));
|
||||||
|
|
||||||
update_location(gui);
|
update_location(gui);
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
#include "terrain/terrain.hpp" // for terrain_type
|
#include "terrain/terrain.hpp" // for terrain_type
|
||||||
#include "units/unit.hpp" // for unit
|
#include "units/unit.hpp" // for unit
|
||||||
#include "units/types.hpp" // for unit_type, unit_type_data, etc
|
#include "units/types.hpp" // for unit_type, unit_type_data, etc
|
||||||
#include "video.hpp" // for CVideo, resize_lock
|
#include "video.hpp" // TODO: draw_manager - only for draw_area
|
||||||
#include "widgets/button.hpp" // for button
|
#include "widgets/button.hpp" // for button
|
||||||
|
|
||||||
#include <cassert> // for assert
|
#include <cassert> // for assert
|
||||||
@ -189,12 +189,10 @@ void show_with_toplevel(const section &toplevel_sec,
|
|||||||
const std::string& show_topic,
|
const std::string& show_topic,
|
||||||
int xloc, int yloc)
|
int xloc, int yloc)
|
||||||
{
|
{
|
||||||
CVideo& video = CVideo::get_singleton();
|
|
||||||
|
|
||||||
const events::event_context dialog_events_context;
|
const events::event_context dialog_events_context;
|
||||||
const gui::dialog_manager manager;
|
const gui::dialog_manager manager;
|
||||||
|
|
||||||
SDL_Rect draw_area = video.draw_area();
|
SDL_Rect draw_area = CVideo::get_singleton().draw_area();
|
||||||
|
|
||||||
const int width = std::min<int>(font::relative_size(1200), draw_area.w - font::relative_size(20));
|
const int width = std::min<int>(font::relative_size(1200), draw_area.w - font::relative_size(20));
|
||||||
const int height = std::min<int>(font::relative_size(850), draw_area.h - font::relative_size(150));
|
const int height = std::min<int>(font::relative_size(850), draw_area.h - font::relative_size(150));
|
||||||
@ -210,11 +208,11 @@ void show_with_toplevel(const section &toplevel_sec,
|
|||||||
yloc = draw_area.h / 2 - height / 2;
|
yloc = draw_area.h / 2 - height / 2;
|
||||||
}
|
}
|
||||||
std::vector<gui::button*> buttons_ptr;
|
std::vector<gui::button*> buttons_ptr;
|
||||||
gui::button close_button_(video, _("Close"));
|
gui::button close_button_(_("Close"));
|
||||||
buttons_ptr.push_back(&close_button_);
|
buttons_ptr.push_back(&close_button_);
|
||||||
|
|
||||||
gui::dialog_frame f(
|
gui::dialog_frame f(
|
||||||
video, _("Help"), gui::dialog_frame::default_style, &buttons_ptr
|
_("Help"), gui::dialog_frame::default_style, &buttons_ptr
|
||||||
);
|
);
|
||||||
f.layout(xloc, yloc, width, height);
|
f.layout(xloc, yloc, width, height);
|
||||||
|
|
||||||
@ -234,7 +232,7 @@ void show_with_toplevel(const section &toplevel_sec,
|
|||||||
generate_contents();
|
generate_contents();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
help_browser hb(video, toplevel_sec);
|
help_browser hb(toplevel_sec);
|
||||||
hb.set_location(xloc + left_padding, yloc + top_padding);
|
hb.set_location(xloc + left_padding, yloc + top_padding);
|
||||||
hb.set_width(width - left_padding - right_padding);
|
hb.set_width(width - left_padding - right_padding);
|
||||||
hb.set_height(height - top_padding - bot_padding);
|
hb.set_height(height - top_padding - bot_padding);
|
||||||
|
@ -19,7 +19,6 @@ class config;
|
|||||||
class terrain_type;
|
class terrain_type;
|
||||||
class unit;
|
class unit;
|
||||||
class unit_type;
|
class unit_type;
|
||||||
class CVideo;
|
|
||||||
class game_config_view;
|
class game_config_view;
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -25,21 +25,19 @@
|
|||||||
#include "sdl/rect.hpp"
|
#include "sdl/rect.hpp"
|
||||||
#include "sdl/input.hpp" // for get_mouse_state
|
#include "sdl/input.hpp" // for get_mouse_state
|
||||||
|
|
||||||
class CVideo;
|
|
||||||
struct SDL_Rect;
|
struct SDL_Rect;
|
||||||
|
|
||||||
namespace help {
|
namespace help {
|
||||||
|
|
||||||
help_browser::help_browser(CVideo& video, const section &toplevel) :
|
help_browser::help_browser(const section &toplevel) :
|
||||||
gui::widget(video),
|
gui::widget(),
|
||||||
menu_(video,
|
menu_(toplevel),
|
||||||
toplevel),
|
text_area_(toplevel), toplevel_(toplevel),
|
||||||
text_area_(video, toplevel), toplevel_(toplevel),
|
|
||||||
ref_cursor_(false),
|
ref_cursor_(false),
|
||||||
back_topics_(),
|
back_topics_(),
|
||||||
forward_topics_(),
|
forward_topics_(),
|
||||||
back_button_(video, "", gui::button::TYPE_PRESS, "button_normal/button_small_H22", gui::button::DEFAULT_SPACE, true, "icons/arrows/long_arrow_ornate_left"),
|
back_button_("", gui::button::TYPE_PRESS, "button_normal/button_small_H22", gui::button::DEFAULT_SPACE, true, "icons/arrows/long_arrow_ornate_left"),
|
||||||
forward_button_(video, "", gui::button::TYPE_PRESS, "button_normal/button_small_H22", gui::button::DEFAULT_SPACE, true, "icons/arrows/long_arrow_ornate_right"),
|
forward_button_("", gui::button::TYPE_PRESS, "button_normal/button_small_H22", gui::button::DEFAULT_SPACE, true, "icons/arrows/long_arrow_ornate_right"),
|
||||||
shown_topic_(nullptr)
|
shown_topic_(nullptr)
|
||||||
{
|
{
|
||||||
// Hide the buttons at first since we do not have any forward or
|
// Hide the buttons at first since we do not have any forward or
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include "help_text_area.hpp" // for help_text_area
|
#include "help_text_area.hpp" // for help_text_area
|
||||||
#include "widgets/button.hpp" // for button
|
#include "widgets/button.hpp" // for button
|
||||||
#include "widgets/widget.hpp" // for widget
|
#include "widgets/widget.hpp" // for widget
|
||||||
class CVideo; // lines 18-18
|
|
||||||
struct SDL_Rect;
|
struct SDL_Rect;
|
||||||
|
|
||||||
namespace help {
|
namespace help {
|
||||||
@ -31,7 +31,7 @@ namespace help {
|
|||||||
class help_browser : public gui::widget
|
class help_browser : public gui::widget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
help_browser(CVideo& video, const section &toplevel);
|
help_browser(const section &toplevel);
|
||||||
|
|
||||||
void adjust_layout();
|
void adjust_layout();
|
||||||
|
|
||||||
|
@ -26,12 +26,10 @@
|
|||||||
#include <utility> // for pair
|
#include <utility> // for pair
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
|
|
||||||
class CVideo; // lines 56-56
|
|
||||||
|
|
||||||
namespace help {
|
namespace help {
|
||||||
|
|
||||||
help_menu::help_menu(CVideo &video, const section& toplevel, int max_height) :
|
help_menu::help_menu(const section& toplevel, int max_height) :
|
||||||
gui::menu(video, empty_string_vector, true, max_height, -1, nullptr, &gui::menu::bluebg_style),
|
gui::menu(empty_string_vector, true, max_height, -1, nullptr, &gui::menu::bluebg_style),
|
||||||
visible_items_(),
|
visible_items_(),
|
||||||
toplevel_(toplevel),
|
toplevel_(toplevel),
|
||||||
expanded_(),
|
expanded_(),
|
||||||
|
@ -20,8 +20,6 @@
|
|||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
#include "widgets/menu.hpp" // for menu
|
#include "widgets/menu.hpp" // for menu
|
||||||
|
|
||||||
class CVideo;
|
|
||||||
|
|
||||||
namespace help { struct section; }
|
namespace help { struct section; }
|
||||||
namespace help { struct topic; }
|
namespace help { struct topic; }
|
||||||
|
|
||||||
@ -34,7 +32,7 @@ namespace help {
|
|||||||
class help_menu : public gui::menu
|
class help_menu : public gui::menu
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
help_menu(CVideo &video, const section &toplevel, int max_height=-1);
|
help_menu(const section &toplevel, int max_height=-1);
|
||||||
int process();
|
int process();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#include "sdl/rect.hpp" // for draw_rectangle, etc
|
#include "sdl/rect.hpp" // for draw_rectangle, etc
|
||||||
#include "sdl/texture.hpp" // for texture
|
#include "sdl/texture.hpp" // for texture
|
||||||
#include "serialization/parser.hpp" // for read, write
|
#include "serialization/parser.hpp" // for read, write
|
||||||
#include "video.hpp" // for CVideo
|
|
||||||
|
|
||||||
#include <algorithm> // for max, min, find_if
|
#include <algorithm> // for max, min, find_if
|
||||||
#include <ostream> // for operator<<, stringstream, etc
|
#include <ostream> // for operator<<, stringstream, etc
|
||||||
@ -43,8 +42,8 @@ static lg::log_domain log_help("help");
|
|||||||
|
|
||||||
namespace help {
|
namespace help {
|
||||||
|
|
||||||
help_text_area::help_text_area(CVideo &video, const section &toplevel) :
|
help_text_area::help_text_area(const section &toplevel) :
|
||||||
gui::scrollarea(video),
|
gui::scrollarea(),
|
||||||
items_(),
|
items_(),
|
||||||
last_row_(),
|
last_row_(),
|
||||||
toplevel_(toplevel),
|
toplevel_(toplevel),
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include "font/standard_colors.hpp" // for NORMAL_COLOR
|
#include "font/standard_colors.hpp" // for NORMAL_COLOR
|
||||||
#include "sdl/texture.hpp" // for texture
|
#include "sdl/texture.hpp" // for texture
|
||||||
#include "widgets/scrollarea.hpp" // for scrollarea
|
#include "widgets/scrollarea.hpp" // for scrollarea
|
||||||
class CVideo;
|
|
||||||
class config;
|
class config;
|
||||||
namespace help { struct section; }
|
namespace help { struct section; }
|
||||||
namespace help { struct topic; }
|
namespace help { struct topic; }
|
||||||
@ -33,7 +33,7 @@ namespace help {
|
|||||||
class help_text_area : public gui::scrollarea
|
class help_text_area : public gui::scrollarea
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
help_text_area(CVideo &video, const section &toplevel);
|
help_text_area(const section &toplevel);
|
||||||
/** Display the topic. */
|
/** Display the topic. */
|
||||||
void show_topic(const topic &t);
|
void show_topic(const topic &t);
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include "tstring.hpp" // for t_string, operator<<
|
#include "tstring.hpp" // for t_string, operator<<
|
||||||
#include "units/helper.hpp" // for resistance_color
|
#include "units/helper.hpp" // for resistance_color
|
||||||
#include "units/types.hpp" // for unit_type, unit_type_data, etc
|
#include "units/types.hpp" // for unit_type, unit_type_data, etc
|
||||||
#include "video.hpp" // fore current_resolution
|
#include "video.hpp" // TODO: draw_manager - only draw_area
|
||||||
|
|
||||||
#include <map> // for map, etc
|
#include <map> // for map, etc
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "sdl/rect.hpp"
|
#include "sdl/rect.hpp"
|
||||||
#include "sdl/input.hpp" // get_mouse_state
|
#include "sdl/input.hpp" // get_mouse_state
|
||||||
#include "sdl/utils.hpp" // blur_surface
|
#include "sdl/utils.hpp" // blur_surface
|
||||||
|
#include "video.hpp"
|
||||||
|
|
||||||
static lg::log_domain log_display("display");
|
static lg::log_domain log_display("display");
|
||||||
#define ERR_DP LOG_STREAM(err, log_display)
|
#define ERR_DP LOG_STREAM(err, log_display)
|
||||||
@ -81,11 +82,11 @@ dialog_manager::~dialog_manager()
|
|||||||
SDL_PushEvent(&pb_event);
|
SDL_PushEvent(&pb_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog_frame::dialog_frame(CVideo& video, const std::string& title,
|
dialog_frame::dialog_frame(const std::string& title,
|
||||||
const style& style,
|
const style& style,
|
||||||
std::vector<button*>* buttons, button* help_button) :
|
std::vector<button*>* buttons, button* help_button) :
|
||||||
title_(title),
|
title_(title),
|
||||||
video_(video),
|
video_(CVideo::get_singleton()),
|
||||||
dialog_style_(style),
|
dialog_style_(style),
|
||||||
buttons_(buttons),
|
buttons_(buttons),
|
||||||
help_button_(help_button),
|
help_button_(help_button),
|
||||||
@ -316,7 +317,7 @@ void dialog_frame::draw_background()
|
|||||||
|
|
||||||
SDL_Rect dialog_frame::draw_title(CVideo* video)
|
SDL_Rect dialog_frame::draw_title(CVideo* video)
|
||||||
{
|
{
|
||||||
SDL_Rect rect = CVideo::get_singleton().draw_area();
|
SDL_Rect rect = video_.draw_area();
|
||||||
return font::pango_draw_text(video, rect, font::SIZE_TITLE, font::TITLE_COLOR,
|
return font::pango_draw_text(video, rect, font::SIZE_TITLE, font::TITLE_COLOR,
|
||||||
title_, dim_.title.x, dim_.title.y, false, font::pango_text::STYLE_NORMAL);
|
title_, dim_.title.x, dim_.title.y, false, font::pango_text::STYLE_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,10 @@ class surface;
|
|||||||
#include "floating_label.hpp"
|
#include "floating_label.hpp"
|
||||||
#include "gui/core/top_level_drawable.hpp"
|
#include "gui/core/top_level_drawable.hpp"
|
||||||
#include "tooltips.hpp"
|
#include "tooltips.hpp"
|
||||||
#include "video.hpp"
|
|
||||||
#include "widgets/button.hpp"
|
#include "widgets/button.hpp"
|
||||||
|
|
||||||
|
class CVideo;
|
||||||
|
|
||||||
namespace gui
|
namespace gui
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ public:
|
|||||||
static const int title_border_w, title_border_h;
|
static const int title_border_w, title_border_h;
|
||||||
static const style default_style;
|
static const style default_style;
|
||||||
|
|
||||||
dialog_frame(CVideo &video, const std::string& title="",
|
dialog_frame(const std::string& title="",
|
||||||
const style& dialog_style=default_style,
|
const style& dialog_style=default_style,
|
||||||
std::vector<button*>* buttons=nullptr,
|
std::vector<button*>* buttons=nullptr,
|
||||||
button* help_button=nullptr);
|
button* help_button=nullptr);
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include "sdl/rect.hpp"
|
#include "sdl/rect.hpp"
|
||||||
#include "serialization/string_utils.hpp"
|
#include "serialization/string_utils.hpp"
|
||||||
#include "sound.hpp"
|
#include "sound.hpp"
|
||||||
#include "video.hpp"
|
#include "video.hpp" // TODO: draw_manager - only needed for draw_area()
|
||||||
#include "wml_separators.hpp"
|
#include "wml_separators.hpp"
|
||||||
|
|
||||||
#include <boost/algorithm/string/predicate.hpp>
|
#include <boost/algorithm/string/predicate.hpp>
|
||||||
@ -40,10 +40,10 @@ namespace gui {
|
|||||||
|
|
||||||
const int default_font_size = font::SIZE_BUTTON;
|
const int default_font_size = font::SIZE_BUTTON;
|
||||||
|
|
||||||
button::button(CVideo& video, const std::string& label, button::TYPE type,
|
button::button(const std::string& label, button::TYPE type,
|
||||||
std::string button_image_name, SPACE_CONSUMPTION spacing,
|
std::string button_image_name, SPACE_CONSUMPTION spacing,
|
||||||
const bool auto_join, std::string overlay_image, int font_size)
|
const bool auto_join, std::string overlay_image, int font_size)
|
||||||
: widget(video, auto_join), type_(type),
|
: widget(auto_join), type_(type),
|
||||||
label_text_(label),
|
label_text_(label),
|
||||||
image_(nullptr), pressedImage_(nullptr), activeImage_(nullptr), pressedActiveImage_(nullptr),
|
image_(nullptr), pressedImage_(nullptr), activeImage_(nullptr), pressedActiveImage_(nullptr),
|
||||||
disabledImage_(nullptr), pressedDisabledImage_(nullptr),
|
disabledImage_(nullptr), pressedDisabledImage_(nullptr),
|
||||||
|
@ -62,7 +62,7 @@ public:
|
|||||||
|
|
||||||
enum SPACE_CONSUMPTION { DEFAULT_SPACE, MINIMUM_SPACE };
|
enum SPACE_CONSUMPTION { DEFAULT_SPACE, MINIMUM_SPACE };
|
||||||
|
|
||||||
button(CVideo& video, const std::string& label, TYPE type=TYPE_PRESS,
|
button(const std::string& label, TYPE type=TYPE_PRESS,
|
||||||
std::string button_image="", SPACE_CONSUMPTION spacing=DEFAULT_SPACE,
|
std::string button_image="", SPACE_CONSUMPTION spacing=DEFAULT_SPACE,
|
||||||
const bool auto_join=true, std::string overlay_image="", int font_size = -1);
|
const bool auto_join=true, std::string overlay_image="", int font_size = -1);
|
||||||
|
|
||||||
|
@ -147,10 +147,10 @@ bool menu::basic_sorter::less(int column, const item& row1, const item& row2) co
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
menu::menu(CVideo& video, const std::vector<std::string>& items,
|
menu::menu(const std::vector<std::string>& items,
|
||||||
bool click_selects, int max_height, int max_width,
|
bool click_selects, int max_height, int max_width,
|
||||||
const sorter* sorter_obj, style *menu_style, const bool auto_join)
|
const sorter* sorter_obj, style *menu_style, const bool auto_join)
|
||||||
: scrollarea(video, auto_join), silent_(false),
|
: scrollarea(auto_join), silent_(false),
|
||||||
max_height_(max_height), max_width_(max_width),
|
max_height_(max_height), max_width_(max_width),
|
||||||
max_items_(-1), item_height_(-1),
|
max_items_(-1), item_height_(-1),
|
||||||
heading_height_(-1),
|
heading_height_(-1),
|
||||||
|
@ -137,7 +137,7 @@ public:
|
|||||||
std::map<int,std::vector<int>> pos_sort_;
|
std::map<int,std::vector<int>> pos_sort_;
|
||||||
};
|
};
|
||||||
|
|
||||||
menu(CVideo& video, const std::vector<std::string>& items,
|
menu(const std::vector<std::string>& items,
|
||||||
bool click_selects=false, int max_height=-1, int max_width=-1,
|
bool click_selects=false, int max_height=-1, int max_width=-1,
|
||||||
const sorter* sorter_obj=nullptr, style *menu_style=nullptr, const bool auto_join=true);
|
const sorter* sorter_obj=nullptr, style *menu_style=nullptr, const bool auto_join=true);
|
||||||
|
|
||||||
|
@ -17,13 +17,13 @@
|
|||||||
|
|
||||||
#include "widgets/scrollarea.hpp"
|
#include "widgets/scrollarea.hpp"
|
||||||
#include "sdl/rect.hpp"
|
#include "sdl/rect.hpp"
|
||||||
#include "video.hpp"
|
#include "video.hpp" // TODO: draw_manager - only needed for draw_area()
|
||||||
#include "sdl/input.hpp" // get_mouse_state
|
#include "sdl/input.hpp" // get_mouse_state
|
||||||
|
|
||||||
namespace gui {
|
namespace gui {
|
||||||
|
|
||||||
scrollarea::scrollarea(CVideo &video, const bool auto_join)
|
scrollarea::scrollarea(const bool auto_join)
|
||||||
: widget(video, auto_join), scrollbar_(video),
|
: widget(auto_join), scrollbar_(),
|
||||||
old_position_(0), recursive_(false), shown_scrollbar_(false),
|
old_position_(0), recursive_(false), shown_scrollbar_(false),
|
||||||
shown_size_(0), full_size_(0), swipe_dy_(0)
|
shown_size_(0), full_size_(0), swipe_dy_(0)
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
//- \param d the display object
|
//- \param d the display object
|
||||||
//- \param pane the widget where wheel events take place
|
//- \param pane the widget where wheel events take place
|
||||||
scrollarea(CVideo &video, bool auto_join=true);
|
scrollarea(bool auto_join=true);
|
||||||
|
|
||||||
virtual void hide(bool value = true);
|
virtual void hide(bool value = true);
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include "sdl/rect.hpp"
|
#include "sdl/rect.hpp"
|
||||||
#include "sdl/texture.hpp"
|
#include "sdl/texture.hpp"
|
||||||
#include "sdl/utils.hpp"
|
#include "sdl/utils.hpp"
|
||||||
#include "video.hpp"
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -44,8 +43,8 @@ const std::string scrollbar_mid_pressed = "buttons/scrollbars/scrollmid-pressed.
|
|||||||
|
|
||||||
namespace gui {
|
namespace gui {
|
||||||
|
|
||||||
scrollbar::scrollbar(CVideo &video)
|
scrollbar::scrollbar()
|
||||||
: widget(video)
|
: widget()
|
||||||
, state_(NORMAL)
|
, state_(NORMAL)
|
||||||
, minimum_grip_height_(0)
|
, minimum_grip_height_(0)
|
||||||
, mousey_on_grip_(0)
|
, mousey_on_grip_(0)
|
||||||
|
@ -33,7 +33,7 @@ public:
|
|||||||
//- @param d the display object
|
//- @param d the display object
|
||||||
//- @param pane the widget where wheel events take place
|
//- @param pane the widget where wheel events take place
|
||||||
//- @param callback a callback interface for warning that the grip has been moved
|
//- @param callback a callback interface for warning that the grip has been moved
|
||||||
scrollbar(CVideo &video);
|
scrollbar();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine where the scrollbar is.
|
* Determine where the scrollbar is.
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include "log.hpp"
|
#include "log.hpp"
|
||||||
#include "sdl/rect.hpp"
|
#include "sdl/rect.hpp"
|
||||||
#include "serialization/string_utils.hpp"
|
#include "serialization/string_utils.hpp"
|
||||||
#include "video.hpp"
|
#include "video.hpp" // TODO: draw_manager - only needed for pixel scale
|
||||||
#include "sdl/input.hpp" // get_mouse_state
|
#include "sdl/input.hpp" // get_mouse_state
|
||||||
|
|
||||||
static lg::log_domain log_display("display");
|
static lg::log_domain log_display("display");
|
||||||
@ -33,8 +33,8 @@ static lg::log_domain log_display("display");
|
|||||||
|
|
||||||
namespace gui {
|
namespace gui {
|
||||||
|
|
||||||
textbox::textbox(CVideo &video, int width, const std::string& text, bool editable, std::size_t max_size, int font_size, double alpha, double alpha_focus, const bool auto_join)
|
textbox::textbox(int width, const std::string& text, bool editable, std::size_t max_size, int font_size, double alpha, double alpha_focus, const bool auto_join)
|
||||||
: scrollarea(video, auto_join), max_size_(max_size), font_size_(font_size), text_(unicode_cast<std::u32string>(text)),
|
: scrollarea(auto_join), max_size_(max_size), font_size_(font_size), text_(unicode_cast<std::u32string>(text)),
|
||||||
cursor_(text_.size()), selstart_(-1), selend_(-1),
|
cursor_(text_.size()), selstart_(-1), selend_(-1),
|
||||||
grabmouse_(false), text_pos_(0), editable_(editable),
|
grabmouse_(false), text_pos_(0), editable_(editable),
|
||||||
show_cursor_(true), show_cursor_at_(0), text_image_(nullptr),
|
show_cursor_(true), show_cursor_at_(0), text_image_(nullptr),
|
||||||
|
@ -26,7 +26,7 @@ namespace gui {
|
|||||||
class textbox : public scrollarea
|
class textbox : public scrollarea
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
textbox(CVideo &video, int width, const std::string& text="", bool editable=true, std::size_t max_size = 256, int font_size = font::SIZE_PLUS, double alpha = 0.4, double alpha_focus = 0.2, const bool auto_join = true);
|
textbox(int width, const std::string& text="", bool editable=true, std::size_t max_size = 256, int font_size = font::SIZE_PLUS, double alpha = 0.4, double alpha_focus = 0.2, const bool auto_join = true);
|
||||||
virtual ~textbox();
|
virtual ~textbox();
|
||||||
|
|
||||||
const std::string text() const;
|
const std::string text() const;
|
||||||
|
@ -31,8 +31,8 @@ namespace gui {
|
|||||||
|
|
||||||
bool widget::mouse_lock_ = false;
|
bool widget::mouse_lock_ = false;
|
||||||
|
|
||||||
widget::widget(CVideo& video, const bool auto_join)
|
widget::widget(const bool auto_join)
|
||||||
: events::sdl_handler(auto_join), focus_(true), video_(&video), rect_(EmptyRect), needs_restore_(false),
|
: events::sdl_handler(auto_join), focus_(true), rect_(EmptyRect), needs_restore_(false),
|
||||||
state_(UNINIT), hidden_override_(false), enabled_(true), clip_(false),
|
state_(UNINIT), hidden_override_(false), enabled_(true), clip_(false),
|
||||||
clip_rect_(EmptyRect), help_string_(0), mouse_lock_local_(false)
|
clip_rect_(EmptyRect), help_string_(0), mouse_lock_local_(false)
|
||||||
{
|
{
|
||||||
@ -68,6 +68,12 @@ bool widget::mouse_locked() const
|
|||||||
return mouse_lock_ && !mouse_lock_local_;
|
return mouse_lock_ && !mouse_lock_local_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: draw_manager - overhaul CVideo interface
|
||||||
|
CVideo& widget::video() const
|
||||||
|
{
|
||||||
|
return CVideo::get_singleton();
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: draw_manager - kill surface restorers
|
// TODO: draw_manager - kill surface restorers
|
||||||
void widget::bg_cancel()
|
void widget::bg_cancel()
|
||||||
{
|
{
|
||||||
|
@ -69,7 +69,7 @@ public:
|
|||||||
virtual void process_tooltip_string(int mousex, int mousey) override;
|
virtual void process_tooltip_string(int mousex, int mousey) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
widget(CVideo& video, const bool auto_join=true);
|
widget(const bool auto_join=true);
|
||||||
virtual ~widget();
|
virtual ~widget();
|
||||||
|
|
||||||
// During each relocation, this function should be called to register
|
// During each relocation, this function should be called to register
|
||||||
@ -80,7 +80,7 @@ protected:
|
|||||||
void bg_update(); // TODO: draw_manager - remove
|
void bg_update(); // TODO: draw_manager - remove
|
||||||
void bg_cancel(); // TODO: draw_manager - remove
|
void bg_cancel(); // TODO: draw_manager - remove
|
||||||
|
|
||||||
CVideo& video() const { return *video_; }
|
CVideo& video() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/* draw_manager interface */
|
/* draw_manager interface */
|
||||||
@ -111,7 +111,6 @@ protected:
|
|||||||
private:
|
private:
|
||||||
void hide_override(bool value = true);
|
void hide_override(bool value = true);
|
||||||
|
|
||||||
CVideo* video_;
|
|
||||||
std::vector<rect> restorer_;
|
std::vector<rect> restorer_;
|
||||||
rect rect_;
|
rect rect_;
|
||||||
mutable bool needs_restore_; // Have we drawn ourselves, so that if moved, we need to restore the background?
|
mutable bool needs_restore_; // Have we drawn ourselves, so that if moved, we need to restore the background?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user