13
0

Update Tabbable c'tor to allow member as top-level widget

Derived classes cannot use `Tabbable (_content_vbox,..)`
`_content_vbox` is a member of Tabbable (which has not
yet been initialized) at the point of construction.

This breaks internal API, hence the omnibus commit
This commit is contained in:
Robin Gareus 2024-11-06 01:28:48 +01:00
parent 8ca9e6bcdd
commit b2e4dd91b9
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
7 changed files with 35 additions and 32 deletions

View File

@ -132,7 +132,7 @@ Mixer_UI::instance ()
} }
Mixer_UI::Mixer_UI () Mixer_UI::Mixer_UI ()
: Tabbable (_content, _("Mixer"), X_("mixer")) : Tabbable (_("Mixer"), X_("mixer"), &_content)
, plugin_search_clear_button (X_("Clear")) , plugin_search_clear_button (X_("Clear"))
, _mixer_scene_release (0) , _mixer_scene_release (0)
, no_track_list_redisplay (false) , no_track_list_redisplay (false)

View File

@ -33,7 +33,7 @@ ARDOUR::DataType PublicEditor::pbdid_dragged_dt = ARDOUR::DataType::NIL;
PublicEditor::PublicEditor (Gtk::Widget& content) PublicEditor::PublicEditor (Gtk::Widget& content)
: EditingContext (X_("Editor")) : EditingContext (X_("Editor"))
, Tabbable (content, _("Editor"), X_("editor")) , Tabbable (_("Editor"), X_("editor"), &content)
{ {
_suspend_route_redisplay_counter.store (0); _suspend_route_redisplay_counter.store (0);
} }

View File

@ -2363,7 +2363,7 @@ MidiPortOptions::pretty_name_edit (std::string const & path, string const & new_
RCOptionEditor::RCOptionEditor () RCOptionEditor::RCOptionEditor ()
: OptionEditorContainer (Config) : OptionEditorContainer (Config)
/* pack self-as-vbox into tabbable */ /* pack self-as-vbox into tabbable */
, Tabbable (*this, _("Preferences"), X_("preferences"), /* detached by default */ false) , Tabbable (_("Preferences"), X_("preferences"), this, /* detached by default */ false)
, _rc_config (Config) , _rc_config (Config)
, _mixer_strip_visibility ("mixer-element-visibility") , _mixer_strip_visibility ("mixer-element-visibility")
, _cairo_image_surface (0) , _cairo_image_surface (0)

View File

@ -78,7 +78,7 @@ using namespace Menu_Helpers;
#define PX_SCALE(px) std::max ((float)px, rintf ((float)px* UIConfiguration::instance ().get_ui_scale ())) #define PX_SCALE(px) std::max ((float)px, rintf ((float)px* UIConfiguration::instance ().get_ui_scale ()))
RecorderUI::RecorderUI () RecorderUI::RecorderUI ()
: Tabbable (_content, _("Recorder"), X_("recorder")) : Tabbable (_("Recorder"), X_("recorder"), &_content)
, _toolbar_sep (1.0) , _toolbar_sep (1.0)
, _btn_rec_all (_("All")) , _btn_rec_all (_("All"))
, _btn_rec_none (_("None")) , _btn_rec_none (_("None"))

View File

@ -65,7 +65,7 @@ using namespace Gtk;
using namespace std; using namespace std;
TriggerPage::TriggerPage () TriggerPage::TriggerPage ()
: Tabbable (_content, _("Cues"), X_("trigger")) : Tabbable (_("Cues"), X_("trigger"), &_content)
, _cue_area_frame (0.5, 0, 1.0, 0) , _cue_area_frame (0.5, 0, 1.0, 0)
, _cue_box (16, 16 * TriggerBox::default_triggers_per_box) , _cue_box (16, 16 * TriggerBox::default_triggers_per_box)
, _master_widget (16, 16) , _master_widget (16, 16)

View File

@ -37,13 +37,17 @@ using namespace Gtk;
using namespace Gtkmm2ext; using namespace Gtkmm2ext;
using namespace ArdourWidgets; using namespace ArdourWidgets;
Tabbable::Tabbable (Gtk::Widget& w, const string& visible_name, string const & nontranslatable_name, bool tabbed_by_default) Tabbable::Tabbable (const string& visible_name, string const & nontranslatable_name, Widget* w, bool tabbed_by_default)
: WindowProxy (visible_name, nontranslatable_name) : WindowProxy (visible_name, nontranslatable_name)
, _contents (w)
, _parent_notebook (0) , _parent_notebook (0)
, tab_requested_by_state (tabbed_by_default) , tab_requested_by_state (tabbed_by_default)
{ {
default_layout (); if (w) {
_contents = w;
} else {
_contents = &_content_vbox;
default_layout ();
}
} }
Tabbable::~Tabbable () Tabbable::~Tabbable ()
@ -119,13 +123,13 @@ Tabbable::use_own_window (bool and_pack_it)
Gtk::Window* win = get (true); Gtk::Window* win = get (true);
if (and_pack_it) { if (and_pack_it) {
Gtk::Container* parent = _contents.get_parent(); Gtk::Container* parent = _contents->get_parent();
if (parent) { if (parent) {
_contents.hide (); _contents->hide ();
parent->remove (_contents); parent->remove (*_contents);
} }
_own_notebook.append_page (_contents); _own_notebook.append_page (*_contents);
_contents.show (); _contents->show ();
} }
return win; return win;
@ -179,7 +183,7 @@ Tabbable::get (bool create)
void void
Tabbable::show_own_window (bool and_pack_it) Tabbable::show_own_window (bool and_pack_it)
{ {
Gtk::Widget* parent = _contents.get_parent(); Gtk::Widget* parent = _contents->get_parent();
Gtk::Allocation alloc; Gtk::Allocation alloc;
if (parent) { if (parent) {
@ -231,7 +235,7 @@ void
Tabbable::change_visibility () Tabbable::change_visibility ()
{ {
if (tabbed()) { if (tabbed()) {
_parent_notebook->set_current_page (_parent_notebook->page_num (_contents)); _parent_notebook->set_current_page (_parent_notebook->page_num (*_contents));
return; return;
} }
@ -299,22 +303,22 @@ Tabbable::attach ()
save_pos_and_size (); save_pos_and_size ();
_contents.hide (); _contents->hide ();
_contents.get_parent()->remove (_contents); _contents->get_parent()->remove (*_contents);
/* leave the window around */ /* leave the window around */
_window->hide (); _window->hide ();
} }
_parent_notebook->append_page (_contents); _parent_notebook->append_page (*_contents);
_parent_notebook->set_tab_detachable (_contents); _parent_notebook->set_tab_detachable (*_contents);
_parent_notebook->set_tab_reorderable (_contents); _parent_notebook->set_tab_reorderable (*_contents);
_parent_notebook->set_current_page (_parent_notebook->page_num (_contents)); _parent_notebook->set_current_page (_parent_notebook->page_num (*_contents));
signal_tabbed_changed (true); signal_tabbed_changed (true);
_contents.show (); _contents->show ();
/* have to force this on, which is semantically correct, since /* have to force this on, which is semantically correct, since
* the user has effectively asked for it. * the user has effectively asked for it.
@ -339,7 +343,7 @@ Tabbable::tabbed () const
return false; return false;
} }
if (_parent_notebook && (_parent_notebook->page_num (_contents) >= 0)) { if (_parent_notebook && (_parent_notebook->page_num (*_contents) >= 0)) {
return true; return true;
} }
@ -350,8 +354,8 @@ void
Tabbable::hide_tab () Tabbable::hide_tab ()
{ {
if (tabbed()) { if (tabbed()) {
_contents.hide(); _contents->hide();
_parent_notebook->remove_page (_contents); _parent_notebook->remove_page (*_contents);
StateChange (*this); StateChange (*this);
} }
} }
@ -360,12 +364,12 @@ void
Tabbable::show_tab () Tabbable::show_tab ()
{ {
if (!window_visible() && _parent_notebook) { if (!window_visible() && _parent_notebook) {
if (_contents.get_parent() == 0) { if (_contents->get_parent() == 0) {
tab_requested_by_state = true; tab_requested_by_state = true;
add_to_notebook (*_parent_notebook); add_to_notebook (*_parent_notebook);
} }
_parent_notebook->set_current_page (_parent_notebook->page_num (_contents)); _parent_notebook->set_current_page (_parent_notebook->page_num (*_contents));
_contents.show (); _contents->show ();
current_toplevel()->present (); current_toplevel()->present ();
} }
} }

View File

@ -48,7 +48,7 @@ namespace ArdourWidgets {
class LIBWIDGETS_API Tabbable : public Gtkmm2ext::WindowProxy class LIBWIDGETS_API Tabbable : public Gtkmm2ext::WindowProxy
{ {
public: public:
Tabbable (Gtk::Widget&, const std::string& user_visible_name, std::string const & untranslated_name, bool tabbed_by_default = true); Tabbable (const std::string& user_visible_name, std::string const & untranslated_name, Gtk::Widget* top = NULL, bool tabbed_by_default = true);
~Tabbable (); ~Tabbable ();
void add_to_notebook (Gtk::Notebook& notebook); void add_to_notebook (Gtk::Notebook& notebook);
@ -58,7 +58,7 @@ public:
void attach (); void attach ();
void detach (); void detach ();
Gtk::Widget& contents() const { return _contents; } Gtk::Widget& contents() const { return *_contents; }
/* this is where ArdourUI packs the tab switchers /* this is where ArdourUI packs the tab switchers
* (record/cues/edit/mix) into my toolbar area, * (record/cues/edit/mix) into my toolbar area,
@ -127,7 +127,6 @@ protected:
EventBoxExt content_att_bottom; /* a placeholder for the property box, if you want one */ EventBoxExt content_att_bottom; /* a placeholder for the property box, if you want one */
/* clang-format on */ /* clang-format on */
/* visibility controls */ /* visibility controls */
ArdourWidgets::ArdourButton left_attachment_button; ArdourWidgets::ArdourButton left_attachment_button;
ArdourWidgets::ArdourButton right_attachment_button; ArdourWidgets::ArdourButton right_attachment_button;
@ -143,7 +142,7 @@ private:
void window_unmapped (); void window_unmapped ();
Gtk::VBox _content_vbox; /* this is the root widget for a full-featured tabbable, which contains: */ Gtk::VBox _content_vbox; /* this is the root widget for a full-featured tabbable, which contains: */
Gtk::Widget& _contents; /* for most Tabbables this will be content_vbox; but rc_options, for example, does something different. */ Gtk::Widget* _contents; /* for most Tabbables this will be content_vbox; but rc_options, for example, does something different. */
Gtk::Notebook _own_notebook; Gtk::Notebook _own_notebook;
Gtk::Notebook* _parent_notebook; Gtk::Notebook* _parent_notebook;
bool tab_requested_by_state; bool tab_requested_by_state;