X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Ftime_axis_view.cc;h=04d7c805332875b0e0387e0b24716cd95dd56214;hb=e11544b59aaf84e2d4ed1a6fb57e1ae5e6e05ebf;hp=7723e122f4e40e4235bd0eddcb8dd17cd8deebd8;hpb=e4fceee69f66a62e0a706c1be4159c8953aa046d;p=ardour.git diff --git a/gtk2_ardour/time_axis_view.cc b/gtk2_ardour/time_axis_view.cc index 7723e122f4..04d7c80533 100644 --- a/gtk2_ardour/time_axis_view.cc +++ b/gtk2_ardour/time_axis_view.cc @@ -79,7 +79,7 @@ TimeAxisView::TimeAxisView (ARDOUR::Session& sess, PublicEditor& ed, TimeAxisVie need_size_info = false; } - canvas_display = new Group (*canvas.root(), 0.0, 0.0); + canvas_display = new Group (*ed.get_trackview_group (), 0.0, 0.0); selection_group = new Group (*canvas_display); selection_group->hide(); @@ -91,13 +91,11 @@ TimeAxisView::TimeAxisView (ARDOUR::Session& sess, PublicEditor& ed, TimeAxisVie _hidden = false; height = 0; effective_height = 0; - height_scaling_factor = 1.0; parent = rent; _has_state = false; last_name_entry_key_press_event = 0; name_packing = NamePackingBits (0); resize_drag_start = -1; - resize_idle_id = -1; /* Create the standard LHS Controls @@ -134,6 +132,7 @@ TimeAxisView::TimeAxisView (ARDOUR::Session& sess, PublicEditor& ed, TimeAxisVie controls_table.set_no_show_all (); resizer.set_size_request (10, 10); + resizer.set_name ("ResizeHandle"); resizer.signal_expose_event().connect (mem_fun (*this, &TimeAxisView::resizer_expose)); resizer.signal_button_press_event().connect (mem_fun (*this, &TimeAxisView::resizer_button_press)); resizer.signal_button_release_event().connect (mem_fun (*this, &TimeAxisView::resizer_button_release)); @@ -230,6 +229,7 @@ TimeAxisView::show_at (double y, int& nth, VBox *parent) */ canvas_display->get_bounds (ix1, iy1, ix2, iy2); + iy1 += editor.get_trackview_group_vertical_offset (); Group* pg = canvas_display->property_parent(); pg->i2w (ix1, iy1); @@ -273,6 +273,9 @@ TimeAxisView::controls_ebox_scroll (GdkEventScroll* ev) if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) { step_height (true); return true; + } else if (Keyboard::no_modifiers_active (ev->state)) { + editor.scroll_tracks_up_line(); + return true; } break; @@ -280,6 +283,9 @@ TimeAxisView::controls_ebox_scroll (GdkEventScroll* ev) if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) { step_height (false); return true; + } else if (Keyboard::no_modifiers_active (ev->state)) { + editor.scroll_tracks_down_line(); + return true; } break; @@ -341,21 +347,16 @@ TimeAxisView::hide () Hiding (); } -void -TimeAxisView::set_height_scaling_factor (double hsf) -{ - height_scaling_factor = hsf; - set_height (height); -} - void TimeAxisView::step_height (bool bigger) { + static const uint32_t step = 20; + if (bigger) { - set_height (height + 4); + set_height (height + step); } else { - if (height > 4) { - set_height (std::max (height - 4, hSmall)); + if (height > step) { + set_height (std::max (height - step, hSmall)); } else if (height != hSmall) { set_height (hSmall); } @@ -376,13 +377,15 @@ void TimeAxisView::set_height(uint32_t h) { height = h; + controls_frame.set_size_request (-1, current_height() + ((order == 0) ? 1 : 0)); - //cerr << "TimeAxisView::set_height_pixels() called h = " << h << endl;//DEBUG + if (canvas_item_visible (selection_group)) { /* resize the selection rect */ show_selection (editor.get_selection().time); } - + + reshow_feature_lines (); } bool @@ -534,7 +537,6 @@ TimeAxisView::conditionally_add_to_selection () Selection& s (editor.get_selection()); if (!s.selected (this)) { - cerr << "set selected track\n"; editor.set_selected_track (*this, Selection::Set); } } @@ -602,6 +604,8 @@ TimeAxisView::set_selected (bool yn) (*i)->set_selected (false); } } + + resizer.queue_draw (); } void @@ -921,11 +925,28 @@ TimeAxisView::get_parent_with_state () return parent->get_parent_with_state (); } -void + +XMLNode& +TimeAxisView::get_state () +{ + XMLNode* node = new XMLNode ("TAV-" + name()); + char buf[32]; + + snprintf (buf, sizeof(buf), "%u", height); + node->add_property ("height", buf); + node->add_property ("marked_for_display", (_marked_for_display ? "1" : "0")); + return *node; +} + +int TimeAxisView::set_state (const XMLNode& node) { const XMLProperty *prop; + if ((prop = node.property ("marked_for_display")) != 0) { + _marked_for_display = (prop->value() == "1"); + } + if ((prop = node.property ("track_height")) != 0) { if (prop->value() == "largest") { @@ -947,12 +968,14 @@ TimeAxisView::set_state (const XMLNode& node) } else if ((prop = node.property ("height")) != 0) { - uint32_t h = atoi (prop->value()); - set_height (h); - + set_height (atoi (prop->value())); + } else { + set_height (hNormal); } + + return 0; } void @@ -1144,8 +1167,6 @@ TimeAxisView::reshow_feature_lines () while (feature_lines.size()< analysis_features.size()) { ArdourCanvas::SimpleLine* l = new ArdourCanvas::SimpleLine (*canvas_display); l->property_color_rgba() = (guint) ARDOUR_UI::config()->canvasvar_ZeroLine.get(); - l->property_y1() = 0; - l->property_y2() = current_height(); feature_lines.push_back (l); } @@ -1161,6 +1182,8 @@ TimeAxisView::reshow_feature_lines () for (i = analysis_features.begin(), l = feature_lines.begin(); i != analysis_features.end() && l != feature_lines.end(); ++i, ++l) { (*l)->property_x1() = editor.frame_to_pixel (*i); (*l)->property_x2() = editor.frame_to_pixel (*i); + (*l)->property_y1() = 0; + (*l)->property_y2() = current_height(); (*l)->show (); } } @@ -1170,6 +1193,7 @@ TimeAxisView::resizer_button_press (GdkEventButton* event) { resize_drag_start = event->y_root; resize_idle_target = current_height(); + editor.start_resize_line_ops (); return true; } @@ -1177,21 +1201,14 @@ bool TimeAxisView::resizer_button_release (GdkEventButton* ev) { resize_drag_start = -1; + editor.end_resize_line_ops (); return true; } -static gboolean -_idle_resizer (gpointer arg) -{ - return ((TimeAxisView*)arg)->idle_resize (); -} - -bool -TimeAxisView::idle_resize () +void +TimeAxisView::idle_resize (uint32_t h) { - set_height (resize_idle_target); - resize_idle_id = -1; - return false; + set_height (h); } bool @@ -1204,26 +1221,51 @@ TimeAxisView::resizer_motion (GdkEventMotion* ev) int32_t delta = (int32_t) floor (resize_drag_start - ev->y_root); resize_idle_target = std::max (resize_idle_target - delta, (int) hSmall); - - if (resize_idle_id < 0) { - resize_idle_id = g_idle_add (_idle_resizer, this); - } - + editor.add_to_idle_resize (this, resize_idle_target); + resize_drag_start = ev->y_root; return true; } - bool TimeAxisView::resizer_expose (GdkEventExpose* event) { - resizer.get_window()->draw_rectangle (resizer.get_style()->get_fg_gc(STATE_ACTIVE), - true, - event->area.x, - event->area.y, - event->area.width, - event->area.height); + int w, h, x, y, d; + Glib::RefPtr win (resizer.get_window()); + Glib::RefPtr dark (resizer.get_style()->get_fg_gc (STATE_NORMAL)); + Glib::RefPtr light (resizer.get_style()->get_bg_gc (STATE_NORMAL)); + + win->draw_rectangle (controls_ebox.get_style()->get_bg_gc(STATE_NORMAL), + true, + event->area.x, + event->area.y, + event->area.width, + event->area.height); + + win->get_geometry (x, y, w, h, d); + + /* handle/line #1 */ + + win->draw_line (dark, 0, 0, w - 2, 0); + win->draw_point (dark, 0, 1); + win->draw_line (light, 1, 1, w - 1, 1); + win->draw_point (light, w - 1, 0); + + /* handle/line #2 */ + + win->draw_line (dark, 0, 4, w - 2, 4); + win->draw_point (dark, 0, 5); + win->draw_line (light, 1, 5, w - 1, 5); + win->draw_point (light, w - 1, 4); + + /* handle/line #3 */ + + win->draw_line (dark, 0, 8, w - 2, 8); + win->draw_point (dark, 0, 9); + win->draw_line (light, 1, 9, w - 1, 9); + win->draw_point (light, w - 1, 8); + return true; }