Make set_active work for container classes (not much tested yet).
This commit is contained in:
parent
bcf474d2f6
commit
9318a00299
6 changed files with 39 additions and 10 deletions
|
@ -83,5 +83,20 @@ void tcontainer_::draw(surface& surface, const bool force,
|
||||||
grid_.draw(surface, force, redraw_background);
|
grid_.draw(surface, force, redraw_background);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tcontainer_::set_active(const bool active)
|
||||||
|
{
|
||||||
|
// Not all our children might have the proper state so let them run
|
||||||
|
// unconditionally.
|
||||||
|
grid_.set_active(active);
|
||||||
|
|
||||||
|
if(active == get_active()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
set_dirty();
|
||||||
|
|
||||||
|
set_self_active(active);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace gui2
|
} // namespace gui2
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,9 @@ public:
|
||||||
set_client_size(get_client_rect());
|
set_client_size(get_client_rect());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Inherited from tcontrol. */
|
||||||
|
void set_active(const bool active);
|
||||||
|
|
||||||
/***** **** ***** ***** wrappers to the grid **** ********* *****/
|
/***** **** ***** ***** wrappers to the grid **** ********* *****/
|
||||||
|
|
||||||
tgrid::iterator begin() { return grid_.begin(); }
|
tgrid::iterator begin() { return grid_.begin(); }
|
||||||
|
@ -147,6 +150,15 @@ private:
|
||||||
/** Returns the space used by the border. */
|
/** Returns the space used by the border. */
|
||||||
virtual tpoint border_space() const { return tpoint(0, 0); }
|
virtual tpoint border_space() const { return tpoint(0, 0); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper for set_active.
|
||||||
|
*
|
||||||
|
* This function should set the control itself active. It's called by
|
||||||
|
* set_active if the state needs to change. The widget is set to dirty() by
|
||||||
|
* set_active so we only need to change the state.
|
||||||
|
*/
|
||||||
|
virtual void set_self_active(const bool active) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the background has been changed the next draw cycle needs to do a full
|
* If the background has been changed the next draw cycle needs to do a full
|
||||||
* redraw and also tell the child items to invalidate their background. This
|
* redraw and also tell the child items to invalidate their background. This
|
||||||
|
|
|
@ -37,8 +37,6 @@ public:
|
||||||
|
|
||||||
tlistbox();
|
tlistbox();
|
||||||
|
|
||||||
// FIXME this might not the right thing to do.
|
|
||||||
void set_active(const bool active) { set_state(active ? ENABLED : DISABLED); };
|
|
||||||
bool get_active() const { return state_ != DISABLED; }
|
bool get_active() const { return state_ != DISABLED; }
|
||||||
unsigned get_state() const { return state_; }
|
unsigned get_state() const { return state_; }
|
||||||
|
|
||||||
|
@ -263,6 +261,10 @@ private:
|
||||||
const std::string& get_control_type() const
|
const std::string& get_control_type() const
|
||||||
{ static const std::string type = "listbox"; return type; }
|
{ static const std::string type = "listbox"; return type; }
|
||||||
|
|
||||||
|
/** Inherited from tcontainer_. */
|
||||||
|
void set_self_active(const bool active)
|
||||||
|
{ state_ = active ? ENABLED : DISABLED; }
|
||||||
|
|
||||||
/** The (lastly) selected row */
|
/** The (lastly) selected row */
|
||||||
unsigned selected_row_;
|
unsigned selected_row_;
|
||||||
|
|
||||||
|
|
|
@ -48,9 +48,6 @@ public:
|
||||||
|
|
||||||
/***** ***** ***** ***** Inherited ***** ***** ***** *****/
|
/***** ***** ***** ***** Inherited ***** ***** ***** *****/
|
||||||
|
|
||||||
/** Inherited from tcontrol. */
|
|
||||||
void set_active(const bool active) {} ; // FIXME implement
|
|
||||||
|
|
||||||
/** Inherited from tcontrol. */
|
/** Inherited from tcontrol. */
|
||||||
bool get_active() const { return state_ != DISABLED; }
|
bool get_active() const { return state_ != DISABLED; }
|
||||||
|
|
||||||
|
@ -114,6 +111,10 @@ private:
|
||||||
/** The builder needs to call us so we can wire in the proper callbacks. */
|
/** The builder needs to call us so we can wire in the proper callbacks. */
|
||||||
void finalize_setup();
|
void finalize_setup();
|
||||||
|
|
||||||
|
/** Inherited from tcontainer_. */
|
||||||
|
void set_self_active(const bool active)
|
||||||
|
{ state_ = active ? ENABLED : DISABLED; }
|
||||||
|
|
||||||
/** Inherited from tcontrol. */
|
/** Inherited from tcontrol. */
|
||||||
const std::string& get_control_type() const
|
const std::string& get_control_type() const
|
||||||
{ static const std::string type = "menubar"; return type; }
|
{ static const std::string type = "menubar"; return type; }
|
||||||
|
|
|
@ -50,9 +50,6 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual SDL_Rect get_client_rect() const;
|
virtual SDL_Rect get_client_rect() const;
|
||||||
|
|
||||||
/** Inherited from tcontrol. */
|
|
||||||
void set_active(const bool /*active*/) {}
|
|
||||||
|
|
||||||
/** Inherited from tcontrol. */
|
/** Inherited from tcontrol. */
|
||||||
bool get_active() const { return true; }
|
bool get_active() const { return true; }
|
||||||
|
|
||||||
|
@ -75,6 +72,9 @@ private:
|
||||||
/** Inherited from tcontainer_. */
|
/** Inherited from tcontainer_. */
|
||||||
tpoint border_space() const;
|
tpoint border_space() const;
|
||||||
|
|
||||||
|
/** Inherited from tcontainer_. */
|
||||||
|
void set_self_active(const bool /*active*/) {}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace gui2
|
} // namespace gui2
|
||||||
|
|
|
@ -117,8 +117,7 @@ public:
|
||||||
void window_resize(tevent_handler&,
|
void window_resize(tevent_handler&,
|
||||||
const unsigned new_width, const unsigned new_height);
|
const unsigned new_width, const unsigned new_height);
|
||||||
|
|
||||||
//! A window is always active atm so ignore the request.
|
//! At the moment a window is always active.
|
||||||
void set_active(const bool /*active*/) {}
|
|
||||||
bool get_active() const { return true; }
|
bool get_active() const { return true; }
|
||||||
unsigned get_state() const { return 0; }
|
unsigned get_state() const { return 0; }
|
||||||
bool needs_full_redraw() const { return false; /* FIXME IMPLEMENT */ }
|
bool needs_full_redraw() const { return false; /* FIXME IMPLEMENT */ }
|
||||||
|
|
Loading…
Add table
Reference in a new issue