roundabout,
created on Wednesday, 26 March 2025, 14:36:53 (1742999813),
received on Wednesday, 26 March 2025, 14:36:57 (1742999817)
Author identity: vlad <vlad.muntoiu@gmail.com>
15d855ece9843491e9e10861a0fe059c146e3ac8
gpanthera.cc
@@ -603,6 +603,32 @@ namespace gPanthera {
return true; // Drop OK
}, false);
scrolled_window = Gtk::make_managed<Gtk::ScrolledWindow>();
auto viewport = Gtk::make_managed<Gtk::Viewport>(nullptr, nullptr);
tab_box = Gtk::make_managed<Gtk::Box>(orientation);
this->prepend(*scrolled_window);
scrolled_window->set_child(*viewport);
viewport->set_child(*tab_box);
this->set_orientation(orientation);
// TODO: Add a box with extra children provided by the application
}
void ContentTabBar::set_orientation(Gtk::Orientation orientation) {
this->Gtk::Box::set_orientation(orientation);
if(orientation == Gtk::Orientation::HORIZONTAL) {
scrolled_window->set_policy(Gtk::PolicyType::AUTOMATIC, Gtk::PolicyType::NEVER);
tab_box->set_orientation(Gtk::Orientation::HORIZONTAL);
scrolled_window->set_hexpand(true);
scrolled_window->set_vexpand(false);
} else if(orientation == Gtk::Orientation::VERTICAL) {
scrolled_window->set_policy(Gtk::PolicyType::NEVER, Gtk::PolicyType::AUTOMATIC);
tab_box->set_orientation(Gtk::Orientation::VERTICAL);
scrolled_window->set_vexpand(true);
scrolled_window->set_hexpand(false);
}
}
ContentTabBar::~ContentTabBar() {
@@ -616,12 +642,12 @@ namespace gPanthera {
void ContentTabBar::update_buttons() {
// Clear the old buttons
auto old_buttons = collect_children(*this);
auto old_buttons = collect_children(*this->tab_box);
for(auto *button : old_buttons) {
if(auto *button_button = dynamic_cast<Gtk::Button*>(button)) {
button_button->unset_child();
tab_box->remove(*button);
}
remove(*button);
}
ContentTab* first_child = nullptr;
for(auto *widget = stack->get_first_child(); widget; widget = widget->get_next_sibling()) {
@@ -632,7 +658,7 @@ namespace gPanthera {
} else {
button->set_group(*first_child);
}
this->append(*button);
this->tab_box->append(*button);
}
}
}
@@ -726,7 +752,7 @@ namespace gPanthera {
// If the pane is not in the same layout manager, reject
return false;
}
auto switcher = dynamic_cast<ContentTabBar*>(this->get_parent());
auto switcher = dynamic_cast<ContentTabBar*>(this->get_parent()->get_parent()->get_parent()->get_parent());
if(switcher) {
auto *stack = switcher->get_stack();
// Move the button to the new position
gpanthera.hh
@@ -175,9 +175,12 @@ namespace gPanthera {
ContentStack *stack;
sigc::connection add_handler, remove_handler;
std::shared_ptr<Gtk::DropTarget> drop_target;
Gtk::ScrolledWindow *scrolled_window;
Gtk::Box *tab_box;
public:
void update_buttons();
explicit ContentTabBar(ContentStack *stack, Gtk::Orientation orientation = Gtk::Orientation::HORIZONTAL);
void set_orientation(Gtk::Orientation orientation);
ContentStack *get_stack() const;
~ContentTabBar() override;
};