Changeset 1274

Show
Ignore:
Timestamp:
06/23/08 12:41:58 (3 months ago)
Author:
drobilla
Message:

Move widget embedding down to FlowCanvas.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • flowcanvas/flowcanvas/Module.hpp

    r1206 r1274  
    8989 
    9090        void fit_canvas(); 
     91         
     92        void embed(Gtk::Container* widget); 
    9193 
    9294        double _border_width; 
     
    104106        Gnome::Canvas::Rect*   _stacked_border; 
    105107        Gnome::Canvas::Pixbuf* _icon_box; 
     108        Gtk::Container*        _embed_container; 
     109        Gnome::Canvas::Widget* _embed_item; 
    106110 
    107111private: 
     
    114118                const std::string& _name; 
    115119        }; 
     120         
     121        void embed_size_request(Gtk::Requisition* req, bool force); 
     122         
     123        int _last_embed_request_width; 
     124        int _last_embed_request_height; 
    116125}; 
    117126 
  • flowcanvas/src/Module.cpp

    r1206 r1274  
    5858        , _stacked_border(NULL) 
    5959        , _icon_box(NULL) 
     60        , _embed_container(NULL) 
     61        , _embed_item(NULL) 
     62        , _last_embed_request_width(0) 
     63        , _last_embed_request_height(0) 
    6064{ 
    6165        _module_box.property_fill_color_rgba() = MODULE_FILL_COLOUR; 
     
    419423} 
    420424 
     425         
     426 
     427/** Embed a widget on the module. 
     428 * 
     429 * Resize may need to be called after this to ensure the module 
     430 * displays correctly. 
     431 */ 
     432void 
     433Module::embed(Gtk::Container* widget) 
     434{ 
     435        if (!widget) { 
     436                delete _embed_item; 
     437                _embed_item = NULL; 
     438                _ports_y_offset = 0; 
     439                _minimum_width = 0; // resize() will takes care of this 
     440                return; 
     441        } else { 
     442                _embed_container = manage(widget); 
     443        } 
     444 
     445        _embed_container->set_border_width(2); 
     446        _embed_container->show_all(); 
     447 
     448        const double y = 4 + _canvas_title.property_text_height(); 
     449        delete _embed_item; 
     450        _embed_item = new Gnome::Canvas::Widget(*this, 2.0, y, *_embed_container); 
     451        _embed_item->show(); 
     452 
     453        Gtk::Requisition r = _embed_container->size_request(); 
     454        embed_size_request(&r, true); 
     455 
     456        _embed_item->raise_to_top(); 
     457 
     458        _embed_container->signal_size_request().connect(sigc::bind( 
     459                                sigc::mem_fun(this, &Module::embed_size_request), false)); 
     460} 
     461 
     462         
     463void 
     464Module::embed_size_request(Gtk::Requisition* r, bool force) 
     465{ 
     466        if (!force && _last_embed_request_width == r->width && _last_embed_request_height == r->height) 
     467                return; 
     468 
     469        if (r->width + 4 > _width) 
     470                set_minimum_width(r->width + 4); 
     471         
     472        _ports_y_offset = r->height + 2; 
     473         
     474        resize(); 
     475 
     476        Gtk::Allocation allocation; 
     477        allocation.set_width(r->width + 4); 
     478        allocation.set_height(r->height + 4); 
     479 
     480        _embed_container->size_allocate(allocation); 
     481        _embed_item->property_width() = _width - 4; 
     482        _embed_item->property_height() = r->height; 
     483 
     484        _last_embed_request_width = r->width; 
     485        _last_embed_request_height = r->height; 
     486} 
     487 
    421488 
    422489/** Resize the module to fit its contents best. 
  • ingen/src/libs/client/OSCClientReceiver.cpp

    r1248 r1274  
    3636        , _st(NULL) 
    3737{ 
    38         start(false); // true = dump, false = shutup 
     38        start(true); // true = dump, false = shutup 
    3939} 
    4040 
  • ingen/src/libs/engine/JackAudioDriver.hpp

    r1230 r1274  
    109109        bool           is_activated() const { return _is_activated; } 
    110110         
    111         inline SampleCount frame_time() const { return jack_frame_time(_client); } 
     111        inline SampleCount frame_time() const {  
     112                const SampleCount t = jack_frame_time(_client); 
     113                std::cerr << "Frame time: " << t << std::endl; 
     114                return t; 
     115        } 
    112116 
    113117        class PortRegistrationFailedException : public std::exception {}; 
  • ingen/src/libs/engine/QueuedEventSource.cpp

    r827 r1274  
    6262{ 
    6363        assert(!ev->is_prepared()); 
     64 
     65        cerr << "[QueuedEventSource] Pushing queued @ " << ev->time() << endl; 
    6466 
    6567        if (_events[_back] != NULL) { 
  • ingen/src/libs/engine/QueuedEventSource.hpp

    r827 r1274  
    5959protected: 
    6060        void push_queued(QueuedEvent* const ev); 
    61         inline void push_stamped(Event* const ev) { _stamped_queue.push(ev); } 
     61        inline void push_stamped(Event* const ev) {  
     62                std::cerr << "[QueuedEventSource] Pushing stamped @ " << ev->time() << std::endl; 
     63                _stamped_queue.push(ev); } 
    6264         
    6365        Event*        pop_earliest_queued_before(const SampleCount time); 
     
    9799        Event* ret = NULL; 
    98100 
    99         if (!_stamped_queue.empty() && _stamped_queue.front()->time() < time) { 
    100                 ret = _stamped_queue.front(); 
    101                 _stamped_queue.pop(); 
     101        if (!_stamped_queue.empty()) { 
     102                if (_stamped_queue.front()->time() < time) { 
     103                        ret = _stamped_queue.front(); 
     104                        std::cerr << "[QueuedEventSource] Popping event @ " << _stamped_queue.front()->time() << std::endl; 
     105                        _stamped_queue.pop(); 
     106                } else { 
     107                        std::cerr << "[QueuedEventSource] Next event is past " << time 
     108                                << " (@ " << _stamped_queue.front()->time() << ")" << std::endl; 
     109                } 
    102110        } 
    103111 
  • ingen/src/libs/gui/NodeModule.cpp

    r1273 r1274  
    4141        , _node(node) 
    4242        , _gui_widget(NULL) 
    43         , _gui_container(NULL) 
    44         , _gui_item(NULL) 
    4543        , _gui_window(NULL) 
    46         , _last_gui_request_width(0) 
    47         , _last_gui_request_height(0) 
    4844{ 
    4945        assert(_node); 
     
    130126                        return; 
    131127                } 
    132                  
    133                 GtkWidget* c_widget = NULL; 
    134  
    135                 if (!_gui_item) { 
    136                  
    137                         const PluginModel* const plugin = dynamic_cast<const PluginModel*>(_node->plugin()); 
    138                         assert(plugin); 
    139  
    140                         _plugin_ui = plugin->ui(App::instance().world(), _node); 
    141  
    142                         if (_plugin_ui) { 
    143                                 c_widget = (GtkWidget*)slv2_ui_instance_get_widget(_plugin_ui->instance()); 
    144                                 _gui_widget = Glib::wrap(c_widget); 
    145                                 assert(_gui_widget); 
    146                          
    147                                 if (_gui_container) 
    148                                         delete _gui_container; 
    149  
    150                                 _gui_container = manage(new Gtk::EventBox()); 
    151                                 _gui_container->set_name("ingen_embedded_node_gui_container"); 
    152                                 _gui_container->set_border_width(2); 
    153                                 _gui_container->add(*_gui_widget); 
    154                                 _gui_container->show_all(); 
    155                          
    156                                 const double y = 4 + _canvas_title.property_text_height(); 
    157                                 _gui_item = new Gnome::Canvas::Widget(*this, 2.0, y, *_gui_container); 
    158                         } 
    159                 } 
    160  
    161                 if (_gui_item) { 
    162  
     128 
     129                if (!_plugin_ui) { 
     130                        const PluginModel* const pm = dynamic_cast<const PluginModel*>(_node->plugin()); 
     131                        assert(pm); 
     132                        _plugin_ui = pm->ui(App::instance().world(), _node); 
     133                } 
     134 
     135                if (_plugin_ui) { 
     136                        GtkWidget* c_widget = (GtkWidget*)slv2_ui_instance_get_widget(_plugin_ui->instance()); 
     137                        _gui_widget = Glib::wrap(c_widget); 
    163138                        assert(_gui_widget); 
     139 
     140                        Gtk::Container* container = new Gtk::EventBox(); 
     141                        container->set_name("ingen_embedded_node_gui_container"); 
     142                        container->add(*_gui_widget); 
     143                        FlowCanvas::Module::embed(container); 
     144                } else { 
     145                        cerr << "ERROR: Failed to create LV2 UI" << endl; 
     146                } 
     147 
     148                if (_gui_widget) { 
    164149                        _gui_widget->show_all(); 
    165                         _gui_item->show(); 
    166  
    167                         Gtk::Requisition r = _gui_container->size_request(); 
    168                         gui_size_request(&r, true); 
    169  
    170                         _gui_item->raise_to_top(); 
    171  
    172                         _gui_container->signal_size_request().connect(sigc::bind( 
    173                                         sigc::mem_fun(this, &NodeModule::gui_size_request), false)); 
    174                  
    175                         for (PortModelList::const_iterator p = _node->ports().begin(); p != _node->ports().end(); ++p) 
     150 
     151                        for (PortModelList::const_iterator p = _node->ports().begin(); 
     152                                        p != _node->ports().end(); ++p) 
    176153                                if ((*p)->type().is_control() && (*p)->is_output()) 
    177154                                        App::instance().engine()->enable_port_broadcasting((*p)->path()); 
    178  
    179                 } else { 
    180                         cerr << "ERROR: Failed to create canvas item for LV2 UI" << endl; 
    181155                } 
    182156 
    183157        } else { // un-embed 
    184158 
    185                 if (_gui_item) { 
    186                         delete _gui_item; 
    187                         _gui_item = NULL; 
    188                         _gui_container = NULL; // managed 
    189                         _gui_widget = NULL; // managed 
    190                         _plugin_ui.reset(); 
    191                 } 
    192  
    193                 _ports_y_offset = 0; 
    194                 _minimum_width = 0; // resize() takes care of it.. 
     159                FlowCanvas::Module::embed(NULL); 
     160                _plugin_ui.reset(); 
    195161 
    196162                for (PortModelList::const_iterator p = _node->ports().begin(); p != _node->ports().end(); ++p) 
     
    199165        } 
    200166                         
    201         if (embed && _gui_item) { 
     167        if (embed && _embed_item) { 
    202168                initialise_gui_values(); 
    203169                set_base_color(0x212222FF); 
     
    207173 
    208174        resize(); 
    209 } 
    210  
    211  
    212 void 
    213 NodeModule::gui_size_request(Gtk::Requisition* r, bool force) 
    214 { 
    215         if (!force && _last_gui_request_width == r->width && _last_gui_request_height == r->height) 
    216                 return; 
    217  
    218         if (r->width + 4 > _width) 
    219                 set_minimum_width(r->width + 4); 
    220          
    221         _ports_y_offset = r->height + 2; 
    222          
    223         resize(); 
    224  
    225         Gtk::Allocation allocation; 
    226         allocation.set_width(r->width + 4); 
    227         allocation.set_height(r->height + 4); 
    228  
    229         _gui_container->size_allocate(allocation); 
    230         _gui_item->property_width() = _width - 4; 
    231         _gui_item->property_height() = r->height; 
    232  
    233         _last_gui_request_width = r->width; 
    234         _last_gui_request_height = r->height; 
    235175} 
    236176 
  • ingen/src/libs/gui/NodeModule.hpp

    r1216 r1274  
    6969         
    7070        void show_control_window(); 
     71        void embed_gui(bool embed); 
    7172        bool popup_gui(); 
    7273        void on_gui_window_close(); 
     
    7980 
    8081        void value_changed(uint32_t index, const Atom& value); 
    81  
    82         void embed_gui(bool embed); 
    83         void gui_size_request(Gtk::Requisition* req, bool force); 
    8482        void initialise_gui_values(); 
    8583 
     
    9088        SharedPtr<PluginUI>    _plugin_ui; 
    9189        Gtk::Widget*           _gui_widget; 
    92         Gtk::Container*        _gui_container; 
    93         Gnome::Canvas::Widget* _gui_item; ///< iff embedded 
    9490        Gtk::Window*           _gui_window; ///< iff popped up 
    95         int                    _last_gui_request_width; 
    96         int                    _last_gui_request_height; 
    9791}; 
    9892