Rename easy_close to click_dismiss.

I never was really happy with the old name, but didn't have a better
alternative. Now I have so rename the stuff.
This commit is contained in:
Mark de Wever 2009-09-08 20:12:11 +00:00
parent 7fe3294f39
commit a299db046d
28 changed files with 80 additions and 75 deletions

View file

@ -10,7 +10,7 @@
[resolution]
definition = "default"
easy_close = "true"
click_dismiss = "true"
[grid]

View file

@ -10,7 +10,7 @@
[resolution]
definition = "message"
easy_close = "true"
click_dismiss = "true"
[grid]

View file

@ -294,7 +294,7 @@
width = "(gamemap_width)"
height = "(screen_height - 30)"
easy_close = "true"
click_dismiss = "true"
[linked_group]
id = "icon"
@ -518,7 +518,7 @@ if(gamemap_width - ({__GUI_IMAGE_WIDTH}) > 675
width = "(gamemap_width)"
height = "(screen_height - 30)"
easy_close = "true"
click_dismiss = "true"
[linked_group]
id = "icon"

View file

@ -147,7 +147,7 @@ twindow* build(CVideo& video, const std::string& type)
lg.id, lg.fixed_width, lg.fixed_height);
}
window->set_easy_close(definition->easy_close);
window->set_click_dismiss(definition->click_dismiss);
boost::intrusive_ptr<const twindow_definition::tresolution> conf =
boost::dynamic_pointer_cast<
@ -217,7 +217,7 @@ twindow_builder::tresolution::tresolution(const config& cfg) :
implementation::get_h_align(cfg["horizontal_placement"])),
maximum_width(lexical_cast_default<unsigned>(cfg["maximum_width"])),
maximum_height(lexical_cast_default<unsigned>(cfg["maximum_height"])),
easy_close(utils::string_bool(cfg["easy_close"])),
click_dismiss(utils::string_bool(cfg["click_dismiss"])),
definition(cfg["definition"]),
linked_groups(),
grid(0)
@ -256,26 +256,27 @@ twindow_builder::tresolution::tresolution(const config& cfg) :
* maximum_height (unsigned = 0) The maximum height of the window (only
* used for automatic placement).
*
* easy_close (bool = false) Does the window need easy close behaviour?
* Easy close behaviour means that any mouse
* click will close the dialog. Note certain
* widgets will automatically disable this
* behaviour since they need to process the
* clicks as well, for example buttons do need
* a click and a misclick on button shouldn't
* close the dialog. NOTE with some widgets
* this behaviour depends on their contents
* (like scrolling labels) so the behaviour
* might get changed depending on the data in
* the dialog. NOTE the default behaviour
* might be changed since it will be disabled
* when can't be used due to widgets which use
* the mouse, including buttons, so it might
* be wise to set the behaviour explicitly
* when not wanted and no mouse using widgets
* are available. This means enter, escape or
* an external source needs to be used to
* close the dialog (which is valid).
* click_dismiss (bool = false) Does the window need click dismiss
* behaviour? Click dismiss behaviour means
* that any mouse click will close the
* dialog. Note certain widgets will
* automatically disable this behaviour since
* they need to process the clicks as well,
* for example buttons do need a click and a
* misclick on button shouldn't close the
* dialog. NOTE with some widgets this
* behaviour depends on their contents (like
* scrolling labels) so the behaviour might
* get changed depending on the data in the
* dialog. NOTE the default behaviour might
* be changed since it will be disabled when
* can't be used due to widgets which use the
* mouse, including buttons, so it might be
* wise to set the behaviour explicitly when
* not wanted and no mouse using widgets are
* available. This means enter, escape or an
* external source needs to be used to close
* the dialog (which is valid).
*
* definition (string = "default")
* Definition of the window which we want to

View file

@ -111,7 +111,7 @@ public:
unsigned maximum_width;
unsigned maximum_height;
bool easy_close;
bool click_dismiss;
std::string definition;

View file

@ -99,7 +99,7 @@ void tmessage::pre_show(CVideo& /*video*/, twindow& window)
window.keyboard_capture(label);
// Override the user value, to make sure it's set properly.
window.set_easy_close(auto_close_);
window.set_click_dismiss(auto_close_);
}
void tmessage::post_show(twindow& /*window*/)

View file

@ -106,7 +106,7 @@ private:
std::string message_;
/**
* Does the window need to use easy_close when the dialog doesn't need a
* Does the window need to use click_dismiss when the dialog doesn't need a
* scrollbar.
*/
bool auto_close_;

View file

@ -88,7 +88,7 @@ void twml_message_::pre_show(CVideo& /*video*/, twindow& window)
input->set_value(*input_text_);
input->set_maximum_length(input_maximum_lenght_);
window.keyboard_capture(input);
window.set_easy_close(false);
window.set_click_dismiss(false);
window.set_escape_disabled(true);
} else {
caption->set_visible(twidget::INVISIBLE);
@ -187,16 +187,16 @@ void twml_message_::pre_show(CVideo& /*video*/, twindow& window)
if(!has_input_) {
window.keyboard_capture(options);
window.set_easy_close(false);
window.set_click_dismiss(false);
window.set_escape_disabled(true);
} else {
window.add_to_keyboard_chain(options);
// easy_close has been disabled due to the input.
// click_dismiss has been disabled due to the input.
}
} else {
options->set_visible(twidget::INVISIBLE);
}
window.set_easy_close(!has_input_ && option_list_.empty());
window.set_click_dismiss(!has_input_ && option_list_.empty());
}
void twml_message_::post_show(twindow& window)

View file

@ -142,9 +142,9 @@ void tcontainer_::set_active(const bool active)
set_self_active(active);
}
bool tcontainer_::disable_easy_close() const
bool tcontainer_::disable_click_dismiss() const
{
return tcontrol::disable_easy_close() && grid_.disable_easy_close();
return tcontrol::disable_click_dismiss() && grid_.disable_click_dismiss();
}
void tcontainer_::init_grid(

View file

@ -144,7 +144,7 @@ public:
void set_active(const bool active);
/** Inherited from tcontrol. */
bool disable_easy_close() const;
bool disable_click_dismiss() const;
/**
* Initializes and builds the grid.

View file

@ -70,7 +70,7 @@ void tcontrol::set_members(const string_map& data)
}
}
bool tcontrol::disable_easy_close() const
bool tcontrol::disable_click_dismiss() const
{
return get_visible() == twidget::VISIBLE && get_active();
}

View file

@ -103,7 +103,7 @@ public:
* The default behavious is that a widget blocks easy close, if not it
* hould override this function.
*/
bool disable_easy_close() const;
bool disable_click_dismiss() const;
/***** ***** ***** ***** layout functions ***** ***** ***** *****/

View file

@ -320,7 +320,8 @@ 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->disable_easy_close() << '\n'
<< "does block click dismiss="
<< control->disable_click_dismiss() << '\n'
<< "</td></tr>\n";
const tscrollbar_container* scrollbar_container =

View file

@ -210,7 +210,7 @@ void tevent_handler::handle_event(const SDL_Event& event)
switch(event.button.button) {
/*
* All button clicks should trigger easy_close() This is doen
* All button clicks should trigger click_dismiss() This is done
* in the mouse_button_up function since that also evaluates
* the state of the mouse before handling the event.
*
@ -588,7 +588,7 @@ void tevent_handler::mouse_button_up(
button.focus = 0;
set_hover();
easy_close();
click_dismiss();
}
void tevent_handler::mouse_click(twidget* widget, tmouse_button& button)

View file

@ -409,12 +409,12 @@ private:
virtual void do_remove_help_popup() = 0;
/**
* Handler for the easy close functionallity.
* Handler for the click dismiss functionallity.
*
* @returns True if the easyclose action is performed,
* @returns True if the click dismiss action is performed,
* false otherwise.
*/
virtual bool easy_close() = 0;
virtual bool click_dismiss() = 0;
};
} // namespace gui2

View file

@ -782,10 +782,10 @@ public:
}
/** Inherited from widget. */
bool disable_easy_close() const
bool disable_click_dismiss() const
{
foreach(titem* item, items_) {
if(item->grid.disable_easy_close()) {
if(item->grid.disable_click_dismiss()) {
return true;
}
}

View file

@ -568,7 +568,7 @@ bool tgrid::has_widget(const twidget* widget) const
return false;
}
bool tgrid::disable_easy_close() const
bool tgrid::disable_click_dismiss() const
{
if(get_visible() != twidget::VISIBLE) {
return false;
@ -578,7 +578,7 @@ bool tgrid::disable_easy_close() const
const twidget* widget = child.widget();
assert(widget);
if(widget->disable_easy_close()) {
if(widget->disable_click_dismiss()) {
return true;
}
}

View file

@ -259,7 +259,7 @@ public:
bool has_widget(const twidget* widget) const;
/** Inherited from tcontrol. */
bool disable_easy_close() const;
bool disable_click_dismiss() const;
/***** ***** ***** setters / getters for members ***** ****** *****/

View file

@ -74,7 +74,7 @@ public:
unsigned get_state() const { return ENABLED; }
/** Inherited from tcontrol. */
bool disable_easy_close() const { return false; }
bool disable_click_dismiss() const { return false; }
private:

View file

@ -45,7 +45,7 @@ public:
unsigned get_state() const { return state_; }
/** Inherited from tcontrol. */
bool disable_easy_close() const { return false; }
bool disable_click_dismiss() const { return false; }
/***** ***** ***** setters / getters for members ***** ****** *****/

View file

@ -53,7 +53,7 @@ public:
unsigned get_state() const { return 0; }
/** Inherited from tcontrol. */
bool disable_easy_close() const { return false; }
bool disable_click_dismiss() const { return false; }
/***** ***** ***** setters / getters for members ***** ****** *****/

View file

@ -441,11 +441,11 @@ const twidget* tscrollbar_container::find_widget(
::find_widget<const twidget>(*this, id, must_be_active);
}
bool tscrollbar_container::disable_easy_close() const
bool tscrollbar_container::disable_click_dismiss() const
{
assert(content_grid_);
return tcontainer_::disable_easy_close()
|| content_grid_->disable_easy_close();
return tcontainer_::disable_click_dismiss()
|| content_grid_->disable_click_dismiss();
}
void tscrollbar_container::vertical_scrollbar_click(twidget* caller)

View file

@ -145,7 +145,7 @@ public:
const std::string& id, const bool must_be_active) const;
/** Inherited from tcontainer_. */
bool disable_easy_close() const;
bool disable_click_dismiss() const;
/***** ***** ***** setters / getters for members ***** ****** *****/

View file

@ -60,7 +60,7 @@ public:
unsigned get_state() const { return 0; }
/** Inherited from tcontrol. */
bool disable_easy_close() const { return false; }
bool disable_click_dismiss() const { return false; }
/***** ***** ***** setters / getters for members ***** ****** *****/

View file

@ -46,7 +46,7 @@ public:
unsigned get_state() const { return 0; }
/** Inherited from tcontrol. */
bool disable_easy_close() const { return false; }
bool disable_click_dismiss() const { return false; }
private:
/** Inherited from tcontrol. */

View file

@ -355,7 +355,7 @@ public:
/***** ***** ***** Misc. ***** ****** *****/
/** Does the widget disable easy close? */
virtual bool disable_easy_close() const = 0;
virtual bool disable_click_dismiss() const = 0;
/***** ***** ***** setters / getters for members ***** ****** *****/

View file

@ -234,7 +234,7 @@ twindow::twindow(CVideo& video,
, y_(y)
, w_(w)
, h_(h)
, easy_close_(false)
, click_dismiss_(false)
, enter_disabled_(false)
, escape_disabled_(false)
, linked_size_()
@ -612,7 +612,7 @@ void twindow::key_press(tevent_handler& /*event_handler*/, bool& handled,
set_retval(CANCEL);
handled = true;
} else if(key == SDLK_SPACE) {
handled = easy_close();
handled = click_dismiss();
}
#ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
if(key == SDLK_F12) {
@ -694,7 +694,7 @@ void twindow::layout()
click_dismiss_button->set_visible(twidget::INVISIBLE);
}
if(easy_close_) {
if(click_dismiss_) {
tbutton* button = NEW_find_widget<tbutton>(this, "ok", false, false);
if(button) {
button->set_visible(twidget::INVISIBLE);
@ -731,7 +731,7 @@ void twindow::layout()
}
/****** Validate click dismiss status. *****/
if(easy_close_ && disable_easy_close()) {
if(click_dismiss_ && disable_click_dismiss()) {
assert(click_dismiss_button);
click_dismiss_button->set_visible(twidget::VISIBLE);
@ -956,9 +956,9 @@ void twindow::do_show_help_popup(const tpoint& location, const t_string& help_po
help_popup_.set_visible(twidget::VISIBLE);
}
bool twindow::easy_close()
bool twindow::click_dismiss()
{
if(does_easy_close()) {
if(does_click_dismiss()) {
set_retval(OK);
return true;
}

View file

@ -236,21 +236,21 @@ public:
/**
* Register a widget that prevents easy closing.
*
* Duplicate registration are ignored. See easy_close_ for more info.
* Duplicate registration are ignored. See click_dismiss_ for more info.
*
* @param id The id of the widget to register.
*/
void add_easy_close_blocker(const std::string& id);
void add_click_dismiss_blocker(const std::string& id);
/**
* Unregister a widget the prevents easy closing.
*
* Removing a non registered id is allowed but will do nothing. See
* easy_close_ for more info.
* click_dismiss_ for more info.
*
* @param id The id of the widget to register.
*/
void remove_easy_close_blocker(const std::string& id);
void remove_click_dismiss_blocker(const std::string& id);
/**
* Does the window close easily?
@ -260,9 +260,9 @@ public:
*
* @returns Whether or not the window closes easily.
*/
bool does_easy_close() const
bool does_click_dismiss() const
{
return easy_close_ && !disable_easy_close();
return click_dismiss_ && !disable_click_dismiss();
}
/**
@ -347,7 +347,10 @@ public:
void set_owner(tdialog* owner) { owner_ = owner; }
void set_easy_close(const bool easy_close) { easy_close_ = easy_close; }
void set_click_dismiss(const bool click_dismiss)
{
click_dismiss_ = click_dismiss;
}
static void set_sunset(const unsigned interval)
{ sunset_ = interval ? interval : 5; }
@ -452,7 +455,7 @@ private:
* 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().
* disable_click_dismiss().
*
* The handling of easy close is done in the window, in order to do so a
* window either needs a click_dismiss or an ok button. Both will be hidden
@ -463,7 +466,7 @@ private:
* @todo After testing the click dismiss feature it should be documented in
* the wiki.
*/
bool easy_close_;
bool click_dismiss_;
/** Disable the enter key see our setter for more info. */
bool enter_disabled_;
@ -540,7 +543,7 @@ private:
{ help_popup_.set_visible(twidget::HIDDEN); }
/** Inherited from tevent_handler. */
bool easy_close();
bool click_dismiss();
/** Inherited from tcontrol. */
const std::string& get_control_type() const;