@@ -128,7 +128,7 @@ class FormHelper {
128128
129129 // / Add a new top-level window
130130 Window *add_window (const Vector2i &pos,
131- const std::string & title = " Untitled" ) {
131+ std::string_view title = " Untitled" ) {
132132 assert (m_screen);
133133 m_window = new Window (m_screen, title);
134134 m_layout = new AdvancedGridLayout ({10 , 0 , 10 , 0 }, {});
@@ -141,7 +141,7 @@ class FormHelper {
141141 }
142142
143143 // / Add a new group that may contain several sub-widgets
144- Label *add_group (const std::string & caption) {
144+ Label *add_group (std::string_view caption) {
145145 Label* label = new Label (m_window, caption, m_group_font_name, m_group_font_size);
146146 if (m_layout->row_count () > 0 )
147147 m_layout->append_row (m_pre_group_spacing); /* Spacing */
@@ -153,7 +153,7 @@ class FormHelper {
153153
154154 // / Add a new data widget controlled using custom getter/setter functions
155155 template <typename Type> detail::FormWidget<Type> *
156- add_variable (const std::string & label, const std::function<void (const Type &)> &setter,
156+ add_variable (std::string_view label, const std::function<void (const Type &)> &setter,
157157 const std::function<Type ()> &getter, bool editable = true ) {
158158 Label *label_w = new Label (m_window, label, m_label_font_name, m_label_font_size);
159159 auto widget = new detail::FormWidget<Type>(m_window);
@@ -180,7 +180,7 @@ class FormHelper {
180180
181181 // / Add a new data widget that exposes a raw variable in memory
182182 template <typename Type> detail::FormWidget<Type> *
183- add_variable (const std::string & label, Type &value, bool editable = true ) {
183+ add_variable (std::string_view label, Type &value, bool editable = true ) {
184184 return add_variable<Type>(label,
185185 [&](const Type & v) { value = v; },
186186 [&]() -> Type { return value; },
@@ -189,7 +189,7 @@ class FormHelper {
189189 }
190190
191191 // / Add a button with a custom callback
192- Button *add_button (const std::string & label, const std::function<void ()> &cb) {
192+ Button *add_button (std::string_view label, const std::function<void ()> &cb) {
193193 Button *button = new Button (m_window, label);
194194 button->set_callback (cb);
195195 button->set_fixed_height (25 );
@@ -201,7 +201,7 @@ class FormHelper {
201201 }
202202
203203 // / Add an arbitrary (optionally labeled) widget to the layout
204- void add_widget (const std::string & label, Widget *widget) {
204+ void add_widget (std::string_view label, Widget *widget) {
205205 m_layout->append_row (0 );
206206 if (label == " " ) {
207207 m_layout->set_anchor (widget, AdvancedGridLayout::Anchor (1 , m_layout->row_count ()-1 , 3 , 1 ));
@@ -237,16 +237,16 @@ class FormHelper {
237237 Vector2i fixed_size () { return m_fixed_size; }
238238
239239 // / The font name being used for group headers.
240- const std::string & group_font_name () const { return m_group_font_name; }
240+ std::string_view group_font_name () const { return m_group_font_name; }
241241
242242 // / Sets the font name to be used for group headers.
243- void set_group_font_name (const std::string & name) { m_group_font_name = name; }
243+ void set_group_font_name (std::string_view name) { m_group_font_name = name; }
244244
245245 // / The font name being used for labels.
246- const std::string & label_font_name () const { return m_label_font_name; }
246+ std::string_view label_font_name () const { return m_label_font_name; }
247247
248248 // / Sets the font name being used for labels.
249- void set_label_font_name (const std::string & name) { m_label_font_name = name; }
249+ void set_label_font_name (std::string_view name) { m_label_font_name = name; }
250250
251251 // / The size of the font being used for group headers.
252252 int group_font_size () const { return m_group_font_size; }
0 commit comments