Convert gui2::tvisible and gui2::tredraw_action to scoped enums

This commit is contained in:
Charles Dang 2016-07-30 11:41:05 +11:00 committed by Celtic Minstrel
parent 8a8316a9b8
commit 82973000a0
5 changed files with 67 additions and 81 deletions

View file

@ -116,7 +116,7 @@ void tmessage::set_button_caption(const tbutton_id button,
}
void tmessage::set_button_visible(const tbutton_id button,
const twidget::tvisible::scoped_enum visible)
const twidget::tvisible visible)
{
buttons_[button].visible = visible;
if(buttons_[button].button) {

View file

@ -79,7 +79,7 @@ public:
const std::string& caption);
void set_button_visible(const tbutton_id button,
const twidget::tvisible::scoped_enum visible);
const twidget::tvisible visible);
void set_button_retval(const tbutton_id button, const int retval);
@ -141,7 +141,7 @@ private:
tbutton* button;
std::string caption;
twidget::tvisible::scoped_enum visible;
twidget::tvisible visible;
int retval;
};

View file

@ -442,7 +442,7 @@ bool twidget::get_is_dirty() const
return is_dirty_;
}
void twidget::set_visible(const tvisible::scoped_enum visible)
void twidget::set_visible(const tvisible visible)
{
if(visible == visible_) {
return;
@ -468,12 +468,12 @@ void twidget::set_visible(const tvisible::scoped_enum visible)
}
}
twidget::tvisible::scoped_enum twidget::get_visible() const
twidget::tvisible twidget::get_visible() const
{
return visible_;
}
twidget::tredraw_action::scoped_enum twidget::get_drawing_action() const
twidget::tredraw_action twidget::get_drawing_action() const
{
return (width_ == 0 || height_ == 0) ? tredraw_action::none
: redraw_action_;

View file

@ -58,50 +58,43 @@ class twidget : private boost::noncopyable,
public:
/** Visibility settings done by the user. */
class tvisible : private boost::noncopyable
enum class tvisible
{
friend class tno_such_friend_exists_but_it_makes_the_compiler_happy;
tvisible();
/**
* The user sets the widget visible, that means:
* * The widget is visible.
* * @ref find_at always 'sees' the widget (the active flag is
* tested later).
* * The widget (if active) handles events (and sends events to
* its children).
* * The widget is drawn (and sends the call to
* @ref populate_dirty_list to children).
*/
visible,
public:
/** @todo C++11 use a scoped enum. */
enum scoped_enum {
/**
* The user sets the widget visible, that means:
* * The widget is visible.
* * @ref find_at always 'sees' the widget (the active flag is
* tested later).
* * The widget (if active) handles events (and sends events to
* its children).
* * The widget is drawn (and sends the call to
* @ref populate_dirty_list to children).
*/
visible,
/**
* The user sets the widget hidden, that means:
* * The widget is invisible but keeps its size.
* * @ref find_at 'sees' the widget if active is @c false.
* * The widget doesn't handle events (and doesn't send events to
* its children).
* * The widget doesn't add itself @ref twindow::dirty_list_ when
* @ref populate_dirty_list is called (nor does it send the
* request to its children).
*/
hidden,
/**
* The user sets the widget hidden, that means:
* * The widget is invisible but keeps its size.
* * @ref find_at 'sees' the widget if active is @c false.
* * The widget doesn't handle events (and doesn't send events to
* its children).
* * The widget doesn't add itself @ref twindow::dirty_list_ when
* @ref populate_dirty_list is called (nor does it send the
* request to its children).
*/
hidden,
/**
* The user set the widget invisible, that means:
* * The widget is invisible and its grid cell has size 0,0.
* * @ref find_at never 'sees' the widget.
* * The widget doesn't handle events (and doesn't send events to
* its children).
* * The widget doesn't add itself @ref twindow::dirty_list_ when
* @ref populate_dirty_list is called (nor does it send the
* request to its children).
*/
invisible
};
/**
* The user set the widget invisible, that means:
* * The widget is invisible and its grid cell has size 0,0.
* * @ref find_at never 'sees' the widget.
* * The widget doesn't handle events (and doesn't send events to
* its children).
* * The widget doesn't add itself @ref twindow::dirty_list_ when
* @ref populate_dirty_list is called (nor does it send the
* request to its children).
*/
invisible
};
/**
@ -110,37 +103,30 @@ public:
* This state only will be used if @ref visible_ is @ref tvisible::visible
* depending on this state the widget might not be visible after all.
*/
class tredraw_action : private boost::noncopyable
enum class tredraw_action
{
friend class tno_such_friend_exists_but_it_makes_the_compiler_happy;
tredraw_action();
/**
* The widget is fully visible.
*
* The widget should be drawn if @ref dirty_ is @c true. The entire
* widget's rectangle should be redrawn.
*/
full,
public:
/** @todo C++11 use a scoped enum. */
enum scoped_enum {
/**
* The widget is fully visible.
*
* The widget should be drawn if @ref dirty_ is @c true. The entire
* widget's rectangle should be redrawn.
*/
full,
/**
* The widget is partly visible.
*
* The should be drawn if @ref dirty_ is @c true. The rectangle to
* redraw in determined by @ref clipping_rectangle_
*/
partly,
/**
* The widget is partly visible.
*
* The should be drawn if @ref dirty_ is @c true. The rectangle to
* redraw in determined by @ref clipping_rectangle_
*/
partly,
/**
* The widget is not visible.
*
* The widget should not be drawn if @ref dirty_ is @c true.
*/
none
};
/**
* The widget is not visible.
*
* The widget should not be drawn if @ref dirty_ is @c true.
*/
none
};
@ -673,10 +659,10 @@ public:
void set_is_dirty(const bool is_dirty);
bool get_is_dirty() const;
void set_visible(const tvisible::scoped_enum visible);
tvisible::scoped_enum get_visible() const;
void set_visible(const tvisible visible);
tvisible get_visible() const;
tredraw_action::scoped_enum get_drawing_action() const;
tredraw_action get_drawing_action() const;
#ifndef LOW_MEM
@ -701,10 +687,10 @@ private:
bool is_dirty_;
/** Field for the status of the visibility. */
tvisible::scoped_enum visible_;
tvisible visible_;
/** Field for the action to do on a drawing request. */
tredraw_action::scoped_enum redraw_action_;
tredraw_action redraw_action_;
/** The clipping rectangle if a widget is partly visible. */
SDL_Rect clipping_rectangle_;

View file

@ -693,7 +693,7 @@ int intf_set_dialog_visible(lua_State *L)
{
typedef gui2::tcontrol::tvisible tvisible;
tvisible::scoped_enum flag = tvisible::visible;
tvisible flag = tvisible::visible;
switch (lua_type(L, 1)) {
case LUA_TBOOLEAN: