GUI2: take find_widget and find ID args as string_view
This commit is contained in:
parent
530cd2b02b
commit
7d92a8cb4a
24 changed files with 58 additions and 69 deletions
|
@ -221,13 +221,13 @@ const widget* container_base::find_at(const point& coordinate,
|
|||
return grid_.find_at(coordinate, must_be_active);
|
||||
}
|
||||
|
||||
widget* container_base::find(const std::string& id, const bool must_be_active)
|
||||
widget* container_base::find(const std::string_view id, const bool must_be_active)
|
||||
{
|
||||
widget* result = styled_widget::find(id, must_be_active);
|
||||
return result ? result : grid_.find(id, must_be_active);
|
||||
}
|
||||
|
||||
const widget* container_base::find(const std::string& id,
|
||||
const widget* container_base::find(const std::string_view id,
|
||||
const bool must_be_active) const
|
||||
{
|
||||
const widget* result = styled_widget::find(id, must_be_active);
|
||||
|
|
|
@ -119,11 +119,10 @@ public:
|
|||
const bool must_be_active) const override;
|
||||
|
||||
/** See @ref widget::find. */
|
||||
widget* find(const std::string& id, const bool must_be_active) override;
|
||||
widget* find(const std::string_view id, const bool must_be_active) override;
|
||||
|
||||
/** See @ref widget::find. */
|
||||
const widget* find(const std::string& id,
|
||||
const bool must_be_active) const override;
|
||||
const widget* find(const std::string_view id, const bool must_be_active) const override;
|
||||
|
||||
/** See @ref styled_widget::set_active. */
|
||||
virtual void set_active(const bool active) override;
|
||||
|
|
|
@ -976,7 +976,7 @@ const widget* independent::find_at(const point& coordinate, const bool must_be_a
|
|||
return grid.find_at(coordinate, must_be_active);
|
||||
}
|
||||
|
||||
widget* independent::find(const std::string& id, const bool must_be_active)
|
||||
widget* independent::find(const std::string_view id, const bool must_be_active)
|
||||
{
|
||||
for(std::size_t i = 0; i < get_item_count(); ++i) {
|
||||
if(is_selected(i)) {
|
||||
|
@ -989,7 +989,7 @@ widget* independent::find(const std::string& id, const bool must_be_active)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
const widget* independent::find(const std::string& id, const bool must_be_active) const
|
||||
const widget* independent::find(const std::string_view id, const bool must_be_active) const
|
||||
{
|
||||
for(std::size_t i = 0; i < get_item_count(); ++i) {
|
||||
if(is_selected(i)) {
|
||||
|
|
|
@ -455,10 +455,10 @@ struct independent : public virtual generator_base
|
|||
virtual const widget* find_at(const point& coordinate, const bool must_be_active) const override;
|
||||
|
||||
/** See @ref widget::find. */
|
||||
widget* find(const std::string& id, const bool must_be_active) override;
|
||||
widget* find(const std::string_view id, const bool must_be_active) override;
|
||||
|
||||
/** See @ref widget::find. */
|
||||
const widget* find(const std::string& id, const bool must_be_active) const override;
|
||||
const widget* find(const std::string_view id, const bool must_be_active) const override;
|
||||
|
||||
/***** ***** ***** ***** keyboard functions ***** ***** ***** *****/
|
||||
|
||||
|
|
|
@ -642,13 +642,12 @@ const widget* grid::find_at(const point& coordinate,
|
|||
*this, coordinate, must_be_active);
|
||||
}
|
||||
|
||||
widget* grid::find(const std::string& id, const bool must_be_active)
|
||||
widget* grid::find(const std::string_view id, const bool must_be_active)
|
||||
{
|
||||
return grid_implementation::find<widget>(*this, id, must_be_active);
|
||||
}
|
||||
|
||||
const widget* grid::find(const std::string& id, const bool must_be_active)
|
||||
const
|
||||
const widget* grid::find(const std::string_view id, const bool must_be_active) const
|
||||
{
|
||||
return grid_implementation::find<const widget>(*this, id, must_be_active);
|
||||
}
|
||||
|
|
|
@ -282,11 +282,10 @@ public:
|
|||
const bool must_be_active) const override;
|
||||
|
||||
/** See @ref widget::find. */
|
||||
widget* find(const std::string& id, const bool must_be_active) override;
|
||||
widget* find(const std::string_view id, const bool must_be_active) override;
|
||||
|
||||
/** See @ref widget::find. */
|
||||
const widget* find(const std::string& id,
|
||||
const bool must_be_active) const override;
|
||||
const widget* find(const std::string_view id, const bool must_be_active) const override;
|
||||
|
||||
/** See @ref widget::has_widget. */
|
||||
virtual bool has_widget(const widget& widget) const override;
|
||||
|
|
|
@ -83,7 +83,7 @@ struct grid_implementation
|
|||
*/
|
||||
template <class W>
|
||||
static W* find(utils::const_clone_ref<grid, W> grid,
|
||||
const std::string& id,
|
||||
const std::string_view id,
|
||||
const bool must_be_active)
|
||||
{
|
||||
// Inherited.
|
||||
|
|
|
@ -131,7 +131,7 @@ const widget* matrix::find_at(const point& coordinate,
|
|||
return content_.find_at(coordinate, must_be_active);
|
||||
}
|
||||
|
||||
widget* matrix::find(const std::string& id, const bool must_be_active)
|
||||
widget* matrix::find(const std::string_view id, const bool must_be_active)
|
||||
{
|
||||
if(widget* result = widget::find(id, must_be_active)) {
|
||||
return result;
|
||||
|
@ -140,7 +140,7 @@ widget* matrix::find(const std::string& id, const bool must_be_active)
|
|||
}
|
||||
}
|
||||
|
||||
const widget* matrix::find(const std::string& id, const bool must_be_active)
|
||||
const widget* matrix::find(const std::string_view id, const bool must_be_active)
|
||||
const
|
||||
{
|
||||
if(const widget* result = widget::find(id, must_be_active)) {
|
||||
|
|
|
@ -134,11 +134,10 @@ public:
|
|||
const bool must_be_active) const override;
|
||||
|
||||
/** See @ref widget::find. */
|
||||
widget* find(const std::string& id, const bool must_be_active) override;
|
||||
widget* find(const std::string_view id, const bool must_be_active) override;
|
||||
|
||||
/** See @ref widget::find. */
|
||||
const widget* find(const std::string& id,
|
||||
const bool must_be_active) const override;
|
||||
const widget* find(const std::string_view id, const bool must_be_active) const override;
|
||||
|
||||
/***** ***** ***** ***** Forwarded to pane_. ***** ***** ****** *****/
|
||||
/**
|
||||
|
|
|
@ -500,12 +500,12 @@ const widget* scrollbar_container::find_at(const point& coordinate, const bool m
|
|||
return w;
|
||||
}
|
||||
|
||||
widget* scrollbar_container::find(const std::string& id, const bool must_be_active)
|
||||
widget* scrollbar_container::find(const std::string_view id, const bool must_be_active)
|
||||
{
|
||||
return scrollbar_container_implementation::find<widget>(*this, id, must_be_active);
|
||||
}
|
||||
|
||||
const widget* scrollbar_container::find(const std::string& id, const bool must_be_active) const
|
||||
const widget* scrollbar_container::find(const std::string_view id, const bool must_be_active) const
|
||||
{
|
||||
return scrollbar_container_implementation::find<const widget>(*this, id, must_be_active);
|
||||
}
|
||||
|
|
|
@ -130,10 +130,10 @@ public:
|
|||
virtual const widget* find_at(const point& coordinate, const bool must_be_active) const override;
|
||||
|
||||
/** See @ref widget::find. */
|
||||
widget* find(const std::string& id, const bool must_be_active) override;
|
||||
widget* find(const std::string_view id, const bool must_be_active) override;
|
||||
|
||||
/** See @ref widget::find. */
|
||||
const widget* find(const std::string& id, const bool must_be_active) const override;
|
||||
const widget* find(const std::string_view id, const bool must_be_active) const override;
|
||||
|
||||
/** See @ref widget::disable_click_dismiss. */
|
||||
bool disable_click_dismiss() const override;
|
||||
|
|
|
@ -85,7 +85,7 @@ struct scrollbar_container_implementation
|
|||
static W*
|
||||
find(utils::const_clone_ref<scrollbar_container, W>
|
||||
scrollbar_container,
|
||||
const std::string& id,
|
||||
const std::string_view id,
|
||||
const bool must_be_active)
|
||||
{
|
||||
// Inherited.
|
||||
|
|
|
@ -40,7 +40,7 @@ struct stacked_widget_implementation
|
|||
{
|
||||
template<typename W>
|
||||
static W* find(utils::const_clone_ref<stacked_widget, W> stack,
|
||||
const std::string& id,
|
||||
const std::string_view id,
|
||||
const bool must_be_active)
|
||||
{
|
||||
// Use base method if find-in-all-layer isn't set.
|
||||
|
@ -193,12 +193,12 @@ const grid* stacked_widget::get_layer_grid(unsigned int i) const
|
|||
return &generator_->item(i);
|
||||
}
|
||||
|
||||
widget* stacked_widget::find(const std::string& id, const bool must_be_active)
|
||||
widget* stacked_widget::find(const std::string_view id, const bool must_be_active)
|
||||
{
|
||||
return stacked_widget_implementation::find<widget>(*this, id, must_be_active);
|
||||
}
|
||||
|
||||
const widget* stacked_widget::find(const std::string& id, const bool must_be_active) const
|
||||
const widget* stacked_widget::find(const std::string_view id, const bool must_be_active) const
|
||||
{
|
||||
return stacked_widget_implementation::find<const widget>(*this, id, must_be_active);
|
||||
}
|
||||
|
|
|
@ -174,10 +174,10 @@ private:
|
|||
|
||||
public:
|
||||
/** See @ref widget::find. */
|
||||
virtual widget* find(const std::string& id, const bool must_be_active) override;
|
||||
virtual widget* find(const std::string_view id, const bool must_be_active) override;
|
||||
|
||||
/** See @ref widget::find. */
|
||||
virtual const widget* find(const std::string& id, const bool must_be_active) const override;
|
||||
virtual const widget* find(const std::string_view id, const bool must_be_active) const override;
|
||||
};
|
||||
|
||||
// }---------- DEFINITION ---------{
|
||||
|
|
|
@ -301,7 +301,7 @@ const widget* styled_widget::find_at(const point& coordinate,
|
|||
: nullptr;
|
||||
}
|
||||
|
||||
widget* styled_widget::find(const std::string& id, const bool must_be_active)
|
||||
widget* styled_widget::find(const std::string_view id, const bool must_be_active)
|
||||
{
|
||||
return (widget::find(id, must_be_active)
|
||||
&& (!must_be_active || get_active()))
|
||||
|
@ -309,7 +309,7 @@ widget* styled_widget::find(const std::string& id, const bool must_be_active)
|
|||
: nullptr;
|
||||
}
|
||||
|
||||
const widget* styled_widget::find(const std::string& id, const bool must_be_active)
|
||||
const widget* styled_widget::find(const std::string_view id, const bool must_be_active)
|
||||
const
|
||||
{
|
||||
return (widget::find(id, must_be_active)
|
||||
|
|
|
@ -192,11 +192,10 @@ public:
|
|||
const bool must_be_active) const override;
|
||||
|
||||
/** See @ref widget::find. */
|
||||
widget* find(const std::string& id, const bool must_be_active) override;
|
||||
widget* find(const std::string_view id, const bool must_be_active) override;
|
||||
|
||||
/** See @ref widget::find. */
|
||||
const widget* find(const std::string& id,
|
||||
const bool must_be_active) const override;
|
||||
const widget* find(const std::string_view id, const bool must_be_active) const override;
|
||||
|
||||
/***** ***** ***** setters / getters for members ***** ****** *****/
|
||||
bool get_use_tooltip_on_label_overflow() const
|
||||
|
|
|
@ -424,7 +424,7 @@ const widget* tree_view_node::find_at(const point& coordinate, const bool must_b
|
|||
return tree_view_node_implementation::find_at<const widget>(*this, coordinate, must_be_active);
|
||||
}
|
||||
|
||||
widget* tree_view_node::find(const std::string& id, const bool must_be_active)
|
||||
widget* tree_view_node::find(const std::string_view id, const bool must_be_active)
|
||||
{
|
||||
widget* result = widget::find(id, must_be_active);
|
||||
if(result) {
|
||||
|
@ -446,7 +446,7 @@ widget* tree_view_node::find(const std::string& id, const bool must_be_active)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
const widget* tree_view_node::find(const std::string& id, const bool must_be_active) const
|
||||
const widget* tree_view_node::find(const std::string_view id, const bool must_be_active) const
|
||||
{
|
||||
const widget* result = widget::find(id, must_be_active);
|
||||
if(result) {
|
||||
|
|
|
@ -191,11 +191,10 @@ public:
|
|||
const bool must_be_active) const override;
|
||||
|
||||
/** See @ref widget::find. */
|
||||
widget* find(const std::string& id, const bool must_be_active) override;
|
||||
widget* find(const std::string_view id, const bool must_be_active) override;
|
||||
|
||||
/** See @ref widget::find. */
|
||||
const widget* find(const std::string& id,
|
||||
const bool must_be_active) const override;
|
||||
const widget* find(const std::string_view id, const bool must_be_active) const override;
|
||||
|
||||
/**
|
||||
* The number of children in this widget.
|
||||
|
|
|
@ -69,7 +69,7 @@ struct viewport_implementation
|
|||
|
||||
template <class W>
|
||||
static utils::const_clone_ptr<widget, W>
|
||||
find(W viewport, const std::string& id, const bool must_be_active)
|
||||
find(W viewport, const std::string_view id, const bool must_be_active)
|
||||
{
|
||||
if(viewport->widget::find(id, must_be_active)) {
|
||||
return viewport;
|
||||
|
@ -131,13 +131,12 @@ const widget* viewport::find_at(const point& coordinate,
|
|||
return viewport_implementation::find_at(this, coordinate, must_be_active);
|
||||
}
|
||||
|
||||
widget* viewport::find(const std::string& id, const bool must_be_active)
|
||||
widget* viewport::find(const std::string_view id, const bool must_be_active)
|
||||
{
|
||||
return viewport_implementation::find(this, id, must_be_active);
|
||||
}
|
||||
|
||||
const widget* viewport::find(const std::string& id, const bool must_be_active)
|
||||
const
|
||||
const widget* viewport::find(const std::string_view id, const bool must_be_active) const
|
||||
{
|
||||
return viewport_implementation::find(this, id, must_be_active);
|
||||
}
|
||||
|
|
|
@ -59,11 +59,10 @@ public:
|
|||
const bool must_be_active) const override;
|
||||
|
||||
/** See @ref widget::find. */
|
||||
widget* find(const std::string& id, const bool must_be_active) override;
|
||||
widget* find(const std::string_view id, const bool must_be_active) override;
|
||||
|
||||
/** See @ref widget::find. */
|
||||
const widget* find(const std::string& id,
|
||||
const bool must_be_active) const override;
|
||||
const widget* find(const std::string_view id, const bool must_be_active) const override;
|
||||
|
||||
private:
|
||||
/** See @ref widget::calculate_best_size. */
|
||||
|
|
|
@ -557,13 +557,12 @@ const widget* widget::find_at(const point& coordinate,
|
|||
return is_at(coordinate, must_be_active) ? this : nullptr;
|
||||
}
|
||||
|
||||
widget* widget::find(const std::string& id, const bool /*must_be_active*/)
|
||||
widget* widget::find(const std::string_view id, const bool /*must_be_active*/)
|
||||
{
|
||||
return id_ == id ? this : nullptr;
|
||||
}
|
||||
|
||||
const widget* widget::find(const std::string& id,
|
||||
const bool /*must_be_active*/) const
|
||||
const widget* widget::find(const std::string_view id, const bool /*must_be_active*/) const
|
||||
{
|
||||
return id_ == id ? this : nullptr;
|
||||
}
|
||||
|
|
|
@ -702,11 +702,10 @@ public:
|
|||
* @retval nullptr No widget with the id found (or not active if
|
||||
* must_be_active was set).
|
||||
*/
|
||||
virtual widget* find(const std::string& id, const bool must_be_active);
|
||||
virtual widget* find(const std::string_view id, const bool must_be_active);
|
||||
|
||||
/** The constant version of @ref find. */
|
||||
virtual const widget* find(const std::string& id,
|
||||
const bool must_be_active) const;
|
||||
virtual const widget* find(const std::string_view id, const bool must_be_active) const;
|
||||
|
||||
/**
|
||||
* Does the widget contain the widget.
|
||||
|
@ -739,25 +738,25 @@ public:
|
|||
* @returns The widget with the id.
|
||||
*/
|
||||
template <class T>
|
||||
NOT_DANGLING T* find_widget(
|
||||
const std::string& id,
|
||||
T* find_widget(
|
||||
const std::string_view id,
|
||||
const bool must_be_active,
|
||||
const bool must_exist)
|
||||
{
|
||||
T* result = dynamic_cast<T*>(this->find(id, must_be_active));
|
||||
VALIDATE(!must_exist || result, missing_widget(id));
|
||||
VALIDATE(!must_exist || result, missing_widget(std::string(id)));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
NOT_DANGLING const T* find_widget(
|
||||
const std::string& id,
|
||||
const T* find_widget(
|
||||
const std::string_view id,
|
||||
const bool must_be_active,
|
||||
const bool must_exist) const
|
||||
{
|
||||
T* result = dynamic_cast<T*>(this->find(id, must_be_active));
|
||||
VALIDATE(!must_exist || result, missing_widget(id));
|
||||
VALIDATE(!must_exist || result, missing_widget(std::string(id)));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -776,16 +775,16 @@ public:
|
|||
* @returns The widget with the id.
|
||||
*/
|
||||
template <class T>
|
||||
NOT_DANGLING T& find_widget(
|
||||
const std::string& id,
|
||||
T& find_widget(
|
||||
const std::string_view id,
|
||||
const bool must_be_active = false)
|
||||
{
|
||||
return *(this->find_widget<T>(id, must_be_active, true));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
NOT_DANGLING const T& find_widget(
|
||||
const std::string& id,
|
||||
const T& find_widget(
|
||||
const std::string_view id,
|
||||
const bool must_be_active = false) const
|
||||
{
|
||||
return *(this->find_widget<T>(id, must_be_active, true));
|
||||
|
|
|
@ -775,12 +775,12 @@ const widget* window::find_at(const point& coordinate,
|
|||
return panel::find_at(coordinate, must_be_active);
|
||||
}
|
||||
|
||||
widget* window::find(const std::string& id, const bool must_be_active)
|
||||
widget* window::find(const std::string_view id, const bool must_be_active)
|
||||
{
|
||||
return container_base::find(id, must_be_active);
|
||||
}
|
||||
|
||||
const widget* window::find(const std::string& id, const bool must_be_active)
|
||||
const widget* window::find(const std::string_view id, const bool must_be_active)
|
||||
const
|
||||
{
|
||||
return container_base::find(id, must_be_active);
|
||||
|
|
|
@ -271,11 +271,10 @@ public:
|
|||
}
|
||||
|
||||
/** See @ref widget::find. */
|
||||
widget* find(const std::string& id, const bool must_be_active) override;
|
||||
widget* find(const std::string_view id, const bool must_be_active) override;
|
||||
|
||||
/** See @ref widget::find. */
|
||||
const widget* find(const std::string& id,
|
||||
const bool must_be_active) const override;
|
||||
const widget* find(const std::string_view id, const bool must_be_active) const override;
|
||||
|
||||
#if 0
|
||||
/** @todo Implement these functions. */
|
||||
|
|
Loading…
Add table
Reference in a new issue