label edit deadlock, build openexr cfg option, code cleanup
[goodguy/history.git] / cinelerra-5.1 / cinelerra / timebar.C
index b295c32390ddbc8996cc3563138093f2853833a5..ed0011cd71f102a52d9b4b45f81436533f1a1536 100644 (file)
 #include "zoombar.h"
 
 
-LabelGUI::LabelGUI(MWindow *mwindow,
-       TimeBar *timebar,
-       int64_t pixel,
-       int y,
-       double position,
-       VFrame **data)
- : BC_Toggle(translate_pixel(mwindow, pixel),
-               y,
-               data ? data : mwindow->theme->label_toggle,
-               0)
+LabelGUI::LabelGUI(MWindow *mwindow, TimeBar *timebar,
+       int64_t pixel, int y,
+       double position, VFrame **data)
+ : BC_Toggle(translate_pixel(mwindow, pixel), y,
+               data ? data : mwindow->theme->label_toggle, 0)
 {
        this->mwindow = mwindow;
        this->timebar = timebar;
@@ -99,14 +94,17 @@ int LabelGUI::button_press_event()
 {
        int result = 0;
 
-       if (this->is_event_win() && get_buttonpress() == 3) {
-               if (label)
-                       timebar->label_edit->start(label);
+       if( this->is_event_win() && get_buttonpress() == 3 ) {
+               if( label ) {
+                       int cur_x, cur_y;
+                       get_abs_cursor_xy(cur_x, cur_y, 0);
+                       timebar->label_edit->start(label, cur_x, cur_y);
+               }
                result = 1;
        } else {
                result = BC_Toggle::button_press_event();
        }
-       if (label)
+       if( label )
                set_tooltip(this->label->textstr);
        return result;
 }
@@ -118,16 +116,11 @@ int LabelGUI::handle_event()
 }
 
 
-InPointGUI::InPointGUI(MWindow *mwindow,
-       TimeBar *timebar,
-       int64_t pixel,
-       double position)
- : LabelGUI(mwindow,
-       timebar,
-       pixel,
-       get_y(mwindow, timebar),
-       position,
-       mwindow->theme->in_point)
+InPointGUI::InPointGUI(MWindow *mwindow, TimeBar *timebar,
+       int64_t pixel, double position)
+ : LabelGUI(mwindow, timebar,
+       pixel, get_y(mwindow, timebar),
+       position, mwindow->theme->in_point)
 {
 //printf("InPointGUI::InPointGUI %d %d\n", pixel, get_y(mwindow, timebar));
 }
@@ -143,16 +136,11 @@ int InPointGUI::get_y(MWindow *mwindow, TimeBar *timebar)
 }
 
 
-OutPointGUI::OutPointGUI(MWindow *mwindow,
-       TimeBar *timebar,
-       int64_t pixel,
-       double position)
- : LabelGUI(mwindow,
-       timebar,
-       pixel,
-       get_y(mwindow, timebar),
-       position,
-       mwindow->theme->out_point)
+OutPointGUI::OutPointGUI(MWindow *mwindow, TimeBar *timebar,
+       int64_t pixel, double position)
+ : LabelGUI(mwindow, timebar,
+       pixel, get_y(mwindow, timebar),
+       position, mwindow->theme->out_point)
 {
 //printf("OutPointGUI::OutPointGUI %d %d\n", pixel, get_y(mwindow, timebar));
 }
@@ -166,10 +154,8 @@ int OutPointGUI::get_y(MWindow *mwindow, TimeBar *timebar)
 }
 
 
-PresentationGUI::PresentationGUI(MWindow *mwindow,
-       TimeBar *timebar,
-       int64_t pixel,
-       double position)
+PresentationGUI::PresentationGUI(MWindow *mwindow, TimeBar *timebar,
+       int64_t pixel, double position)
  : LabelGUI(mwindow, timebar, pixel, get_y(mwindow, timebar), position)
 {
 }
@@ -177,12 +163,8 @@ PresentationGUI::~PresentationGUI()
 {
 }
 
-TimeBar::TimeBar(MWindow *mwindow,
-       BC_WindowBase *gui,
-       int x,
-       int y,
-       int w,
-       int h)
+TimeBar::TimeBar(MWindow *mwindow, BC_WindowBase *gui,
+       int x, int y, int w, int h)
  : BC_SubWindow(x, y, w, h)
 {
 //printf("TimeBar::TimeBar %d %d %d %d\n", x, y, w, h);
@@ -195,9 +177,9 @@ TimeBar::TimeBar(MWindow *mwindow,
 
 TimeBar::~TimeBar()
 {
-       if(in_point) delete in_point;
-       if(out_point) delete out_point;
-       if(label_edit) delete label_edit;
+       delete in_point;
+       delete out_point;
+       delete label_edit;
        labels.remove_all_objects();
        presentations.remove_all_objects();
 }
@@ -222,8 +204,7 @@ int64_t TimeBar::position_to_pixel(double position)
 
 double TimeBar::pixel_to_position(int pixel)
 {
-       if(pane)
-       {
+       if( pane ) {
                pixel += mwindow->edl->local_session->view_start[pane->number];
        }
 
@@ -237,19 +218,12 @@ void TimeBar::update_labels()
        int output = 0;
        EDL *edl = get_edl();
 
-       if(edl)
-       {
-               for(Label *current = edl->labels->first;
-                       current;
-                       current = NEXT)
-               {
+       if( edl ) {
+               for( Label *current=edl->labels->first; current; current=NEXT ) {
                        int64_t pixel = position_to_pixel(current->position);
-
-                       if(pixel >= 0 && pixel < get_w())
-                       {
+                       if( pixel >= 0 && pixel < get_w()  ) {
 // Create new label
-                               if(output >= labels.total)
-                               {
+                               if( output >= labels.total ) {
                                        LabelGUI *new_label;
                                        add_subwindow(new_label =
                                                new LabelGUI(mwindow,
@@ -266,13 +240,11 @@ void TimeBar::update_labels()
 // Reposition old label
                                {
                                        LabelGUI *gui = labels.values[output];
-                                       if(gui->pixel != pixel)
-                                       {
+                                       if( gui->pixel != pixel ) {
                                                gui->pixel = pixel;
                                                gui->reposition(0);
                                        }
-                                       else
-                                       {
+                                       else {
                                                gui->draw_face(1,0);
                                        }
 
@@ -281,11 +253,11 @@ void TimeBar::update_labels()
                                        labels.values[output]->label = current;
                                }
 
-                               if(edl->local_session->get_selectionstart(1) <= current->position &&
-                                       edl->local_session->get_selectionend(1) >= current->position)
+                               if( edl->local_session->get_selectionstart(1) <= current->position &&
+                                   edl->local_session->get_selectionend(1) >= current->position )
                                        labels.values[output]->update(1);
                                else
-                               if(labels.values[output]->get_value())
+                               if( labels.values[output]->get_value() )
                                        labels.values[output]->update(0);
 
                                output++;
@@ -305,39 +277,35 @@ void TimeBar::update_labels()
 
 void TimeBar::update_highlights()
 {
-       for(int i = 0; i < labels.total; i++)
-       {
+       for( int i = 0; i < labels.total; i++ ) {
                LabelGUI *label = labels.values[i];
-               if(mwindow->edl->equivalent(label->position,
+               if( mwindow->edl->equivalent(label->position,
                                mwindow->edl->local_session->get_selectionstart(1)) ||
-                       mwindow->edl->equivalent(label->position,
-                               mwindow->edl->local_session->get_selectionend(1)))
-               {
-                       if(!label->get_value()) label->update(1);
+                   mwindow->edl->equivalent(label->position,
+                               mwindow->edl->local_session->get_selectionend(1)) ) {
+                       if( !label->get_value() ) label->update(1);
                }
                else
-                       if(label->get_value()) label->update(0);
+                       if( label->get_value() ) label->update(0);
        }
 
-       if(mwindow->edl->equivalent(mwindow->edl->local_session->get_inpoint(),
+       if( mwindow->edl->equivalent(mwindow->edl->local_session->get_inpoint(),
                        mwindow->edl->local_session->get_selectionstart(1)) ||
                mwindow->edl->equivalent(mwindow->edl->local_session->get_inpoint(),
-                       mwindow->edl->local_session->get_selectionend(1)))
-       {
-               if(in_point) in_point->update(1);
+                       mwindow->edl->local_session->get_selectionend(1)) ) {
+               if( in_point ) in_point->update(1);
        }
        else
-               if(in_point) in_point->update(0);
+               if( in_point ) in_point->update(0);
 
-       if(mwindow->edl->equivalent(mwindow->edl->local_session->get_outpoint(),
+       if( mwindow->edl->equivalent(mwindow->edl->local_session->get_outpoint(),
                        mwindow->edl->local_session->get_selectionstart(1)) ||
                mwindow->edl->equivalent(mwindow->edl->local_session->get_outpoint(),
-                       mwindow->edl->local_session->get_selectionend(1)))
-       {
-               if(out_point) out_point->update(1);
+                       mwindow->edl->local_session->get_selectionend(1)) ) {
+               if( out_point ) out_point->update(1);
        }
        else
-               if(out_point) out_point->update(0);
+               if( out_point ) out_point->update(0);
 }
 
 void TimeBar::update_points()
@@ -346,34 +314,27 @@ void TimeBar::update_points()
        int64_t pixel = !edl ? 0 :
                position_to_pixel(edl->local_session->get_inpoint());
 
-       if(in_point)
-       {
-               if(edl &&
-                       edl->local_session->inpoint_valid() &&
-                       pixel >= 0 && pixel < get_w())
-               {
-                       if(!EQUIV(edl->local_session->get_inpoint(), in_point->position) ||
-                               in_point->pixel != pixel)
-                       {
+       if( in_point ) {
+               if( edl && edl->local_session->inpoint_valid() &&
+                   pixel >= 0 && pixel < get_w() ) {
+                       if( !EQUIV(edl->local_session->get_inpoint(), in_point->position) ||
+                           in_point->pixel != pixel ) {
                                in_point->pixel = pixel;
                                in_point->position = edl->local_session->get_inpoint();
                                in_point->reposition(0);
                        }
-                       else
-                       {
+                       else {
                                in_point->draw_face(1, 0);
                        }
                }
-               else
-               {
+               else {
                        delete in_point;
                        in_point = 0;
                }
        }
        else
-       if(edl && edl->local_session->inpoint_valid() &&
-               pixel >= 0 && pixel < get_w())
-       {
+       if( edl && edl->local_session->inpoint_valid() &&
+           pixel >= 0 && pixel < get_w() ) {
                add_subwindow(in_point = new InPointGUI(mwindow,
                        this, pixel, edl->local_session->get_inpoint()));
                in_point->set_cursor(ARROW_CURSOR, 0, 0);
@@ -382,34 +343,27 @@ void TimeBar::update_points()
        pixel = !edl ? 0 :
                 position_to_pixel(edl->local_session->get_outpoint());
 
-       if(out_point)
-       {
+       if( out_point ) {
                if( edl && edl->local_session->outpoint_valid() &&
-                       pixel >= 0 && pixel < get_w())
-               {
-                       if(!EQUIV(edl->local_session->get_outpoint(), out_point->position) ||
-                               out_point->pixel != pixel)
-                       {
+                   pixel >= 0 && pixel < get_w()) {
+                       if( !EQUIV(edl->local_session->get_outpoint(), out_point->position) ||
+                           out_point->pixel != pixel ) {
                                out_point->pixel = pixel;
                                out_point->position = edl->local_session->get_outpoint();
                                out_point->reposition(0);
                        }
-                       else
-                       {
+                       else {
                                out_point->draw_face(1, 0);
                        }
                }
-               else
-               {
+               else {
                        delete out_point;
                        out_point = 0;
                }
        }
        else
-       if(edl &&
-               edl->local_session->outpoint_valid() &&
-               pixel >= 0 && pixel < get_w())
-       {
+       if( edl && edl->local_session->outpoint_valid() &&
+           pixel >= 0 && pixel < get_w() ) {
                add_subwindow(out_point = new OutPointGUI(mwindow,
                        this, pixel, edl->local_session->get_outpoint()));
                out_point->set_cursor(ARROW_CURSOR, 0, 0);
@@ -434,10 +388,8 @@ void TimeBar::update(int flush)
        int64_t pixel = -1;
        int x = get_relative_cursor_x();
 // Draw highlight position
-       if(edl &&
-               (highlighted || current_operation == TIMEBAR_DRAG) &&
-               x >= 0 && x < get_w())
-       {
+       if( edl && (highlighted || current_operation == TIMEBAR_DRAG) &&
+           x >= 0 && x < get_w() ) {
 //printf("TimeBar::update %d %d\n", __LINE__, x);
                double position = pixel_to_position(x);
 
@@ -446,15 +398,13 @@ void TimeBar::update(int flush)
                update_clock(position);
        }
 
-       if(pixel < 0)
-       {
+       if( pixel < 0 ) {
                double position = test_highlight();
-               if(position >= 0) pixel = position_to_pixel(position);
+               if( position >= 0 ) pixel = position_to_pixel(position);
        }
 
 
-       if(pixel >= 0 && pixel < get_w())
-       {
+       if( pixel >= 0 && pixel < get_w() ) {
                set_color(mwindow->theme->timebar_cursor_color);
                set_line_dashes(1);
 //printf("TimeBar::update %d pane=%d pixel=%jd\n", __LINE__, pane->number, pixel);
@@ -463,8 +413,7 @@ void TimeBar::update(int flush)
        }
 
 
-       if(edl)
-       {
+       if( edl ) {
                double playback_start = edl->local_session->playback_start;
                if( playback_start >= 0 ) {
                        int64_t pixel = position_to_pixel(playback_start);
@@ -526,8 +475,7 @@ void TimeBar::draw_range()
 
 
 //printf("TimeBar::draw_range %d %p\n", __LINE__, get_edl());
-       if(has_preview() && get_edl())
-       {
+       if( has_preview() && get_edl() ) {
                int x1, x2;
                get_preview_pixels(x1, x2);
 
@@ -542,8 +490,7 @@ void TimeBar::draw_range()
 
 
                EDL *edl = get_edl();
-               if(edl)
-               {
+               if( edl ) {
                        int64_t pixel = position_to_pixel(
                                edl->local_session->get_selectionstart(1));
 // Draw insertion point position if this timebar belongs to a window which
@@ -571,21 +518,18 @@ double TimeBar::get_edl_length()
 {
        edl_length = 0;
 
-       if(get_edl())
-       {
+       if( get_edl() ) {
 //printf("TimeBar::get_edl_length 1 %f\n", get_edl()->tracks->total_playable_length());
                edl_length = get_edl()->tracks->total_playable_length();
        }
 
 //printf("TimeBar::get_edl_length 2\n");
-       if(!EQUIV(edl_length, 0))
-       {
+       if( !EQUIV(edl_length, 0) ) {
 //printf("TimeBar::get_edl_length 3\n");
                time_per_pixel = edl_length / get_w();
 //printf("TimeBar::get_edl_length 4\n");
        }
-       else
-       {
+       else {
                time_per_pixel = 0;
        }
 //printf("TimeBar::get_edl_length 5\n");
@@ -600,21 +544,18 @@ int TimeBar::get_preview_pixels(int &x1, int &x2)
 
        get_edl_length();
 
-       if(get_edl())
-       {
-               if(!EQUIV(edl_length, 0))
-               {
-                       if(get_edl()->local_session->preview_end <= 0 ||
-                               get_edl()->local_session->preview_end > edl_length)
+       if( get_edl() ) {
+               if( !EQUIV(edl_length, 0) ) {
+                       if( get_edl()->local_session->preview_end <= 0 ||
+                           get_edl()->local_session->preview_end > edl_length )
                                get_edl()->local_session->preview_end = edl_length;
-                       if(get_edl()->local_session->preview_start >
-                               get_edl()->local_session->preview_end)
+                       if( get_edl()->local_session->preview_start >
+                               get_edl()->local_session->preview_end )
                                get_edl()->local_session->preview_start = 0;
                        x1 = (int)(get_edl()->local_session->preview_start / time_per_pixel);
                        x2 = (int)(get_edl()->local_session->preview_end / time_per_pixel);
                }
-               else
-               {
+               else {
                        x1 = 0;
                        x2 = get_w();
                }
@@ -633,59 +574,52 @@ int TimeBar::test_preview(int buttonpress)
        int result = 0;
 
 
-       if(get_edl() && cursor_inside() && buttonpress >= 0)
-       {
+       if( get_edl() && cursor_inside() && buttonpress >= 0 ) {
                int x1, x2, x = get_relative_cursor_x();
                get_preview_pixels(x1, x2);
 //printf("TimeBar::test_preview %d %d %d\n", x1, x2, x);
 // Inside left handle
-               if(x >= x1 - HANDLE_W && x < x1 + HANDLE_W &&
+               if( x >= x1 - HANDLE_W && x < x1 + HANDLE_W &&
 // Ignore left handle if both handles are up against the left side
-                       x2 > HANDLE_W)
-               {
-                       if(buttonpress)
-                       {
+                   x2 > HANDLE_W ) {
+                       if( buttonpress ) {
                                current_operation = TIMEBAR_DRAG_LEFT;
                                start_position = get_edl()->local_session->preview_start;
                                start_cursor_x = x;
                        }
-                       else if(get_cursor() != LEFT_CURSOR)
+                       else if( get_cursor() != LEFT_CURSOR )
                                set_cursor(LEFT_CURSOR, 0, 1);
                        result = 1;
                }
 // Inside right handle
-               else if(x >= x2 - HANDLE_W && x < x2 + HANDLE_W &&
+               else if( x >= x2 - HANDLE_W && x < x2 + HANDLE_W &&
 // Ignore right handle if both handles are up against the right side
-                       x1 < get_w() - HANDLE_W)
-               {
-                       if(buttonpress)
-                       {
+                   x1 < get_w() - HANDLE_W ) {
+                       if( buttonpress ) {
                                current_operation = TIMEBAR_DRAG_RIGHT;
                                start_position = get_edl()->local_session->preview_end;
                                start_cursor_x = x;
                        }
-                       else if(get_cursor() != RIGHT_CURSOR)
+                       else if( get_cursor() != RIGHT_CURSOR )
                                set_cursor(RIGHT_CURSOR, 0, 1);
                        result = 1;
                }
 // Inside preview
-               else if(get_button_down() && get_buttonpress() == 3 &&
-                       x >= x1 && x < x2)
-               {
-                       if(buttonpress)
-                       {
+               else if( get_button_down() && get_buttonpress() == 3 &&
+                   x >= x1 && x < x2 ) {
+                       if( buttonpress ) {
                                current_operation = TIMEBAR_DRAG_CENTER;
                                starting_start_position = get_edl()->local_session->preview_start;
                                starting_end_position = get_edl()->local_session->preview_end;
                                start_cursor_x = x;
                        }
-                       if(get_cursor() != HSEPARATE_CURSOR)
+                       if( get_cursor() != HSEPARATE_CURSOR )
                                set_cursor(HSEPARATE_CURSOR, 0, 1);
                        result = 1;
                }
        }
 
-       if(!result && get_cursor() != ARROW_CURSOR)
+       if( !result && get_cursor() != ARROW_CURSOR )
                set_cursor(ARROW_CURSOR, 0, 1);
 
 
@@ -696,8 +630,7 @@ int TimeBar::move_preview(int &redraw)
 {
        int result = 0, x = get_relative_cursor_x();
 
-       if(current_operation == TIMEBAR_DRAG_LEFT)
-       {
+       if( current_operation == TIMEBAR_DRAG_LEFT ) {
                get_edl()->local_session->preview_start =
                        start_position + time_per_pixel * (x - start_cursor_x);
                CLAMP(get_edl()->local_session->preview_start,
@@ -706,8 +639,7 @@ int TimeBar::move_preview(int &redraw)
                result = 1;
        }
        else
-       if(current_operation == TIMEBAR_DRAG_RIGHT)
-       {
+       if( current_operation == TIMEBAR_DRAG_RIGHT ) {
                get_edl()->local_session->preview_end =
                        start_position + time_per_pixel * (x - start_cursor_x);
                CLAMP(get_edl()->local_session->preview_end,
@@ -716,19 +648,16 @@ int TimeBar::move_preview(int &redraw)
                result = 1;
        }
        else
-       if(current_operation == TIMEBAR_DRAG_CENTER)
-       {
+       if( current_operation == TIMEBAR_DRAG_CENTER ) {
                double dt = time_per_pixel * (x - start_cursor_x);
                get_edl()->local_session->preview_start = starting_start_position + dt;
                get_edl()->local_session->preview_end = starting_end_position + dt;
-               if(get_edl()->local_session->preview_start < 0)
-               {
+               if( get_edl()->local_session->preview_start < 0 ) {
                        get_edl()->local_session->preview_end -= get_edl()->local_session->preview_start;
                        get_edl()->local_session->preview_start = 0;
                }
                else
-               if(get_edl()->local_session->preview_end > edl_length)
-               {
+               if( get_edl()->local_session->preview_end > edl_length ) {
                        get_edl()->local_session->preview_start -= get_edl()->local_session->preview_end - edl_length;
                        get_edl()->local_session->preview_end = edl_length;
                }
@@ -737,8 +666,7 @@ int TimeBar::move_preview(int &redraw)
 
 //printf("TimeBar::move_preview %d %d\n", __LINE__, current_operation);
 
-       if(result)
-       {
+       if( result ) {
                update_preview();
                redraw = 1;
        }
@@ -763,36 +691,30 @@ void TimeBar::stop_playback()
 int TimeBar::button_press_event()
 {
        int result = 0;
-       if(is_event_win() && cursor_above())
-       {
-               if(has_preview() && get_buttonpress() == 3)
-               {
+       if( is_event_win() && cursor_above() ) {
+               if( has_preview() && get_buttonpress() == 3 ) {
                        result = test_preview(1);
                }
 // Change time format
-               else if(ctrl_down())
-               {
-                       if(get_buttonpress() == 1)
+               else if( ctrl_down() ) {
+                       if( get_buttonpress() == 1 )
                                mwindow->next_time_format();
                        else
-                       if(get_buttonpress() == 2)
+                       if( get_buttonpress() == 2 )
                                mwindow->prev_time_format();
                        result = 1;
                }
-               else if(get_buttonpress() == 1)
-               {
+               else if( get_buttonpress() == 1 ) {
                        stop_playback();
 
 // Select region between two labels
-                       if(get_double_click())
-                       {
+                       if( get_double_click() ) {
                                int x = get_relative_cursor_x();
                                double position = pixel_to_position(x);
 // Test labels
                                select_region(position);
                        }
-                       else
-                       {
+                       else {
 
 // Reposition highlight cursor
                                update_cursor();
@@ -816,7 +738,7 @@ int TimeBar::cursor_motion_event()
        int redraw = 0;
 
 //printf("TimeBar::cursor_motion_event %d %p %d\n", __LINE__, this, current_operation);
-       switch(current_operation)
+       switch( current_operation )
        {
                case TIMEBAR_DRAG:
                {
@@ -831,19 +753,18 @@ int TimeBar::cursor_motion_event()
                case TIMEBAR_DRAG_LEFT:
                case TIMEBAR_DRAG_RIGHT:
                case TIMEBAR_DRAG_CENTER:
-                       if(has_preview())
+                       if( has_preview() )
                                result = move_preview(redraw);
                        break;
 
                default:
-                       if(cursor_above())
-                       {
+                       if( cursor_above() ) {
                                highlighted = 1;
                                redraw = 1;
                        }
 
 //printf("TimeBar::cursor_motion_event 20\n");
-                       if(has_preview())
+                       if( has_preview() )
                                result = test_preview(0);
 //printf("TimeBar::cursor_motion_event 30\n");
                        break;
@@ -851,8 +772,7 @@ int TimeBar::cursor_motion_event()
 
 
 //printf("TimeBar::cursor_motion_event %d %d\n", __LINE__, current_operation);
-       if(redraw)
-       {
+       if( redraw ) {
                update(1);
        }
 //printf("TimeBar::cursor_motion_event %d %p %d\n", __LINE__, this, current_operation);
@@ -862,8 +782,7 @@ int TimeBar::cursor_motion_event()
 
 int TimeBar::cursor_leave_event()
 {
-       if(highlighted)
-       {
+       if( highlighted ) {
                highlighted = 0;
                update(1);
        }
@@ -875,7 +794,7 @@ int TimeBar::button_release_event()
 //printf("TimeBar::button_release_event %d %d\n", __LINE__, current_operation);
        int result = 0;
        int need_redraw = 0;
-       switch(current_operation)
+       switch( current_operation )
        {
                case TIMEBAR_DRAG:
                        mwindow->gui->get_focused_pane()->canvas->stop_dragscroll();
@@ -885,16 +804,14 @@ int TimeBar::button_release_event()
                        break;
 
                default:
-                       if(current_operation != TIMEBAR_NONE)
-                       {
+                       if( current_operation != TIMEBAR_NONE ) {
                                current_operation = TIMEBAR_NONE;
                                result = 1;
                        }
                        break;
        }
 
-       if((!cursor_above() && highlighted) || need_redraw)
-       {
+       if( (!cursor_above() && highlighted) || need_redraw ) {
                highlighted = 0;
                update(1);
        }
@@ -914,40 +831,34 @@ void TimeBar::handle_mwindow_drag()
 int TimeBar::select_region(double position)
 {
        Label *start = 0, *end = 0, *current;
-       for(current = mwindow->edl->labels->first; current; current = NEXT)
-       {
-               if(current->position > position)
-               {
+       for( current = mwindow->edl->labels->first; current; current = NEXT ) {
+               if( current->position > position ) {
                        end = current;
                        break;
                }
        }
 
-       for(current = mwindow->edl->labels->last ; current; current = PREVIOUS)
-       {
-               if(current->position <= position)
-               {
+       for( current = mwindow->edl->labels->last ; current; current = PREVIOUS ) {
+               if( current->position <= position ) {
                        start = current;
                        break;
                }
        }
 
 // Select region
-       if(end != start)
-       {
-               if(!start)
+       if( end != start ) {
+               if( !start )
                        mwindow->edl->local_session->set_selectionstart(0);
                else
                        mwindow->edl->local_session->set_selectionstart(start->position);
 
-               if(!end)
+               if( !end )
                        mwindow->edl->local_session->set_selectionend(mwindow->edl->tracks->total_length());
                else
                        mwindow->edl->local_session->set_selectionend(end->position);
        }
        else
-       if(end || start)
-       {
+       if( end || start ) {
                mwindow->edl->local_session->set_selectionstart(start->position);
                mwindow->edl->local_session->set_selectionend(start->position);
        }