diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index ff3da460c..e46c1e78d 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -125,6 +125,8 @@ libgui_la_SOURCES = \ $(lumigui_srcdir)/widgets/timeline-widget.hpp \ $(lumigui_srcdir)/widgets/timeline/timeline-view-window.cpp \ $(lumigui_srcdir)/widgets/timeline/timeline-view-window.hpp \ + $(lumigui_srcdir)/widgets/timeline/timeline-header-widget.cpp \ + $(lumigui_srcdir)/widgets/timeline/timeline-header-widget.hpp \ $(lumigui_srcdir)/widgets/timeline/timeline-header-container.cpp \ $(lumigui_srcdir)/widgets/timeline/timeline-header-container.hpp \ $(lumigui_srcdir)/widgets/timeline/timeline-body.cpp \ diff --git a/src/gui/lumiera_ui.rc b/src/gui/lumiera_ui.rc index 7cf803285..df1a55437 100644 --- a/src/gui/lumiera_ui.rc +++ b/src/gui/lumiera_ui.rc @@ -151,13 +151,14 @@ style "timeline_ruler" = "default_base" gtkmm__CustomObject_TimelineRuler::playback_period_arrow_stem_size = 3 } -style "timeline_header_container" = "default_base" +style "timeline_header_widget" = "default_base" { - gtkmm__CustomObject_HeaderContainer::heading_margin = 4 + gtkmm__CustomObject_TimelineHeaderWidget::margin = 4 + gtkmm__CustomObject_TimelineHeaderWidget::expand_button_size = 12 } class "gtkmm__CustomObject_TimelineBody" style:highest "timeline_body" class "gtkmm__CustomObject_TimelineRuler" style:highest "timeline_ruler" -class "gtkmm__CustomObject_TimelineHeaderContainer" style:highest "timeline_header_container" +class "gtkmm__CustomObject_TimelineHeaderWidget" style:highest "timeline_header_widget" diff --git a/src/gui/widgets/timeline-widget.hpp b/src/gui/widgets/timeline-widget.hpp index f362faaff..b95073230 100644 --- a/src/gui/widgets/timeline-widget.hpp +++ b/src/gui/widgets/timeline-widget.hpp @@ -314,6 +314,7 @@ protected: friend class timeline::TimelineViewWindow; friend class timeline::TimelineBody; friend class timeline::TimelineHeaderContainer; + friend class timeline::TimelineHeaderWidget; friend class timeline::TimelineLayoutHelper; friend class timeline::TimelineRuler; friend class timeline::Tool; diff --git a/src/gui/widgets/timeline/timeline-header-container.cpp b/src/gui/widgets/timeline/timeline-header-container.cpp index 4d311721d..172c130d6 100644 --- a/src/gui/widgets/timeline/timeline-header-container.cpp +++ b/src/gui/widgets/timeline/timeline-header-container.cpp @@ -40,9 +40,7 @@ namespace timeline { TimelineHeaderContainer::TimelineHeaderContainer( gui::widgets::TimelineWidget &timeline_widget) : Glib::ObjectBase("TimelineHeaderContainer"), - timelineWidget(timeline_widget), - margin(-1), - expand_button_size(12) + timelineWidget(timeline_widget) { // This widget will not have a window at first set_flags(Gtk::NO_WINDOW); @@ -65,12 +63,6 @@ TimelineHeaderContainer::TimelineHeaderContainer( menu_list.push_back( Menu_Helpers::MenuElem(_("_Add Track"), sigc::mem_fun(timelineWidget, &TimelineWidget::on_add_track_command) ) ); - - // Install style properties - register_styles(); - - // Load the styles up - read_styles(); } void @@ -148,19 +140,7 @@ bool TimelineHeaderContainer::on_button_press_event ( switch(event->button) { - case 1: // Left Click - // Did the user press the button on an expander? - if(hoveringExpander) - { - // Yes? The prime for a release event - clickedExpander = hoveringExpander; - queue_draw(); - } - else if(hoveringTrack) // Is the user hovering on a track - { - - } - + case 1: // Left Click break; case 3: // Right Click @@ -194,17 +174,6 @@ bool TimelineHeaderContainer::on_button_release_event ( { TimelineLayoutHelper &layout = timelineWidget.layoutHelper; - // Did the user release the button on an expander? - if(clickedExpander != NULL) - { - // Yes? The toggle the expanding - clickedExpander->expand_collapse( - clickedExpander->get_expanded() ? Track::Collapse : Track::Expand); - clickedExpander.reset(); - - layout.update_layout(); - } - // Has the user been dragging? if(layout.get_dragging_track()) layout.end_dragging_track(); @@ -216,45 +185,35 @@ bool TimelineHeaderContainer::on_motion_notify_event ( GdkEventMotion* event) { REQUIRE(event != NULL); + REQUIRE(gdkWindow); const bool result = Container::on_motion_notify_event(event); - - const Gdk::Point point(event->x, event->y); - TimelineLayoutHelper &layout = timelineWidget.layoutHelper; + + TimelineLayoutHelper &layout = timelineWidget.layoutHelper; + + // Get the mouse point + int window_x = 0, window_y = 0; + gdkWindow->get_origin(window_x, window_y); + mousePoint = Gdk::Point(event->x_root - window_x, + event->y_root - window_y); // Are we beginning to drag a header? if((event->state & GDK_BUTTON1_MASK) && hoveringTrack && - !hoveringExpander && !layout.get_dragging_track()) + !layout.get_dragging_track()) { - layout.begin_dragging_track(hoveringTrack); + layout.begin_dragging_track(mousePoint); return result; } // Are we currently dragging? if(layout.get_dragging_track()) { - layout.drag_to_point(point); + layout.drag_to_point(mousePoint); return result; } // Hit test the rectangle - hoveringTrack = layout.header_from_point(point); - - if(hoveringTrack) - { - const optional rect = - get_expander_button_rectangle(hoveringTrack); - - REQUIRE(rect); - - // Are we hovering on the expander? - if(util::pt_in_rect(point, *rect)) - { - hoveringExpander = hoveringTrack; - queue_draw(); - } - else hoveringExpander.reset(); - } + hoveringTrack = layout.header_from_point(mousePoint); return result; } @@ -295,8 +254,7 @@ TimelineHeaderContainer::on_size_allocate (Allocation& allocation) // Resize the widget's window if(gdkWindow) { - gdkWindow->move(allocation.get_x(), allocation.get_y()); - gdkWindow->resize( + gdkWindow->move_resize(allocation.get_x(), allocation.get_y(), allocation.get_width(), allocation.get_height()); } @@ -330,35 +288,6 @@ TimelineHeaderContainer::on_layout_changed() layout_headers(); } -bool -TimelineHeaderContainer::on_expose_event(GdkEventExpose *event) -{ - if(gdkWindow) - { - const Allocation container_allocation = get_allocation(); - - // Paint a border underneath all the headers - const TimelineLayoutHelper::TrackTree &layout_tree = - timelineWidget.layoutHelper.get_layout_tree(); - - TimelineLayoutHelper::TrackTree::pre_order_iterator iterator; - for(iterator = ++layout_tree.begin(); // ++ so that we skip the sequence root - iterator != layout_tree.end(); - iterator++) - { - shared_ptr model_track = *iterator; - REQUIRE(model_track); - - draw_header_decoration(model_track, - Gdk::Rectangle(0, 0, - container_allocation.get_width(), - container_allocation.get_height())); - } - } - - return Container::on_expose_event(event); -} - void TimelineHeaderContainer::on_scroll() { @@ -373,15 +302,12 @@ TimelineHeaderContainer::on_hovering_track_changed( { (void)hovering_track; - // The hovering track has changed, redraw so we can light the header - queue_draw(); + } void TimelineHeaderContainer::layout_headers() { - REQUIRE(margin >= 0); // read_styles must have been called before now - // We can't layout before the widget has been set up if(!gdkWindow) return; @@ -390,6 +316,9 @@ TimelineHeaderContainer::layout_headers() timelineWidget.layoutHelper; const TimelineLayoutHelper::TrackTree &layout_tree = layout_helper.get_layout_tree(); + + shared_ptr dragging_track = + layout_helper.get_dragging_track(); TimelineLayoutHelper::TrackTree::pre_order_iterator iterator; for(iterator = ++layout_tree.begin(); // ++ so that we skip the sequence root @@ -408,17 +337,9 @@ TimelineHeaderContainer::layout_headers() { REQUIRE(header_rect->get_width() >= 0); REQUIRE(header_rect->get_height() >= 0); - - // Calculate the allocation of the header widget - Allocation header_allocation( - header_rect->get_x() + margin + expand_button_size, // x - header_rect->get_y() + margin, // y - max( header_rect->get_width() - expand_button_size - - margin * 2, 0 ), // width - header_rect->get_height() - margin * 2); // height // Apply the allocation to the header - widget.size_allocate (header_allocation); + widget.size_allocate (*header_rect); if(!widget.is_visible()) widget.show(); } @@ -426,78 +347,9 @@ TimelineHeaderContainer::layout_headers() if(widget.is_visible()) widget.hide(); } - + // Repaint the background of our parenting - queue_draw (); -} - -void -TimelineHeaderContainer::draw_header_decoration( - shared_ptr model_track, - const Gdk::Rectangle &clip_rect) -{ - REQUIRE(model_track != NULL); - REQUIRE(clip_rect.get_width() > 0); - REQUIRE(clip_rect.get_height() > 0); - - Glib::RefPtr