void Dialog::add_button(Button &button, int code)
{
add(button);
- button.signal_clicked.connect(sigc::bind(sigc::mem_fun(this, &Dialog::response), code));
+ connect_button(button, code);
+}
+
+void Dialog::add_button(unique_ptr<Button> button, int code)
+{
+ Button &b = *button;
+ add(move(button));
+ connect_button(b, code);
+}
+
+Button &Dialog::add_button(const string &text, int code)
+{
+ Button &b = add_new<Button>(text);
+ connect_button(b, code);
+ return b;
}
void Dialog::set_modal(bool m)
signal_ungrab_pointer.emit();
}
-void Dialog::button_release(int x, int y, unsigned button)
+void Dialog::connect_button(Button &button, int code)
{
- Panel::button_release(x, y, button);
- check_stale();
-}
-
-bool Dialog::key_release(unsigned key, unsigned mod)
-{
- bool result = Panel::key_release(key, mod);
- check_stale();
- return result;
-}
-
-bool Dialog::navigate(Navigation nav)
-{
- bool result = Panel::navigate(nav);
- check_stale();
- return result;
+ button.signal_clicked.connect(sigc::bind(sigc::mem_fun(this, &Dialog::response), code));
}
void Dialog::response(int code)
{
on_response(code);
signal_response.emit(code);
- stale = true;
-}
-
-void Dialog::check_stale()
-{
- if(stale)
- delete this;
+ set_visible(false);
}
{
unique_ptr<Button> btn = make_unique<Button>();
load_sub(*btn);
- obj.add_button(*btn.get(), c);
- last_widget = wdg_map[n] = btn.release();
+ Widget *wdg = btn.get();
+ obj.add_button(move(btn), c);
+ last_widget = wdg_map[n] = wdg;
}
} // namespace GLtk