LabelGUI::~LabelGUI()
{
+ if( timebar->drag_label == this )
+ timebar->drag_label = 0;
}
int LabelGUI::get_y(MWindow *mwindow, TimeBar *timebar)
int LabelGUI::button_press_event()
{
- int result = 0;
+ int result = test_drag_label(1);
if( this->is_event_win() && get_buttonpress() == 3 ) {
if( label ) {
return result;
}
+int LabelGUI::button_release_event()
+{
+ int ret = BC_Toggle::button_release_event();
+ test_drag_label(0);
+ return ret;
+}
+
+int LabelGUI::test_drag_label(int press)
+{
+ if( is_event_win() && get_buttonpress() == 1 ) {
+ switch( timebar->current_operation ) {
+ case TIMEBAR_NONE:
+ if( press && get_value() ) {
+ timebar->current_operation = TIMEBAR_DRAG_LABEL;
+ timebar->drag_label = this;
+ set_cursor(HSEPARATE_CURSOR, 0, 0);
+ mwindow->undo->update_undo_before(_("drag label"), this);
+ return 1;
+ }
+ break;
+ case TIMEBAR_DRAG_LABEL:
+ if( !press ) {
+ timebar->current_operation = TIMEBAR_NONE;
+ set_cursor(ARROW_CURSOR, 0, 0);
+ mwindow->undo->update_undo_after(_("drag label"), LOAD_TIMEBAR);
+ }
+ break;
+ }
+ }
+ return 0;
+}
+
int LabelGUI::handle_event()
{
timebar->select_label(position);
//printf("TimeBar::TimeBar %d %d %d %d\n", x, y, w, h);
this->gui = gui;
this->mwindow = mwindow;
+ this->drag_label = 0;
label_edit = new LabelEdit(mwindow, mwindow->awindow, 0);
pane = 0;
highlighted = 0;
}
else
if( out_point ) out_point->update(0);
+
+ draw_inout_highlight();
+}
+
+void TimeBar::draw_inout_highlight()
+{
+ EDL *edl = get_edl();
+ if( !edl->local_session->inpoint_valid() ) return;
+ if( !edl->local_session->outpoint_valid() ) return;
+ double in_position = edl->local_session->get_inpoint();
+ double out_position = edl->local_session->get_outpoint();
+ if( in_position >= out_position ) return;
+ int in_x = position_to_pixel(in_position);
+ int out_x = position_to_pixel(out_position);
+ CLAMP(in_x, 0, get_w());
+ CLAMP(out_x, 0, get_w());
+ set_color(mwindow->theme->inout_highlight_color);
+ int lw = 5;
+ set_line_width(lw);
+ set_inverse();
+ draw_line(in_x, get_h()-2*lw, out_x, get_h()-2*lw);
+ set_opaque();
+ set_line_width(1);
}
void TimeBar::update_points()
//printf("TimeBar::cursor_motion_event %d %p %d\n", __LINE__, this, current_operation);
switch( current_operation )
{
- case TIMEBAR_DRAG:
- {
- update_cursor();
- handle_mwindow_drag();
- result = 1;
-//printf("TimeBar::cursor_motion_event %d %d\n", __LINE__, current_operation);
- break;
- }
-
-
case TIMEBAR_DRAG_LEFT:
case TIMEBAR_DRAG_RIGHT:
case TIMEBAR_DRAG_CENTER:
result = move_preview(redraw);
break;
+ case TIMEBAR_DRAG_LABEL:
+ if( drag_label ) {
+ int pixel = get_relative_cursor_x();
+ double position = pixel_to_position(pixel);
+ if( drag_label->label )
+ drag_label->label->position = position;
+ else if( drag_label == in_point ) {
+ EDL *edl = get_edl();
+ edl->local_session->set_inpoint(position);
+ }
+ else if( drag_label == out_point ) {
+ EDL *edl = get_edl();
+ edl->local_session->set_outpoint(position);
+ }
+ }
+ highlighted = 1;
+ redraw = 1; // fall thru
+
+ case TIMEBAR_DRAG:
+ update_cursor();
+ handle_mwindow_drag();
+ result = 1;
+//printf("TimeBar::cursor_motion_event %d %d\n", __LINE__, current_operation);
+ break;
+
default:
if( cursor_above() ) {
highlighted = 1;