From 93cd60723f8816b0c787b1ce9fe7aa6067e0e749 Mon Sep 17 00:00:00 2001 From: Good Guy Date: Thu, 3 Jan 2019 18:53:51 -0700 Subject: [PATCH] fix delete_edit optimize segv, add dump submenu/dump_undo, add dbl edge drag/drop + highlight --- cinelerra-5.1/blds/cinelerra.spec | 20 ++-- cinelerra-5.1/cinelerra/edl.C | 1 - cinelerra-5.1/cinelerra/mainmenu.C | 53 ++++++++-- cinelerra-5.1/cinelerra/mainmenu.h | 54 +++++----- cinelerra-5.1/cinelerra/mainmenu.inc | 95 ++++++++++++++++++ cinelerra-5.1/cinelerra/mwindow.h | 2 +- cinelerra-5.1/cinelerra/mwindowedit.C | 7 +- cinelerra-5.1/cinelerra/trackcanvas.C | 139 +++++++++++++++----------- cinelerra-5.1/cinelerra/trackcanvas.h | 4 + cinelerra-5.1/guicast/bccolors.h | 49 +-------- cinelerra-5.1/guicast/colors.h | 2 +- 11 files changed, 273 insertions(+), 153 deletions(-) diff --git a/cinelerra-5.1/blds/cinelerra.spec b/cinelerra-5.1/blds/cinelerra.spec index b8367ead..edc24815 100644 --- a/cinelerra-5.1/blds/cinelerra.spec +++ b/cinelerra-5.1/blds/cinelerra.spec @@ -19,8 +19,13 @@ URL: https://cinelerra-gg.org/ Source0: %{cin}-%{version}-%{ver}.tar.bz2 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root -%if 0%{?fedora}%{?centos} +%if 0%{?fedora} %define rhat 1 +%define distro fedora +%endif +%if 0%{?centos} +%define rhat 1 +%define distro centos %endif BuildRequires: autoconf @@ -79,18 +84,20 @@ Multimedia editing and construction %clean %{__rm} -rf %{buildroot} +%if 0%{?rhat} %post if [ -d /etc/yum.repos.d ]; then echo > /etc/yum.repos.d/cin.repo "[cin]" - echo >> /etc/yum.repos.d/cin.repo name=cinelerra-gg - echo >> /etc/yum.repos.d/cin.repo baseurl=https://cinelerra-gg.org/download/pkgs/fedora$releasever/ - echo >> /etc/yum.repos.d/cin.repo enabled=1 - echo >> /etc/yum.repos.d/cin.repo gpgcheck=0 + echo >> /etc/yum.repos.d/cin.repo "name=cinelerra-gg" + echo >> /etc/yum.repos.d/cin.repo "baseurl=https://cinelerra-gg.org/download/pkgs/%{distro}\$releasever/" + echo >> /etc/yum.repos.d/cin.repo "enabled=1" + echo >> /etc/yum.repos.d/cin.repo "gpgcheck=0" fi %postun if [ -d /etc/yum.repos.d ]; then rm -f /etc/yum.repos.d/cin.repo fi +%endif %files %defattr(-, root, root, -) @@ -98,8 +105,5 @@ fi %{_libdir}/* %{_datadir}/* -%exclude /usr/src/debug -%exclude /usr/lib/debug - %changelog diff --git a/cinelerra-5.1/cinelerra/edl.C b/cinelerra-5.1/cinelerra/edl.C index 6f2b7e58..f5a1a9cc 100644 --- a/cinelerra-5.1/cinelerra/edl.C +++ b/cinelerra-5.1/cinelerra/edl.C @@ -830,7 +830,6 @@ void EDL::delete_edits(ArrayList *edits, int collapse) edit->startproject -= length; } delete dead_edit; - track->optimize(); } optimize(); } diff --git a/cinelerra-5.1/cinelerra/mainmenu.C b/cinelerra-5.1/cinelerra/mainmenu.C index 11edba8f..da1dbd33 100644 --- a/cinelerra-5.1/cinelerra/mainmenu.C +++ b/cinelerra-5.1/cinelerra/mainmenu.C @@ -134,8 +134,8 @@ void MainMenu::create_objects() filemenu->add_item(new BC_MenuItem("-")); filemenu->add_item(quit_program = new Quit(mwindow)); quit_program->create_objects(save); - filemenu->add_item(new DumpEDL(mwindow)); - filemenu->add_item(new DumpPlugins(mwindow)); + filemenu->add_item(dump_menu = new MainDumpsMenu(mwindow)); + dump_menu->create_objects(); filemenu->add_item(new LoadBackup(mwindow)); filemenu->add_item(new SaveBackup(mwindow)); @@ -585,6 +585,36 @@ int MainMenu::add_load(char *path) // ================================== menu items +MainDumpsSubMenu::MainDumpsSubMenu(BC_MenuItem *menu_item) + : BC_SubMenu() +{ + this->menu_item = menu_item; +} +MainDumpsSubMenu::~MainDumpsSubMenu() +{ +} + + +MainDumpsMenu::MainDumpsMenu(MWindow *mwindow) + : BC_MenuItem(_("Dumps...")) +{ + this->mwindow = mwindow; + this->dumps_menu = 0; +} +MainDumpsMenu::~MainDumpsMenu() +{ +} + +void MainDumpsMenu::create_objects() +{ + add_submenu(dumps_menu = new MainDumpsSubMenu(this)); +// dumps_menu->add_item(new DumpCICache(mwindow)); + dumps_menu->add_item(new DumpEDL(mwindow)); + dumps_menu->add_item(new DumpPlugins(mwindow)); + dumps_menu->add_item(new DumpAssets(mwindow)); + dumps_menu->add_item(new DumpUndo(mwindow)); +}; + DumpCICache::DumpCICache(MWindow *mwindow) : BC_MenuItem(_("Dump CICache")) @@ -604,9 +634,7 @@ DumpEDL::DumpEDL(MWindow *mwindow) int DumpEDL::handle_event() { -//printf("DumpEDL::handle_event 1\n"); mwindow->dump_edl(); -//printf("DumpEDL::handle_event 2\n"); return 1; } @@ -618,20 +646,29 @@ DumpPlugins::DumpPlugins(MWindow *mwindow) int DumpPlugins::handle_event() { -//printf("DumpEDL::handle_event 1\n"); mwindow->dump_plugins(); -//printf("DumpEDL::handle_event 2\n"); return 1; } - DumpAssets::DumpAssets(MWindow *mwindow) : BC_MenuItem(_("Dump Assets")) { this->mwindow = mwindow; } int DumpAssets::handle_event() { - mwindow->assets->dump(); + mwindow->edl->assets->dump(); + return 1; +} + +DumpUndo::DumpUndo(MWindow *mwindow) + : BC_MenuItem(_("Dump Undo")) +{ + this->mwindow = mwindow; +} + +int DumpUndo::handle_event() +{ + mwindow->dump_undo(); return 1; } diff --git a/cinelerra-5.1/cinelerra/mainmenu.h b/cinelerra-5.1/cinelerra/mainmenu.h index b87e8088..2e965f41 100644 --- a/cinelerra-5.1/cinelerra/mainmenu.h +++ b/cinelerra-5.1/cinelerra/mainmenu.h @@ -22,36 +22,11 @@ #ifndef MAINMENU_H #define MAINMENU_H -class AEffectMenu; -class LabelsFollowEdits; -class PluginsFollowEdits; -class KeyframesFollowEdits; -class CursorOnFrames; -class TypelessKeyframes; -class SetBRenderActive; -class LoopPlayback; - -class Redo; -class ShowVWindow; -class ShowAWindow; -class ShowGWindow; -class ShowCWindow; -class ShowLWindow; -class Undo; -class KeyframeCurveType; -class KeyframeCurveTypeMenu; -class KeyframeCurveTypeItem; -class SplitX; -class SplitY; -class MixerViewer; -class LoadLayoutItem; -class LoadLayout; - - #include "arraylist.h" #include "guicast.h" #include "bchash.inc" #include "loadfile.inc" +#include "mainmenu.inc" #include "mwindow.inc" #include "mwindowgui.inc" #include "maxchannels.h" @@ -115,6 +90,7 @@ public: MenuAEffectItem *aeffect[TOTAL_EFFECTS]; MenuVEffectItem *veffect[TOTAL_EFFECTS]; Quit *quit_program; // affected by save + MainDumpsMenu *dump_menu; Undo *undo; Redo *redo; int total_aeffects; @@ -168,7 +144,25 @@ public: MWindow *mwindow; }; +class MainDumpsSubMenu : public BC_SubMenu +{ +public: + MainDumpsSubMenu(BC_MenuItem *menu_item); + ~MainDumpsSubMenu(); + + BC_MenuItem *menu_item; +}; + +class MainDumpsMenu : public BC_MenuItem +{ +public: + MainDumpsMenu(MWindow *mwindow); + ~MainDumpsMenu(); + void create_objects(); + MWindow *mwindow; + MainDumpsSubMenu *dumps_menu; +}; class DumpCICache : public BC_MenuItem { @@ -202,6 +196,14 @@ public: MWindow *mwindow; }; +class DumpUndo : public BC_MenuItem +{ +public: + DumpUndo(MWindow *mwindow); + int handle_event(); + MWindow *mwindow; +}; + class Redo : public BC_MenuItem { public: diff --git a/cinelerra-5.1/cinelerra/mainmenu.inc b/cinelerra-5.1/cinelerra/mainmenu.inc index f1178ff4..e372c2b6 100644 --- a/cinelerra-5.1/cinelerra/mainmenu.inc +++ b/cinelerra-5.1/cinelerra/mainmenu.inc @@ -25,4 +25,99 @@ class MainMenu; #define MENUBARPIXELS 25 +class AEffectMenu; +class LabelsFollowEdits; +class PluginsFollowEdits; +class KeyframesFollowEdits; +class CursorOnFrames; +class TypelessKeyframes; +class SetBRenderActive; +class LoopPlayback; +class Redo; +class ShowVWindow; +class ShowAWindow; +class ShowGWindow; +class ShowCWindow; +class ShowLWindow; +class Undo; +class KeyframeCurveType; +class KeyframeCurveTypeMenu; +class KeyframeCurveTypeItem; +class SplitX; +class SplitY; +class MixerViewer; +class LoadLayoutItem; +class LoadLayout; +class MainMenu; +class Undo; +class MainDumpsSubMenu; +class MainDumpsMenu; +class DumpCICache; +class DumpEDL; +class DumpPlugins; +class DumpAssets; +class DumpUndo; +class Redo; +class Cut; +class Copy; +class Paste; +class Clear; +class CutKeyframes; +class CopyKeyframes; +class PasteKeyframes; +class ClearKeyframes; +class StraightenKeyframes; +class BendKeyframes; +class KeyframeCurveType; +class KeyframeCurveTypeMenu; +class KeyframeCurveTypeItem; +class CutDefaultKeyframe; +class CopyDefaultKeyframe; +class PasteDefaultKeyframe; +class ClearDefaultKeyframe; +class PasteSilence; +class SelectAll; +class ClearLabels; +class CutCommercials; +class DetachTransitions; +class MuteSelection; +class TrimSelection; +class TileMixers; +class AddAudioTrack; +class DeleteAudioTrack; +class DefaultATransition; +class MapAudio1; +class MapAudio2; +class AddVideoTrack; +class DeleteVideoTrack; +class ResetTranslation; +class DefaultVTransition; +class AddSubttlTrack; +class PasteSubttl; +class MoveTracksUp; +class MoveTracksDown; +class DeleteTracks; +class ConcatenateTracks; +class DeleteTrack; +class LoopPlayback; +class SetBRenderActive; +class LabelsFollowEdits; +class PluginsFollowEdits; +class KeyframesFollowEdits; +class CursorOnFrames; +class TypelessKeyframes; +class ScrubSpeed; +class SaveSettingsNow; +class ShowVWindow; +class ShowAWindow; +class ShowGWindow; +class ShowCWindow; +class ShowLWindow; +class TileWindows; +class SplitX; +class SplitY; +class MixerViewer; +class LoadLayoutItem; +class LoadLayout; + #endif diff --git a/cinelerra-5.1/cinelerra/mwindow.h b/cinelerra-5.1/cinelerra/mwindow.h index a69a3a50..fecb5258 100644 --- a/cinelerra-5.1/cinelerra/mwindow.h +++ b/cinelerra-5.1/cinelerra/mwindow.h @@ -409,7 +409,7 @@ public: int edit_edits, int edit_labels, int edit_autos, int edit_plugins); void paste_clipboard(Track *first_track, double position, int overwrite, int edit_edits, int edit_labels, int edit_autos, int edit_plugins); - void move_group(EDL *group, Track *first_track, double position); + void move_group(EDL *group, Track *first_track, double position, int overwrite); // Move effect to position void move_effect(Plugin *plugin, Track *track, int64_t position); void move_effect(Plugin *plugin, PluginSet *plugin_set, int64_t position); diff --git a/cinelerra-5.1/cinelerra/mwindowedit.C b/cinelerra-5.1/cinelerra/mwindowedit.C index 9711719a..99c666f1 100644 --- a/cinelerra-5.1/cinelerra/mwindowedit.C +++ b/cinelerra-5.1/cinelerra/mwindowedit.C @@ -1264,14 +1264,17 @@ void MWindow::paste_clipboard(Track *first_track, double position, int overwrite clip->remove_user(); } -void MWindow::move_group(EDL *group, Track *first_track, double position) +void MWindow::move_group(EDL *group, Track *first_track, double position, int overwrite) { undo->update_undo_before(); ArrayListedits; edl->tracks->get_selected_edits(&edits); edl->delete_edits(&edits, 0); - paste_edits(group, first_track, position, 1, 1, 1, 1, 1); + paste_edits(group, first_track, position, overwrite, 1, + edl->session->labels_follow_edits, + edl->session->plugins_follow_edits, + edl->session->autos_follow_edits); // big debate over whether to do this, must either clear selected, or no tweaking // edl->tracks->clear_selected_edits(); diff --git a/cinelerra-5.1/cinelerra/trackcanvas.C b/cinelerra-5.1/cinelerra/trackcanvas.C index bdeb7713..cf20fe90 100644 --- a/cinelerra-5.1/cinelerra/trackcanvas.C +++ b/cinelerra-5.1/cinelerra/trackcanvas.C @@ -278,7 +278,6 @@ int TrackCanvas::drag_stop_event() { int result = gui->drag_stop(); if( !result && mwindow->session->current_operation ) { - mwindow->edl->tracks->clear_selected_edits(); mwindow->session->current_operation = NO_OPERATION; drag_scroll = 0; } @@ -521,10 +520,12 @@ int TrackCanvas::drag_stop(int *redraw) double drop_position = new_pos; int ret = test_track_group(drag_group, drop_track, new_pos); if( !ret && new_pos != drop_position ) { + drop_position = new_pos; ret = test_track_group(drag_group, drop_track, new_pos); } - if( ret ) - mwindow->move_group(drag_group, drop_track, new_pos); + if( ret >= 0 ) + mwindow->move_group(drag_group, drop_track, drop_position, + ret > 0 ? !shift_down() : shift_down()); drag_group->remove_user(); mwindow->session->drag_group = 0; } @@ -716,19 +717,16 @@ void TrackCanvas::draw(int mode, int hide_cursor) void TrackCanvas::update_cursor(int flush) { - switch(mwindow->edl->session->editing_mode) - { - case EDITING_ARROW: set_cursor(ARROW_CURSOR, 0, flush); break; - case EDITING_IBEAM: set_cursor(IBEAM_CURSOR, 0, flush); break; - } + if( arrow_mode() ) + set_cursor(ARROW_CURSOR, 0, flush); + else if( ibeam_mode() ) + set_cursor(IBEAM_CURSOR, 0, flush); } void TrackCanvas::test_timer() { - if(resource_timer->get_difference() > 1000 && - !hourglass_enabled) - { + if( resource_timer->get_difference() > 1000 && !hourglass_enabled ) { start_hourglass(); hourglass_enabled = 1; } @@ -1591,15 +1589,17 @@ void TrackCanvas::draw_highlighting() double drop_position = new_pos; int color = GREEN; int ret = test_track_group(drag_group, track, new_pos); - if( !ret && new_pos != drop_position ) { - double pos = new_pos; - pos += mwindow->session->drag_position - cur_pos; - cx = mwindow->edl->get_position_cursorx(pos, pane->number); - ret = test_track_group(drag_group, track, new_pos); - color = ret ? YELLOW : RED; + if( ret < 0 ) + color = ORANGE; + else if( !ret ) { + if( new_pos != drop_position ) { + double pos = new_pos; + pos += mwindow->session->drag_position - cur_pos; + cx = mwindow->edl->get_position_cursorx(pos, pane->number); + ret = test_track_group(drag_group, track, new_pos); + } + color = ret > 0 ? YELLOW : shift_down() ? RED : BLUE; } - else if( !ret ) - color = RED; track_dimensions(mwindow->session->track_highlighted, x, y, w, h); int dx = cx - mwindow->session->drag_origin_x; int dy = y - mwindow->session->drag_origin_y; @@ -1672,6 +1672,19 @@ void TrackCanvas::draw_highlighting() draw_selected_edits(mwindow->edl, 0, 0, GREEN+BLUE, RED); } +// x does not reliably draw a really big rectangle +void TrackCanvas::draw_selected(int x, int y, int w, int h) +{ + int x1 = bmax(x, 0), x2 = bmin(x+w, get_w()); + if( x1 > x2 ) return; + int y1 = bmax(y, 0), y2 = bmin(y+h, get_h()); + if( y1 > y2 ) return; + if( x >= 0 && x < get_w() ) draw_line(x,y1, x,y2); + if( x+w >= 0 && x+w < get_w() ) draw_line(x+w,y1, x+w,y2); + if( y >= 0 && y < get_h() ) draw_line(x1,y, x2,y); + if( y+h >= 0 && y+h < get_h() ) draw_line(x1,y+h, x2,y+h); +} + void TrackCanvas::draw_selected_edits(EDL *edl, int dx, int dy, int color0, int color1) { for( Track *track=edl->tracks->first; track; track=track->next ) { @@ -1686,11 +1699,11 @@ void TrackCanvas::draw_selected_edits(EDL *edl, int dx, int dy, int color0, int int inner = color1 < 0 ? color0 : !edit->group_id ? color0 : mwindow->get_group_color(edit->group_id); set_color(inner); - draw_rectangle(x, y, w, h); + draw_selected(x, y, w, h); int outer = color1 < 0 ? color0 : !edit->group_id ? color1 : inner; set_color(outer); - draw_rectangle(x-1, y-1, w+2, h+2); - draw_rectangle(x-2, y-2, w+1, h+1); + draw_selected(x-1, y-1, w+2, h+2); + draw_selected(x-2, y-2, w+1, h+1); } } } @@ -4130,17 +4143,14 @@ int TrackCanvas::cursor_update(int in_motion) int update_scroll = 0; int update_overlay = 0; int update_cursor = 0; - int new_cursor = 0; int rerender = 0; double position = 0.; //printf("TrackCanvas::cursor_update %d\n", __LINE__); // Default cursor - switch(mwindow->edl->session->editing_mode) - { - case EDITING_ARROW: new_cursor = ARROW_CURSOR; break; - case EDITING_IBEAM: new_cursor = IBEAM_CURSOR; break; - } + int new_cursor = + arrow_mode() ? ARROW_CURSOR : + ibeam_mode() ? IBEAM_CURSOR : 0; switch(mwindow->session->current_operation) { @@ -4829,6 +4839,15 @@ int TrackCanvas::do_tracks(int cursor_x, int cursor_y, int button_press) return result; } +int TrackCanvas::arrow_mode() +{ + return mwindow->edl->session->editing_mode == EDITING_ARROW ? 1 : 0; +} +int TrackCanvas::ibeam_mode() +{ + return mwindow->edl->session->editing_mode == EDITING_IBEAM ? 1 : 0; +} + int TrackCanvas::do_edits(int cursor_x, int cursor_y, int button_press, int drag_start, int &redraw, int &rerender, int &new_cursor, int &update_cursor) { @@ -4841,26 +4860,23 @@ int TrackCanvas::do_edits(int cursor_x, int cursor_y, int button_press, int drag // Cursor inside a track // Cursor inside an edit - if(cursor_x >= edit_x && cursor_x < edit_x + edit_w && - cursor_y >= edit_y && cursor_y < edit_y + edit_h) { + if( cursor_x >= edit_x && cursor_x < edit_x + edit_w && + cursor_y >= edit_y && cursor_y < edit_y + edit_h ) { if( button_press && get_buttonpress() == LEFT_BUTTON ) { - if( get_double_click() && (ctrl_down() || - mwindow->edl->session->editing_mode == EDITING_IBEAM) ) { -// Select duration of edit + if( get_double_click() ) { + mwindow->edl->tracks->clear_selected_edits(); + mwindow->edl->tracks->select_affected_edits( + edit->track->from_units(edit->startproject), + edit->track, 1); double start = edit->track->from_units(edit->startproject); start = mwindow->edl->align_to_frame(start, 0); mwindow->edl->local_session->set_selectionstart(start); double end = edit->track->from_units(edit->startproject+edit->length); end = mwindow->edl->align_to_frame(end, 0); mwindow->edl->local_session->set_selectionend(end); - mwindow->edl->tracks->clear_selected_edits(); - mwindow->edl->tracks->select_affected_edits( - edit->track->from_units(edit->startproject), - edit->track, 1); - result = 1; + result = 1; // Select edit duration or select_region } - else if( mwindow->edl->session->editing_mode == EDITING_ARROW || - ctrl_down() ) { + else if( arrow_mode() || (ibeam_mode() && ctrl_down()) ) { mwindow->session->drag_edit = edit; mwindow->session->current_operation = GROUP_TOGGLE; result = 1; @@ -4880,8 +4896,9 @@ int TrackCanvas::do_edits(int cursor_x, int cursor_y, int button_press, int drag drag_start = 0; // if unselected "fast" drag if( !edit->silence() && !edit->is_selected ) { mwindow->edl->tracks->clear_selected_edits(); - if( ctrl_down() ) { + if( ibeam_mode() ) { double start = edit->track->from_units(edit->startproject); + mwindow->edl->local_session->set_selectionstart(start); mwindow->edl->local_session->set_selectionend(start); edit->set_selected(1); } @@ -4892,7 +4909,7 @@ int TrackCanvas::do_edits(int cursor_x, int cursor_y, int button_press, int drag drag_start = 1; } // Construct list of all affected edits - if( ctrl_down() || drag_start ) { + if( drag_start || ibeam_mode() ) { mwindow->edl->tracks->get_selected_edits(mwindow->session->drag_edits); if( mwindow->session->drag_edits->size() > 0 ) { mwindow->session->current_operation = DRAG_EDIT; @@ -4908,7 +4925,7 @@ int TrackCanvas::do_edits(int cursor_x, int cursor_y, int button_press, int drag update_cursor = 1; } } - else if( edit->is_selected ) { + else if( edit->is_selected && arrow_mode() ) { if( mwindow->session->drag_group ) mwindow->session->drag_group->remove_user(); double start_position = 0; @@ -4939,7 +4956,7 @@ int TrackCanvas::test_track_group(EDL *group, Track *first_track, double &pos) Track *src = group->tracks->first; for( Track *track=first_track; track && src; track=track->next ) { if( !track->record ) continue; - if( src->data_type != track->data_type ) return 0; + if( src->data_type != track->data_type ) return -1; for( Edit *src_edit=src->edits->first; src_edit; src_edit=src_edit->next ) { if( src_edit->silence() ) continue; if( edit_intersects(track, src_edit, pos) ) return 0; @@ -4956,23 +4973,32 @@ int TrackCanvas::edit_intersects(Track *track, Edit *src_edit, double &pos) int64_t src_end = src_start + src_edit->length; double new_start = src_edit->track->from_units(src_start) + pos; double new_end = src_edit->track->from_units(src_end) + pos; - int64_t trk_start = track->to_units(new_start, 0); - int64_t trk_end = track->to_units(new_end, 0); + int64_t trk_start = track->to_units(new_start, 1); + int64_t trk_end = track->to_units(new_end, 1); for( Edit *edit=track->edits->first; edit; edit=edit->next ) { if( edit->is_selected || edit->silence() ) continue; int64_t edit_start = edit->startproject; if( edit_start >= trk_end ) continue; int64_t edit_end = edit_start + edit->length; if( trk_start >= edit_end ) continue; - int lt_dist = abs(trk_end - edit_start); - int rt_dist = abs(edit_end - trk_start); + int64_t lt_dist = labs(trk_end - edit_start); + int64_t rt_dist = labs(edit_end - trk_start); + int64_t position; if( lt_dist < rt_dist ) { - pos = edit->track->from_units(edit_start) - - src_edit->track->from_units(src_end); + position = edit_start; + lt_dist = abs(trk_start - edit_start); + rt_dist = abs(trk_end - edit_start); + if( lt_dist > rt_dist ) + position -= src_end; } else { - pos = edit->track->from_units(edit_end); + position = edit_end; + lt_dist = abs(trk_start - edit_end); + rt_dist = abs(trk_end - edit_end); + if( lt_dist > rt_dist ) + position -= src_end; } + pos = edit->track->from_units(position); return 1; } return 0; @@ -5193,9 +5219,8 @@ int TrackCanvas::button_press_event() mwindow->move_right(get_w() / 5); } else { - switch(mwindow->edl->session->editing_mode) { + if( arrow_mode() ) do { // Test handles and resource boundaries and highlight a track - case EDITING_ARROW: { if( do_transitions(cursor_x, cursor_y, 1, new_cursor, update_cursor) ) break; @@ -5223,10 +5248,9 @@ int TrackCanvas::button_press_event() if( do_tracks(cursor_x, cursor_y, 1) ) break; result = 0; - break; } - + } while(0); + else if( ibeam_mode() ) do { // Test handles only and select a region - case EDITING_IBEAM: { double position = mwindow->edl->get_cursor_position(cursor_x, pane->number); //printf("TrackCanvas::button_press_event %d\n", position); @@ -5256,8 +5280,7 @@ int TrackCanvas::button_press_event() rerender = start_selection(position); mwindow->session->current_operation = SELECT_REGION; update_cursor = 1; - break; } - } + } while(0); } if( rerender ) { diff --git a/cinelerra-5.1/cinelerra/trackcanvas.h b/cinelerra-5.1/cinelerra/trackcanvas.h index 8a123c96..91641466 100644 --- a/cinelerra-5.1/cinelerra/trackcanvas.h +++ b/cinelerra-5.1/cinelerra/trackcanvas.h @@ -277,6 +277,10 @@ public: void get_pixmap_size(Edit *edit, int64_t edit_x, int64_t edit_w, int64_t &pixmap_x, int64_t &pixmap_w, int64_t &pixmap_h); ResourcePixmap* create_pixmap(Edit *edit, int64_t edit_x, int64_t pixmap_x, int64_t pixmap_w, int64_t pixmap_h); void update_cursor(int flush); + void draw_selected(int x, int y, int w, int h); + int arrow_mode(); + int ibeam_mode(); + // Get edit and handle the cursor is over int do_edit_handles(int cursor_x, int cursor_y, diff --git a/cinelerra-5.1/guicast/bccolors.h b/cinelerra-5.1/guicast/bccolors.h index 9226f3a5..94be40bc 100644 --- a/cinelerra-5.1/guicast/bccolors.h +++ b/cinelerra-5.1/guicast/bccolors.h @@ -26,6 +26,7 @@ #include "bccolors.inc" #include "clip.h" +#include "colors.h" #include "vframe.inc" #include @@ -335,52 +336,4 @@ public: static int hsv_to_yuv(float &y, float &u, float &v, float h, float s, float va, float max) { return 0; }; }; - -// standard colors -#define BLACK 0x000000 -#define WHITE 0xFFFFFF - -#define LTBLUE 0x9090FF -#define BLUE 0x0000FF -#define DKBLUE 0x000090 - -#define LTPINK 0xFFC0C0 -#define PINK 0xFF8080 -#define RED 0xFF0000 - -#define LTGREEN 0xC0FFC0 -#define GREEN 0x00FF00 -#define DKGREEN 0x009000 - -#define YELLOW 0xFFFF00 -#define LTYELLOW 0xFFFFA0 -#define MEYELLOW 0xFFFF00 -#define MDYELLOW 0xFFFFD2 -#define DKYELLOW 0xFFFFB4 - -#define LTCYAN 0x00CBCB -#define MECYAN 0x009696 -#define MDCYAN 0x007E7E -#define DKCYAN 0x004949 - -#define LTPURPLE 0xFFC0FF -#define MEPURPLE 0xFF00FF -#define MDPURPLE 0xC000C0 -#define DKPURPLE 0xA000A0 - -#define LTGREY 0xE0E0E0 -#define MEGREY 0xAFAFAF -#define DMGREY 0x999999 -#define MDGREY 0x7D7D7D -#define DKGREY 0x4B4B4B - -#define BLOND 0xb4b487 -#define SLBLUE 0x6040c0 - -#define MNGREY 0xe6e6e6 -#define FGGREY 0xe3e3e3 -#define MNBLUE 0x003cff -#define ORANGE 0xffdd76 -#define FTGREY 0xbcbcbc - #endif diff --git a/cinelerra-5.1/guicast/colors.h b/cinelerra-5.1/guicast/colors.h index a0878fd0..6cb6081b 100644 --- a/cinelerra-5.1/guicast/colors.h +++ b/cinelerra-5.1/guicast/colors.h @@ -66,7 +66,7 @@ #define MNGREY 0xe6e6e6 #define FGGREY 0xe3e3e3 #define MNBLUE 0x003cff -#define ORANGE 0xffdd76 +#define ORANGE 0xff8000 #define FTGREY 0xbcbcbc #endif -- 2.26.2