Remove the old easy block algorithm code.

This commit is contained in:
Mark de Wever 2009-06-21 14:08:29 +00:00
parent 86aa9471c5
commit 8b31dec40d
24 changed files with 8 additions and 157 deletions

View File

@ -108,7 +108,7 @@ void tmessage::pre_show(CVideo& /*video*/, twindow& window)
*/
window.NEW_layout();
if(! window.does_easy_close()) {
if(window.disable_easy_close()) {
set_button_visible(ok, twidget::VISIBLE);
}
}

View File

@ -211,7 +211,7 @@ void twml_message_::pre_show(CVideo& /*video*/, twindow& window)
button->set_visible(twidget::INVISIBLE);
window.NEW_layout();
if(! window.does_easy_close()) {
if(window.disable_easy_close()) {
button->set_visible(twidget::VISIBLE);
}
}

View File

@ -76,7 +76,6 @@ void tbutton::set_state(const tstate state)
{
if(state != state_) {
state_ = state;
set_block_easy_close(get_visible() && get_active());
set_dirty(true);
}
}

View File

@ -65,9 +65,6 @@ public:
/** Inherited from tcontrol. */
unsigned get_state() const { return state_; }
/** Inherited from tcontrol. */
bool does_block_easy_close() const { return true; }
/***** ***** ***** setters / getters for members ***** ****** *****/
void set_retval(const int retval) { retval_ = retval; }

View File

@ -143,15 +143,6 @@ public:
/** Inherited from tcontrol. */
void set_active(const bool active);
/**
* Inherited from tcontrol.
*
* NOTE normally containers don't block, but their children may. But
* normally the state for the children is set as well so we don't need to
* delegate the request to our children.
*/
bool does_block_easy_close() const { return false; }
/** Inherited from tcontrol. */
bool disable_easy_close() const;

View File

@ -58,31 +58,6 @@ void tcontrol::set_members(const string_map& data)
}
}
void tcontrol::set_block_easy_close(const bool block)
{
twindow* window = get_window();
if(!window) {
/*
* This can happen in a listbox when the row data is manipulated before
* the listbox is finalized. In that case that widget should do set the
* state in its finalizer.
*/
DBG_GUI_G << "tcontrol(" + get_control_type() + ") " + __func__ + ": "
"No window set, this might be a bug.\n";
return;
}
if(block) {
if(id().empty()) {
set_id(get_uid());
}
window->add_easy_close_blocker(id());
} else if(!id().empty()) {
// It might never have been enabled so the id might be empty.
window->remove_easy_close_blocker(id());
}
}
bool tcontrol::disable_easy_close() const
{
return get_visible() == twidget::VISIBLE && get_active();

View File

@ -97,29 +97,6 @@ public:
/***** ***** ***** ***** Easy close handling ***** ***** ***** *****/
/**
* Adds or removes a widget to/from the easy close block list.
*
* For adding to the block list an id is required, if not set it will get
* one.
*
* @param block If true it's added to the blocklist, removed
* otherwise.
*/
void set_block_easy_close(const bool block = true);
/**
* Does the widget block the easy close feature?
*
* NOTE widgets that return true here, probably also need to make
* modifications to their set_state() function. Easy close blocking _must_
* be disabled when the widget is disabled or not visible. (The tcontrol
* class handles the visibility part.)
*
* @returns Whether or not it blocks.
*/
virtual bool does_block_easy_close() const = 0;
/**
* Inherited from twidget.
*

View File

@ -320,7 +320,7 @@ void tdebug_layout_graph::widget_generate_state_info(
<< control->get_use_tooltip_on_label_overflow() << '\n'
<< "</td></tr>\n"
<< "<tr><td>\n"
<< "does block easy close=" << control->does_block_easy_close() << '\n'
<< "does block easy close=" << control->disable_easy_close() << '\n'
<< "</td></tr>\n";
const tscrollbar_container* scrollbar_container =

View File

@ -76,16 +76,6 @@ void tgrid::set_child(twidget* widget, const unsigned row,
if(cell.widget()) {
// make sure the new child is valid before deferring
cell.widget()->set_parent(this);
// Init the easy close state here, normally when put in a grid the grid
// does have a parent window.
tcontrol* control = dynamic_cast<tcontrol*>(cell.widget());
if(control) {
control->set_block_easy_close(
control->get_visible()
&& control->get_active()
&& control->does_block_easy_close());
}
}
}

View File

@ -47,9 +47,6 @@ public:
/** Inherited from tcontrol. */
unsigned get_state() const { return ENABLED; }
/** Inherited from tcontrol. */
bool does_block_easy_close() const { return false; }
/** Inherited from tcontrol. */
bool disable_easy_close() const { return false; }

View File

@ -44,9 +44,6 @@ public:
/** Inherited from tcontrol. */
unsigned get_state() const { return state_; }
/** Inherited from tcontrol. */
bool does_block_easy_close() const { return false; }
/** Inherited from tcontrol. */
bool disable_easy_close() const { return false; }

View File

@ -52,9 +52,6 @@ public:
/** Inherited from tcontrol. */
unsigned get_state() const { return 0; }
/** Inherited from tcontrol. */
bool does_block_easy_close() const { return false; }
/** Inherited from tcontrol. */
bool disable_easy_close() const { return false; }

View File

@ -199,7 +199,6 @@ void tscrollbar_::set_state(const tstate state)
{
if(state != state_) {
state_ = state;
set_block_easy_close(get_visible() && get_active());
set_dirty(true);
}
}

View File

@ -128,9 +128,6 @@ public:
/** Inherited from tcontrol. */
unsigned get_state() const { return state_; }
/** Inherited from tcontrol. */
bool does_block_easy_close() const { return true; }
/***** ***** ***** setters / getters for members ***** ****** *****/
void set_item_count(const unsigned item_count)

View File

@ -327,10 +327,6 @@ void tscrollbar_container::
// Update the buttons.
set_scrollbar_button_status();
// Set the easy close status.
set_block_easy_close(get_visible() == twidget::VISIBLE
&& get_active() && does_block_easy_close());
// Now set the visible part of the content.
content_visible_area_ = content_->get_rect();
content_grid_->set_visible_area(content_visible_area_);
@ -445,26 +441,6 @@ const twidget* tscrollbar_container::find_widget(
::find_widget<const twidget>(*this, id, must_be_active);
}
bool tscrollbar_container::does_block_easy_close() const
{
assert(vertical_scrollbar_grid_
&& vertical_scrollbar_
&& horizontal_scrollbar_grid_
&& horizontal_scrollbar_);
const bool vertical_block =
vertical_scrollbar_grid_->get_visible() == twidget::VISIBLE
&& !(vertical_scrollbar_->at_begin()
&& vertical_scrollbar_->at_end());
const bool horizontal_block =
horizontal_scrollbar_grid_->get_visible() == twidget::VISIBLE
&& !(horizontal_scrollbar_->at_begin()
&& horizontal_scrollbar_->at_end());
return vertical_block || horizontal_block;
}
bool tscrollbar_container::disable_easy_close() const
{
assert(content_grid_);
@ -550,10 +526,6 @@ void tscrollbar_container::finalize_setup()
content_grid_->set_parent(this);
/***** Set the easy close status. *****/
set_block_easy_close(get_visible() == twidget::VISIBLE
&& get_active() && does_block_easy_close());
/***** Let our subclasses initialize themselves. *****/
finalize_subclass();
}

View File

@ -139,9 +139,6 @@ public:
const twidget* find_widget(
const std::string& id, const bool must_be_active) const;
/** Inherited from tcontainer_. */
bool does_block_easy_close() const;
/** Inherited from tcontainer_. */
bool disable_easy_close() const;

View File

@ -59,9 +59,6 @@ public:
/** Inherited from tcontrol. */
unsigned get_state() const { return 0; }
/** Inherited from tcontrol. */
bool does_block_easy_close() const { return false; }
/** Inherited from tcontrol. */
bool disable_easy_close() const { return false; }

View File

@ -326,7 +326,6 @@ void ttext_::set_state(const tstate state)
{
if(state != state_) {
state_ = state;
set_block_easy_close(get_visible() && get_active());
set_dirty(true);
}
}

View File

@ -75,9 +75,6 @@ public:
/** Inherited from tcontrol. */
unsigned get_state() const { return state_; }
/** Inherited from tcontrol. */
bool does_block_easy_close() const { return true; }
/***** ***** ***** ***** expose some functions ***** ***** ***** *****/
void set_maximum_length(const size_t maximum_length);

View File

@ -143,7 +143,6 @@ void ttoggle_button::set_state(const tstate state)
{
if(state != state_) {
state_ = state;
set_block_easy_close(get_visible() && get_active());
set_dirty(true);
}
}

View File

@ -70,9 +70,6 @@ public:
/** Inherited from tcontrol. */
unsigned get_state() const { return state_; }
/** Inherited from tcontrol. */
bool does_block_easy_close() const { return true; }
/** Inherited from tcontrol. */
void update_canvas();

View File

@ -45,9 +45,6 @@ public:
/** Inherited from tcontrol. */
unsigned get_state() const { return 0; }
/** Inherited from tcontrol. */
bool does_block_easy_close() const { return false; }
/** Inherited from tcontrol. */
bool disable_easy_close() const { return false; }

View File

@ -232,7 +232,6 @@ twindow::twindow(CVideo& video,
, w_(w)
, h_(h)
, easy_close_(false)
, easy_close_blocker_()
, easy_close_disabled_(false)
, escape_disabled_(false)
, linked_size_()
@ -616,21 +615,6 @@ void twindow::key_press(tevent_handler& /*event_handler*/, bool& handled,
#endif
}
void twindow::add_easy_close_blocker(const std::string& id)
{
// avoid duplicates.
remove_easy_close_blocker(id);
easy_close_blocker_.push_back(id);
}
void twindow::remove_easy_close_blocker(const std::string& id)
{
easy_close_blocker_.erase(
std::remove(easy_close_blocker_.begin(), easy_close_blocker_.end(), id),
easy_close_blocker_.end());
}
void twindow::init_linked_size_group(const std::string& id,
const bool fixed_width, const bool fixed_height)
{

View File

@ -256,7 +256,7 @@ public:
* @returns Whether or not the window closes easily.
*/
bool does_easy_close() const
{ return easy_close_ && easy_close_blocker_.empty() && !easy_close_disabled_; }
{ return easy_close_ && !easy_close_disabled_; }
/**
* Disable the escape key.
@ -401,17 +401,13 @@ private:
/**
* Do we want to have easy close behaviour?
*
* Easy closing means that whenever a mouse click is done the dialog will be
* closed. The widgets in the window may override this behaviour by
* registering themselves as blockers. These items will be stored in
* easy_close_blocker_. So in order to do an easy close the boolean needs to
* be true and the vector empty.
* Easy closing means that whenever a mouse click is done the dialog will
* be closed. The widgets in the window may override this behaviour by
* registering themselves as blockers. This is tested by the function
* disable_easy_close().
*/
bool easy_close_;
/** The list with items which prevent the easy close behaviour. */
std::vector<std::string> easy_close_blocker_;
/**
* Hold the state of the easy close disable state.
*