Code cleanup of the widget's code.
Improved function names, descriptions and ordering of the functions. Also added override markers for C++11.
This commit is contained in:
parent
7d78b028b4
commit
dcc6035b9f
62 changed files with 1400 additions and 1026 deletions
|
@ -40,6 +40,7 @@
|
||||||
#include "log.hpp"
|
#include "log.hpp"
|
||||||
#include "marked-up_text.hpp"
|
#include "marked-up_text.hpp"
|
||||||
#include "wml_separators.hpp"
|
#include "wml_separators.hpp"
|
||||||
|
#include "wml_exception.hpp"
|
||||||
|
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <boost/scoped_ptr.hpp>
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "gui/dialogs/message.hpp"
|
#include "gui/dialogs/message.hpp"
|
||||||
#include "gui/dialogs/transient_message.hpp"
|
#include "gui/dialogs/transient_message.hpp"
|
||||||
#include "gui/widgets/window.hpp"
|
#include "gui/widgets/window.hpp"
|
||||||
|
#include "wml_exception.hpp"
|
||||||
|
|
||||||
#include "../clipboard.hpp"
|
#include "../clipboard.hpp"
|
||||||
#include "../game_preferences.hpp"
|
#include "../game_preferences.hpp"
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "serialization/parser.hpp"
|
#include "serialization/parser.hpp"
|
||||||
#include "serialization/validator.hpp"
|
#include "serialization/validator.hpp"
|
||||||
#include "version.hpp"
|
#include "version.hpp"
|
||||||
|
#include "wml_exception.hpp"
|
||||||
|
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <clocale>
|
#include <clocale>
|
||||||
|
|
|
@ -104,10 +104,10 @@ public:
|
||||||
|
|
||||||
/***** ***** ***** setters / getters for members ***** ****** *****/
|
/***** ***** ***** setters / getters for members ***** ****** *****/
|
||||||
|
|
||||||
void set_width(const unsigned width) { w_ = width; set_dirty(); }
|
void set_width(const unsigned width) { w_ = width; set_dirty(true); }
|
||||||
unsigned get_width() const { return w_; }
|
unsigned get_width() const { return w_; }
|
||||||
|
|
||||||
void set_height(const unsigned height) { h_ = height; set_dirty(); }
|
void set_height(const unsigned height) { h_ = height; set_dirty(true); }
|
||||||
unsigned get_height() const { return h_; }
|
unsigned get_height() const { return h_; }
|
||||||
|
|
||||||
surface& surf() { return canvas_; }
|
surface& surf() { return canvas_; }
|
||||||
|
@ -115,7 +115,7 @@ public:
|
||||||
void set_variable(const std::string& key, const variant& value)
|
void set_variable(const std::string& key, const variant& value)
|
||||||
{
|
{
|
||||||
variables_.add(key, value);
|
variables_.add(key, value);
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -430,7 +430,7 @@ void thandler::disconnect(tdispatcher* dispatcher)
|
||||||
|
|
||||||
/***** Set proper state for the other dispatchers. *****/
|
/***** Set proper state for the other dispatchers. *****/
|
||||||
FOREACH(AUTO dispatcher, dispatchers_) {
|
FOREACH(AUTO dispatcher, dispatchers_) {
|
||||||
dynamic_cast<twidget&>(*dispatcher).set_dirty();
|
dynamic_cast<twidget&>(*dispatcher).set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
activate();
|
activate();
|
||||||
|
@ -480,7 +480,7 @@ void thandler::draw(const bool force)
|
||||||
* causes black borders around the window. So there's the choice
|
* causes black borders around the window. So there's the choice
|
||||||
* between two evils.
|
* between two evils.
|
||||||
*/
|
*/
|
||||||
dynamic_cast<twidget&>(*dispatcher).set_dirty();
|
dynamic_cast<twidget&>(*dispatcher).set_dirty(true);
|
||||||
} else {
|
} else {
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,10 @@
|
||||||
#ifndef GUI_AUXILIARY_FIND_WIDGET_TPP_INCLUDED
|
#ifndef GUI_AUXILIARY_FIND_WIDGET_TPP_INCLUDED
|
||||||
#define GUI_AUXILIARY_FIND_WIDGET_TPP_INCLUDED
|
#define GUI_AUXILIARY_FIND_WIDGET_TPP_INCLUDED
|
||||||
|
|
||||||
|
#include "gui/widgets/helper.hpp"
|
||||||
#include "gui/widgets/widget.hpp"
|
#include "gui/widgets/widget.hpp"
|
||||||
|
#include "utils/const_clone.tpp"
|
||||||
|
#include "wml_exception.hpp"
|
||||||
|
|
||||||
namespace gui2 {
|
namespace gui2 {
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#include "gui/widgets/window.hpp"
|
#include "gui/widgets/window.hpp"
|
||||||
#include "formula_string_utils.hpp"
|
#include "formula_string_utils.hpp"
|
||||||
#include "utils/foreach.tpp"
|
#include "utils/foreach.tpp"
|
||||||
|
#include "wml_exception.hpp"
|
||||||
|
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "gettext.hpp"
|
#include "gettext.hpp"
|
||||||
#include "gui/auxiliary/log.hpp"
|
#include "gui/auxiliary/log.hpp"
|
||||||
#include "gui/widgets/control.hpp"
|
#include "gui/widgets/control.hpp"
|
||||||
|
#include "wml_exception.hpp"
|
||||||
|
|
||||||
namespace gui2 {
|
namespace gui2 {
|
||||||
|
|
||||||
|
@ -63,7 +64,7 @@ void tbuilder_control::init_control(tcontrol* control) const
|
||||||
control->set_use_tooltip_on_label_overflow(use_tooltip_on_label_overflow);
|
control->set_use_tooltip_on_label_overflow(use_tooltip_on_label_overflow);
|
||||||
#ifndef LOW_MEM
|
#ifndef LOW_MEM
|
||||||
control->set_debug_border_mode(debug_border_mode);
|
control->set_debug_border_mode(debug_border_mode);
|
||||||
control->set_debug_border_color(debug_border_color);
|
control->set_debug_border_colour(debug_border_color);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
|
|
||||||
#include "gui/auxiliary/window_builder.hpp"
|
#include "gui/auxiliary/window_builder.hpp"
|
||||||
|
|
||||||
|
#include "config.hpp"
|
||||||
|
|
||||||
namespace gui2 {
|
namespace gui2 {
|
||||||
|
|
||||||
namespace implementation {
|
namespace implementation {
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
typedef std::map<std::string, t_string> string_map;
|
||||||
|
|
||||||
namespace gui2 {
|
namespace gui2 {
|
||||||
|
|
||||||
namespace implementation {
|
namespace implementation {
|
||||||
|
|
|
@ -17,8 +17,10 @@
|
||||||
|
|
||||||
#include "gui/auxiliary/window_builder/pane.hpp"
|
#include "gui/auxiliary/window_builder/pane.hpp"
|
||||||
|
|
||||||
|
#include "config.hpp"
|
||||||
#include "gettext.hpp"
|
#include "gettext.hpp"
|
||||||
#include "gui/widgets/pane.hpp"
|
#include "gui/widgets/pane.hpp"
|
||||||
|
#include "wml_exception.hpp"
|
||||||
|
|
||||||
namespace gui2 {
|
namespace gui2 {
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#include "gui/auxiliary/window_builder/viewport.hpp"
|
#include "gui/auxiliary/window_builder/viewport.hpp"
|
||||||
|
|
||||||
|
#include "config.hpp"
|
||||||
#include "gui/widgets/viewport.hpp"
|
#include "gui/widgets/viewport.hpp"
|
||||||
|
|
||||||
namespace gui2 {
|
namespace gui2 {
|
||||||
|
|
|
@ -75,25 +75,25 @@ REGISTER_DIALOG(addon_list)
|
||||||
void taddon_list::collapse(tgrid& grid)
|
void taddon_list::collapse(tgrid& grid)
|
||||||
{
|
{
|
||||||
find_widget<ttoggle_button>(&grid, "expand", false)
|
find_widget<ttoggle_button>(&grid, "expand", false)
|
||||||
.set_visible(twidget::VISIBLE);
|
.set_visible(twidget::tvisible::visible);
|
||||||
|
|
||||||
find_widget<ttoggle_button>(&grid, "collapse", false)
|
find_widget<ttoggle_button>(&grid, "collapse", false)
|
||||||
.set_visible(twidget::INVISIBLE);
|
.set_visible(twidget::tvisible::invisible);
|
||||||
|
|
||||||
find_widget<tlabel>(&grid, "description", false)
|
find_widget<tlabel>(&grid, "description", false)
|
||||||
.set_visible(twidget::INVISIBLE);
|
.set_visible(twidget::tvisible::invisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
void taddon_list::expand(tgrid& grid)
|
void taddon_list::expand(tgrid& grid)
|
||||||
{
|
{
|
||||||
find_widget<ttoggle_button>(&grid, "expand", false)
|
find_widget<ttoggle_button>(&grid, "expand", false)
|
||||||
.set_visible(twidget::HIDDEN);
|
.set_visible(twidget::tvisible::hidden);
|
||||||
|
|
||||||
find_widget<ttoggle_button>(&grid, "collapse", false)
|
find_widget<ttoggle_button>(&grid, "collapse", false)
|
||||||
.set_visible(twidget::VISIBLE);
|
.set_visible(twidget::tvisible::visible);
|
||||||
|
|
||||||
find_widget<tlabel>(&grid, "description", false)
|
find_widget<tlabel>(&grid, "description", false)
|
||||||
.set_visible(twidget::VISIBLE);
|
.set_visible(twidget::tvisible::visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
void taddon_list::pre_show(CVideo& /*video*/, twindow& window)
|
void taddon_list::pre_show(CVideo& /*video*/, twindow& window)
|
||||||
|
@ -291,7 +291,7 @@ void taddon_list::create_campaign(tpane& pane, const config& campaign)
|
||||||
, false);
|
, false);
|
||||||
|
|
||||||
if(collapse) {
|
if(collapse) {
|
||||||
collapse->set_visible(twidget::INVISIBLE);
|
collapse->set_visible(twidget::tvisible::invisible);
|
||||||
collapse->set_callback_state_change(boost::bind(
|
collapse->set_callback_state_change(boost::bind(
|
||||||
&taddon_list::collapse
|
&taddon_list::collapse
|
||||||
, this
|
, this
|
||||||
|
@ -304,7 +304,7 @@ void taddon_list::create_campaign(tpane& pane, const config& campaign)
|
||||||
, boost::ref(*grid)));
|
, boost::ref(*grid)));
|
||||||
|
|
||||||
find_widget<tlabel>(grid, "description", false)
|
find_widget<tlabel>(grid, "description", false)
|
||||||
.set_visible(twidget::INVISIBLE);
|
.set_visible(twidget::tvisible::invisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,7 +185,7 @@ void tcampaign_selection::pre_show(CVideo& /*video*/, twindow& window)
|
||||||
if(ttree_view* tree = find_widget<ttree_view>(
|
if(ttree_view* tree = find_widget<ttree_view>(
|
||||||
&window, "campaign_tree", false, false)) {
|
&window, "campaign_tree", false, false)) {
|
||||||
|
|
||||||
tree->set_visible(twidget::INVISIBLE);
|
tree->set_visible(twidget::tvisible::invisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Setup campaign list. *****/
|
/***** Setup campaign list. *****/
|
||||||
|
@ -226,7 +226,7 @@ void tcampaign_selection::pre_show(CVideo& /*video*/, twindow& window)
|
||||||
|
|
||||||
twidget* widget = grid->find("victory", false);
|
twidget* widget = grid->find("victory", false);
|
||||||
if (widget && !campaign["completed"].to_bool()) {
|
if (widget && !campaign["completed"].to_bool()) {
|
||||||
widget->set_visible(twidget::HIDDEN);
|
widget->set_visible(twidget::tvisible::hidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** Add detail item ***/
|
/*** Add detail item ***/
|
||||||
|
|
|
@ -163,7 +163,7 @@ void tdebug_clock::update_time(const bool force)
|
||||||
canvas.set_variable("minute", variant(minute_stamp));
|
canvas.set_variable("minute", variant(minute_stamp));
|
||||||
canvas.set_variable("second", variant(second_stamp));
|
canvas.set_variable("second", variant(second_stamp));
|
||||||
}
|
}
|
||||||
clock_->set_dirty();
|
clock_->set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::map<std::string, std::string> tags;
|
const std::map<std::string, std::string> tags;
|
||||||
|
|
|
@ -234,9 +234,9 @@ void tgame_load::display_savegame(twindow& window)
|
||||||
find_widget<twidget>(&window, "preview_pane", false);
|
find_widget<twidget>(&window, "preview_pane", false);
|
||||||
|
|
||||||
if(selected_row == -1) {
|
if(selected_row == -1) {
|
||||||
preview_pane.set_visible(twidget::HIDDEN);
|
preview_pane.set_visible(twidget::tvisible::hidden);
|
||||||
} else {
|
} else {
|
||||||
preview_pane.set_visible(twidget::VISIBLE);
|
preview_pane.set_visible(twidget::tvisible::visible);
|
||||||
|
|
||||||
savegame::save_info& game = games_[selected_row];
|
savegame::save_info& game = games_[selected_row];
|
||||||
filename_ = game.name();
|
filename_ = game.name();
|
||||||
|
|
|
@ -108,10 +108,10 @@ void tsub_player_list::init(gui2::twindow &w, const std::string &id)
|
||||||
void tsub_player_list::show_toggle_callback(gui2::twidget* /*widget*/)
|
void tsub_player_list::show_toggle_callback(gui2::twidget* /*widget*/)
|
||||||
{
|
{
|
||||||
if (show_toggle->get_value()) {
|
if (show_toggle->get_value()) {
|
||||||
list->set_visible(twidget::INVISIBLE);
|
list->set_visible(twidget::tvisible::invisible);
|
||||||
show_toggle->set_icon_name("lobby/group-folded.png");
|
show_toggle->set_icon_name("lobby/group-folded.png");
|
||||||
} else {
|
} else {
|
||||||
list->set_visible(twidget::VISIBLE);
|
list->set_visible(twidget::tvisible::visible);
|
||||||
show_toggle->set_icon_name("lobby/group-expanded.png");
|
show_toggle->set_icon_name("lobby/group-expanded.png");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,13 +130,13 @@ void tsub_player_list::auto_hide()
|
||||||
*/
|
*/
|
||||||
assert(label);
|
assert(label);
|
||||||
tree_label->set_label(label->label() + " (0)");
|
tree_label->set_label(label->label() + " (0)");
|
||||||
// tree_label->set_visible(twidget::INVISIBLE);
|
// tree_label->set_visible(twidget::tvisible::invisible);
|
||||||
} else {
|
} else {
|
||||||
assert(label);
|
assert(label);
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << label->label() << " (" << tree->size() << ")";
|
ss << label->label() << " (" << tree->size() << ")";
|
||||||
tree_label->set_label(ss.str());
|
tree_label->set_label(ss.str());
|
||||||
// tree_label->set_visible(twidget::VISIBLE);
|
// tree_label->set_visible(twidget::tvisible::visible);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ void tplayer_list::init(gui2::twindow &w)
|
||||||
, true);
|
, true);
|
||||||
|
|
||||||
find_widget<twidget>(&w, "old_player_list", false)
|
find_widget<twidget>(&w, "old_player_list", false)
|
||||||
.set_visible(twidget::INVISIBLE);
|
.set_visible(twidget::tvisible::invisible);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo This is a hack to fold the items.
|
* @todo This is a hack to fold the items.
|
||||||
|
@ -519,7 +519,9 @@ void set_visible_if_exists(tgrid* grid, const char* id, bool visible)
|
||||||
{
|
{
|
||||||
twidget* w = grid->find(id, false);
|
twidget* w = grid->find(id, false);
|
||||||
if (w) {
|
if (w) {
|
||||||
w->set_visible(visible ? twidget::VISIBLE : twidget::INVISIBLE);
|
w->set_visible(visible
|
||||||
|
? twidget::tvisible::visible
|
||||||
|
: twidget::tvisible::invisible);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1147,7 +1149,7 @@ void tlobby_main::increment_waiting_whsipers(const std::string& name)
|
||||||
//label.set_use_markup(true);
|
//label.set_use_markup(true);
|
||||||
//label.set_label(colorize("<" + t->name + ">", "red"));
|
//label.set_label(colorize("<" + t->name + ">", "red"));
|
||||||
find_widget<timage>(grid, "pending_messages", false)
|
find_widget<timage>(grid, "pending_messages", false)
|
||||||
.set_visible(twidget::VISIBLE);
|
.set_visible(twidget::tvisible::visible);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1166,7 +1168,7 @@ void tlobby_main::increment_waiting_messages(const std::string& room)
|
||||||
//label.set_use_markup(true);
|
//label.set_use_markup(true);
|
||||||
//label.set_label(colorize(t->name, "red"));
|
//label.set_label(colorize(t->name, "red"));
|
||||||
find_widget<timage>(grid, "pending_messages", false)
|
find_widget<timage>(grid, "pending_messages", false)
|
||||||
.set_visible(twidget::VISIBLE);
|
.set_visible(twidget::tvisible::visible);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1257,7 +1259,7 @@ void tlobby_main::active_window_changed()
|
||||||
//tlabel& label = grid->get_widget<tlabel>("room", false);
|
//tlabel& label = grid->get_widget<tlabel>("room", false);
|
||||||
//label.set_label(expected_label);
|
//label.set_label(expected_label);
|
||||||
find_widget<timage>(grid, "pending_messages", false)
|
find_widget<timage>(grid, "pending_messages", false)
|
||||||
.set_visible(twidget::HIDDEN);
|
.set_visible(twidget::tvisible::hidden);
|
||||||
t.pending_messages = 0;
|
t.pending_messages = 0;
|
||||||
|
|
||||||
find_widget<tbutton>(window_, "close_window", false)
|
find_widget<tbutton>(window_, "close_window", false)
|
||||||
|
|
|
@ -112,7 +112,7 @@ void tlobby_player_info::pre_show(CVideo& /*video*/, twindow& window)
|
||||||
|
|
||||||
if (!preferences::is_authenticated()) {
|
if (!preferences::is_authenticated()) {
|
||||||
twidget* aw = window.find("admin", false);
|
twidget* aw = window.find("admin", false);
|
||||||
aw->set_visible(twidget::INVISIBLE);
|
aw->set_visible(twidget::tvisible::invisible);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ void tmessage::set_button_caption(const tbutton_id button,
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmessage::set_button_visible(const tbutton_id button,
|
void tmessage::set_button_visible(const tbutton_id button,
|
||||||
const twidget::tvisible visible)
|
const twidget::tvisible::scoped_enum visible)
|
||||||
{
|
{
|
||||||
buttons_[button].visible = visible;
|
buttons_[button].visible = visible;
|
||||||
if(buttons_[button].button) {
|
if(buttons_[button].button) {
|
||||||
|
@ -133,7 +133,7 @@ void tmessage::set_button_retval(const tbutton_id button,
|
||||||
tmessage::tbutton_status::tbutton_status()
|
tmessage::tbutton_status::tbutton_status()
|
||||||
: button(NULL)
|
: button(NULL)
|
||||||
, caption()
|
, caption()
|
||||||
, visible(twidget::INVISIBLE)
|
, visible(twidget::tvisible::invisible)
|
||||||
, retval(twindow::NONE)
|
, retval(twindow::NONE)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -159,23 +159,23 @@ int show_message(CVideo& video, const std::string& title,
|
||||||
case tmessage::auto_close :
|
case tmessage::auto_close :
|
||||||
break;
|
break;
|
||||||
case tmessage::ok_button :
|
case tmessage::ok_button :
|
||||||
dlg.set_button_visible(tmessage::ok, twidget::VISIBLE);
|
dlg.set_button_visible(tmessage::ok, twidget::tvisible::visible);
|
||||||
dlg.set_button_caption(tmessage::ok, _("OK"));
|
dlg.set_button_caption(tmessage::ok, _("OK"));
|
||||||
break;
|
break;
|
||||||
case tmessage::close_button :
|
case tmessage::close_button :
|
||||||
dlg.set_button_visible(tmessage::ok, twidget::VISIBLE);
|
dlg.set_button_visible(tmessage::ok, twidget::tvisible::visible);
|
||||||
break;
|
break;
|
||||||
case tmessage::ok_cancel_buttons :
|
case tmessage::ok_cancel_buttons :
|
||||||
dlg.set_button_visible(tmessage::ok, twidget::VISIBLE);
|
dlg.set_button_visible(tmessage::ok, twidget::tvisible::visible);
|
||||||
dlg.set_button_caption(tmessage::ok, _("OK"));
|
dlg.set_button_caption(tmessage::ok, _("OK"));
|
||||||
/* FALL DOWN */
|
/* FALL DOWN */
|
||||||
case tmessage::cancel_button :
|
case tmessage::cancel_button :
|
||||||
dlg.set_button_visible(tmessage::cancel, twidget::VISIBLE);
|
dlg.set_button_visible(tmessage::cancel, twidget::tvisible::visible);
|
||||||
break;
|
break;
|
||||||
case tmessage::yes_no_buttons :
|
case tmessage::yes_no_buttons :
|
||||||
dlg.set_button_visible(tmessage::ok, twidget::VISIBLE);
|
dlg.set_button_visible(tmessage::ok, twidget::tvisible::visible);
|
||||||
dlg.set_button_caption(tmessage::ok, _("Yes"));
|
dlg.set_button_caption(tmessage::ok, _("Yes"));
|
||||||
dlg.set_button_visible(tmessage::cancel, twidget::VISIBLE);
|
dlg.set_button_visible(tmessage::cancel, twidget::tvisible::visible);
|
||||||
dlg.set_button_caption(tmessage::cancel, _("No"));
|
dlg.set_button_caption(tmessage::cancel, _("No"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ public:
|
||||||
const std::string& caption);
|
const std::string& caption);
|
||||||
|
|
||||||
void set_button_visible(const tbutton_id button,
|
void set_button_visible(const tbutton_id button,
|
||||||
const twidget::tvisible visible);
|
const twidget::tvisible::scoped_enum visible);
|
||||||
|
|
||||||
void set_button_retval(const tbutton_id button,
|
void set_button_retval(const tbutton_id button,
|
||||||
const int retval);
|
const int retval);
|
||||||
|
@ -118,7 +118,7 @@ private:
|
||||||
|
|
||||||
tbutton* button;
|
tbutton* button;
|
||||||
std::string caption;
|
std::string caption;
|
||||||
twidget::tvisible visible;
|
twidget::tvisible::scoped_enum visible;
|
||||||
int retval;
|
int retval;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ void tsimple_item_selector::pre_show(CVideo& /*video*/, twindow& window)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(single_button_) {
|
if(single_button_) {
|
||||||
button_cancel.set_visible(gui2::twidget::INVISIBLE);
|
button_cancel.set_visible(gui2::twidget::tvisible::invisible);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,7 @@ static void animate_logo(
|
||||||
* this possible problem. Of course this is expensive but the logo is
|
* this possible problem. Of course this is expensive but the logo is
|
||||||
* animated once so the cost is only once.
|
* animated once so the cost is only once.
|
||||||
*/
|
*/
|
||||||
window.set_dirty();
|
window.set_dirty(true);
|
||||||
|
|
||||||
if(percentage == 100) {
|
if(percentage == 100) {
|
||||||
remove_timer(timer_id);
|
remove_timer(timer_id);
|
||||||
|
@ -385,8 +385,8 @@ void ttitle_screen::pre_show(CVideo& video, twindow& window)
|
||||||
/***** Set the clock button. *****/
|
/***** Set the clock button. *****/
|
||||||
tbutton& clock = find_widget<tbutton>(&window, "clock", false);
|
tbutton& clock = find_widget<tbutton>(&window, "clock", false);
|
||||||
clock.set_visible(show_debug_clock_button
|
clock.set_visible(show_debug_clock_button
|
||||||
? twidget::VISIBLE
|
? twidget::tvisible::visible
|
||||||
: twidget::INVISIBLE);
|
: twidget::tvisible::invisible);
|
||||||
|
|
||||||
connect_signal_mouse_left_click(
|
connect_signal_mouse_left_click(
|
||||||
clock
|
clock
|
||||||
|
|
|
@ -90,8 +90,8 @@ void twml_message_::pre_show(CVideo& /*video*/, twindow& window)
|
||||||
window.set_click_dismiss(false);
|
window.set_click_dismiss(false);
|
||||||
window.set_escape_disabled(true);
|
window.set_escape_disabled(true);
|
||||||
} else {
|
} else {
|
||||||
caption.set_visible(twidget::INVISIBLE);
|
caption.set_visible(twidget::tvisible::invisible);
|
||||||
input.set_visible(twidget::INVISIBLE);
|
input.set_visible(twidget::tvisible::invisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the option list related fields.
|
// Find the option list related fields.
|
||||||
|
@ -138,7 +138,7 @@ void twml_message_::pre_show(CVideo& /*video*/, twindow& window)
|
||||||
// click_dismiss has been disabled due to the input.
|
// click_dismiss has been disabled due to the input.
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
options.set_visible(twidget::INVISIBLE);
|
options.set_visible(twidget::tvisible::invisible);
|
||||||
}
|
}
|
||||||
window.set_click_dismiss(!has_input_ && option_list_.empty());
|
window.set_click_dismiss(!has_input_ && option_list_.empty());
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,12 +25,12 @@
|
||||||
|
|
||||||
namespace gui2 {
|
namespace gui2 {
|
||||||
|
|
||||||
void tcontainer_::layout_init(const bool full_initialization)
|
void tcontainer_::layout_initialise(const bool full_initialisation)
|
||||||
{
|
{
|
||||||
// Inherited.
|
// Inherited.
|
||||||
tcontrol::layout_init(full_initialization);
|
tcontrol::layout_initialise(full_initialisation);
|
||||||
|
|
||||||
grid_.layout_init(full_initialization);
|
grid_.layout_initialise(full_initialisation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tcontainer_::reduce_width(const unsigned maximum_width)
|
void tcontainer_::reduce_width(const unsigned maximum_width)
|
||||||
|
@ -108,18 +108,18 @@ void tcontainer_::set_origin(const tpoint& origin)
|
||||||
grid_.set_origin(client_position);
|
grid_.set_origin(client_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tcontainer_::set_visible_area(const SDL_Rect& area)
|
void tcontainer_::set_visible_rectangle(const SDL_Rect& rectangle)
|
||||||
{
|
{
|
||||||
// Inherited.
|
// Inherited.
|
||||||
twidget::set_visible_area(area);
|
twidget::set_visible_rectangle(rectangle);
|
||||||
|
|
||||||
grid_.set_visible_area(area);
|
grid_.set_visible_rectangle(rectangle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tcontainer_::impl_draw_children(surface& frame_buffer)
|
void tcontainer_::impl_draw_children(surface& frame_buffer)
|
||||||
{
|
{
|
||||||
assert(get_visible() == twidget::VISIBLE
|
assert(get_visible() == twidget::tvisible::visible
|
||||||
&& grid_.get_visible() == twidget::VISIBLE);
|
&& grid_.get_visible() == twidget::tvisible::visible);
|
||||||
|
|
||||||
grid_.draw_children(frame_buffer);
|
grid_.draw_children(frame_buffer);
|
||||||
}
|
}
|
||||||
|
@ -129,8 +129,8 @@ void tcontainer_::impl_draw_children(
|
||||||
, int x_offset
|
, int x_offset
|
||||||
, int y_offset)
|
, int y_offset)
|
||||||
{
|
{
|
||||||
assert(get_visible() == twidget::VISIBLE
|
assert(get_visible() == twidget::tvisible::visible
|
||||||
&& grid_.get_visible() == twidget::VISIBLE);
|
&& grid_.get_visible() == twidget::tvisible::visible);
|
||||||
|
|
||||||
grid_.draw_children(frame_buffer, x_offset, y_offset);
|
grid_.draw_children(frame_buffer, x_offset, y_offset);
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ void tcontainer_::set_active(const bool active)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
|
|
||||||
set_self_active(active);
|
set_self_active(active);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,12 +45,12 @@ public:
|
||||||
*
|
*
|
||||||
* The client area is the area available for widgets.
|
* The client area is the area available for widgets.
|
||||||
*/
|
*/
|
||||||
virtual SDL_Rect get_client_rect() const { return get_rect(); }
|
virtual SDL_Rect get_client_rect() const { return get_rectangle(); }
|
||||||
|
|
||||||
/***** ***** ***** ***** layout functions ***** ***** ***** *****/
|
/***** ***** ***** ***** layout functions ***** ***** ***** *****/
|
||||||
|
|
||||||
/** Inherited from tcontrol. */
|
/** See @ref twidget::layout_initialise. */
|
||||||
void layout_init(const bool full_initialization);
|
virtual void layout_initialise(const bool full_initialisation) OVERRIDE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to reduce the width of a container.
|
* Tries to reduce the width of a container.
|
||||||
|
@ -102,8 +102,8 @@ public:
|
||||||
/** Inherited from twidget. */
|
/** Inherited from twidget. */
|
||||||
void set_origin(const tpoint& origin);
|
void set_origin(const tpoint& origin);
|
||||||
|
|
||||||
/** Inherited from twidget. */
|
/** See @ref twidget::set_visible_rectangle. */
|
||||||
void set_visible_area(const SDL_Rect& area);
|
virtual void set_visible_rectangle(const SDL_Rect& rectangle) OVERRIDE;
|
||||||
|
|
||||||
/** Inherited from twidget. */
|
/** Inherited from twidget. */
|
||||||
void impl_draw_children(surface& frame_buffer);
|
void impl_draw_children(surface& frame_buffer);
|
||||||
|
|
|
@ -152,7 +152,7 @@ void tcontrol::set_members(const string_map& data)
|
||||||
|
|
||||||
bool tcontrol::disable_click_dismiss() const
|
bool tcontrol::disable_click_dismiss() const
|
||||||
{
|
{
|
||||||
return get_visible() == twidget::VISIBLE && get_active();
|
return get_visible() == twidget::tvisible::visible && get_active();
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator::twalker_* tcontrol::create_walker()
|
iterator::twalker_* tcontrol::create_walker()
|
||||||
|
@ -195,12 +195,12 @@ unsigned tcontrol::get_characters_per_line() const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tcontrol::layout_init(const bool full_initialization)
|
void tcontrol::layout_initialise(const bool full_initialisation)
|
||||||
{
|
{
|
||||||
// Inherited.
|
// Inherited.
|
||||||
twidget::layout_init(full_initialization);
|
twidget::layout_initialise(full_initialisation);
|
||||||
|
|
||||||
if(full_initialization) {
|
if(full_initialisation) {
|
||||||
shrunken_ = false;
|
shrunken_ = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -310,7 +310,7 @@ void tcontrol::set_label(const t_string& label)
|
||||||
label_ = label;
|
label_ = label;
|
||||||
set_layout_size(tpoint(0, 0));
|
set_layout_size(tpoint(0, 0));
|
||||||
update_canvas();
|
update_canvas();
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tcontrol::set_use_markup(bool use_markup)
|
void tcontrol::set_use_markup(bool use_markup)
|
||||||
|
@ -321,7 +321,7 @@ void tcontrol::set_use_markup(bool use_markup)
|
||||||
|
|
||||||
use_markup_ = use_markup;
|
use_markup_ = use_markup;
|
||||||
update_canvas();
|
update_canvas();
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tcontrol::set_text_alignment(const PangoAlignment text_alignment)
|
void tcontrol::set_text_alignment(const PangoAlignment text_alignment)
|
||||||
|
@ -332,7 +332,7 @@ void tcontrol::set_text_alignment(const PangoAlignment text_alignment)
|
||||||
|
|
||||||
text_alignment_ = text_alignment;
|
text_alignment_ = text_alignment;
|
||||||
update_canvas();
|
update_canvas();
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tcontrol::update_canvas()
|
void tcontrol::update_canvas()
|
||||||
|
@ -376,10 +376,10 @@ void tcontrol::impl_draw_background(surface& frame_buffer)
|
||||||
{
|
{
|
||||||
DBG_GUI_D << LOG_HEADER
|
DBG_GUI_D << LOG_HEADER
|
||||||
<< " label '" << debug_truncate(label_)
|
<< " label '" << debug_truncate(label_)
|
||||||
<< "' size " << get_rect()
|
<< "' size " << get_rectangle()
|
||||||
<< ".\n";
|
<< ".\n";
|
||||||
|
|
||||||
canvas(get_state()).blit(frame_buffer, get_rect());
|
canvas(get_state()).blit(frame_buffer, get_rectangle());
|
||||||
}
|
}
|
||||||
|
|
||||||
void tcontrol::impl_draw_background(
|
void tcontrol::impl_draw_background(
|
||||||
|
@ -389,7 +389,7 @@ void tcontrol::impl_draw_background(
|
||||||
{
|
{
|
||||||
DBG_GUI_D << LOG_HEADER
|
DBG_GUI_D << LOG_HEADER
|
||||||
<< " label '" << debug_truncate(label_)
|
<< " label '" << debug_truncate(label_)
|
||||||
<< "' size " << get_rect()
|
<< "' size " << get_rectangle()
|
||||||
<< ".\n";
|
<< ".\n";
|
||||||
|
|
||||||
canvas(get_state()).blit(
|
canvas(get_state()).blit(
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
#include "gui/widgets/widget.hpp"
|
#include "gui/widgets/widget.hpp"
|
||||||
#include "../../text.hpp"
|
#include "../../text.hpp"
|
||||||
|
|
||||||
|
typedef std::map<std::string, t_string> string_map;
|
||||||
|
|
||||||
namespace gui2 {
|
namespace gui2 {
|
||||||
|
|
||||||
namespace implementation {
|
namespace implementation {
|
||||||
|
@ -140,10 +142,13 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual unsigned get_characters_per_line() const;
|
virtual unsigned get_characters_per_line() const;
|
||||||
|
|
||||||
/** Inherited from twidget. */
|
/**
|
||||||
/** @todo Also handle the tooltip state if shrunken_ &&
|
* See @ref twidget::layout_initialise.
|
||||||
* use_tooltip_on_label_overflow_. */
|
*
|
||||||
void layout_init(const bool full_initialization);
|
* @todo Also handle the tooltip state.
|
||||||
|
* Handle if shrunken_ && use_tooltip_on_label_overflow_.
|
||||||
|
*/
|
||||||
|
virtual void layout_initialise(const bool full_initialisation) OVERRIDE;
|
||||||
|
|
||||||
/** Inherited from twidget. */
|
/** Inherited from twidget. */
|
||||||
void request_reduce_width(const unsigned maximum_width);
|
void request_reduce_width(const unsigned maximum_width);
|
||||||
|
|
|
@ -331,7 +331,7 @@ void tdebug_layout_graph::widget_generate_state_info(
|
||||||
<< "drawing action=" << control->get_drawing_action() << '\n'
|
<< "drawing action=" << control->get_drawing_action() << '\n'
|
||||||
<< "</td></tr>\n"
|
<< "</td></tr>\n"
|
||||||
<< "<tr><td>\n"
|
<< "<tr><td>\n"
|
||||||
<< "clip rect=" << control->clip_rect_ << '\n'
|
<< "clip rect=" << control->clipping_rectangle_ << '\n'
|
||||||
<< "</td></tr>\n"
|
<< "</td></tr>\n"
|
||||||
<< "<tr><td>\n"
|
<< "<tr><td>\n"
|
||||||
<< "use tooltip on label overflow="
|
<< "use tooltip on label overflow="
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include "gui/widgets/window.hpp"
|
#include "gui/widgets/window.hpp"
|
||||||
#include "utils/foreach.tpp"
|
#include "utils/foreach.tpp"
|
||||||
|
#include "wml_exception.hpp"
|
||||||
|
|
||||||
namespace gui2 {
|
namespace gui2 {
|
||||||
|
|
||||||
|
@ -120,7 +121,9 @@ tpoint thorizontal_list::calculate_best_size() const
|
||||||
for(size_t i = 0; i < get_item_count(); ++i) {
|
for(size_t i = 0; i < get_item_count(); ++i) {
|
||||||
|
|
||||||
const tgrid& grid = item(i);
|
const tgrid& grid = item(i);
|
||||||
if(grid.get_visible() == twidget::INVISIBLE || !get_item_shown(i)) {
|
if(grid.get_visible() == twidget::tvisible::invisible
|
||||||
|
|| !get_item_shown(i)) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +153,9 @@ void thorizontal_list::place(const tpoint& origin, const tpoint& size)
|
||||||
for(size_t i = 0; i < get_item_count(); ++i) {
|
for(size_t i = 0; i < get_item_count(); ++i) {
|
||||||
|
|
||||||
tgrid& grid = item(i);
|
tgrid& grid = item(i);
|
||||||
if(grid.get_visible() == twidget::INVISIBLE || !get_item_shown(i)) {
|
if(grid.get_visible() == twidget::tvisible::invisible
|
||||||
|
|| !get_item_shown(i)) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +178,9 @@ void thorizontal_list::set_origin(const tpoint& origin)
|
||||||
for(size_t i = 0; i < get_item_count(); ++i) {
|
for(size_t i = 0; i < get_item_count(); ++i) {
|
||||||
|
|
||||||
tgrid& grid = item(i);
|
tgrid& grid = item(i);
|
||||||
if(grid.get_visible() == twidget::INVISIBLE || !get_item_shown(i)) {
|
if(grid.get_visible() == twidget::tvisible::invisible
|
||||||
|
|| !get_item_shown(i)) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +189,7 @@ void thorizontal_list::set_origin(const tpoint& origin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void thorizontal_list::set_visible_area(const SDL_Rect& area)
|
void thorizontal_list::set_visible_rectangle(const SDL_Rect& rectangle)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Note for most implementations this function could work only for the
|
* Note for most implementations this function could work only for the
|
||||||
|
@ -193,7 +200,7 @@ void thorizontal_list::set_visible_area(const SDL_Rect& area)
|
||||||
for(size_t i = 0; i < get_item_count(); ++i) {
|
for(size_t i = 0; i < get_item_count(); ++i) {
|
||||||
|
|
||||||
tgrid& grid = item(i);
|
tgrid& grid = item(i);
|
||||||
grid.set_visible_area(area);
|
grid.set_visible_rectangle(rectangle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +212,9 @@ twidget* thorizontal_list::find_at(
|
||||||
for(size_t i = 0; i < get_item_count(); ++i) {
|
for(size_t i = 0; i < get_item_count(); ++i) {
|
||||||
|
|
||||||
tgrid& grid = item(i);
|
tgrid& grid = item(i);
|
||||||
if(grid.get_visible() == twidget::INVISIBLE || !get_item_shown(i)) {
|
if(grid.get_visible() == twidget::tvisible::invisible
|
||||||
|
|| !get_item_shown(i)) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +236,9 @@ const twidget* thorizontal_list::find_at(const tpoint& coordinate,
|
||||||
for(size_t i = 0; i < get_item_count(); ++i) {
|
for(size_t i = 0; i < get_item_count(); ++i) {
|
||||||
|
|
||||||
const tgrid& grid = item(i);
|
const tgrid& grid = item(i);
|
||||||
if(grid.get_visible() == twidget::INVISIBLE || !get_item_shown(i)) {
|
if(grid.get_visible() == twidget::tvisible::invisible
|
||||||
|
|| !get_item_shown(i)) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +286,7 @@ void thorizontal_list::handle_key_right_arrow(
|
||||||
|
|
||||||
for(size_t i = get_selected_item() + 1; i < get_item_count(); ++i) {
|
for(size_t i = get_selected_item() + 1; i < get_item_count(); ++i) {
|
||||||
|
|
||||||
if(item(i).get_visible() == twidget::INVISIBLE
|
if(item(i).get_visible() == twidget::tvisible::invisible
|
||||||
|| !get_item_shown(i)) {
|
|| !get_item_shown(i)) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
@ -313,7 +324,9 @@ tpoint tvertical_list::calculate_best_size() const
|
||||||
for(size_t i = 0; i < get_item_count(); ++i) {
|
for(size_t i = 0; i < get_item_count(); ++i) {
|
||||||
|
|
||||||
const tgrid& grid = item(i);
|
const tgrid& grid = item(i);
|
||||||
if(grid.get_visible() == twidget::INVISIBLE || !get_item_shown(i)) {
|
if(grid.get_visible() == twidget::tvisible::invisible
|
||||||
|
|| !get_item_shown(i)) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,7 +356,9 @@ void tvertical_list::place(const tpoint& origin, const tpoint& size)
|
||||||
for(size_t i = 0; i < get_item_count(); ++i) {
|
for(size_t i = 0; i < get_item_count(); ++i) {
|
||||||
|
|
||||||
tgrid& grid = item(i);
|
tgrid& grid = item(i);
|
||||||
if(grid.get_visible() == twidget::INVISIBLE || !get_item_shown(i)) {
|
if(grid.get_visible() == twidget::tvisible::invisible
|
||||||
|
|| !get_item_shown(i)) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,7 +381,9 @@ void tvertical_list::set_origin(const tpoint& origin)
|
||||||
for(size_t i = 0; i < get_item_count(); ++i) {
|
for(size_t i = 0; i < get_item_count(); ++i) {
|
||||||
|
|
||||||
tgrid& grid = item(i);
|
tgrid& grid = item(i);
|
||||||
if(grid.get_visible() == twidget::INVISIBLE || !get_item_shown(i)) {
|
if(grid.get_visible() == twidget::tvisible::invisible
|
||||||
|
|| !get_item_shown(i)) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,7 +392,7 @@ void tvertical_list::set_origin(const tpoint& origin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tvertical_list::set_visible_area(const SDL_Rect& area)
|
void tvertical_list::set_visible_rectangle(const SDL_Rect& rectangle)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Note for most implementations this function could work only for the
|
* Note for most implementations this function could work only for the
|
||||||
|
@ -386,7 +403,7 @@ void tvertical_list::set_visible_area(const SDL_Rect& area)
|
||||||
for(size_t i = 0; i < get_item_count(); ++i) {
|
for(size_t i = 0; i < get_item_count(); ++i) {
|
||||||
|
|
||||||
tgrid& grid = item(i);
|
tgrid& grid = item(i);
|
||||||
grid.set_visible_area(area);
|
grid.set_visible_rectangle(rectangle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,7 +415,9 @@ twidget* tvertical_list::find_at(
|
||||||
for(size_t i = 0; i < get_item_count(); ++i) {
|
for(size_t i = 0; i < get_item_count(); ++i) {
|
||||||
|
|
||||||
tgrid& grid = item(i);
|
tgrid& grid = item(i);
|
||||||
if(grid.get_visible() == twidget::INVISIBLE || !get_item_shown(i)) {
|
if(grid.get_visible() == twidget::tvisible::invisible
|
||||||
|
|| !get_item_shown(i)) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,7 +440,9 @@ const twidget* tvertical_list::find_at(const tpoint& coordinate,
|
||||||
for(size_t i = 0; i < get_item_count(); ++i) {
|
for(size_t i = 0; i < get_item_count(); ++i) {
|
||||||
|
|
||||||
const tgrid& grid = item(i);
|
const tgrid& grid = item(i);
|
||||||
if(grid.get_visible() == twidget::INVISIBLE || !get_item_shown(i)) {
|
if(grid.get_visible() == twidget::tvisible::invisible
|
||||||
|
|| !get_item_shown(i)) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -467,7 +488,7 @@ void tvertical_list::handle_key_down_arrow(SDLMod /*modifier*/, bool& handled)
|
||||||
|
|
||||||
for(size_t i = get_selected_item() + 1; i < get_item_count(); ++i) {
|
for(size_t i = get_selected_item() + 1; i < get_item_count(); ++i) {
|
||||||
|
|
||||||
if(item(i).get_visible() == twidget::INVISIBLE
|
if(item(i).get_visible() == twidget::tvisible::invisible
|
||||||
|| !get_item_shown(i)) {
|
|| !get_item_shown(i)) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
@ -606,10 +627,10 @@ const twidget* tindependent::find(
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tindependent::set_visible_area(const SDL_Rect& area)
|
void tindependent::set_visible_rectangle(const SDL_Rect& rectangle)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Set the visible area for every item.
|
* Set the visible rectangle for every item.
|
||||||
*
|
*
|
||||||
* @todo evaluate whether setting it only for the visible item is better
|
* @todo evaluate whether setting it only for the visible item is better
|
||||||
* and what the consequences are.
|
* and what the consequences are.
|
||||||
|
@ -617,7 +638,7 @@ void tindependent::set_visible_area(const SDL_Rect& area)
|
||||||
for(size_t i = 0; i < get_item_count(); ++i) {
|
for(size_t i = 0; i < get_item_count(); ++i) {
|
||||||
|
|
||||||
tgrid& grid = item(i);
|
tgrid& grid = item(i);
|
||||||
grid.set_visible_area(area);
|
grid.set_visible_rectangle(rectangle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
#include <boost/intrusive_ptr.hpp>
|
#include <boost/intrusive_ptr.hpp>
|
||||||
|
|
||||||
|
typedef std::map< std::string, t_string > string_map;
|
||||||
|
|
||||||
namespace gui2 {
|
namespace gui2 {
|
||||||
|
|
||||||
struct tbuilder_grid;
|
struct tbuilder_grid;
|
||||||
|
@ -236,8 +238,8 @@ public:
|
||||||
* become pure virtuals.
|
* become pure virtuals.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Inherited from twidget. */
|
/** See @ref twidget::layout_initialise. */
|
||||||
virtual void layout_init(const bool full_initialization) = 0;
|
virtual void layout_initialise(const bool full_initialisation) OVERRIDE = 0;
|
||||||
|
|
||||||
/** Inherited from twidget. */
|
/** Inherited from twidget. */
|
||||||
virtual void request_reduce_width(const unsigned maximum_width) = 0;
|
virtual void request_reduce_width(const unsigned maximum_width) = 0;
|
||||||
|
@ -254,8 +256,8 @@ public:
|
||||||
/** Inherited from twidget. */
|
/** Inherited from twidget. */
|
||||||
virtual void set_origin(const tpoint& origin) = 0;
|
virtual void set_origin(const tpoint& origin) = 0;
|
||||||
|
|
||||||
/** Inherited from twidget. */
|
/** See @ref twidget::set_visible_rectangle. */
|
||||||
void set_visible_area(const SDL_Rect& area) = 0;
|
virtual void set_visible_rectangle(const SDL_Rect& rectangle) OVERRIDE = 0;
|
||||||
|
|
||||||
/** Inherited from twidget. */
|
/** Inherited from twidget. */
|
||||||
virtual void impl_draw_children(surface& frame_buffer) = 0;
|
virtual void impl_draw_children(surface& frame_buffer) = 0;
|
||||||
|
|
|
@ -218,11 +218,11 @@ struct thorizontal_list
|
||||||
void set_origin(const tpoint& origin);
|
void set_origin(const tpoint& origin);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the visible area of the generator.
|
* Sets the visible rectangle of the generator.
|
||||||
*
|
*
|
||||||
* @param area The visible area.
|
* @param rectangle The visible rectangle.
|
||||||
*/
|
*/
|
||||||
void set_visible_area(const SDL_Rect& area);
|
void set_visible_rectangle(const SDL_Rect& rectangle);
|
||||||
|
|
||||||
/** Inherited from tgenerator_. */
|
/** Inherited from tgenerator_. */
|
||||||
twidget* find_at(const tpoint& coordinate, const bool must_be_active);
|
twidget* find_at(const tpoint& coordinate, const bool must_be_active);
|
||||||
|
@ -288,8 +288,8 @@ struct tvertical_list
|
||||||
/** See thorizontal_list::set_origin(). */
|
/** See thorizontal_list::set_origin(). */
|
||||||
void set_origin(const tpoint& origin);
|
void set_origin(const tpoint& origin);
|
||||||
|
|
||||||
/** See thorizontal_list::set_visible_area(). */
|
/** See @ref thorizontal_list::set_visible_rectangle(). */
|
||||||
void set_visible_area(const SDL_Rect& area);
|
void set_visible_rectangle(const SDL_Rect& rectangle);
|
||||||
|
|
||||||
/** See thorizontal_list::find_at(). */
|
/** See thorizontal_list::find_at(). */
|
||||||
twidget* find_at(const tpoint& coordinate, const bool must_be_active);
|
twidget* find_at(const tpoint& coordinate, const bool must_be_active);
|
||||||
|
@ -364,8 +364,8 @@ struct tmatrix
|
||||||
void set_origin(const tpoint& /*origin*/)
|
void set_origin(const tpoint& /*origin*/)
|
||||||
{ ERROR_LOG(false); }
|
{ ERROR_LOG(false); }
|
||||||
|
|
||||||
/** See thorizontal_list::set_visible_area(). */
|
/** See @ref thorizontal_list::set_visible_rectangle(). */
|
||||||
void set_visible_area(const SDL_Rect& /*area*/)
|
void set_visible_rectangle(const SDL_Rect& /*rectangle*/ )
|
||||||
{ ERROR_LOG(false); }
|
{ ERROR_LOG(false); }
|
||||||
|
|
||||||
/** See thorizontal_list::find_at(). */
|
/** See thorizontal_list::find_at(). */
|
||||||
|
@ -425,8 +425,8 @@ struct tindependent
|
||||||
/** See thorizontal_list::set_origin(). */
|
/** See thorizontal_list::set_origin(). */
|
||||||
void set_origin(const tpoint& origin);
|
void set_origin(const tpoint& origin);
|
||||||
|
|
||||||
/** See thorizontal_list::set_visible_area(). */
|
/** See @ref thorizontal_list::set_visible_rectangle(). */
|
||||||
void set_visible_area(const SDL_Rect& area);
|
void set_visible_rectangle(const SDL_Rect& rectangle);
|
||||||
|
|
||||||
/** See thorizontal_list::find_at(). */
|
/** See thorizontal_list::find_at(). */
|
||||||
twidget* find_at(const tpoint& coordinate, const bool must_be_active);
|
twidget* find_at(const tpoint& coordinate, const bool must_be_active);
|
||||||
|
@ -503,7 +503,9 @@ struct tshow
|
||||||
{
|
{
|
||||||
void select(tgrid& grid, const bool show)
|
void select(tgrid& grid, const bool show)
|
||||||
{
|
{
|
||||||
grid.set_visible(show ? twidget::VISIBLE : twidget::HIDDEN);
|
grid.set_visible(show
|
||||||
|
? twidget::tvisible::visible
|
||||||
|
: twidget::tvisible::hidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -624,8 +626,8 @@ public:
|
||||||
/*** Set the proper visible state. ***/
|
/*** Set the proper visible state. ***/
|
||||||
items_[index]->shown = show;
|
items_[index]->shown = show;
|
||||||
items_[index]->grid.set_visible(show
|
items_[index]->grid.set_visible(show
|
||||||
? twidget::VISIBLE
|
? twidget::tvisible::visible
|
||||||
: twidget::INVISIBLE);
|
: twidget::tvisible::invisible);
|
||||||
|
|
||||||
/*** Update the selection. ***/
|
/*** Update the selection. ***/
|
||||||
minimum_selection::set_item_shown(index, show);
|
minimum_selection::set_item_shown(index, show);
|
||||||
|
@ -747,12 +749,14 @@ public:
|
||||||
impl_create_items(index, list_builder, data, callback);
|
impl_create_items(index, list_builder, data, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Inherited from tgenerator_. */
|
/** See @ref twidget::layout_initialise. */
|
||||||
void layout_init(const bool full_initialization)
|
virtual void layout_initialise(const bool full_initialisation) OVERRIDE
|
||||||
{
|
{
|
||||||
FOREACH(AUTO item, items_) {
|
FOREACH(AUTO item, items_) {
|
||||||
if(item->grid.get_visible() != twidget::INVISIBLE && item->shown) {
|
if(item->grid.get_visible() != twidget::tvisible::invisible
|
||||||
item->grid.layout_init(full_initialization);
|
&& item->shown) {
|
||||||
|
|
||||||
|
item->grid.layout_initialise(full_initialisation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -793,19 +797,21 @@ public:
|
||||||
placement::set_origin(origin);
|
placement::set_origin(origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Inherited from tgenerator_. */
|
/** See @ref twidget::set_visible_rectangle. */
|
||||||
void set_visible_area(const SDL_Rect& area)
|
virtual void set_visible_rectangle(const SDL_Rect& rectangle) OVERRIDE
|
||||||
{
|
{
|
||||||
placement::set_visible_area(area);
|
placement::set_visible_rectangle(rectangle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Inherited from tgenerator_. */
|
/** Inherited from tgenerator_. */
|
||||||
void impl_draw_children(surface& frame_buffer)
|
void impl_draw_children(surface& frame_buffer)
|
||||||
{
|
{
|
||||||
assert(this->get_visible() == twidget::VISIBLE);
|
assert(this->get_visible() == twidget::tvisible::visible);
|
||||||
|
|
||||||
FOREACH(AUTO item, items_) {
|
FOREACH(AUTO item, items_) {
|
||||||
if(item->grid.get_visible() == twidget::VISIBLE && item->shown) {
|
if(item->grid.get_visible() == twidget::tvisible::visible
|
||||||
|
&& item->shown) {
|
||||||
|
|
||||||
item->grid.draw_children(frame_buffer);
|
item->grid.draw_children(frame_buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -814,10 +820,12 @@ public:
|
||||||
/** Inherited from tgenerator_. */
|
/** Inherited from tgenerator_. */
|
||||||
void impl_draw_children(surface& frame_buffer, int x_offset, int y_offset)
|
void impl_draw_children(surface& frame_buffer, int x_offset, int y_offset)
|
||||||
{
|
{
|
||||||
assert(this->get_visible() == twidget::VISIBLE);
|
assert(this->get_visible() == twidget::tvisible::visible);
|
||||||
|
|
||||||
FOREACH(AUTO item, items_) {
|
FOREACH(AUTO item, items_) {
|
||||||
if(item->grid.get_visible() == twidget::VISIBLE && item->shown) {
|
if(item->grid.get_visible() == twidget::tvisible::visible
|
||||||
|
&& item->shown) {
|
||||||
|
|
||||||
item->grid.draw_children(frame_buffer, x_offset, y_offset);
|
item->grid.draw_children(frame_buffer, x_offset, y_offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,15 +182,15 @@ void tgrid::set_active(const bool active)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tgrid::layout_init(const bool full_initialization)
|
void tgrid::layout_initialise(const bool full_initialisation)
|
||||||
{
|
{
|
||||||
// Inherited.
|
// Inherited.
|
||||||
twidget::layout_init(full_initialization);
|
twidget::layout_initialise(full_initialisation);
|
||||||
|
|
||||||
// Clear child caches.
|
// Clear child caches.
|
||||||
FOREACH(AUTO& child, children_) {
|
FOREACH(AUTO& child, children_) {
|
||||||
|
|
||||||
child.layout_init(full_initialization);
|
child.layout_initialise(full_initialisation);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -564,17 +564,17 @@ void tgrid::set_origin(const tpoint& origin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tgrid::set_visible_area(const SDL_Rect& area)
|
void tgrid::set_visible_rectangle(const SDL_Rect& rectangle)
|
||||||
{
|
{
|
||||||
// Inherited.
|
// Inherited.
|
||||||
twidget::set_visible_area(area);
|
twidget::set_visible_rectangle(rectangle);
|
||||||
|
|
||||||
FOREACH(AUTO& child, children_) {
|
FOREACH(AUTO& child, children_) {
|
||||||
|
|
||||||
twidget* widget = child.widget();
|
twidget* widget = child.widget();
|
||||||
assert(widget);
|
assert(widget);
|
||||||
|
|
||||||
widget->set_visible_area(area);
|
widget->set_visible_rectangle(rectangle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -643,7 +643,7 @@ bool tgrid::has_widget(const twidget* widget) const
|
||||||
|
|
||||||
bool tgrid::disable_click_dismiss() const
|
bool tgrid::disable_click_dismiss() const
|
||||||
{
|
{
|
||||||
if(get_visible() != twidget::VISIBLE) {
|
if(get_visible() != twidget::tvisible::visible) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -711,7 +711,7 @@ tpoint tgrid::tchild::get_best_size() const
|
||||||
return border_space();
|
return border_space();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(widget_->get_visible() == twidget::INVISIBLE) {
|
if(widget_->get_visible() == twidget::tvisible::invisible) {
|
||||||
DBG_GUI_L << LOG_CHILD_HEADER
|
DBG_GUI_L << LOG_CHILD_HEADER
|
||||||
<< " has widget " << true
|
<< " has widget " << true
|
||||||
<< " widget visible " << false
|
<< " widget visible " << false
|
||||||
|
@ -733,7 +733,7 @@ tpoint tgrid::tchild::get_best_size() const
|
||||||
void tgrid::tchild::place(tpoint origin, tpoint size)
|
void tgrid::tchild::place(tpoint origin, tpoint size)
|
||||||
{
|
{
|
||||||
assert(widget());
|
assert(widget());
|
||||||
if(widget()->get_visible() == twidget::INVISIBLE) {
|
if(widget()->get_visible() == twidget::tvisible::invisible) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -871,12 +871,12 @@ void tgrid::tchild::place(tpoint origin, tpoint size)
|
||||||
widget()->place(widget_orig, widget_size);
|
widget()->place(widget_orig, widget_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tgrid::tchild::layout_init(const bool full_initialization)
|
void tgrid::tchild::layout_initialise(const bool full_initialisation)
|
||||||
{
|
{
|
||||||
assert(widget_);
|
assert(widget_);
|
||||||
|
|
||||||
if(widget_->get_visible() != twidget::INVISIBLE) {
|
if(widget_->get_visible() != twidget::tvisible::invisible) {
|
||||||
widget_->layout_init(full_initialization);
|
widget_->layout_initialise(full_initialisation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -939,7 +939,7 @@ void tgrid::impl_draw_children(surface& frame_buffer)
|
||||||
*/
|
*/
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
|
|
||||||
assert(get_visible() == twidget::VISIBLE);
|
assert(get_visible() == twidget::tvisible::visible);
|
||||||
set_dirty(false);
|
set_dirty(false);
|
||||||
|
|
||||||
FOREACH(AUTO& child, children_) {
|
FOREACH(AUTO& child, children_) {
|
||||||
|
@ -947,11 +947,11 @@ void tgrid::impl_draw_children(surface& frame_buffer)
|
||||||
twidget* widget = child.widget();
|
twidget* widget = child.widget();
|
||||||
assert(widget);
|
assert(widget);
|
||||||
|
|
||||||
if(widget->get_visible() != twidget::VISIBLE) {
|
if(widget->get_visible() != twidget::tvisible::visible) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(widget->get_drawing_action() == twidget::NOT_DRAWN) {
|
if(widget->get_drawing_action() == twidget::tredraw_action::none) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -978,7 +978,7 @@ void tgrid::impl_draw_children(
|
||||||
*/
|
*/
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
|
|
||||||
assert(get_visible() == twidget::VISIBLE);
|
assert(get_visible() == twidget::tvisible::visible);
|
||||||
set_dirty(false);
|
set_dirty(false);
|
||||||
|
|
||||||
FOREACH(AUTO& child, children_) {
|
FOREACH(AUTO& child, children_) {
|
||||||
|
@ -986,11 +986,11 @@ void tgrid::impl_draw_children(
|
||||||
twidget* widget = child.widget();
|
twidget* widget = child.widget();
|
||||||
assert(widget);
|
assert(widget);
|
||||||
|
|
||||||
if(widget->get_visible() != twidget::VISIBLE) {
|
if(widget->get_visible() != twidget::tvisible::visible) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(widget->get_drawing_action() == twidget::NOT_DRAWN) {
|
if(widget->get_drawing_action() == twidget::tredraw_action::none) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1060,7 +1060,7 @@ void tgrid_implementation::cell_request_reduce_height(
|
||||||
{
|
{
|
||||||
assert(child.widget_);
|
assert(child.widget_);
|
||||||
|
|
||||||
if(child.widget_->get_visible() == twidget::INVISIBLE) {
|
if(child.widget_->get_visible() == twidget::tvisible::invisible) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1073,7 +1073,7 @@ void tgrid_implementation::cell_request_reduce_width(
|
||||||
{
|
{
|
||||||
assert(child.widget_);
|
assert(child.widget_);
|
||||||
|
|
||||||
if(child.widget_->get_visible() == twidget::INVISIBLE) {
|
if(child.widget_->get_visible() == twidget::tvisible::invisible) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ public:
|
||||||
{
|
{
|
||||||
assert(row < row_grow_factor_.size());
|
assert(row < row_grow_factor_.size());
|
||||||
row_grow_factor_[row] = factor;
|
row_grow_factor_[row] = factor;
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -98,7 +98,7 @@ public:
|
||||||
{
|
{
|
||||||
assert(column< col_grow_factor_.size());
|
assert(column< col_grow_factor_.size());
|
||||||
col_grow_factor_[column] = factor;
|
col_grow_factor_[column] = factor;
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** ***** ***** ***** CHILD MANIPULATION ***** ***** ***** *****/
|
/***** ***** ***** ***** CHILD MANIPULATION ***** ***** ***** *****/
|
||||||
|
@ -179,8 +179,8 @@ public:
|
||||||
|
|
||||||
/***** ***** ***** ***** layout functions ***** ***** ***** *****/
|
/***** ***** ***** ***** layout functions ***** ***** ***** *****/
|
||||||
|
|
||||||
/** Inherited from twidget. */
|
/** See @ref twidget::layout_initialise. */
|
||||||
void layout_init(const bool full_initialization);
|
virtual void layout_initialise(const bool full_initialisation) OVERRIDE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to reduce the width of a container.
|
* Tries to reduce the width of a container.
|
||||||
|
@ -240,8 +240,8 @@ public:
|
||||||
/** Inherited from twidget. */
|
/** Inherited from twidget. */
|
||||||
void set_origin(const tpoint& origin);
|
void set_origin(const tpoint& origin);
|
||||||
|
|
||||||
/** Inherited from twidget. */
|
/** See @ref twidget::set_visible_rectangle. */
|
||||||
void set_visible_area(const SDL_Rect& area);
|
virtual void set_visible_rectangle(const SDL_Rect& rectangle) OVERRIDE;
|
||||||
|
|
||||||
/** Inherited from twidget. */
|
/** Inherited from twidget. */
|
||||||
void layout_children();
|
void layout_children();
|
||||||
|
@ -315,8 +315,8 @@ private:
|
||||||
*/
|
*/
|
||||||
void place(tpoint origin, tpoint size);
|
void place(tpoint origin, tpoint size);
|
||||||
|
|
||||||
/** Forwards layout_init() to the cell. */
|
/** Forwards @ref tgrid::layout_initialise to the cell. */
|
||||||
void layout_init(const bool full_initialization);
|
void layout_initialise(const bool full_initialisation);
|
||||||
|
|
||||||
/** Returns the can_wrap for the cell. */
|
/** Returns the can_wrap for the cell. */
|
||||||
bool can_wrap() const
|
bool can_wrap() const
|
||||||
|
|
|
@ -156,7 +156,7 @@ void tlist::remove_row(const unsigned row, unsigned count)
|
||||||
|
|
||||||
unsigned height_reduced = 0;
|
unsigned height_reduced = 0;
|
||||||
for(; count; --count) {
|
for(; count; --count) {
|
||||||
if(generator_->item(row).get_visible() != INVISIBLE) {
|
if(generator_->item(row).get_visible() != tvisible::invisible) {
|
||||||
height_reduced += generator_->item(row).get_height();
|
height_reduced += generator_->item(row).get_height();
|
||||||
}
|
}
|
||||||
generator_->delete_item(row);
|
generator_->delete_item(row);
|
||||||
|
@ -208,8 +208,8 @@ void tlist::set_row_shown(const unsigned row, const bool shown)
|
||||||
if(resize_needed) {
|
if(resize_needed) {
|
||||||
window->invalidate_layout();
|
window->invalidate_layout();
|
||||||
} else {
|
} else {
|
||||||
// grid().set_visible_area(content_visible_area());
|
// grid().set_visible_rectangle(content_visible_rectangle());
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(selected_row != get_selected_row()) {
|
if(selected_row != get_selected_row()) {
|
||||||
|
@ -242,8 +242,8 @@ void tlist::set_row_shown(const std::vector<bool>& shown)
|
||||||
if(resize_needed) {
|
if(resize_needed) {
|
||||||
window->invalidate_layout();
|
window->invalidate_layout();
|
||||||
} else {
|
} else {
|
||||||
// content_grid_->set_visible_area(content_visible_area());
|
// content_grid_->set_visible_rectangle(content_visible_rectangle());
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(selected_row != get_selected_row()) {
|
if(selected_row != get_selected_row()) {
|
||||||
|
@ -297,7 +297,7 @@ void tlist::place(const tpoint& origin, const tpoint& size)
|
||||||
if(selected_item != -1) {
|
if(selected_item != -1) {
|
||||||
/*
|
/*
|
||||||
const SDL_Rect& visible = content_visible_area();
|
const SDL_Rect& visible = content_visible_area();
|
||||||
SDL_Rect rect = generator_->item(selected_item).get_rect();
|
SDL_Rect rect = generator_->item(selected_item).get_rectangle();
|
||||||
|
|
||||||
rect.x = visible.x;
|
rect.x = visible.x;
|
||||||
rect.w = visible.w;
|
rect.w = visible.w;
|
||||||
|
@ -330,7 +330,7 @@ void tlist::resize_content(
|
||||||
need_layout_ = true;
|
need_layout_ = true;
|
||||||
// If the content grows assume it "overwrites" the old content.
|
// If the content grows assume it "overwrites" the old content.
|
||||||
if(width_modification < 0 || height_modification < 0) {
|
if(width_modification < 0 || height_modification < 0) {
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
DBG_GUI_L << LOG_HEADER << " succeeded.\n";
|
DBG_GUI_L << LOG_HEADER << " succeeded.\n";
|
||||||
} else {
|
} else {
|
||||||
|
@ -352,16 +352,16 @@ void tlist::init()
|
||||||
* So make them invisible for now.
|
* So make them invisible for now.
|
||||||
*/
|
*/
|
||||||
tgrid* g = find_widget<tgrid>(&grid(), "_header_grid", false, false);
|
tgrid* g = find_widget<tgrid>(&grid(), "_header_grid", false, false);
|
||||||
if(g) g->set_visible(twidget::INVISIBLE);
|
if(g) g->set_visible(twidget::tvisible::invisible);
|
||||||
|
|
||||||
g = find_widget<tgrid>(&grid(), "_footer_grid", false, false);
|
g = find_widget<tgrid>(&grid(), "_footer_grid", false, false);
|
||||||
if(g) g->set_visible(twidget::INVISIBLE);
|
if(g) g->set_visible(twidget::tvisible::invisible);
|
||||||
|
|
||||||
g = find_widget<tgrid>(&grid(), "_vertical_scrollbar_grid", false, false);
|
g = find_widget<tgrid>(&grid(), "_vertical_scrollbar_grid", false, false);
|
||||||
if(g) g->set_visible(twidget::INVISIBLE);
|
if(g) g->set_visible(twidget::tvisible::invisible);
|
||||||
|
|
||||||
g = find_widget<tgrid>(&grid(), "_horizontal_scrollbar_grid", false, false);
|
g = find_widget<tgrid>(&grid(), "_horizontal_scrollbar_grid", false, false);
|
||||||
if(g) g->set_visible(twidget::INVISIBLE);
|
if(g) g->set_visible(twidget::tvisible::invisible);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,10 +371,10 @@ void tlist::layout_children(const bool force)
|
||||||
grid().place(grid().get_origin(), grid().get_size());
|
grid().place(grid().get_origin(), grid().get_size());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
grid().set_visible_area(content_visible_area_);
|
grid().set_visible_rectangle(content_visible_area_);
|
||||||
*/
|
*/
|
||||||
need_layout_ = false;
|
need_layout_ = false;
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ void tlistbox::remove_row(const unsigned row, unsigned count)
|
||||||
|
|
||||||
int height_reduced = 0;
|
int height_reduced = 0;
|
||||||
for(; count; --count) {
|
for(; count; --count) {
|
||||||
if(generator_->item(row).get_visible() != INVISIBLE) {
|
if(generator_->item(row).get_visible() != tvisible::invisible) {
|
||||||
height_reduced += generator_->item(row).get_height();
|
height_reduced += generator_->item(row).get_height();
|
||||||
}
|
}
|
||||||
generator_->delete_item(row);
|
generator_->delete_item(row);
|
||||||
|
@ -142,8 +142,8 @@ void tlistbox::set_row_shown(const unsigned row, const bool shown)
|
||||||
if(resize_needed) {
|
if(resize_needed) {
|
||||||
window->invalidate_layout();
|
window->invalidate_layout();
|
||||||
} else {
|
} else {
|
||||||
content_grid_->set_visible_area(content_visible_area());
|
content_grid_->set_visible_rectangle(content_visible_area());
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(selected_row != get_selected_row() && callback_value_changed_) {
|
if(selected_row != get_selected_row() && callback_value_changed_) {
|
||||||
|
@ -176,8 +176,8 @@ void tlistbox::set_row_shown(const std::vector<bool>& shown)
|
||||||
if(resize_needed) {
|
if(resize_needed) {
|
||||||
window->invalidate_layout();
|
window->invalidate_layout();
|
||||||
} else {
|
} else {
|
||||||
content_grid_->set_visible_area(content_visible_area());
|
content_grid_->set_visible_rectangle(content_visible_area());
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(selected_row != get_selected_row() && callback_value_changed_) {
|
if(selected_row != get_selected_row() && callback_value_changed_) {
|
||||||
|
@ -237,7 +237,7 @@ void tlistbox::list_item_clicked(twidget* caller)
|
||||||
|
|
||||||
bool tlistbox::update_content_size()
|
bool tlistbox::update_content_size()
|
||||||
{
|
{
|
||||||
if(get_visible() == twidget::INVISIBLE) {
|
if(get_visible() == twidget::tvisible::invisible) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,8 +246,8 @@ bool tlistbox::update_content_size()
|
||||||
}
|
}
|
||||||
|
|
||||||
if(content_resize_request(true)) {
|
if(content_resize_request(true)) {
|
||||||
content_grid_->set_visible_area(content_visible_area());
|
content_grid_->set_visible_rectangle(content_visible_area());
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,7 +270,7 @@ void tlistbox::place(const tpoint& origin, const tpoint& size)
|
||||||
const int selected_item = generator_->get_selected_item();
|
const int selected_item = generator_->get_selected_item();
|
||||||
if(selected_item != -1) {
|
if(selected_item != -1) {
|
||||||
const SDL_Rect& visible = content_visible_area();
|
const SDL_Rect& visible = content_visible_area();
|
||||||
SDL_Rect rect = generator_->item(selected_item).get_rect();
|
SDL_Rect rect = generator_->item(selected_item).get_rectangle();
|
||||||
|
|
||||||
rect.x = visible.x;
|
rect.x = visible.x;
|
||||||
rect.w = visible.w;
|
rect.w = visible.w;
|
||||||
|
@ -302,7 +302,7 @@ void tlistbox::resize_content(
|
||||||
need_layout_ = true;
|
need_layout_ = true;
|
||||||
// If the content grows assume it "overwrites" the old content.
|
// If the content grows assume it "overwrites" the old content.
|
||||||
if(width_modification < 0 || height_modification < 0) {
|
if(width_modification < 0 || height_modification < 0) {
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
DBG_GUI_L << LOG_HEADER << " succeeded.\n";
|
DBG_GUI_L << LOG_HEADER << " succeeded.\n";
|
||||||
} else {
|
} else {
|
||||||
|
@ -337,7 +337,7 @@ void tlistbox::handle_key_up_arrow(SDLMod modifier, bool& handled)
|
||||||
// horizontal scrollbar position.
|
// horizontal scrollbar position.
|
||||||
const SDL_Rect& visible = content_visible_area();
|
const SDL_Rect& visible = content_visible_area();
|
||||||
SDL_Rect rect = generator_->item(
|
SDL_Rect rect = generator_->item(
|
||||||
generator_->get_selected_item()).get_rect();
|
generator_->get_selected_item()).get_rectangle();
|
||||||
|
|
||||||
rect.x = visible.x;
|
rect.x = visible.x;
|
||||||
rect.w = visible.w;
|
rect.w = visible.w;
|
||||||
|
@ -364,7 +364,7 @@ void tlistbox::handle_key_down_arrow(SDLMod modifier, bool& handled)
|
||||||
// horizontal scrollbar position.
|
// horizontal scrollbar position.
|
||||||
const SDL_Rect& visible = content_visible_area();
|
const SDL_Rect& visible = content_visible_area();
|
||||||
SDL_Rect rect = generator_->item(
|
SDL_Rect rect = generator_->item(
|
||||||
generator_->get_selected_item()).get_rect();
|
generator_->get_selected_item()).get_rectangle();
|
||||||
|
|
||||||
rect.x = visible.x;
|
rect.x = visible.x;
|
||||||
rect.w = visible.w;
|
rect.w = visible.w;
|
||||||
|
@ -392,7 +392,7 @@ void tlistbox::handle_key_left_arrow(SDLMod modifier, bool& handled)
|
||||||
// vertical scrollbar position.
|
// vertical scrollbar position.
|
||||||
const SDL_Rect& visible = content_visible_area();
|
const SDL_Rect& visible = content_visible_area();
|
||||||
SDL_Rect rect = generator_->item(
|
SDL_Rect rect = generator_->item(
|
||||||
generator_->get_selected_item()).get_rect();
|
generator_->get_selected_item()).get_rectangle();
|
||||||
|
|
||||||
rect.y = visible.y;
|
rect.y = visible.y;
|
||||||
rect.h = visible.h;
|
rect.h = visible.h;
|
||||||
|
@ -419,7 +419,7 @@ void tlistbox::handle_key_right_arrow(SDLMod modifier, bool& handled)
|
||||||
// vertical scrollbar position.
|
// vertical scrollbar position.
|
||||||
const SDL_Rect& visible = content_visible_area();
|
const SDL_Rect& visible = content_visible_area();
|
||||||
SDL_Rect rect = generator_->item(
|
SDL_Rect rect = generator_->item(
|
||||||
generator_->get_selected_item()).get_rect();
|
generator_->get_selected_item()).get_rectangle();
|
||||||
|
|
||||||
rect.y = visible.y;
|
rect.y = visible.y;
|
||||||
rect.h = visible.h;
|
rect.h = visible.h;
|
||||||
|
@ -511,10 +511,10 @@ void tlistbox::layout_children(const bool force)
|
||||||
content_grid()->get_origin()
|
content_grid()->get_origin()
|
||||||
, content_grid()->get_size());
|
, content_grid()->get_size());
|
||||||
|
|
||||||
content_grid()->set_visible_area(content_visible_area_);
|
content_grid()->set_visible_rectangle(content_visible_area_);
|
||||||
|
|
||||||
need_layout_ = false;
|
need_layout_ = false;
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,9 +108,9 @@ void tmatrix::place(const tpoint& origin, const tpoint& size)
|
||||||
content_.place(origin, size);
|
content_.place(origin, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmatrix::layout_init(const bool full_initialization)
|
void tmatrix::layout_initialise(const bool full_initialisation)
|
||||||
{
|
{
|
||||||
content_.layout_init(full_initialization);
|
content_.layout_initialise(full_initialisation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmatrix::impl_draw_children(
|
void tmatrix::impl_draw_children(
|
||||||
|
|
|
@ -114,8 +114,8 @@ public:
|
||||||
/** Inherited from twidget. */
|
/** Inherited from twidget. */
|
||||||
void place(const tpoint& origin, const tpoint& size);
|
void place(const tpoint& origin, const tpoint& size);
|
||||||
|
|
||||||
/** Inherited from twidget. */
|
/** See @ref twidget::layout_initialise. */
|
||||||
void layout_init(const bool full_initialization);
|
virtual void layout_initialise(const bool full_initialisation) OVERRIDE;
|
||||||
|
|
||||||
/** Inherited from twidget. */
|
/** Inherited from twidget. */
|
||||||
void impl_draw_children(surface& frame_buffer, int x_offset, int y_offset);
|
void impl_draw_children(surface& frame_buffer, int x_offset, int y_offset);
|
||||||
|
|
|
@ -217,14 +217,14 @@ void tminimap::impl_draw_background(surface& frame_buffer)
|
||||||
assert(terrain_);
|
assert(terrain_);
|
||||||
|
|
||||||
DBG_GUI_D << LOG_HEADER
|
DBG_GUI_D << LOG_HEADER
|
||||||
<< " size " << get_rect()
|
<< " size " << get_rectangle()
|
||||||
<< ".\n";
|
<< ".\n";
|
||||||
|
|
||||||
if(map_data_.empty()) {
|
if(map_data_.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Rect rect = get_rect();
|
SDL_Rect rect = get_rectangle();
|
||||||
assert(rect.w > 0 && rect.h > 0);
|
assert(rect.w > 0 && rect.h > 0);
|
||||||
|
|
||||||
const ::surface surf = get_image(rect.w, rect.h);
|
const ::surface surf = get_image(rect.w, rect.h);
|
||||||
|
|
|
@ -55,7 +55,7 @@ public:
|
||||||
/***** ***** ***** setters / getters for members ***** ****** *****/
|
/***** ***** ***** setters / getters for members ***** ****** *****/
|
||||||
|
|
||||||
void set_map_data(const std::string& map_data)
|
void set_map_data(const std::string& map_data)
|
||||||
{ if(map_data != map_data_) { map_data_ = map_data; set_dirty(); } }
|
{ if(map_data != map_data_) { map_data_ = map_data; set_dirty(true); } }
|
||||||
|
|
||||||
std::string get_map_data() const { return map_data_; }
|
std::string get_map_data() const { return map_data_; }
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ struct tpane_implementation
|
||||||
typedef typename utils::tconst_clone<tpane::titem, W>::reference thack;
|
typedef typename utils::tconst_clone<tpane::titem, W>::reference thack;
|
||||||
BOOST_FOREACH(thack item, pane->items_) {
|
BOOST_FOREACH(thack item, pane->items_) {
|
||||||
|
|
||||||
if(item.grid->get_visible() == twidget::INVISIBLE) {
|
if(item.grid->get_visible() == twidget::tvisible::invisible) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ struct tpane_implementation
|
||||||
* If the adjusted coordinate is in the item's grid let the grid
|
* If the adjusted coordinate is in the item's grid let the grid
|
||||||
* resolve the coordinate.
|
* resolve the coordinate.
|
||||||
*/
|
*/
|
||||||
const SDL_Rect rect = item.grid->get_rect();
|
const SDL_Rect rect = item.grid->get_rectangle();
|
||||||
if(
|
if(
|
||||||
coordinate.x >= rect.x
|
coordinate.x >= rect.x
|
||||||
&& coordinate.y >= rect.y
|
&& coordinate.y >= rect.y
|
||||||
|
@ -190,15 +190,15 @@ void tpane::place(const tpoint& origin, const tpoint& size)
|
||||||
place_children();
|
place_children();
|
||||||
}
|
}
|
||||||
|
|
||||||
void tpane::layout_init(const bool full_initialization)
|
void tpane::layout_initialise(const bool full_initialisation)
|
||||||
{
|
{
|
||||||
DBG_GUI_D << LOG_HEADER << '\n';
|
DBG_GUI_D << LOG_HEADER << '\n';
|
||||||
|
|
||||||
twidget::layout_init(full_initialization);
|
twidget::layout_initialise(full_initialisation);
|
||||||
|
|
||||||
FOREACH(AUTO& item, items_) {
|
FOREACH(AUTO& item, items_) {
|
||||||
if(item.grid->get_visible() != twidget::INVISIBLE) {
|
if(item.grid->get_visible() != twidget::tvisible::invisible) {
|
||||||
item.grid->layout_init(full_initialization);
|
item.grid->layout_initialise(full_initialisation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ void tpane::impl_draw_children(
|
||||||
DBG_GUI_D << LOG_HEADER << '\n';
|
DBG_GUI_D << LOG_HEADER << '\n';
|
||||||
|
|
||||||
FOREACH(AUTO& item, items_) {
|
FOREACH(AUTO& item, items_) {
|
||||||
if(item.grid->get_visible() != twidget::INVISIBLE) {
|
if(item.grid->get_visible() != twidget::tvisible::invisible) {
|
||||||
item.grid->draw_children(frame_buffer, x_offset, y_offset);
|
item.grid->draw_children(frame_buffer, x_offset, y_offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,8 +238,8 @@ void tpane::filter(const tfilter_functor& filter_functor)
|
||||||
FOREACH(AUTO& item, items_) {
|
FOREACH(AUTO& item, items_) {
|
||||||
item.grid->set_visible(
|
item.grid->set_visible(
|
||||||
filter_functor(item)
|
filter_functor(item)
|
||||||
? twidget::VISIBLE
|
? twidget::tvisible::visible
|
||||||
: twidget::INVISIBLE);
|
: twidget::tvisible::invisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_origin_children();
|
set_origin_children();
|
||||||
|
@ -303,7 +303,7 @@ void tpane::place_children()
|
||||||
prepare_placement();
|
prepare_placement();
|
||||||
unsigned index = 0;
|
unsigned index = 0;
|
||||||
FOREACH(AUTO& item, items_) {
|
FOREACH(AUTO& item, items_) {
|
||||||
if(item.grid->get_visible() == twidget::INVISIBLE) {
|
if(item.grid->get_visible() == twidget::tvisible::invisible) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ void tpane::set_origin_children()
|
||||||
prepare_placement();
|
prepare_placement();
|
||||||
unsigned index = 0;
|
unsigned index = 0;
|
||||||
FOREACH(AUTO& item, items_) {
|
FOREACH(AUTO& item, items_) {
|
||||||
if(item.grid->get_visible() == twidget::INVISIBLE) {
|
if(item.grid->get_visible() == twidget::tvisible::invisible) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,7 +333,7 @@ void tpane::place_or_set_origin_children()
|
||||||
prepare_placement();
|
prepare_placement();
|
||||||
unsigned index = 0;
|
unsigned index = 0;
|
||||||
FOREACH(AUTO& item, items_) {
|
FOREACH(AUTO& item, items_) {
|
||||||
if(item.grid->get_visible() == twidget::INVISIBLE) {
|
if(item.grid->get_visible() == twidget::tvisible::invisible) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,7 +353,7 @@ void tpane::prepare_placement() const
|
||||||
placer_->initialise();
|
placer_->initialise();
|
||||||
|
|
||||||
FOREACH(const AUTO& item, items_) {
|
FOREACH(const AUTO& item, items_) {
|
||||||
if(item.grid->get_visible() == twidget::INVISIBLE) {
|
if(item.grid->get_visible() == twidget::tvisible::invisible) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,7 +372,7 @@ void tpane::signal_handler_request_placement(
|
||||||
if(widget) {
|
if(widget) {
|
||||||
FOREACH(AUTO& item, items_) {
|
FOREACH(AUTO& item, items_) {
|
||||||
if(item.grid->has_widget(widget)) {
|
if(item.grid->has_widget(widget)) {
|
||||||
if(item.grid->get_visible() != twidget::INVISIBLE) {
|
if(item.grid->get_visible() != twidget::tvisible::invisible) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This time we call init layout but also the linked widget
|
* This time we call init layout but also the linked widget
|
||||||
|
@ -380,7 +380,7 @@ void tpane::signal_handler_request_placement(
|
||||||
* addon_list. This code can use some more tuning,
|
* addon_list. This code can use some more tuning,
|
||||||
* polishing and testing.
|
* polishing and testing.
|
||||||
*/
|
*/
|
||||||
item.grid->layout_init(false);
|
item.grid->layout_initialise(false);
|
||||||
get_window()->layout_linked_widgets();
|
get_window()->layout_linked_widgets();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
|
typedef std::map< std::string, t_string > string_map;
|
||||||
|
|
||||||
namespace gui2 {
|
namespace gui2 {
|
||||||
|
|
||||||
namespace implementation {
|
namespace implementation {
|
||||||
|
@ -79,8 +81,8 @@ public:
|
||||||
/** Inherited from twidget. */
|
/** Inherited from twidget. */
|
||||||
void place(const tpoint& origin, const tpoint& size);
|
void place(const tpoint& origin, const tpoint& size);
|
||||||
|
|
||||||
/** Inherited from twidget. */
|
/** See @ref twidget::layout_initialise. */
|
||||||
void layout_init(const bool full_initialization);
|
virtual void layout_initialise(const bool full_initialisation) OVERRIDE;
|
||||||
|
|
||||||
/** Inherited from twidget. */
|
/** Inherited from twidget. */
|
||||||
void impl_draw_children(surface& frame_buffer, int x_offset, int y_offset);
|
void impl_draw_children(surface& frame_buffer, int x_offset, int y_offset);
|
||||||
|
|
|
@ -38,7 +38,7 @@ SDL_Rect tpanel::get_client_rect() const
|
||||||
boost::dynamic_pointer_cast<const tpanel_definition::tresolution>(config());
|
boost::dynamic_pointer_cast<const tpanel_definition::tresolution>(config());
|
||||||
assert(conf);
|
assert(conf);
|
||||||
|
|
||||||
SDL_Rect result = get_rect();
|
SDL_Rect result = get_rectangle();
|
||||||
result.x += conf->left_border;
|
result.x += conf->left_border;
|
||||||
result.y += conf->top_border;
|
result.y += conf->top_border;
|
||||||
result.w -= conf->left_border + conf->right_border;
|
result.w -= conf->left_border + conf->right_border;
|
||||||
|
@ -50,10 +50,10 @@ SDL_Rect tpanel::get_client_rect() const
|
||||||
void tpanel::impl_draw_background(surface& frame_buffer)
|
void tpanel::impl_draw_background(surface& frame_buffer)
|
||||||
{
|
{
|
||||||
DBG_GUI_D << LOG_HEADER
|
DBG_GUI_D << LOG_HEADER
|
||||||
<< " size " << get_rect()
|
<< " size " << get_rectangle()
|
||||||
<< ".\n";
|
<< ".\n";
|
||||||
|
|
||||||
canvas(0).blit(frame_buffer, get_rect());
|
canvas(0).blit(frame_buffer, get_rectangle());
|
||||||
}
|
}
|
||||||
|
|
||||||
void tpanel::impl_draw_background(
|
void tpanel::impl_draw_background(
|
||||||
|
@ -62,7 +62,7 @@ void tpanel::impl_draw_background(
|
||||||
, int y_offset)
|
, int y_offset)
|
||||||
{
|
{
|
||||||
DBG_GUI_D << LOG_HEADER
|
DBG_GUI_D << LOG_HEADER
|
||||||
<< " size " << get_rect()
|
<< " size " << get_rectangle()
|
||||||
<< ".\n";
|
<< ".\n";
|
||||||
|
|
||||||
canvas(0).blit(
|
canvas(0).blit(
|
||||||
|
@ -72,7 +72,7 @@ void tpanel::impl_draw_background(
|
||||||
|
|
||||||
void tpanel::impl_draw_foreground(surface& frame_buffer)
|
void tpanel::impl_draw_foreground(surface& frame_buffer)
|
||||||
{
|
{
|
||||||
canvas(1).blit(frame_buffer, get_rect());
|
canvas(1).blit(frame_buffer, get_rectangle());
|
||||||
}
|
}
|
||||||
|
|
||||||
void tpanel::impl_draw_foreground(
|
void tpanel::impl_draw_foreground(
|
||||||
|
|
|
@ -129,7 +129,7 @@ void tpassword_box::post_function() {
|
||||||
// Why do the selection functions not update
|
// Why do the selection functions not update
|
||||||
// the canvas?
|
// the canvas?
|
||||||
update_canvas();
|
update_canvas();
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& tpassword_box::get_control_type() const
|
const std::string& tpassword_box::get_control_type() const
|
||||||
|
|
|
@ -44,7 +44,7 @@ void tprogress_bar::set_percentage(const unsigned percentage)
|
||||||
c.set_variable("percentage", variant(percentage));
|
c.set_variable("percentage", variant(percentage));
|
||||||
}
|
}
|
||||||
|
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@ void tscrollbar_::update_canvas() {
|
||||||
tmp.set_variable("positioner_offset", variant(positioner_offset_));
|
tmp.set_variable("positioner_offset", variant(positioner_offset_));
|
||||||
tmp.set_variable("positioner_length", variant(positioner_length_));
|
tmp.set_variable("positioner_length", variant(positioner_length_));
|
||||||
}
|
}
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscrollbar_::set_state(const tstate state)
|
void tscrollbar_::set_state(const tstate state)
|
||||||
|
|
|
@ -115,44 +115,50 @@ tscrollbar_container::tscrollbar_container(const unsigned canvas_count)
|
||||||
, event::tdispatcher::back_post_child);
|
, event::tdispatcher::back_post_child);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscrollbar_container::layout_init(const bool full_initialization)
|
void tscrollbar_container::layout_initialise(const bool full_initialisation)
|
||||||
{
|
{
|
||||||
// Inherited.
|
// Inherited.
|
||||||
tcontainer_::layout_init(full_initialization);
|
tcontainer_::layout_initialise(full_initialisation);
|
||||||
|
|
||||||
if(full_initialization) {
|
if(full_initialisation) {
|
||||||
|
|
||||||
assert(vertical_scrollbar_grid_);
|
assert(vertical_scrollbar_grid_);
|
||||||
switch(vertical_scrollbar_mode_) {
|
switch(vertical_scrollbar_mode_) {
|
||||||
case always_visible :
|
case always_visible :
|
||||||
vertical_scrollbar_grid_->set_visible(twidget::VISIBLE);
|
vertical_scrollbar_grid_
|
||||||
|
->set_visible(twidget::tvisible::visible);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case auto_visible :
|
case auto_visible :
|
||||||
vertical_scrollbar_grid_->set_visible(twidget::HIDDEN);
|
vertical_scrollbar_grid_
|
||||||
|
->set_visible(twidget::tvisible::hidden);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default :
|
default :
|
||||||
vertical_scrollbar_grid_->set_visible(twidget::INVISIBLE);
|
vertical_scrollbar_grid_
|
||||||
|
->set_visible(twidget::tvisible::invisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(horizontal_scrollbar_grid_);
|
assert(horizontal_scrollbar_grid_);
|
||||||
switch(horizontal_scrollbar_mode_) {
|
switch(horizontal_scrollbar_mode_) {
|
||||||
case always_visible :
|
case always_visible :
|
||||||
horizontal_scrollbar_grid_->set_visible(twidget::VISIBLE);
|
horizontal_scrollbar_grid_
|
||||||
|
->set_visible(twidget::tvisible::visible);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case auto_visible :
|
case auto_visible :
|
||||||
horizontal_scrollbar_grid_->set_visible(twidget::HIDDEN);
|
horizontal_scrollbar_grid_
|
||||||
|
->set_visible(twidget::tvisible::hidden);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default :
|
default :
|
||||||
horizontal_scrollbar_grid_->set_visible(twidget::INVISIBLE);
|
horizontal_scrollbar_grid_
|
||||||
|
->set_visible(twidget::tvisible::invisible);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(content_grid_);
|
assert(content_grid_);
|
||||||
content_grid_->layout_init(full_initialization);
|
content_grid_->layout_initialise(full_initialisation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscrollbar_container::request_reduce_height(
|
void tscrollbar_container::request_reduce_height(
|
||||||
|
@ -167,10 +173,13 @@ void tscrollbar_container::request_reduce_height(
|
||||||
*/
|
*/
|
||||||
/** @todo Evaluate whether sizing hints are required. */
|
/** @todo Evaluate whether sizing hints are required. */
|
||||||
assert(content_grid_);
|
assert(content_grid_);
|
||||||
const unsigned offset = horizontal_scrollbar_grid_
|
const unsigned offset
|
||||||
&& horizontal_scrollbar_grid_->get_visible() != twidget::INVISIBLE
|
= horizontal_scrollbar_grid_
|
||||||
? horizontal_scrollbar_grid_->get_best_size().y
|
&& horizontal_scrollbar_grid_->get_visible()
|
||||||
: 0;
|
!= twidget::tvisible::invisible
|
||||||
|
? horizontal_scrollbar_grid_->get_best_size().y
|
||||||
|
: 0;
|
||||||
|
|
||||||
content_grid_->request_reduce_height(maximum_height - offset);
|
content_grid_->request_reduce_height(maximum_height - offset);
|
||||||
|
|
||||||
// Did we manage to achieve the wanted size?
|
// Did we manage to achieve the wanted size?
|
||||||
|
@ -189,16 +198,16 @@ void tscrollbar_container::request_reduce_height(
|
||||||
|
|
||||||
assert(vertical_scrollbar_grid_);
|
assert(vertical_scrollbar_grid_);
|
||||||
const bool resized =
|
const bool resized =
|
||||||
vertical_scrollbar_grid_->get_visible() == twidget::INVISIBLE;
|
vertical_scrollbar_grid_->get_visible() == twidget::tvisible::invisible;
|
||||||
|
|
||||||
// Always set the bar visible, is a nop is already visible.
|
// Always set the bar visible, is a nop is already visible.
|
||||||
vertical_scrollbar_grid_->set_visible(twidget::VISIBLE);
|
vertical_scrollbar_grid_->set_visible(twidget::tvisible::visible);
|
||||||
|
|
||||||
const tpoint scrollbar_size = vertical_scrollbar_grid_->get_best_size();
|
const tpoint scrollbar_size = vertical_scrollbar_grid_->get_best_size();
|
||||||
|
|
||||||
// If showing the scrollbar increased the height, hide and abort.
|
// If showing the scrollbar increased the height, hide and abort.
|
||||||
if(resized && scrollbar_size.y > size.y) {
|
if(resized && scrollbar_size.y > size.y) {
|
||||||
vertical_scrollbar_grid_->set_visible(twidget::INVISIBLE);
|
vertical_scrollbar_grid_->set_visible(twidget::tvisible::invisible);
|
||||||
DBG_GUI_L << LOG_HEADER
|
DBG_GUI_L << LOG_HEADER
|
||||||
<< " request failed, showing the scrollbar"
|
<< " request failed, showing the scrollbar"
|
||||||
<< " increased the height to " << scrollbar_size.y
|
<< " increased the height to " << scrollbar_size.y
|
||||||
|
@ -237,10 +246,13 @@ void tscrollbar_container::request_reduce_width(
|
||||||
// First ask our content, it might be able to wrap which looks better as
|
// First ask our content, it might be able to wrap which looks better as
|
||||||
// a scrollbar.
|
// a scrollbar.
|
||||||
assert(content_grid_);
|
assert(content_grid_);
|
||||||
const unsigned offset = vertical_scrollbar_grid_
|
const unsigned offset
|
||||||
&& vertical_scrollbar_grid_->get_visible() != twidget::INVISIBLE
|
= vertical_scrollbar_grid_
|
||||||
? vertical_scrollbar_grid_->get_best_size().x
|
&& vertical_scrollbar_grid_->get_visible()
|
||||||
: 0;
|
!= twidget::tvisible::invisible
|
||||||
|
? vertical_scrollbar_grid_->get_best_size().x
|
||||||
|
: 0;
|
||||||
|
|
||||||
content_grid_->request_reduce_width(maximum_width - offset);
|
content_grid_->request_reduce_width(maximum_width - offset);
|
||||||
|
|
||||||
// Did we manage to achieve the wanted size?
|
// Did we manage to achieve the wanted size?
|
||||||
|
@ -259,7 +271,7 @@ void tscrollbar_container::request_reduce_width(
|
||||||
|
|
||||||
// Always set the bar visible, is a nop when it's already visible.
|
// Always set the bar visible, is a nop when it's already visible.
|
||||||
assert(horizontal_scrollbar_grid_);
|
assert(horizontal_scrollbar_grid_);
|
||||||
horizontal_scrollbar_grid_->set_visible(twidget::VISIBLE);
|
horizontal_scrollbar_grid_->set_visible(twidget::tvisible::visible);
|
||||||
size = get_best_size();
|
size = get_best_size();
|
||||||
|
|
||||||
const tpoint scrollbar_size = horizontal_scrollbar_grid_->get_best_size();
|
const tpoint scrollbar_size = horizontal_scrollbar_grid_->get_best_size();
|
||||||
|
@ -268,7 +280,7 @@ void tscrollbar_container::request_reduce_width(
|
||||||
if(horizontal_scrollbar_mode_ == auto_visible_first_run
|
if(horizontal_scrollbar_mode_ == auto_visible_first_run
|
||||||
&& scrollbar_size.x > size.x) {
|
&& scrollbar_size.x > size.x) {
|
||||||
|
|
||||||
horizontal_scrollbar_grid_->set_visible(twidget::INVISIBLE);
|
horizontal_scrollbar_grid_->set_visible(twidget::tvisible::invisible);
|
||||||
DBG_GUI_L << LOG_HEADER
|
DBG_GUI_L << LOG_HEADER
|
||||||
<< " request failed, showing the scrollbar"
|
<< " request failed, showing the scrollbar"
|
||||||
<< " increased the width to " << scrollbar_size.x
|
<< " increased the width to " << scrollbar_size.x
|
||||||
|
@ -295,14 +307,16 @@ tpoint tscrollbar_container::calculate_best_size() const
|
||||||
log_scope2(log_gui_layout, LOG_SCOPE_HEADER);
|
log_scope2(log_gui_layout, LOG_SCOPE_HEADER);
|
||||||
|
|
||||||
/***** get vertical scrollbar size *****/
|
/***** get vertical scrollbar size *****/
|
||||||
const tpoint vertical_scrollbar =
|
const tpoint vertical_scrollbar
|
||||||
vertical_scrollbar_grid_->get_visible() == twidget::INVISIBLE
|
= vertical_scrollbar_grid_->get_visible()
|
||||||
|
== twidget::tvisible::invisible
|
||||||
? tpoint(0, 0)
|
? tpoint(0, 0)
|
||||||
: vertical_scrollbar_grid_->get_best_size();
|
: vertical_scrollbar_grid_->get_best_size();
|
||||||
|
|
||||||
/***** get horizontal scrollbar size *****/
|
/***** get horizontal scrollbar size *****/
|
||||||
const tpoint horizontal_scrollbar =
|
const tpoint horizontal_scrollbar
|
||||||
horizontal_scrollbar_grid_->get_visible() == twidget::INVISIBLE
|
= horizontal_scrollbar_grid_->get_visible()
|
||||||
|
== twidget::tvisible::invisible
|
||||||
? tpoint(0, 0)
|
? tpoint(0, 0)
|
||||||
: horizontal_scrollbar_grid_->get_best_size();
|
: horizontal_scrollbar_grid_->get_best_size();
|
||||||
|
|
||||||
|
@ -333,7 +347,7 @@ static void set_scrollbar_mode(tgrid* scrollbar_grid, tscrollbar_* scrollbar,
|
||||||
assert(scrollbar_grid && scrollbar);
|
assert(scrollbar_grid && scrollbar);
|
||||||
|
|
||||||
if(scrollbar_mode == tscrollbar_container::always_invisible) {
|
if(scrollbar_mode == tscrollbar_container::always_invisible) {
|
||||||
scrollbar_grid->set_visible(twidget::INVISIBLE);
|
scrollbar_grid->set_visible(twidget::tvisible::invisible);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,8 +360,8 @@ static void set_scrollbar_mode(tgrid* scrollbar_grid, tscrollbar_* scrollbar,
|
||||||
const bool scrollbar_needed = items > visible_items;
|
const bool scrollbar_needed = items > visible_items;
|
||||||
|
|
||||||
scrollbar_grid->set_visible(scrollbar_needed
|
scrollbar_grid->set_visible(scrollbar_needed
|
||||||
? twidget::VISIBLE
|
? twidget::tvisible::visible
|
||||||
: twidget::HIDDEN);
|
: twidget::tvisible::hidden);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,8 +400,8 @@ void tscrollbar_container::place(const tpoint& origin, const tpoint& size)
|
||||||
set_scrollbar_button_status();
|
set_scrollbar_button_status();
|
||||||
|
|
||||||
// Now set the visible part of the content.
|
// Now set the visible part of the content.
|
||||||
content_visible_area_ = content_->get_rect();
|
content_visible_area_ = content_->get_rectangle();
|
||||||
content_grid_->set_visible_area(content_visible_area_);
|
content_grid_->set_visible_rectangle(content_visible_area_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscrollbar_container::set_origin(const tpoint& origin)
|
void tscrollbar_container::set_origin(const tpoint& origin)
|
||||||
|
@ -403,18 +417,19 @@ void tscrollbar_container::set_origin(const tpoint& origin)
|
||||||
content_grid_->set_origin(content_origin);
|
content_grid_->set_origin(content_origin);
|
||||||
|
|
||||||
// Changing the origin also invalidates the visible area.
|
// Changing the origin also invalidates the visible area.
|
||||||
content_grid_->set_visible_area(content_visible_area_);
|
content_grid_->set_visible_rectangle(content_visible_area_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscrollbar_container::set_visible_area(const SDL_Rect& area)
|
void tscrollbar_container::set_visible_rectangle(const SDL_Rect& rectangle)
|
||||||
{
|
{
|
||||||
// Inherited.
|
// Inherited.
|
||||||
tcontainer_::set_visible_area(area);
|
tcontainer_::set_visible_rectangle(rectangle);
|
||||||
|
|
||||||
// Now get the visible part of the content.
|
// Now get the visible part of the content.
|
||||||
content_visible_area_ = intersect_rects(area, content_->get_rect());
|
content_visible_area_
|
||||||
|
= intersect_rects(rectangle, content_->get_rectangle());
|
||||||
|
|
||||||
content_grid_->set_visible_area(content_visible_area_);
|
content_grid_->set_visible_rectangle(content_visible_area_);
|
||||||
}
|
}
|
||||||
|
|
||||||
twidget* tscrollbar_container::find_at(
|
twidget* tscrollbar_container::find_at(
|
||||||
|
@ -497,7 +512,7 @@ bool tscrollbar_container::content_resize_request(const bool force_sizing)
|
||||||
if(horizontal_scrollbar_mode_ == always_invisible
|
if(horizontal_scrollbar_mode_ == always_invisible
|
||||||
|| (horizontal_scrollbar_mode_ == auto_visible_first_run
|
|| (horizontal_scrollbar_mode_ == auto_visible_first_run
|
||||||
&& horizontal_scrollbar_grid_->get_visible()
|
&& horizontal_scrollbar_grid_->get_visible()
|
||||||
== twidget::INVISIBLE)) {
|
== twidget::tvisible::invisible)) {
|
||||||
|
|
||||||
DBG_GUI_L << LOG_HEADER
|
DBG_GUI_L << LOG_HEADER
|
||||||
<< " can't use horizontal scrollbar, ask window.\n";
|
<< " can't use horizontal scrollbar, ask window.\n";
|
||||||
|
@ -513,7 +528,7 @@ bool tscrollbar_container::content_resize_request(const bool force_sizing)
|
||||||
if(vertical_scrollbar_mode_ == always_invisible
|
if(vertical_scrollbar_mode_ == always_invisible
|
||||||
|| (vertical_scrollbar_mode_ == auto_visible_first_run
|
|| (vertical_scrollbar_mode_ == auto_visible_first_run
|
||||||
&& vertical_scrollbar_grid_->get_visible()
|
&& vertical_scrollbar_grid_->get_visible()
|
||||||
== twidget::INVISIBLE)) {
|
== twidget::tvisible::invisible)) {
|
||||||
|
|
||||||
DBG_GUI_L << LOG_HEADER
|
DBG_GUI_L << LOG_HEADER
|
||||||
<< " can't use vertical scrollbar, ask window.\n";
|
<< " can't use vertical scrollbar, ask window.\n";
|
||||||
|
@ -597,7 +612,7 @@ bool tscrollbar_container::content_resize_width(const int width_modification)
|
||||||
if(horizontal_scrollbar_mode_ == always_invisible
|
if(horizontal_scrollbar_mode_ == always_invisible
|
||||||
|| (horizontal_scrollbar_mode_ == auto_visible_first_run
|
|| (horizontal_scrollbar_mode_ == auto_visible_first_run
|
||||||
&& horizontal_scrollbar_grid_->get_visible()
|
&& horizontal_scrollbar_grid_->get_visible()
|
||||||
== twidget::INVISIBLE)) {
|
== twidget::tvisible::invisible)) {
|
||||||
|
|
||||||
DBG_GUI_L << " can't use horizontal scrollbar, ask window.\n";
|
DBG_GUI_L << " can't use horizontal scrollbar, ask window.\n";
|
||||||
twindow* window = get_window();
|
twindow* window = get_window();
|
||||||
|
@ -645,7 +660,7 @@ bool tscrollbar_container::content_resize_height(const int height_modification)
|
||||||
if(vertical_scrollbar_mode_ == always_invisible
|
if(vertical_scrollbar_mode_ == always_invisible
|
||||||
|| (vertical_scrollbar_mode_ == auto_visible_first_run
|
|| (vertical_scrollbar_mode_ == auto_visible_first_run
|
||||||
&& vertical_scrollbar_grid_->get_visible()
|
&& vertical_scrollbar_grid_->get_visible()
|
||||||
== twidget::INVISIBLE)) {
|
== twidget::tvisible::invisible)) {
|
||||||
|
|
||||||
DBG_GUI_L << " can't use vertical scrollbar, ask window.\n";
|
DBG_GUI_L << " can't use vertical scrollbar, ask window.\n";
|
||||||
twindow* window = get_window();
|
twindow* window = get_window();
|
||||||
|
@ -749,8 +764,8 @@ void tscrollbar_container::
|
||||||
|
|
||||||
void tscrollbar_container::impl_draw_children(surface& frame_buffer)
|
void tscrollbar_container::impl_draw_children(surface& frame_buffer)
|
||||||
{
|
{
|
||||||
assert(get_visible() == twidget::VISIBLE
|
assert(get_visible() == twidget::tvisible::visible
|
||||||
&& content_grid_->get_visible() == twidget::VISIBLE);
|
&& content_grid_->get_visible() == twidget::tvisible::visible);
|
||||||
|
|
||||||
// Inherited.
|
// Inherited.
|
||||||
tcontainer_::impl_draw_children(frame_buffer);
|
tcontainer_::impl_draw_children(frame_buffer);
|
||||||
|
@ -763,8 +778,8 @@ void tscrollbar_container::impl_draw_children(
|
||||||
, int x_offset
|
, int x_offset
|
||||||
, int y_offset)
|
, int y_offset)
|
||||||
{
|
{
|
||||||
assert(get_visible() == twidget::VISIBLE
|
assert(get_visible() == twidget::tvisible::visible
|
||||||
&& content_grid_->get_visible() == twidget::VISIBLE);
|
&& content_grid_->get_visible() == twidget::tvisible::visible);
|
||||||
|
|
||||||
// Inherited.
|
// Inherited.
|
||||||
tcontainer_::impl_draw_children(frame_buffer, x_offset, y_offset);
|
tcontainer_::impl_draw_children(frame_buffer, x_offset, y_offset);
|
||||||
|
@ -1031,8 +1046,8 @@ void tscrollbar_container::scrollbar_moved()
|
||||||
content_->get_y() - y_offset);
|
content_->get_y() - y_offset);
|
||||||
|
|
||||||
content_grid_->set_origin(content_origin);
|
content_grid_->set_origin(content_origin);
|
||||||
content_grid_->set_visible_area(content_visible_area_);
|
content_grid_->set_visible_rectangle(content_visible_area_);
|
||||||
content_grid_->set_dirty();
|
content_grid_->set_dirty(true);
|
||||||
|
|
||||||
// Update scrollbar.
|
// Update scrollbar.
|
||||||
set_scrollbar_button_status();
|
set_scrollbar_button_status();
|
||||||
|
@ -1100,7 +1115,7 @@ void tscrollbar_container::signal_handler_sdl_wheel_up(
|
||||||
|
|
||||||
assert(vertical_scrollbar_grid_ && vertical_scrollbar_);
|
assert(vertical_scrollbar_grid_ && vertical_scrollbar_);
|
||||||
|
|
||||||
if(vertical_scrollbar_grid_->get_visible() == twidget::VISIBLE) {
|
if(vertical_scrollbar_grid_->get_visible() == twidget::tvisible::visible) {
|
||||||
vertical_scrollbar_->scroll(tscrollbar_::HALF_JUMP_BACKWARDS);
|
vertical_scrollbar_->scroll(tscrollbar_::HALF_JUMP_BACKWARDS);
|
||||||
scrollbar_moved();
|
scrollbar_moved();
|
||||||
handled = true;
|
handled = true;
|
||||||
|
@ -1115,7 +1130,7 @@ void tscrollbar_container::signal_handler_sdl_wheel_down(
|
||||||
|
|
||||||
assert(vertical_scrollbar_grid_ && vertical_scrollbar_);
|
assert(vertical_scrollbar_grid_ && vertical_scrollbar_);
|
||||||
|
|
||||||
if(vertical_scrollbar_grid_->get_visible() == twidget::VISIBLE) {
|
if(vertical_scrollbar_grid_->get_visible() == twidget::tvisible::visible) {
|
||||||
vertical_scrollbar_->scroll(tscrollbar_::HALF_JUMP_FORWARD);
|
vertical_scrollbar_->scroll(tscrollbar_::HALF_JUMP_FORWARD);
|
||||||
scrollbar_moved();
|
scrollbar_moved();
|
||||||
handled = true;
|
handled = true;
|
||||||
|
@ -1130,7 +1145,7 @@ void tscrollbar_container::signal_handler_sdl_wheel_left(
|
||||||
|
|
||||||
assert(horizontal_scrollbar_grid_ && horizontal_scrollbar_);
|
assert(horizontal_scrollbar_grid_ && horizontal_scrollbar_);
|
||||||
|
|
||||||
if(horizontal_scrollbar_grid_->get_visible() == twidget::VISIBLE) {
|
if(horizontal_scrollbar_grid_->get_visible() == twidget::tvisible::visible) {
|
||||||
horizontal_scrollbar_->scroll(tscrollbar_::HALF_JUMP_BACKWARDS);
|
horizontal_scrollbar_->scroll(tscrollbar_::HALF_JUMP_BACKWARDS);
|
||||||
scrollbar_moved();
|
scrollbar_moved();
|
||||||
handled = true;
|
handled = true;
|
||||||
|
@ -1145,7 +1160,7 @@ void tscrollbar_container::signal_handler_sdl_wheel_right(
|
||||||
|
|
||||||
assert(horizontal_scrollbar_grid_ && horizontal_scrollbar_);
|
assert(horizontal_scrollbar_grid_ && horizontal_scrollbar_);
|
||||||
|
|
||||||
if(horizontal_scrollbar_grid_->get_visible() == twidget::VISIBLE) {
|
if(horizontal_scrollbar_grid_->get_visible() == twidget::tvisible::visible) {
|
||||||
horizontal_scrollbar_->scroll(tscrollbar_::HALF_JUMP_FORWARD);
|
horizontal_scrollbar_->scroll(tscrollbar_::HALF_JUMP_FORWARD);
|
||||||
scrollbar_moved();
|
scrollbar_moved();
|
||||||
handled = true;
|
handled = true;
|
||||||
|
|
|
@ -85,8 +85,8 @@ public:
|
||||||
|
|
||||||
/***** ***** ***** ***** layout functions ***** ***** ***** *****/
|
/***** ***** ***** ***** layout functions ***** ***** ***** *****/
|
||||||
|
|
||||||
/** Inherited from tcontainer_. */
|
/** See @ref twidget::layout_initialise. */
|
||||||
void layout_init(const bool full_initialization);
|
virtual void layout_initialise(const bool full_initialisation) OVERRIDE;
|
||||||
|
|
||||||
/** Inherited from twidget. */
|
/** Inherited from twidget. */
|
||||||
void request_reduce_height(const unsigned maximum_height);
|
void request_reduce_height(const unsigned maximum_height);
|
||||||
|
@ -114,8 +114,8 @@ public:
|
||||||
/** Inherited from tcontainer_. */
|
/** Inherited from tcontainer_. */
|
||||||
void set_origin(const tpoint& origin);
|
void set_origin(const tpoint& origin);
|
||||||
|
|
||||||
/** Inherited from tcontainer_. */
|
/** See @ref twidget::set_visible_rectangle. */
|
||||||
void set_visible_area(const SDL_Rect& area);
|
virtual void set_visible_rectangle(const SDL_Rect& rectangle) OVERRIDE;
|
||||||
|
|
||||||
/***** ***** ***** inherited ****** *****/
|
/***** ***** ***** inherited ****** *****/
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "serialization/schema_validator.hpp"
|
#include "serialization/schema_validator.hpp"
|
||||||
#include "formula_string_utils.hpp"
|
#include "formula_string_utils.hpp"
|
||||||
#include "utils/foreach.tpp"
|
#include "utils/foreach.tpp"
|
||||||
|
#include "wml_exception.hpp"
|
||||||
|
|
||||||
namespace gui2 {
|
namespace gui2 {
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ public:
|
||||||
/***** ***** ***** setters / getters for members ***** ****** *****/
|
/***** ***** ***** setters / getters for members ***** ****** *****/
|
||||||
|
|
||||||
void set_best_slider_length(const unsigned length)
|
void set_best_slider_length(const unsigned length)
|
||||||
{ best_slider_length_ = length; set_dirty(); }
|
{ best_slider_length_ = length; set_dirty(true); }
|
||||||
|
|
||||||
void set_minimum_value_label(const t_string& minimum_value_label)
|
void set_minimum_value_label(const t_string& minimum_value_label)
|
||||||
{ minimum_value_label_ = minimum_value_label; }
|
{ minimum_value_label_ = minimum_value_label; }
|
||||||
|
|
|
@ -66,7 +66,7 @@ void ttext_::set_maximum_length(const size_t maximum_length)
|
||||||
selection_length_ = maximum_length - selection_start_;
|
selection_length_ = maximum_length - selection_start_;
|
||||||
}
|
}
|
||||||
update_canvas();
|
update_canvas();
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ void ttext_::set_value(const std::string& text)
|
||||||
selection_start_ = text_.get_length();
|
selection_start_ = text_.get_length();
|
||||||
selection_length_ = 0;
|
selection_length_ = 0;
|
||||||
update_canvas();
|
update_canvas();
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ void ttext_::set_cursor(const size_t offset, const bool select)
|
||||||
copy_selection(true);
|
copy_selection(true);
|
||||||
#endif
|
#endif
|
||||||
update_canvas();
|
update_canvas();
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
assert(offset <= text_.get_length());
|
assert(offset <= text_.get_length());
|
||||||
|
@ -106,7 +106,7 @@ void ttext_::set_cursor(const size_t offset, const bool select)
|
||||||
selection_length_ = 0;
|
selection_length_ = 0;
|
||||||
|
|
||||||
update_canvas();
|
update_canvas();
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ void ttext_::insert_char(const Uint16 unicode)
|
||||||
// Update status
|
// Update status
|
||||||
set_cursor(selection_start_ + 1, false);
|
set_cursor(selection_start_ + 1, false);
|
||||||
update_canvas();
|
update_canvas();
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ void ttext_::paste_selection(const bool mouse)
|
||||||
selection_start_ += text_.insert_text(selection_start_, text);
|
selection_start_ += text_.insert_text(selection_start_, text);
|
||||||
|
|
||||||
update_canvas();
|
update_canvas();
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
fire(event::NOTIFY_MODIFIED, *this, NULL);
|
fire(event::NOTIFY_MODIFIED, *this, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ void ttext_::set_selection_start(const size_t selection_start)
|
||||||
{
|
{
|
||||||
if(selection_start != selection_start_) {
|
if(selection_start != selection_start_) {
|
||||||
selection_start_ = selection_start;
|
selection_start_ = selection_start;
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ void ttext_::set_selection_length(const int selection_length)
|
||||||
{
|
{
|
||||||
if(selection_length != selection_length_) {
|
if(selection_length != selection_length_) {
|
||||||
selection_length_ = selection_length;
|
selection_length_ = selection_length;
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -235,7 +235,7 @@ void ttext_box::handle_mouse_selection(tpoint mouse, const bool start_selection)
|
||||||
|
|
||||||
set_cursor(offset, !start_selection);
|
set_cursor(offset, !start_selection);
|
||||||
update_canvas();
|
update_canvas();
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
dragging_ |= start_selection;
|
dragging_ |= start_selection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ void ttext_box::update_offsets()
|
||||||
tmp.set_variable("text_font_height", variant(text_height_));
|
tmp.set_variable("text_font_height", variant(text_height_));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Force an update of the canvas since now text_font_height is known.
|
// Force an update of the canvas since now text_font_height is known.
|
||||||
update_canvas();
|
update_canvas();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ void ttoggle_button::update_canvas()
|
||||||
canvas.set_variable("icon", variant(icon_name_));
|
canvas.set_variable("icon", variant(icon_name_));
|
||||||
}
|
}
|
||||||
|
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ttoggle_button::set_value(const bool selected)
|
void ttoggle_button::set_value(const bool selected)
|
||||||
|
|
|
@ -102,7 +102,7 @@ SDL_Rect ttoggle_panel::get_client_rect() const
|
||||||
boost::dynamic_pointer_cast<const ttoggle_panel_definition::tresolution>(config());
|
boost::dynamic_pointer_cast<const ttoggle_panel_definition::tresolution>(config());
|
||||||
assert(conf);
|
assert(conf);
|
||||||
|
|
||||||
SDL_Rect result = get_rect();
|
SDL_Rect result = get_rectangle();
|
||||||
result.x += conf->left_border;
|
result.x += conf->left_border;
|
||||||
result.y += conf->top_border;
|
result.y += conf->top_border;
|
||||||
result.w -= conf->left_border + conf->right_border;
|
result.w -= conf->left_border + conf->right_border;
|
||||||
|
|
|
@ -131,7 +131,7 @@ void ttree_view::resize_content(
|
||||||
need_layout_ = true;
|
need_layout_ = true;
|
||||||
// If the content grows assume it "overwrites" the old content.
|
// If the content grows assume it "overwrites" the old content.
|
||||||
if(width_modification < 0 || height_modification < 0) {
|
if(width_modification < 0 || height_modification < 0) {
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
DBG_GUI_L << LOG_HEADER << " succeeded.\n";
|
DBG_GUI_L << LOG_HEADER << " succeeded.\n";
|
||||||
} else {
|
} else {
|
||||||
|
@ -147,7 +147,7 @@ void ttree_view::layout_children(const bool force)
|
||||||
root_node_->place(indention_step_size_
|
root_node_->place(indention_step_size_
|
||||||
, get_origin()
|
, get_origin()
|
||||||
, content_grid()->get_size().x);
|
, content_grid()->get_size().x);
|
||||||
root_node_->set_visible_area(content_visible_area_);
|
root_node_->set_visible_rectangle(content_visible_area_);
|
||||||
|
|
||||||
need_layout_ = false;
|
need_layout_ = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ ttree_view_node::ttree_view_node(const std::string& id
|
||||||
, false);
|
, false);
|
||||||
|
|
||||||
if(icon_) {
|
if(icon_) {
|
||||||
icon_->set_visible(twidget::HIDDEN);
|
icon_->set_visible(twidget::tvisible::hidden);
|
||||||
icon_->connect_signal<event::LEFT_BUTTON_CLICK>(
|
icon_->connect_signal<event::LEFT_BUTTON_CLICK>(
|
||||||
boost::bind(&ttree_view_node::
|
boost::bind(&ttree_view_node::
|
||||||
signal_handler_left_button_click
|
signal_handler_left_button_click
|
||||||
|
@ -71,7 +71,7 @@ ttree_view_node::ttree_view_node(const std::string& id
|
||||||
}
|
}
|
||||||
|
|
||||||
if(parent_node_ && parent_node_->icon_) {
|
if(parent_node_ && parent_node_->icon_) {
|
||||||
parent_node_->icon_->set_visible(twidget::VISIBLE);
|
parent_node_->icon_->set_visible(twidget::tvisible::visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
twidget& widget = find_widget<twidget>(
|
twidget& widget = find_widget<twidget>(
|
||||||
|
@ -329,7 +329,7 @@ tpoint ttree_view_node::get_current_size() const
|
||||||
|
|
||||||
const ttree_view_node& node = *itor;
|
const ttree_view_node& node = *itor;
|
||||||
|
|
||||||
if(node.grid_.get_visible() == twidget::INVISIBLE) {
|
if(node.grid_.get_visible() == twidget::tvisible::invisible) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,7 +363,7 @@ tpoint ttree_view_node::get_unfolded_size() const
|
||||||
|
|
||||||
const ttree_view_node& node = *itor;
|
const ttree_view_node& node = *itor;
|
||||||
|
|
||||||
if(node.grid_.get_visible() == twidget::INVISIBLE) {
|
if(node.grid_.get_visible() == twidget::tvisible::invisible) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,7 +400,7 @@ tpoint ttree_view_node::calculate_best_size(const int indention_level
|
||||||
|
|
||||||
const ttree_view_node& node = *itor;
|
const ttree_view_node& node = *itor;
|
||||||
|
|
||||||
if(node.grid_.get_visible() == twidget::INVISIBLE) {
|
if(node.grid_.get_visible() == twidget::tvisible::invisible) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,11 +468,11 @@ unsigned ttree_view_node::place(
|
||||||
return origin.y - offset;
|
return origin.y - offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ttree_view_node::set_visible_area(const SDL_Rect& area)
|
void ttree_view_node::set_visible_rectangle(const SDL_Rect& rectangle)
|
||||||
{
|
{
|
||||||
log_scope2(log_gui_layout, LOG_SCOPE_HEADER);
|
log_scope2(log_gui_layout, LOG_SCOPE_HEADER);
|
||||||
DBG_GUI_L << LOG_HEADER << " area " << area << ".\n";
|
DBG_GUI_L << LOG_HEADER << " rectangle " << rectangle << ".\n";
|
||||||
grid_.set_visible_area(area);
|
grid_.set_visible_rectangle(rectangle);
|
||||||
|
|
||||||
if(is_folded()) {
|
if(is_folded()) {
|
||||||
DBG_GUI_L << LOG_HEADER << " folded node done.\n";
|
DBG_GUI_L << LOG_HEADER << " folded node done.\n";
|
||||||
|
@ -480,7 +480,7 @@ void ttree_view_node::set_visible_area(const SDL_Rect& area)
|
||||||
}
|
}
|
||||||
|
|
||||||
FOREACH(AUTO& node, children_) {
|
FOREACH(AUTO& node, children_) {
|
||||||
node.set_visible_area(area);
|
node.set_visible_rectangle(rectangle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -248,7 +248,8 @@ private:
|
||||||
, tpoint origin
|
, tpoint origin
|
||||||
, unsigned width);
|
, unsigned width);
|
||||||
|
|
||||||
void set_visible_area(const SDL_Rect& area);
|
/** See @ref twidget::set_visible_rectangle. */
|
||||||
|
virtual void set_visible_rectangle(const SDL_Rect& rectangle) OVERRIDE;
|
||||||
|
|
||||||
void impl_draw_children(surface& frame_buffer);
|
void impl_draw_children(surface& frame_buffer);
|
||||||
void impl_draw_children(surface& frame_buffer, int x_offset, int y_offset);
|
void impl_draw_children(surface& frame_buffer, int x_offset, int y_offset);
|
||||||
|
|
|
@ -121,12 +121,12 @@ void tviewport::place(const tpoint& origin, const tpoint& size)
|
||||||
widget_.place(tpoint(0, 0), widget_.get_best_size());
|
widget_.place(tpoint(0, 0), widget_.get_best_size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void tviewport::layout_init(const bool full_initialization)
|
void tviewport::layout_initialise(const bool full_initialisation)
|
||||||
{
|
{
|
||||||
twidget::layout_init(full_initialization);
|
twidget::layout_initialise(full_initialisation);
|
||||||
|
|
||||||
if(widget_.get_visible() != twidget::INVISIBLE) {
|
if(widget_.get_visible() != twidget::tvisible::invisible) {
|
||||||
widget_.layout_init(full_initialization);
|
widget_.layout_initialise(full_initialisation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ void tviewport::impl_draw_children(
|
||||||
x_offset += get_x();
|
x_offset += get_x();
|
||||||
y_offset += get_y();
|
y_offset += get_y();
|
||||||
|
|
||||||
if(widget_.get_visible() != twidget::INVISIBLE) {
|
if(widget_.get_visible() != twidget::tvisible::invisible) {
|
||||||
widget_.draw_background(frame_buffer, x_offset, y_offset);
|
widget_.draw_background(frame_buffer, x_offset, y_offset);
|
||||||
widget_.draw_children(frame_buffer, x_offset, y_offset);
|
widget_.draw_children(frame_buffer, x_offset, y_offset);
|
||||||
widget_.draw_foreground(frame_buffer, x_offset, y_offset);
|
widget_.draw_foreground(frame_buffer, x_offset, y_offset);
|
||||||
|
|
|
@ -53,8 +53,8 @@ public:
|
||||||
/** Inherited from twidget. */
|
/** Inherited from twidget. */
|
||||||
void place(const tpoint& origin, const tpoint& size);
|
void place(const tpoint& origin, const tpoint& size);
|
||||||
|
|
||||||
/** Inherited from twidget. */
|
/** See @ref twidget::layout_initialise. */
|
||||||
void layout_init(const bool full_initialization);
|
virtual void layout_initialise(const bool full_initialisation) OVERRIDE;
|
||||||
|
|
||||||
/** Inherited from twidget. */
|
/** Inherited from twidget. */
|
||||||
void impl_draw_children(surface& frame_buffer, int x_offset, int y_offset);
|
void impl_draw_children(surface& frame_buffer, int x_offset, int y_offset);
|
||||||
|
|
|
@ -22,25 +22,27 @@
|
||||||
|
|
||||||
namespace gui2 {
|
namespace gui2 {
|
||||||
|
|
||||||
|
/***** ***** ***** Constructor and destructor. ***** ***** *****/
|
||||||
|
|
||||||
twidget::twidget()
|
twidget::twidget()
|
||||||
: id_("")
|
: id_("")
|
||||||
, parent_(NULL)
|
, parent_(NULL)
|
||||||
, x_(-1)
|
, x_(-1)
|
||||||
, y_(-1)
|
, y_(-1)
|
||||||
, w_(0)
|
, width_(0)
|
||||||
, h_(0)
|
, height_(0)
|
||||||
, dirty_(true)
|
|
||||||
, visible_(VISIBLE)
|
|
||||||
, drawing_action_(DRAWN)
|
|
||||||
, clip_rect_()
|
|
||||||
, layout_size_(tpoint(0,0))
|
, layout_size_(tpoint(0,0))
|
||||||
, linked_group_()
|
|
||||||
#ifndef LOW_MEM
|
|
||||||
, debug_border_mode_(0)
|
|
||||||
, debug_border_color_(0)
|
|
||||||
#endif
|
|
||||||
#ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
|
#ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
|
||||||
, last_best_size_(tpoint(0,0))
|
, last_best_size_(tpoint(0,0))
|
||||||
|
#endif
|
||||||
|
, linked_group_()
|
||||||
|
, dirty_(true)
|
||||||
|
, visible_(tvisible::visible)
|
||||||
|
, redraw_action_(tredraw_action::full)
|
||||||
|
, clipping_rectangle_()
|
||||||
|
#ifndef LOW_MEM
|
||||||
|
, debug_border_mode_(0)
|
||||||
|
, debug_border_colour_(0)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
DBG_GUI_LF << "widget create: " << static_cast<void*>(this) << "\n";
|
DBG_GUI_LF << "widget create: " << static_cast<void*>(this) << "\n";
|
||||||
|
@ -51,20 +53,20 @@ twidget::twidget(const tbuilder_widget& builder)
|
||||||
, parent_(NULL)
|
, parent_(NULL)
|
||||||
, x_(-1)
|
, x_(-1)
|
||||||
, y_(-1)
|
, y_(-1)
|
||||||
, w_(0)
|
, width_(0)
|
||||||
, h_(0)
|
, height_(0)
|
||||||
, dirty_(true)
|
|
||||||
, visible_(VISIBLE)
|
|
||||||
, drawing_action_(DRAWN)
|
|
||||||
, clip_rect_()
|
|
||||||
, layout_size_(tpoint(0,0))
|
, layout_size_(tpoint(0,0))
|
||||||
, linked_group_(builder.linked_group)
|
|
||||||
#ifndef LOW_MEM
|
|
||||||
, debug_border_mode_(builder.debug_border_mode)
|
|
||||||
, debug_border_color_(builder.debug_border_color)
|
|
||||||
#endif
|
|
||||||
#ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
|
#ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
|
||||||
, last_best_size_(tpoint(0,0))
|
, last_best_size_(tpoint(0,0))
|
||||||
|
#endif
|
||||||
|
, linked_group_(builder.linked_group)
|
||||||
|
, dirty_(true)
|
||||||
|
, visible_(tvisible::visible)
|
||||||
|
, redraw_action_(tredraw_action::full)
|
||||||
|
, clipping_rectangle_()
|
||||||
|
#ifndef LOW_MEM
|
||||||
|
, debug_border_mode_(builder.debug_border_mode)
|
||||||
|
, debug_border_colour_(builder.debug_border_color)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
DBG_GUI_LF << "widget create: " << static_cast<void*>(this) << "\n";
|
DBG_GUI_LF << "widget create: " << static_cast<void*>(this) << "\n";
|
||||||
|
@ -72,8 +74,9 @@ twidget::twidget(const tbuilder_widget& builder)
|
||||||
|
|
||||||
twidget::~twidget()
|
twidget::~twidget()
|
||||||
{
|
{
|
||||||
DBG_GUI_LF << "widget destroy: " << static_cast<void*>(this)
|
DBG_GUI_LF
|
||||||
<< " (id: " << id_ << ")\n";
|
<< "widget destroy: " << static_cast<void*>(this)
|
||||||
|
<< " (id: " << id_ << ")\n";
|
||||||
|
|
||||||
twidget* p = parent();
|
twidget* p = parent();
|
||||||
while(p) {
|
while(p) {
|
||||||
|
@ -88,104 +91,28 @@ twidget::~twidget()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***** ***** ***** ***** ID functions. ***** ***** ***** *****/
|
||||||
|
|
||||||
void twidget::set_id(const std::string& id)
|
void twidget::set_id(const std::string& id)
|
||||||
{
|
{
|
||||||
DBG_GUI_LF << "set id of " << static_cast<void*>(this)
|
DBG_GUI_LF
|
||||||
<< " to '" << id << "' "
|
<< "set id of " << static_cast<void*>(this)
|
||||||
<< "(was '" << id_ << "'). Widget type: " <<
|
<< " to '" << id << "' "
|
||||||
(dynamic_cast<tcontrol*>(this) ?
|
<< "(was '" << id_ << "'). Widget type: "
|
||||||
dynamic_cast<tcontrol*>(this)->get_control_type()
|
<< (dynamic_cast<tcontrol*>(this)
|
||||||
: typeid(twidget).name())
|
? dynamic_cast<tcontrol*>(this)->get_control_type()
|
||||||
<< "\n";
|
: typeid(twidget).name())
|
||||||
|
<< "\n";
|
||||||
|
|
||||||
id_ = id;
|
id_ = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string& twidget::id() const
|
||||||
void twidget::layout_init(const bool /*full_initialization*/)
|
|
||||||
{
|
{
|
||||||
assert(visible_ != INVISIBLE);
|
return id_;
|
||||||
assert(get_window());
|
|
||||||
|
|
||||||
layout_size_ = tpoint(0,0);
|
|
||||||
if(!linked_group_.empty()) {
|
|
||||||
get_window()->add_linked_widget(linked_group_, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tpoint twidget::get_best_size() const
|
/***** ***** ***** ***** Parent functions ***** ***** ***** *****/
|
||||||
{
|
|
||||||
assert(visible_ != INVISIBLE);
|
|
||||||
|
|
||||||
tpoint result = layout_size_;
|
|
||||||
if(result == tpoint(0, 0)) {
|
|
||||||
result = calculate_best_size();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
|
|
||||||
last_best_size_ = result;
|
|
||||||
#endif
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void twidget::place(const tpoint& origin, const tpoint& size)
|
|
||||||
{
|
|
||||||
assert(size.x >= 0);
|
|
||||||
assert(size.y >= 0);
|
|
||||||
|
|
||||||
x_ = origin.x;
|
|
||||||
y_ = origin.y;
|
|
||||||
w_ = size.x;
|
|
||||||
h_ = size.y;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
std::cerr << "Id " << id()
|
|
||||||
<< " rect " << get_rect()
|
|
||||||
<< " parent "
|
|
||||||
<< (parent ? parent->get_x() : 0)
|
|
||||||
<< ','
|
|
||||||
<< (parent ? parent->get_y() : 0)
|
|
||||||
<< " screen origin " << x_ << ',' << y_
|
|
||||||
<< ".\n";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
set_dirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void twidget::set_size(const tpoint& size)
|
|
||||||
{
|
|
||||||
assert(size.x >= 0);
|
|
||||||
assert(size.y >= 0);
|
|
||||||
|
|
||||||
w_ = size.x;
|
|
||||||
h_ = size.y;
|
|
||||||
|
|
||||||
set_dirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
twidget* twidget::find_at(const tpoint& coordinate,
|
|
||||||
const bool must_be_active)
|
|
||||||
{
|
|
||||||
return is_at(coordinate, must_be_active) ? this : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
const twidget* twidget::find_at(const tpoint& coordinate,
|
|
||||||
const bool must_be_active) const
|
|
||||||
{
|
|
||||||
return is_at(coordinate, must_be_active) ? this : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_Rect twidget::get_dirty_rect() const
|
|
||||||
{
|
|
||||||
return drawing_action_ == DRAWN
|
|
||||||
? get_rect()
|
|
||||||
: clip_rect_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void twidget::move(const int x_offset, const int y_offset)
|
|
||||||
{
|
|
||||||
x_ += x_offset;
|
|
||||||
y_ += y_offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
twindow* twidget::get_window()
|
twindow* twidget::get_window()
|
||||||
{
|
{
|
||||||
|
@ -197,7 +124,7 @@ twindow* twidget::get_window()
|
||||||
result = result->parent_;
|
result = result->parent_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// on error dynamic_cast return 0 which is what we want.
|
// on error dynamic_cast returns NULL which is what we want.
|
||||||
return dynamic_cast<twindow*>(result);
|
return dynamic_cast<twindow*>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +138,7 @@ const twindow* twidget::get_window() const
|
||||||
result = result->parent_;
|
result = result->parent_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// on error dynamic_cast return 0 which is what we want.
|
// on error dynamic_cast returns NULL which is what we want.
|
||||||
return dynamic_cast<const twindow*>(result);
|
return dynamic_cast<const twindow*>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,16 +148,285 @@ tdialog* twidget::dialog()
|
||||||
return window ? window->dialog() : NULL;
|
return window ? window->dialog() : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void twidget::set_parent(twidget* parent)
|
||||||
|
{
|
||||||
|
parent_ = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
twidget* twidget::parent()
|
||||||
|
{
|
||||||
|
return parent_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** ***** ***** ***** Size and layout functions. ***** ***** ***** *****/
|
||||||
|
|
||||||
|
void twidget::layout_initialise(const bool /*full_initialisation*/)
|
||||||
|
{
|
||||||
|
assert(visible_ != tvisible::invisible);
|
||||||
|
assert(get_window());
|
||||||
|
|
||||||
|
layout_size_ = tpoint(0,0);
|
||||||
|
if(!linked_group_.empty()) {
|
||||||
|
get_window()->add_linked_widget(linked_group_, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void twidget::demand_reduce_width(const unsigned /*maximum_width*/)
|
||||||
|
{
|
||||||
|
/* DO NOTHING */
|
||||||
|
}
|
||||||
|
|
||||||
|
void twidget::request_reduce_height(const unsigned /*maximum_height*/)
|
||||||
|
{
|
||||||
|
/* DO NOTHING */
|
||||||
|
}
|
||||||
|
|
||||||
|
void twidget::demand_reduce_height(const unsigned /*maximum_height*/)
|
||||||
|
{
|
||||||
|
/* DO NOTHING */
|
||||||
|
}
|
||||||
|
|
||||||
|
tpoint twidget::get_best_size() const
|
||||||
|
{
|
||||||
|
assert(visible_ != tvisible::invisible);
|
||||||
|
|
||||||
|
tpoint result = layout_size_;
|
||||||
|
if(result == tpoint(0, 0)) {
|
||||||
|
result = calculate_best_size();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
|
||||||
|
last_best_size_ = result;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool twidget::can_wrap() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void twidget::set_origin(const tpoint& origin)
|
||||||
|
{
|
||||||
|
x_ = origin.x;
|
||||||
|
y_ = origin.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void twidget::set_size(const tpoint& size)
|
||||||
|
{
|
||||||
|
assert(size.x >= 0);
|
||||||
|
assert(size.y >= 0);
|
||||||
|
|
||||||
|
width_ = size.x;
|
||||||
|
height_ = size.y;
|
||||||
|
|
||||||
|
set_dirty(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void twidget::place(const tpoint& origin, const tpoint& size)
|
||||||
|
{
|
||||||
|
assert(size.x >= 0);
|
||||||
|
assert(size.y >= 0);
|
||||||
|
|
||||||
|
x_ = origin.x;
|
||||||
|
y_ = origin.y;
|
||||||
|
width_ = size.x;
|
||||||
|
height_ = size.y;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
std::cerr
|
||||||
|
<< "Id " << id()
|
||||||
|
<< " rect " << get_rectangle()
|
||||||
|
<< " parent "
|
||||||
|
<< (parent ? parent->get_x() : 0)
|
||||||
|
<< ','
|
||||||
|
<< (parent ? parent->get_y() : 0)
|
||||||
|
<< " screen origin " << x_ << ',' << y_
|
||||||
|
<< ".\n";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
set_dirty(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void twidget::move(const int x_offset, const int y_offset)
|
||||||
|
{
|
||||||
|
x_ += x_offset;
|
||||||
|
y_ += y_offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
void twidget::layout_children()
|
||||||
|
{
|
||||||
|
/* DO NOTHING */
|
||||||
|
}
|
||||||
|
|
||||||
|
tpoint twidget::get_origin() const
|
||||||
|
{
|
||||||
|
return tpoint(x_, y_);
|
||||||
|
}
|
||||||
|
|
||||||
|
tpoint twidget::get_size() const
|
||||||
|
{
|
||||||
|
return tpoint(width_, height_);
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_Rect twidget::get_rectangle() const
|
||||||
|
{
|
||||||
|
return create_rect(get_origin(), get_size());
|
||||||
|
}
|
||||||
|
|
||||||
|
int twidget::get_x() const
|
||||||
|
{
|
||||||
|
return x_;
|
||||||
|
}
|
||||||
|
|
||||||
|
int twidget::get_y() const
|
||||||
|
{
|
||||||
|
return y_;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned twidget::get_width() const
|
||||||
|
{
|
||||||
|
return width_;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned twidget::get_height() const
|
||||||
|
{
|
||||||
|
return height_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void twidget::set_layout_size(const tpoint& size)
|
||||||
|
{
|
||||||
|
layout_size_ = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
const tpoint& twidget::layout_size() const
|
||||||
|
{
|
||||||
|
return layout_size_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void twidget::set_linked_group(const std::string& linked_group)
|
||||||
|
{
|
||||||
|
linked_group_ = linked_group;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** ***** ***** ***** Drawing functions. ***** ***** ***** *****/
|
||||||
|
|
||||||
|
SDL_Rect twidget::calculate_blitting_rectangle(
|
||||||
|
const int x_offset
|
||||||
|
, const int y_offset)
|
||||||
|
{
|
||||||
|
SDL_Rect result = get_rectangle();
|
||||||
|
result.x += x_offset;
|
||||||
|
result.y += y_offset;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_Rect twidget::calculate_clipping_rectangle(
|
||||||
|
const int x_offset
|
||||||
|
, const int y_offset)
|
||||||
|
{
|
||||||
|
SDL_Rect result = clipping_rectangle_;
|
||||||
|
result.x += x_offset;
|
||||||
|
result.y += y_offset;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void twidget::draw_background(surface& frame_buffer, int x_offset, int y_offset)
|
||||||
|
{
|
||||||
|
assert(visible_ == tvisible::visible);
|
||||||
|
|
||||||
|
if(redraw_action_ == tredraw_action::partly) {
|
||||||
|
const SDL_Rect clipping_rectangle
|
||||||
|
= calculate_clipping_rectangle(x_offset, y_offset);
|
||||||
|
|
||||||
|
clip_rect_setter clip(frame_buffer, &clipping_rectangle);
|
||||||
|
draw_debug_border(frame_buffer, x_offset, y_offset);
|
||||||
|
impl_draw_background(frame_buffer, x_offset, y_offset);
|
||||||
|
} else {
|
||||||
|
draw_debug_border(frame_buffer, x_offset, y_offset);
|
||||||
|
impl_draw_background(frame_buffer, x_offset, y_offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void twidget::draw_background(surface& frame_buffer)
|
||||||
|
{
|
||||||
|
assert(visible_ == tvisible::visible);
|
||||||
|
|
||||||
|
if(redraw_action_ == tredraw_action::partly) {
|
||||||
|
clip_rect_setter clip(frame_buffer, &clipping_rectangle_);
|
||||||
|
draw_debug_border(frame_buffer);
|
||||||
|
impl_draw_background(frame_buffer);
|
||||||
|
} else {
|
||||||
|
draw_debug_border(frame_buffer);
|
||||||
|
impl_draw_background(frame_buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void twidget::draw_children(surface& frame_buffer, int x_offset, int y_offset)
|
||||||
|
{
|
||||||
|
assert(visible_ == tvisible::visible);
|
||||||
|
|
||||||
|
if(redraw_action_ == tredraw_action::partly) {
|
||||||
|
const SDL_Rect clipping_rectangle
|
||||||
|
= calculate_clipping_rectangle(x_offset, y_offset);
|
||||||
|
|
||||||
|
clip_rect_setter clip(frame_buffer, &clipping_rectangle);
|
||||||
|
impl_draw_children(frame_buffer, x_offset, y_offset);
|
||||||
|
} else {
|
||||||
|
impl_draw_children(frame_buffer, x_offset, y_offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void twidget::draw_children(surface& frame_buffer)
|
||||||
|
{
|
||||||
|
assert(visible_ == tvisible::visible);
|
||||||
|
|
||||||
|
if(redraw_action_ == tredraw_action::partly) {
|
||||||
|
clip_rect_setter clip(frame_buffer, &clipping_rectangle_);
|
||||||
|
impl_draw_children(frame_buffer);
|
||||||
|
} else {
|
||||||
|
impl_draw_children(frame_buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void twidget::draw_foreground(surface& frame_buffer, int x_offset, int y_offset)
|
||||||
|
{
|
||||||
|
assert(visible_ == tvisible::visible);
|
||||||
|
|
||||||
|
if(redraw_action_ == tredraw_action::partly) {
|
||||||
|
const SDL_Rect clipping_rectangle
|
||||||
|
= calculate_clipping_rectangle(x_offset, y_offset);
|
||||||
|
|
||||||
|
clip_rect_setter clip(frame_buffer, &clipping_rectangle);
|
||||||
|
impl_draw_foreground(frame_buffer, x_offset, y_offset);
|
||||||
|
} else {
|
||||||
|
impl_draw_foreground(frame_buffer, x_offset, y_offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void twidget::draw_foreground(surface& frame_buffer)
|
||||||
|
{
|
||||||
|
assert(visible_ == tvisible::visible);
|
||||||
|
|
||||||
|
if(redraw_action_ == tredraw_action::partly) {
|
||||||
|
clip_rect_setter clip(frame_buffer, &clipping_rectangle_);
|
||||||
|
impl_draw_foreground(frame_buffer);
|
||||||
|
} else {
|
||||||
|
impl_draw_foreground(frame_buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void twidget::populate_dirty_list(twindow& caller,
|
void twidget::populate_dirty_list(twindow& caller,
|
||||||
std::vector<twidget*>& call_stack)
|
std::vector<twidget*>& call_stack)
|
||||||
{
|
{
|
||||||
assert(call_stack.empty() || call_stack.back() != this);
|
assert(call_stack.empty() || call_stack.back() != this);
|
||||||
|
|
||||||
if(visible_ != VISIBLE) {
|
if(visible_ != tvisible::visible) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(get_drawing_action() == NOT_DRAWN) {
|
if(get_drawing_action() == tredraw_action::none) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,14 +439,52 @@ void twidget::populate_dirty_list(twindow& caller,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void twidget::set_visible(const tvisible visible)
|
void twidget::child_populate_dirty_list(
|
||||||
|
twindow& /*caller*/
|
||||||
|
, const std::vector<twidget*>& /*call_stack*/)
|
||||||
|
{
|
||||||
|
/* DO NOTHING */
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_Rect twidget::get_dirty_rectangle() const
|
||||||
|
{
|
||||||
|
return redraw_action_ == tredraw_action::full
|
||||||
|
? get_rectangle()
|
||||||
|
: clipping_rectangle_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void twidget::set_visible_rectangle(const SDL_Rect& rectangle)
|
||||||
|
{
|
||||||
|
clipping_rectangle_ = intersect_rects(rectangle, get_rectangle());
|
||||||
|
|
||||||
|
if(clipping_rectangle_ == get_rectangle()) {
|
||||||
|
redraw_action_ = tredraw_action::full;
|
||||||
|
} else if(clipping_rectangle_ == empty_rect) {
|
||||||
|
redraw_action_ = tredraw_action::none;
|
||||||
|
} else {
|
||||||
|
redraw_action_ = tredraw_action::partly;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void twidget::set_dirty(const bool dirty)
|
||||||
|
{
|
||||||
|
dirty_ = dirty;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool twidget::get_dirty() const
|
||||||
|
{
|
||||||
|
return dirty_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void twidget::set_visible(const tvisible::scoped_enum visible)
|
||||||
{
|
{
|
||||||
if(visible == visible_) {
|
if(visible == visible_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switching to or from invisible should invalidate the layout.
|
// Switching to or from invisible should invalidate the layout.
|
||||||
const bool need_resize = visible_ == INVISIBLE || visible == INVISIBLE;
|
const bool need_resize
|
||||||
|
= visible_ == tvisible::invisible || visible == tvisible::invisible;
|
||||||
visible_ = visible;
|
visible_ = visible;
|
||||||
|
|
||||||
if(need_resize) {
|
if(need_resize) {
|
||||||
|
@ -264,152 +498,58 @@ void twidget::set_visible(const tvisible visible)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
twidget::tdrawing_action twidget::get_drawing_action() const
|
twidget::tvisible::scoped_enum twidget::get_visible() const
|
||||||
{
|
{
|
||||||
return (w_ == 0 || h_ == 0)
|
return visible_;
|
||||||
? NOT_DRAWN
|
|
||||||
: drawing_action_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void twidget::set_visible_area(const SDL_Rect& area)
|
twidget::tredraw_action::scoped_enum twidget::get_drawing_action() const
|
||||||
{
|
{
|
||||||
clip_rect_ = intersect_rects(area, get_rect());
|
return (width_ == 0 || height_ == 0)
|
||||||
|
? tredraw_action::none
|
||||||
if(clip_rect_ == get_rect()) {
|
: redraw_action_;
|
||||||
drawing_action_ = DRAWN;
|
|
||||||
} else if(clip_rect_ == empty_rect) {
|
|
||||||
drawing_action_ = NOT_DRAWN;
|
|
||||||
} else {
|
|
||||||
drawing_action_ = PARTLY_DRAWN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_Rect twidget::calculate_blitting_rectangle(
|
|
||||||
const int x_offset
|
|
||||||
, const int y_offset)
|
|
||||||
{
|
|
||||||
SDL_Rect result = get_rect();
|
|
||||||
result.x += x_offset;
|
|
||||||
result.y += y_offset;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_Rect twidget::calculate_clipping_rectangle(
|
|
||||||
const int x_offset
|
|
||||||
, const int y_offset)
|
|
||||||
{
|
|
||||||
SDL_Rect result = clip_rect_;
|
|
||||||
result.x += x_offset;
|
|
||||||
result.y += y_offset;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void twidget::draw_background(surface& frame_buffer)
|
|
||||||
{
|
|
||||||
assert(visible_ == VISIBLE);
|
|
||||||
|
|
||||||
if(drawing_action_ == PARTLY_DRAWN) {
|
|
||||||
clip_rect_setter clip(frame_buffer, &clip_rect_);
|
|
||||||
draw_debug_border(frame_buffer);
|
|
||||||
impl_draw_background(frame_buffer);
|
|
||||||
} else {
|
|
||||||
draw_debug_border(frame_buffer);
|
|
||||||
impl_draw_background(frame_buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void twidget::draw_background(surface& frame_buffer, int x_offset, int y_offset)
|
|
||||||
{
|
|
||||||
assert(visible_ == VISIBLE);
|
|
||||||
|
|
||||||
if(drawing_action_ == PARTLY_DRAWN) {
|
|
||||||
const SDL_Rect clipping_rectangle =
|
|
||||||
calculate_clipping_rectangle(x_offset, y_offset);
|
|
||||||
|
|
||||||
clip_rect_setter clip(frame_buffer, &clipping_rectangle);
|
|
||||||
draw_debug_border(frame_buffer, x_offset, y_offset);
|
|
||||||
impl_draw_background(frame_buffer, x_offset, y_offset);
|
|
||||||
} else {
|
|
||||||
draw_debug_border(frame_buffer, x_offset, y_offset);
|
|
||||||
impl_draw_background(frame_buffer, x_offset, y_offset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void twidget::draw_children(surface& frame_buffer)
|
|
||||||
{
|
|
||||||
assert(visible_ == VISIBLE);
|
|
||||||
|
|
||||||
if(drawing_action_ == PARTLY_DRAWN) {
|
|
||||||
clip_rect_setter clip(frame_buffer, &clip_rect_);
|
|
||||||
impl_draw_children(frame_buffer);
|
|
||||||
} else {
|
|
||||||
impl_draw_children(frame_buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void twidget::draw_children(surface& frame_buffer, int x_offset, int y_offset)
|
|
||||||
{
|
|
||||||
assert(visible_ == VISIBLE);
|
|
||||||
|
|
||||||
if(drawing_action_ == PARTLY_DRAWN) {
|
|
||||||
const SDL_Rect clipping_rectangle =
|
|
||||||
calculate_clipping_rectangle(x_offset, y_offset);
|
|
||||||
|
|
||||||
clip_rect_setter clip(frame_buffer, &clipping_rectangle);
|
|
||||||
impl_draw_children(frame_buffer, x_offset, y_offset);
|
|
||||||
} else {
|
|
||||||
impl_draw_children(frame_buffer, x_offset, y_offset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void twidget::draw_foreground(surface& frame_buffer)
|
|
||||||
{
|
|
||||||
assert(visible_ == VISIBLE);
|
|
||||||
|
|
||||||
if(drawing_action_ == PARTLY_DRAWN) {
|
|
||||||
clip_rect_setter clip(frame_buffer, &clip_rect_);
|
|
||||||
impl_draw_foreground(frame_buffer);
|
|
||||||
} else {
|
|
||||||
impl_draw_foreground(frame_buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void twidget::draw_foreground(surface& frame_buffer, int x_offset, int y_offset)
|
|
||||||
{
|
|
||||||
assert(visible_ == VISIBLE);
|
|
||||||
|
|
||||||
if(drawing_action_ == PARTLY_DRAWN) {
|
|
||||||
const SDL_Rect clipping_rectangle =
|
|
||||||
calculate_clipping_rectangle(x_offset, y_offset);
|
|
||||||
|
|
||||||
clip_rect_setter clip(frame_buffer, &clipping_rectangle);
|
|
||||||
impl_draw_foreground(frame_buffer, x_offset, y_offset);
|
|
||||||
} else {
|
|
||||||
impl_draw_foreground(frame_buffer, x_offset, y_offset);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef LOW_MEM
|
#ifndef LOW_MEM
|
||||||
|
|
||||||
|
void twidget::set_debug_border_mode(const unsigned debug_border_mode)
|
||||||
|
{
|
||||||
|
debug_border_mode_ = debug_border_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void twidget::set_debug_border_colour(const unsigned debug_border_colour)
|
||||||
|
{
|
||||||
|
debug_border_colour_ = debug_border_colour;
|
||||||
|
}
|
||||||
|
|
||||||
void twidget::draw_debug_border(surface& frame_buffer)
|
void twidget::draw_debug_border(surface& frame_buffer)
|
||||||
{
|
{
|
||||||
SDL_Rect r = drawing_action_ == PARTLY_DRAWN
|
SDL_Rect r = redraw_action_ == tredraw_action::partly
|
||||||
? clip_rect_
|
? clipping_rectangle_
|
||||||
: get_rect();
|
: get_rectangle();
|
||||||
|
|
||||||
switch(debug_border_mode_) {
|
switch(debug_border_mode_) {
|
||||||
case 0:
|
case 0:
|
||||||
/* DO NOTHING */
|
/* DO NOTHING */
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
draw_rectangle(r.x, r.y, r.w, r.h
|
draw_rectangle(
|
||||||
, debug_border_color_, frame_buffer);
|
r.x
|
||||||
|
, r.y
|
||||||
|
, r.w
|
||||||
|
, r.h
|
||||||
|
, debug_border_colour_
|
||||||
|
, frame_buffer);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
sdl_fill_rect(frame_buffer, &r, debug_border_color_);
|
sdl_fill_rect(frame_buffer, &r, debug_border_colour_);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
|
@ -420,7 +560,7 @@ void twidget::draw_debug_border(
|
||||||
, int x_offset
|
, int x_offset
|
||||||
, int y_offset)
|
, int y_offset)
|
||||||
{
|
{
|
||||||
SDL_Rect r = drawing_action_ == PARTLY_DRAWN
|
SDL_Rect r = redraw_action_ == tredraw_action::partly
|
||||||
? calculate_clipping_rectangle(x_offset, y_offset)
|
? calculate_clipping_rectangle(x_offset, y_offset)
|
||||||
: calculate_blitting_rectangle(x_offset, y_offset);
|
: calculate_blitting_rectangle(x_offset, y_offset);
|
||||||
|
|
||||||
|
@ -428,29 +568,78 @@ void twidget::draw_debug_border(
|
||||||
case 0:
|
case 0:
|
||||||
/* DO NOTHING */
|
/* DO NOTHING */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
draw_rectangle(r.x, r.y, r.w, r.h
|
draw_rectangle(
|
||||||
, debug_border_color_, frame_buffer);
|
r.x
|
||||||
|
, r.y
|
||||||
|
, r.w
|
||||||
|
, r.h
|
||||||
|
, debug_border_colour_
|
||||||
|
, frame_buffer);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
sdl_fill_rect(frame_buffer, &r, debug_border_color_);
|
sdl_fill_rect(frame_buffer, &r, debug_border_colour_);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/***** ***** ***** ***** Query functions ***** ***** ***** *****/
|
||||||
|
|
||||||
|
twidget* twidget::find_at(
|
||||||
|
const tpoint& coordinate
|
||||||
|
, const bool must_be_active)
|
||||||
|
{
|
||||||
|
return is_at(coordinate, must_be_active) ? this : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const twidget* twidget::find_at(const tpoint& coordinate,
|
||||||
|
const bool must_be_active) const
|
||||||
|
{
|
||||||
|
return is_at(coordinate, must_be_active) ? this : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
twidget* twidget::find(
|
||||||
|
const std::string& id
|
||||||
|
, const bool /*must_be_active*/)
|
||||||
|
{
|
||||||
|
return id_ == id ? this : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const twidget* twidget::find(
|
||||||
|
const std::string& id
|
||||||
|
, const bool /*must_be_active*/) const
|
||||||
|
{
|
||||||
|
return id_ == id ? this : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool twidget::has_widget(const twidget* widget) const
|
||||||
|
{
|
||||||
|
return widget == this;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool twidget::is_at(const tpoint& coordinate) const
|
||||||
|
{
|
||||||
|
return is_at(coordinate, true);
|
||||||
|
}
|
||||||
|
|
||||||
bool twidget::is_at(const tpoint& coordinate, const bool must_be_active) const
|
bool twidget::is_at(const tpoint& coordinate, const bool must_be_active) const
|
||||||
{
|
{
|
||||||
if(visible_ == INVISIBLE
|
if(visible_ == tvisible::invisible
|
||||||
|| (visible_ == HIDDEN && must_be_active)) {
|
|| (visible_ == tvisible::hidden && must_be_active)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return coordinate.x >= x_
|
return coordinate.x >= x_
|
||||||
&& coordinate.x < (x_ + static_cast<int>(w_))
|
&& coordinate.x < (x_ + static_cast<int>(width_))
|
||||||
&& coordinate.y >= y_
|
&& coordinate.y >= y_
|
||||||
&& coordinate.y < (y_ + static_cast<int>(h_)) ? true : false;
|
&& coordinate.y < (y_ + static_cast<int>(height_));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gui2
|
} // namespace gui2
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -675,9 +675,9 @@ int twindow::show(const bool restore, const unsigned auto_close_timeout)
|
||||||
|
|
||||||
// restore area
|
// restore area
|
||||||
if(restore) {
|
if(restore) {
|
||||||
SDL_Rect rect = get_rect();
|
SDL_Rect rect = get_rectangle();
|
||||||
sdl_blit(restorer_, 0, video_.getSurface(), &rect);
|
sdl_blit(restorer_, 0, video_.getSurface(), &rect);
|
||||||
update_rect(get_rect());
|
update_rect(get_rectangle());
|
||||||
font::undraw_floating_labels(video_.getSurface());
|
font::undraw_floating_labels(video_.getSurface());
|
||||||
}
|
}
|
||||||
throw;
|
throw;
|
||||||
|
@ -687,9 +687,9 @@ int twindow::show(const bool restore, const unsigned auto_close_timeout)
|
||||||
|
|
||||||
// restore area
|
// restore area
|
||||||
if(restore) {
|
if(restore) {
|
||||||
SDL_Rect rect = get_rect();
|
SDL_Rect rect = get_rectangle();
|
||||||
sdl_blit(restorer_, 0, video_.getSurface(), &rect);
|
sdl_blit(restorer_, 0, video_.getSurface(), &rect);
|
||||||
update_rect(get_rect());
|
update_rect(get_rectangle());
|
||||||
font::undraw_floating_labels(video_.getSurface());
|
font::undraw_floating_labels(video_.getSurface());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -712,7 +712,7 @@ void twindow::draw()
|
||||||
// since all will be redrawn when needed with dirty rects. Since that
|
// since all will be redrawn when needed with dirty rects. Since that
|
||||||
// doesn't work yet we need to undraw the window.
|
// doesn't work yet we need to undraw the window.
|
||||||
if(restorer_) {
|
if(restorer_) {
|
||||||
SDL_Rect rect = get_rect();
|
SDL_Rect rect = get_rectangle();
|
||||||
sdl_blit(restorer_, 0, frame_buffer, &rect);
|
sdl_blit(restorer_, 0, frame_buffer, &rect);
|
||||||
// Since the old area might be bigger as the new one, invalidate
|
// Since the old area might be bigger as the new one, invalidate
|
||||||
// it.
|
// it.
|
||||||
|
@ -722,7 +722,7 @@ void twindow::draw()
|
||||||
layout();
|
layout();
|
||||||
|
|
||||||
// Get new surface for restoring
|
// Get new surface for restoring
|
||||||
SDL_Rect rect = get_rect();
|
SDL_Rect rect = get_rectangle();
|
||||||
// We want the labels underneath the window so draw them and use them
|
// We want the labels underneath the window so draw them and use them
|
||||||
// as restore point.
|
// as restore point.
|
||||||
font::draw_floating_labels(frame_buffer);
|
font::draw_floating_labels(frame_buffer);
|
||||||
|
@ -773,7 +773,7 @@ void twindow::draw()
|
||||||
|
|
||||||
const SDL_Rect dirty_rect = new_widgets
|
const SDL_Rect dirty_rect = new_widgets
|
||||||
? screen_area()
|
? screen_area()
|
||||||
: item.back()->get_dirty_rect();
|
: item.back()->get_dirty_rectangle();
|
||||||
|
|
||||||
// For testing we disable the clipping rect and force the entire screen to
|
// For testing we disable the clipping rect and force the entire screen to
|
||||||
// update. This way an item rendered at the wrong place is directly visible.
|
// update. This way an item rendered at the wrong place is directly visible.
|
||||||
|
@ -801,16 +801,17 @@ void twindow::draw()
|
||||||
*
|
*
|
||||||
* Before drawing there needs to be determined whether a dirty widget
|
* Before drawing there needs to be determined whether a dirty widget
|
||||||
* really needs to be redrawn. If the widget doesn't need to be
|
* really needs to be redrawn. If the widget doesn't need to be
|
||||||
* redrawing either being not VISIBLE or has status NOT_DRAWN. If
|
* redrawing either being not tvisible::visible or has status
|
||||||
* it's not drawn it's still set not dirty to avoid it keep getting
|
* twidget::tredraw_action::none. If it's not drawn it's still set not
|
||||||
* on the dirty list.
|
* dirty to avoid it keep getting on the dirty list.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for(std::vector<twidget*>::iterator itor = item.begin();
|
for(std::vector<twidget*>::iterator itor = item.begin();
|
||||||
itor != item.end(); ++itor) {
|
itor != item.end(); ++itor) {
|
||||||
|
|
||||||
if((**itor).get_visible() != twidget::VISIBLE
|
if((**itor).get_visible() != twidget::tvisible::visible
|
||||||
|| (**itor).get_drawing_action() == twidget::NOT_DRAWN) {
|
|| (**itor).get_drawing_action()
|
||||||
|
== twidget::tredraw_action::none) {
|
||||||
|
|
||||||
for(std::vector<twidget*>::iterator citor = itor;
|
for(std::vector<twidget*>::iterator citor = itor;
|
||||||
citor != item.end(); ++citor) {
|
citor != item.end(); ++citor) {
|
||||||
|
@ -824,7 +825,7 @@ void twindow::draw()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore.
|
// Restore.
|
||||||
SDL_Rect rect = get_rect();
|
SDL_Rect rect = get_rectangle();
|
||||||
sdl_blit(restorer_, 0, frame_buffer, &rect);
|
sdl_blit(restorer_, 0, frame_buffer, &rect);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -890,14 +891,14 @@ void twindow::draw()
|
||||||
populate_dirty_list(*this, call_stack);
|
populate_dirty_list(*this, call_stack);
|
||||||
assert(dirty_list_.empty());
|
assert(dirty_list_.empty());
|
||||||
|
|
||||||
SDL_Rect rect = get_rect();
|
SDL_Rect rect = get_rectangle();
|
||||||
update_rect(rect);
|
update_rect(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void twindow::undraw()
|
void twindow::undraw()
|
||||||
{
|
{
|
||||||
if(restorer_) {
|
if(restorer_) {
|
||||||
SDL_Rect rect = get_rect();
|
SDL_Rect rect = get_rectangle();
|
||||||
sdl_blit(restorer_, 0, video_.getSurface(), &rect);
|
sdl_blit(restorer_, 0, video_.getSurface(), &rect);
|
||||||
// Since the old area might be bigger as the new one, invalidate
|
// Since the old area might be bigger as the new one, invalidate
|
||||||
// it.
|
// it.
|
||||||
|
@ -999,12 +1000,12 @@ void twindow::layout()
|
||||||
if((click_dismiss_button
|
if((click_dismiss_button
|
||||||
= find_widget<tbutton>(this, "click_dismiss", false, false))) {
|
= find_widget<tbutton>(this, "click_dismiss", false, false))) {
|
||||||
|
|
||||||
click_dismiss_button->set_visible(twidget::INVISIBLE);
|
click_dismiss_button->set_visible(twidget::tvisible::invisible);
|
||||||
}
|
}
|
||||||
if(click_dismiss_) {
|
if(click_dismiss_) {
|
||||||
tbutton* button = find_widget<tbutton>(this, "ok", false, false);
|
tbutton* button = find_widget<tbutton>(this, "ok", false, false);
|
||||||
if(button) {
|
if(button) {
|
||||||
button->set_visible(twidget::INVISIBLE);
|
button->set_visible(twidget::tvisible::invisible);
|
||||||
click_dismiss_button = button;
|
click_dismiss_button = button;
|
||||||
}
|
}
|
||||||
VALIDATE(click_dismiss_button
|
VALIDATE(click_dismiss_button
|
||||||
|
@ -1012,8 +1013,8 @@ void twindow::layout()
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Layout. *****/
|
/***** Layout. *****/
|
||||||
layout_init(true);
|
layout_initialise(true);
|
||||||
generate_dot_file("layout_init", LAYOUT);
|
generate_dot_file("layout_initialise", LAYOUT);
|
||||||
|
|
||||||
layout_linked_widgets();
|
layout_linked_widgets();
|
||||||
|
|
||||||
|
@ -1040,7 +1041,7 @@ void twindow::layout()
|
||||||
/****** Validate click dismiss status. *****/
|
/****** Validate click dismiss status. *****/
|
||||||
if(click_dismiss_ && disable_click_dismiss()) {
|
if(click_dismiss_ && disable_click_dismiss()) {
|
||||||
assert(click_dismiss_button);
|
assert(click_dismiss_button);
|
||||||
click_dismiss_button->set_visible(twidget::VISIBLE);
|
click_dismiss_button->set_visible(twidget::tvisible::visible);
|
||||||
|
|
||||||
connect_signal_mouse_left_click(
|
connect_signal_mouse_left_click(
|
||||||
*click_dismiss_button
|
*click_dismiss_button
|
||||||
|
@ -1050,8 +1051,8 @@ void twindow::layout()
|
||||||
, OK
|
, OK
|
||||||
, true));
|
, true));
|
||||||
|
|
||||||
layout_init(true);
|
layout_initialise(true);
|
||||||
generate_dot_file("layout_init", LAYOUT);
|
generate_dot_file("layout_initialise", LAYOUT);
|
||||||
|
|
||||||
layout_linked_widgets();
|
layout_linked_widgets();
|
||||||
|
|
||||||
|
@ -1312,7 +1313,7 @@ void twindow_implementation::layout(twindow& window,
|
||||||
DBG_GUI_L << LOG_IMPL_HEADER
|
DBG_GUI_L << LOG_IMPL_HEADER
|
||||||
<< " Status: Width has been modified, rerun.\n";
|
<< " Status: Width has been modified, rerun.\n";
|
||||||
|
|
||||||
window.layout_init(false);
|
window.layout_initialise(false);
|
||||||
window.layout_linked_widgets();
|
window.layout_linked_widgets();
|
||||||
layout(window, maximum_width, maximum_height);
|
layout(window, maximum_width, maximum_height);
|
||||||
return;
|
return;
|
||||||
|
@ -1499,13 +1500,14 @@ void twindow::signal_handler_request_placement(
|
||||||
* layout property must be set by the engine after validation.
|
* layout property must be set by the engine after validation.
|
||||||
*
|
*
|
||||||
* - All visible grid cells; A grid cell is visible when the widget inside
|
* - All visible grid cells; A grid cell is visible when the widget inside
|
||||||
* of it doesn't have the state INVISIBLE. Widgets which are HIDDEN are
|
* of it doesn't have the state tvisible::invisible. Widgets which have the
|
||||||
* sized properly since when they become VISIBLE the layout shouldn't be
|
* state @ref tvisible::hidden are sized properly since when they become
|
||||||
* invalidated. A grid cell that's invisible has size 0,0.
|
* @ref tvisible::visible the layout shouldn't be invalidated. A grid cell
|
||||||
|
* that's invisible has size 0,0.
|
||||||
*
|
*
|
||||||
* - All resizable grid cells; A grid cell is resizable under the following
|
* - All resizable grid cells; A grid cell is resizable under the following
|
||||||
* conditions:
|
* conditions:
|
||||||
* - The widget is VISIBLE.
|
* - The widget is tvisible::visible.
|
||||||
* - The widget is not in a shared size group.
|
* - The widget is not in a shared size group.
|
||||||
*
|
*
|
||||||
* There are two layout algorithms with a different purpose.
|
* There are two layout algorithms with a different purpose.
|
||||||
|
@ -1524,7 +1526,7 @@ void twindow::signal_handler_request_placement(
|
||||||
* Here is the algorithm used to layout the window:
|
* Here is the algorithm used to layout the window:
|
||||||
*
|
*
|
||||||
* - Perform a full initialization
|
* - Perform a full initialization
|
||||||
* (@ref gui2::twidget::layout_init (full_initialization = true)):
|
* (@ref gui2::twidget::layout_initialise (full_initialisation = true)):
|
||||||
* - Clear the internal best size cache for all widgets.
|
* - Clear the internal best size cache for all widgets.
|
||||||
* - For widgets with scrollbars hide them unless the
|
* - For widgets with scrollbars hide them unless the
|
||||||
* @ref gui2::tscrollbar_container::tscrollbar_mode "scrollbar_mode" is
|
* @ref gui2::tscrollbar_container::tscrollbar_mode "scrollbar_mode" is
|
||||||
|
@ -1616,7 +1618,7 @@ void twindow::signal_handler_request_placement(
|
||||||
*
|
*
|
||||||
* - Relayout:
|
* - Relayout:
|
||||||
* - Initialize all widgets
|
* - Initialize all widgets
|
||||||
* (@ref gui2::twidget::layout_init (full_initialization = false))
|
* (@ref gui2::twidget::layout_initialise (full_initialisation = false))
|
||||||
* - Handle shared sizes, since the reinitialization resets that state.
|
* - Handle shared sizes, since the reinitialization resets that state.
|
||||||
* - Goto start layout loop.
|
* - Goto start layout loop.
|
||||||
*
|
*
|
||||||
|
|
|
@ -410,7 +410,7 @@ public:
|
||||||
void set_variable(const std::string& key, const variant& value)
|
void set_variable(const std::string& key, const variant& value)
|
||||||
{
|
{
|
||||||
variables_.add(key, value);
|
variables_.add(key, value);
|
||||||
set_dirty();
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Reference in a new issue