GTK docking interfaces

By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.

Dismiss

Tab reordering

roundabout,
created on Saturday, 15 March 2025, 10:16:25 (1742033785), received on Saturday, 15 March 2025, 10:16:28 (1742033788)
Author identity: vlad <vlad.muntoiu@gmail.com>

7f7fda8000b027c264908f44fde7ae9a90e9a2cb

gpanthera.cc

@@ -533,10 +533,51 @@ namespace gPanthera {

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        drag_source->set_actions(Gdk::DragAction::MOVE);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        auto const paintable = Gtk::WidgetPaintable::create();
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        paintable->set_widget(*this);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    drag_source->set_icon(paintable, 0, 0);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    drag_source->set_icon(paintable->get_current_image(), 0, 0);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        return Gdk::ContentProvider::create(value);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    }, false);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    update_active_style();
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                drag_source->signal_drag_begin().connect([this](const Glib::RefPtr<Gdk::Drag>&) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    this->set_opacity(0);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                }, false);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                drop_target = Gtk::DropTarget::create(ContentPage::get_type(), Gdk::DragAction::MOVE);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                // Process dropped buttons by inserting them after the current button
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                drop_target->signal_drop().connect([this](const Glib::ValueBase& value, double x, double y) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    const auto &widget = static_cast<const Glib::Value<ContentPage*>&>(value).get();
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    if(widget) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        if(auto page = dynamic_cast<ContentPage*>(widget)) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                            if(page->content_manager != this->page->content_manager) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                // If the pane is not in the same layout manager, reject
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                return false;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                            }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                            auto switcher = dynamic_cast<ContentTabBar*>(this->get_parent());
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                            if(switcher) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                auto *stack = switcher->get_stack();
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                // Move the button to the new position
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                page->redock(stack);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                if(switcher->get_orientation() == Gtk::Orientation::HORIZONTAL) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                    if(x < static_cast<double>(this->get_allocated_width()) / 2) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                        page->insert_before(*stack, *this->page);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                    } else {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                        page->insert_after(*stack, *this->page);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                    }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                } else if(switcher->get_orientation() == Gtk::Orientation::VERTICAL) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                    if(y < static_cast<double>(this->get_allocated_height()) / 2) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                        page->insert_before(*stack, *this->page);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                    } else {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                        page->insert_after(*stack, *this->page);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                    }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                switcher->update_buttons();
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                            }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    return true;  // Drop OK
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                }, false);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                this->add_controller(drop_target);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    // Pop out if dragged to an external location
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    // TODO: Implement this, allow defining custom behavior at the content manager level
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                }
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                            
                                

gpanthera.hh

@@ -136,6 +136,7 @@ namespace gPanthera {

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                class ContentTab : public Gtk::ToggleButton {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                private:
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    std::shared_ptr<Gtk::DragSource> drag_source;
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                std::shared_ptr<Gtk::DropTarget> drop_target;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    Glib::Value<ContentPage*> value;
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    void update_active_style();
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    sigc::connection active_style_handler;