~ubuntu-branches/ubuntu/lucid/ardour/lucid-proposed

« back to all changes in this revision

Viewing changes to gtk2_ardour/editor.cc

  • Committer: Bazaar Package Importer
  • Author(s): Luke Yelavich
  • Date: 2008-07-29 11:27:04 UTC
  • mfrom: (1.1.15 upstream)
  • Revision ID: james.westby@ubuntu.com-20080729112704-x1rmgb4tjotjyu5u
Tags: 1:2.5-0ubuntu1
* New upstream release.
* debian/patches/s390-FTBFS.patch: Dropped, as it fails to apply, and
  Ubuntu doesn't concern itself with s390.
* debian/control:
  - Fix package description, thanks to the patch in Debian bug #485892.
  - Metadata cleanup and sync control/control.in files.
  - Add libaubio-dev to Build-Depends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
#include "gui_thread.h"
81
81
#include "sfdb_ui.h"
82
82
#include "rhythm_ferret.h"
 
83
#include "actions.h"
83
84
 
84
85
#ifdef FFT_ANALYSIS
85
86
#include "analysis_window.h"
253
254
        clicked_control_point = 0;
254
255
        last_update_frame = 0;
255
256
        drag_info.item = 0;
 
257
        drag_info.copied_location = 0;
256
258
        current_mixer_strip = 0;
257
259
        current_bbt_points = 0;
258
260
        
336
338
        select_new_marker = false;
337
339
        zoomed_to_region = false;
338
340
        rhythm_ferret = 0;
 
341
        allow_vertical_scroll = false;
 
342
        no_save_visual = false;
 
343
        need_resize_line = false;
 
344
        resize_line_y = 0;
 
345
        old_resize_line_y = -1;
 
346
        no_region_list_redisplay = false;
 
347
        resize_idle_id = -1;
339
348
 
340
349
        _scrubbing = false;
341
350
        scrubbing_direction = 0;
354
363
        
355
364
        set_mouse_mode (MouseObject, true);
356
365
 
357
 
        last_visual_state.frames_per_unit = 0;
358
 
 
359
366
        frames_per_unit = 2048; /* too early to use reset_zoom () */
360
367
        reset_hscrollbar_stepping ();
361
368
        
791
798
        ControlProtocol::ZoomIn.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), false));
792
799
        ControlProtocol::ZoomOut.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), true));
793
800
        ControlProtocol::ScrollTimeline.connect (mem_fun (*this, &Editor::control_scroll));
 
801
        BasicUI::AccessAction.connect (mem_fun (*this, &Editor::access_action));
794
802
 
795
803
        Config->ParameterChanged.connect (mem_fun (*this, &Editor::parameter_changed));
796
804
        Route::SyncOrderKeys.connect (mem_fun (*this, &Editor::sync_order_keys));
940
948
 
941
949
        if (fpu < 1.0) {
942
950
                fpu = 1.0;
943
 
                zoom_range_clock.set ((nframes_t) floor (fpu * canvas_width));
 
951
                zoom_range_clock.set ((nframes64_t) floor (fpu * canvas_width));
944
952
        } else if (fpu > session->current_end_frame() / canvas_width) {
945
953
                fpu = session->current_end_frame() / canvas_width;
946
 
                zoom_range_clock.set ((nframes_t) floor (fpu * canvas_width));
 
954
                zoom_range_clock.set ((nframes64_t) floor (fpu * canvas_width));
947
955
        }
948
956
        
949
957
        temporal_zoom (fpu);
963
971
        /*
964
972
                _control_scroll_target is an optional<T>
965
973
        
966
 
                it acts like a pointer to an nframes_t, with
 
974
                it acts like a pointer to an nframes64_t, with
967
975
                a operator conversion to boolean to check
968
976
                that it has a value could possibly use
969
977
                playhead_cursor->current_frame to store the
976
984
                _dragging_playhead = true;
977
985
        }
978
986
 
979
 
        if ((fraction < 0.0f) && (*_control_scroll_target < (nframes_t) fabs(step))) {
 
987
        if ((fraction < 0.0f) && (*_control_scroll_target < (nframes64_t) fabs(step))) {
980
988
                *_control_scroll_target = 0;
981
989
        } else if ((fraction > 0.0f) && (max_frames - *_control_scroll_target < step)) {
982
990
                *_control_scroll_target = max_frames - (current_page_frames()*2); // allow room for slop in where the PH is on the screen
983
991
        } else {
984
 
                *_control_scroll_target += (nframes_t) floor (step);
 
992
                *_control_scroll_target += (nframes64_t) floor (step);
985
993
        }
986
994
 
987
995
        /* move visuals, we'll catch up with it later */
1012
1020
}
1013
1021
 
1014
1022
bool
1015
 
Editor::deferred_control_scroll (nframes_t target)
 
1023
Editor::deferred_control_scroll (nframes64_t target)
1016
1024
{
1017
1025
        session->request_locate (*_control_scroll_target, session->transport_rolling());
1018
1026
        // reset for next stream
1022
1030
}
1023
1031
 
1024
1032
void
 
1033
Editor::access_action (std::string action_group, std::string action_item)
 
1034
{
 
1035
        if (!session) {
 
1036
                return;
 
1037
        }
 
1038
 
 
1039
        ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::access_action), action_group, action_item));
 
1040
 
 
1041
        cout<< "OSC: Recieved: "<< action_item << endl;
 
1042
 
 
1043
        RefPtr<Action> act;
 
1044
        act = ActionManager::get_action( action_group.c_str(), action_item.c_str() );
 
1045
 
 
1046
        if (act) {
 
1047
                act->activate();
 
1048
        }
 
1049
                
 
1050
 
 
1051
}
 
1052
 
 
1053
void
1025
1054
Editor::on_realize ()
1026
1055
{
1027
1056
        Window::on_realize ();
1042
1071
}
1043
1072
 
1044
1073
void
1045
 
Editor::map_position_change (nframes_t frame)
 
1074
Editor::map_position_change (nframes64_t frame)
1046
1075
{
1047
1076
        ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::map_position_change), frame));
1048
1077
 
1055
1084
}       
1056
1085
 
1057
1086
void
1058
 
Editor::center_screen (nframes_t frame)
 
1087
Editor::center_screen (nframes64_t frame)
1059
1088
{
1060
1089
        double page = canvas_width * frames_per_unit;
1061
1090
 
1068
1097
}
1069
1098
 
1070
1099
void
1071
 
Editor::center_screen_internal (nframes_t frame, float page)
 
1100
Editor::center_screen_internal (nframes64_t frame, float page)
1072
1101
{
1073
1102
        page /= 2;
1074
1103
                
1075
1104
        if (frame > page) {
1076
 
                frame -= (nframes_t) page;
 
1105
                frame -= (nframes64_t) page;
1077
1106
        } else {
1078
1107
                frame = 0;
1079
1108
        }
1086
1115
{
1087
1116
        ENSURE_GUI_THREAD (mem_fun (*this, &Editor::handle_new_duration));
1088
1117
 
1089
 
        nframes_t new_end = session->get_maximum_extent() + (nframes_t) floorf (current_page_frames() * 0.10f);
 
1118
        nframes64_t new_end = session->get_maximum_extent() + (nframes64_t) floorf (current_page_frames() * 0.10f);
1090
1119
                                  
1091
1120
        if (new_end > last_canvas_frame) {
1092
1121
                last_canvas_frame = new_end;
1095
1124
        }
1096
1125
 
1097
1126
        horizontal_adjustment.set_value (leftmost_frame/frames_per_unit);
 
1127
        //cerr << "Editor::handle_new_duration () called ha v:l:u:ps:lcf = " << horizontal_adjustment.get_value() << ":" << horizontal_adjustment.get_lower() << ":" << horizontal_adjustment.get_upper() << ":" << horizontal_adjustment.get_page_size() << ":" << last_canvas_frame << endl;//DEBUG
1098
1128
}
1099
1129
 
1100
1130
void
1426
1456
}
1427
1457
 
1428
1458
void
1429
 
Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type, bool with_selection, nframes_t frame)
 
1459
Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type, bool with_selection, nframes64_t frame)
1430
1460
{
1431
1461
        using namespace Menu_Helpers;
1432
 
        Menu* (Editor::*build_menu_function)(nframes_t);
 
1462
        Menu* (Editor::*build_menu_function)(nframes64_t);
1433
1463
        Menu *menu;
1434
1464
 
1435
1465
        switch (item_type) {
1541
1571
}
1542
1572
 
1543
1573
Menu*
1544
 
Editor::build_track_context_menu (nframes_t ignored)
 
1574
Editor::build_track_context_menu (nframes64_t ignored)
1545
1575
{
1546
1576
        using namespace Menu_Helpers;
1547
1577
 
1553
1583
}
1554
1584
 
1555
1585
Menu*
1556
 
Editor::build_track_bus_context_menu (nframes_t ignored)
 
1586
Editor::build_track_bus_context_menu (nframes64_t ignored)
1557
1587
{
1558
1588
        using namespace Menu_Helpers;
1559
1589
 
1565
1595
}
1566
1596
 
1567
1597
Menu*
1568
 
Editor::build_track_region_context_menu (nframes_t frame)
 
1598
Editor::build_track_region_context_menu (nframes64_t frame)
1569
1599
{
1570
1600
        using namespace Menu_Helpers;
1571
1601
        MenuList& edit_items  = track_region_context_menu.items();
1578
1608
                boost::shared_ptr<Playlist> pl;
1579
1609
                
1580
1610
                if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()))) {
1581
 
                        Playlist::RegionList* regions = pl->regions_at ((nframes_t) floor ( (double)frame * ds->speed()));
1582
 
                        for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1583
 
                                add_region_context_items (atv->audio_view(), (*i), edit_items);
 
1611
                        Playlist::RegionList* regions = pl->regions_at ((nframes64_t) floor ( (double)frame * ds->speed()));
 
1612
 
 
1613
                        if (selection->regions.size() > 1) {
 
1614
                                // there's already a multiple selection: just add a 
 
1615
                                // single region context menu that will act on all 
 
1616
                                // selected regions
 
1617
                                boost::shared_ptr<Region> dummy_region; // = NULL               
 
1618
                                add_region_context_items (atv->audio_view(), dummy_region, edit_items);                 
 
1619
                        } else {
 
1620
                                for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
 
1621
                                        add_region_context_items (atv->audio_view(), (*i), edit_items);
 
1622
                                }
1584
1623
                        }
 
1624
 
1585
1625
                        delete regions;
1586
1626
                }
1587
1627
        }
1592
1632
}
1593
1633
 
1594
1634
Menu*
1595
 
Editor::build_track_crossfade_context_menu (nframes_t frame)
 
1635
Editor::build_track_crossfade_context_menu (nframes64_t frame)
1596
1636
{
1597
1637
        using namespace Menu_Helpers;
1598
1638
        MenuList& edit_items  = track_crossfade_context_menu.items();
1618
1658
                                add_crossfade_context_items (atv->audio_view(), (*i), edit_items, many);
1619
1659
                        }
1620
1660
 
1621
 
                        for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1622
 
                                add_region_context_items (atv->audio_view(), (*i), edit_items);
 
1661
                        if (selection->regions.size() > 1) {
 
1662
                                // there's already a multiple selection: just add a 
 
1663
                                // single region context menu that will act on all 
 
1664
                                // selected regions
 
1665
                                boost::shared_ptr<Region> dummy_region; // = NULL               
 
1666
                                add_region_context_items (atv->audio_view(), dummy_region, edit_items);                 
 
1667
                        } else {
 
1668
                                for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
 
1669
                                        add_region_context_items (atv->audio_view(), (*i), edit_items);
 
1670
                                }
1623
1671
                        }
1624
 
 
1625
1672
                        delete regions;
1626
1673
                }
1627
1674
        }
1672
1719
 
1673
1720
 
1674
1721
Menu*
1675
 
Editor::build_track_selection_context_menu (nframes_t ignored)
 
1722
Editor::build_track_selection_context_menu (nframes64_t ignored)
1676
1723
{
1677
1724
        using namespace Menu_Helpers;
1678
1725
        MenuList& edit_items  = track_selection_context_menu.items();
1754
1801
 
1755
1802
        if (region) {
1756
1803
                ar = boost::dynamic_pointer_cast<AudioRegion> (region);
 
1804
 
 
1805
                /* when this particular menu pops up, make the relevant region 
 
1806
                   become selected.
 
1807
                */
 
1808
 
 
1809
                region_menu->signal_map_event().connect (
 
1810
                        bind (
 
1811
                                mem_fun(*this, &Editor::set_selected_regionview_from_map_event), 
 
1812
                                sv, 
 
1813
                                boost::weak_ptr<Region>(region)
 
1814
                        )
 
1815
                );
 
1816
 
 
1817
                items.push_back (MenuElem (_("Rename"), mem_fun(*this, &Editor::rename_region)));
 
1818
                items.push_back (MenuElem (_("Popup region editor"), mem_fun(*this, &Editor::edit_region)));
1757
1819
        }
1758
1820
 
1759
 
        /* when this particular menu pops up, make the relevant region 
1760
 
           become selected.
1761
 
        */
1762
 
 
1763
 
        region_menu->signal_map_event().connect (bind (mem_fun(*this, &Editor::set_selected_regionview_from_map_event), sv, boost::weak_ptr<Region>(region)));
1764
 
 
1765
 
        items.push_back (MenuElem (_("Rename"), mem_fun(*this, &Editor::rename_region)));
1766
 
        items.push_back (MenuElem (_("Popup region editor"), mem_fun(*this, &Editor::edit_region)));
1767
1821
        items.push_back (MenuElem (_("Raise to top layer"), mem_fun(*this, &Editor::raise_region_to_top)));
1768
1822
        items.push_back (MenuElem (_("Lower to bottom layer"), mem_fun  (*this, &Editor::lower_region_to_bottom)));
1769
1823
        items.push_back (SeparatorElem());
1783
1837
 
1784
1838
        sigc::connection fooc;
1785
1839
 
1786
 
        items.push_back (CheckMenuElem (_("Lock")));
1787
 
        CheckMenuItem* region_lock_item = static_cast<CheckMenuItem*>(&items.back());
1788
 
        if (region->locked()) {
1789
 
                region_lock_item->set_active();
1790
 
        }
1791
 
        region_lock_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_lock));
1792
 
 
1793
 
        items.push_back (CheckMenuElem (_("Glue to Bars&Beats")));
1794
 
        CheckMenuItem* bbt_glue_item = static_cast<CheckMenuItem*>(&items.back());
1795
 
 
1796
 
        switch (region->positional_lock_style()) {
1797
 
        case Region::MusicTime:
1798
 
                bbt_glue_item->set_active (true);
1799
 
                break;
1800
 
        default:
1801
 
                bbt_glue_item->set_active (false);
1802
 
                break;
1803
 
        }
1804
 
 
1805
 
        bbt_glue_item->signal_activate().connect (bind (mem_fun (*this, &Editor::set_region_lock_style), Region::MusicTime));
1806
 
 
1807
 
        items.push_back (CheckMenuElem (_("Mute")));
1808
 
        CheckMenuItem* region_mute_item = static_cast<CheckMenuItem*>(&items.back());
1809
 
        fooc = region_mute_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_mute));
1810
 
        if (region->muted()) {
1811
 
                fooc.block (true);
1812
 
                region_mute_item->set_active();
1813
 
                fooc.block (false);
1814
 
        }
1815
 
        
1816
 
        if (!Profile->get_sae()) {
1817
 
                items.push_back (CheckMenuElem (_("Opaque")));
1818
 
                CheckMenuItem* region_opaque_item = static_cast<CheckMenuItem*>(&items.back());
1819
 
                fooc = region_opaque_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_opaque));
1820
 
                if (region->opaque()) {
 
1840
        if (region) {
 
1841
                items.push_back (CheckMenuElem (_("Lock")));
 
1842
                CheckMenuItem* region_lock_item = static_cast<CheckMenuItem*>(&items.back());
 
1843
                if (region->locked()) {
 
1844
                        region_lock_item->set_active();
 
1845
                }
 
1846
                region_lock_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_lock));
 
1847
 
 
1848
                items.push_back (CheckMenuElem (_("Glue to Bars&Beats")));
 
1849
                CheckMenuItem* bbt_glue_item = static_cast<CheckMenuItem*>(&items.back());
 
1850
 
 
1851
                switch (region->positional_lock_style()) {
 
1852
                case Region::MusicTime:
 
1853
                        bbt_glue_item->set_active (true);
 
1854
                        break;
 
1855
                default:
 
1856
                        bbt_glue_item->set_active (false);
 
1857
                        break;
 
1858
                }
 
1859
 
 
1860
                bbt_glue_item->signal_activate().connect (bind (mem_fun (*this, &Editor::set_region_lock_style), Region::MusicTime));
 
1861
 
 
1862
                items.push_back (CheckMenuElem (_("Mute")));
 
1863
                CheckMenuItem* region_mute_item = static_cast<CheckMenuItem*>(&items.back());
 
1864
                fooc = region_mute_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_mute));
 
1865
                if (region->muted()) {
1821
1866
                        fooc.block (true);
1822
 
                        region_opaque_item->set_active();
 
1867
                        region_mute_item->set_active();
1823
1868
                        fooc.block (false);
1824
1869
                }
 
1870
        
 
1871
                if (!Profile->get_sae()) {
 
1872
                        items.push_back (CheckMenuElem (_("Opaque")));
 
1873
                        CheckMenuItem* region_opaque_item = static_cast<CheckMenuItem*>(&items.back());
 
1874
                        fooc = region_opaque_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_opaque));
 
1875
                        if (region->opaque()) {
 
1876
                                fooc.block (true);
 
1877
                                region_opaque_item->set_active();
 
1878
                                fooc.block (false);
 
1879
                        }
 
1880
                }
 
1881
        } else {
 
1882
                // multiple regions selected
 
1883
                // how should these act? 
 
1884
                // here they toggle the property of all selected regions
 
1885
        
 
1886
                items.push_back (MenuElem (_("Lock"), mem_fun(*this, &Editor::toggle_region_lock)));
 
1887
                items.push_back (MenuElem (_("Mute"), mem_fun(*this, &Editor::toggle_region_mute)));
 
1888
                if (!Profile->get_sae()) {
 
1889
                        items.push_back (MenuElem (_("Opaque"), mem_fun(*this, &Editor::toggle_region_opaque)));
 
1890
                }
1825
1891
        }
1826
1892
 
1827
1893
        items.push_back (CheckMenuElem (_("Original position"), mem_fun(*this, &Editor::naturalize)));
1828
 
        if (region->at_natural_position()) {
 
1894
        if (region && region->at_natural_position()) {
1829
1895
                items.back().set_sensitive (false);
1830
1896
        }
1831
1897
        
1913
1979
        items.push_back (MenuElem (_("Multi-Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), true))));
1914
1980
        items.push_back (MenuElem (_("Fill Track"), (mem_fun(*this, &Editor::region_fill_track))));
1915
1981
        items.push_back (SeparatorElem());
1916
 
        items.push_back (MenuElem (_("Remove"), mem_fun(*this, &Editor::remove_clicked_region)));
 
1982
        items.push_back (MenuElem (_("Remove"), mem_fun(*this, &Editor::remove_region)));
1917
1983
 
1918
1984
        /* OK, stick the region submenu at the top of the list, and then add
1919
1985
           the standard items.
1924
1990
        */
1925
1991
 
1926
1992
        string::size_type pos = 0;
1927
 
        string menu_item_name = region->name();
 
1993
        string menu_item_name = (region) ? region->name() : _("Selected regions");
1928
1994
 
1929
1995
        while ((pos = menu_item_name.find ("_", pos)) != string::npos) {
1930
1996
                menu_item_name.replace (pos, 1, "__");
1971
2037
        items.push_back (MenuElem (_("Duplicate range"), bind (mem_fun(*this, &Editor::duplicate_dialog), false)));
1972
2038
        items.push_back (MenuElem (_("Create chunk from range"), mem_fun(*this, &Editor::create_named_selection)));
1973
2039
        items.push_back (SeparatorElem());
1974
 
        items.push_back (MenuElem (_("Bounce range"), mem_fun(*this, &Editor::bounce_range_selection)));
 
2040
        items.push_back (MenuElem (_("Consolidate range"), bind (mem_fun(*this, &Editor::bounce_range_selection), true)));
 
2041
        items.push_back (MenuElem (_("Bounce range to region list"), bind (mem_fun(*this, &Editor::bounce_range_selection), false)));
1975
2042
        items.push_back (MenuElem (_("Export range"), mem_fun(*this, &Editor::export_selection)));
1976
2043
}
1977
2044
 
2275
2342
        move (x, y);
2276
2343
 
2277
2344
        if (session && (prop = node.property ("playhead"))) {
2278
 
                nframes_t pos = atol (prop->value().c_str());
 
2345
                nframes64_t pos = atol (prop->value().c_str());
2279
2346
                playhead_cursor->set_position (pos);
2280
2347
        } else {
2281
2348
                playhead_cursor->set_position (0);
2450
2517
 
2451
2518
        node->add_property ("edit-point", enum_2_string (_edit_point));
2452
2519
 
2453
 
        snprintf (buf, sizeof (buf), "%" PRIu32, playhead_cursor->current_frame);
 
2520
        snprintf (buf, sizeof (buf), "%" PRIi64, playhead_cursor->current_frame);
2454
2521
        node->add_property ("playhead", buf);
2455
2522
 
2456
2523
        node->add_property ("show-waveforms", _show_waveforms ? "yes" : "no");
2512
2579
        switch (snap_type) {
2513
2580
        case SnapToCDFrame:
2514
2581
                if (((direction == 0) && (start % (one_second/75) > (one_second/75) / 2)) || (direction > 0)) {
2515
 
                        start = (nframes_t) ceil ((double) start / (one_second / 75)) * (one_second / 75);
 
2582
                        start = (nframes64_t) ceil ((double) start / (one_second / 75)) * (one_second / 75);
2516
2583
                } else {
2517
 
                        start = (nframes_t) floor ((double) start / (one_second / 75)) * (one_second / 75);
 
2584
                        start = (nframes64_t) floor ((double) start / (one_second / 75)) * (one_second / 75);
2518
2585
                }
2519
2586
                break;
2520
2587
 
2521
2588
        case SnapToSMPTEFrame:
2522
2589
                if (((direction == 0) && (fmod((double)start, (double)session->frames_per_smpte_frame()) > (session->frames_per_smpte_frame() / 2))) || (direction > 0)) {
2523
 
                        start = (nframes_t) (ceil ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
 
2590
                        start = (nframes64_t) (ceil ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2524
2591
                } else {
2525
 
                        start = (nframes_t) (floor ((double) start / session->frames_per_smpte_frame()) *  session->frames_per_smpte_frame());
 
2592
                        start = (nframes64_t) (floor ((double) start / session->frames_per_smpte_frame()) *  session->frames_per_smpte_frame());
2526
2593
                }
2527
2594
                break;
2528
2595
 
2534
2601
                        start -= session->smpte_offset ();
2535
2602
                }    
2536
2603
                if (((direction == 0) && (start % one_smpte_second > one_smpte_second / 2)) || direction > 0) {
2537
 
                        start = (nframes_t) ceil ((double) start / one_smpte_second) * one_smpte_second;
 
2604
                        start = (nframes64_t) ceil ((double) start / one_smpte_second) * one_smpte_second;
2538
2605
                } else {
2539
 
                        start = (nframes_t) floor ((double) start / one_smpte_second) * one_smpte_second;
 
2606
                        start = (nframes64_t) floor ((double) start / one_smpte_second) * one_smpte_second;
2540
2607
                }
2541
2608
                
2542
2609
                if (session->smpte_offset_negative())
2555
2622
                        start -= session->smpte_offset ();
2556
2623
                }
2557
2624
                if (((direction == 0) && (start % one_smpte_minute > one_smpte_minute / 2)) || direction > 0) {
2558
 
                        start = (nframes_t) ceil ((double) start / one_smpte_minute) * one_smpte_minute;
 
2625
                        start = (nframes64_t) ceil ((double) start / one_smpte_minute) * one_smpte_minute;
2559
2626
                } else {
2560
 
                        start = (nframes_t) floor ((double) start / one_smpte_minute) * one_smpte_minute;
 
2627
                        start = (nframes64_t) floor ((double) start / one_smpte_minute) * one_smpte_minute;
2561
2628
                }
2562
2629
                if (session->smpte_offset_negative())
2563
2630
                {
2569
2636
                
2570
2637
        case SnapToSeconds:
2571
2638
                if (((direction == 0) && (start % one_second > one_second / 2)) || (direction > 0)) {
2572
 
                        start = (nframes_t) ceil ((double) start / one_second) * one_second;
 
2639
                        start = (nframes64_t) ceil ((double) start / one_second) * one_second;
2573
2640
                } else {
2574
 
                        start = (nframes_t) floor ((double) start / one_second) * one_second;
 
2641
                        start = (nframes64_t) floor ((double) start / one_second) * one_second;
2575
2642
                }
2576
2643
                break;
2577
2644
                
2578
2645
        case SnapToMinutes:
2579
2646
                if (((direction == 0) && (start % one_minute > one_minute / 2)) || (direction > 0)) {
2580
 
                        start = (nframes_t) ceil ((double) start / one_minute) * one_minute;
 
2647
                        start = (nframes64_t) ceil ((double) start / one_minute) * one_minute;
2581
2648
                } else {
2582
 
                        start = (nframes_t) floor ((double) start / one_minute) * one_minute;
 
2649
                        start = (nframes64_t) floor ((double) start / one_minute) * one_minute;
2583
2650
                }
2584
2651
                break;
2585
2652
 
2656
2723
        case SnapToRegionSync:
2657
2724
        case SnapToRegionBoundary:
2658
2725
                if (!region_boundary_cache.empty()) {
2659
 
                        vector<nframes_t>::iterator i;
 
2726
                        vector<nframes64_t>::iterator i;
2660
2727
 
2661
2728
                        if (direction > 0) {
2662
2729
                                i = std::upper_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
3491
3558
                        v->push_back (*i);
3492
3559
                }
3493
3560
 
3494
 
        } else if (track != 0 && group == 0 || (track != 0 && group != 0 && !group->is_active())) {
 
3561
        } else if ((track != 0 && group == 0) || (track != 0 && group != 0 && !group->is_active())) {
3495
3562
                
3496
3563
                /* just the view for this track
3497
3564
                 */
3681
3748
        return *_playlist_selector;
3682
3749
}
3683
3750
 
3684
 
nframes_t
3685
 
Editor::get_nudge_distance (nframes_t pos, nframes_t& next)
 
3751
nframes64_t
 
3752
Editor::get_nudge_distance (nframes64_t pos, nframes64_t& next)
3686
3753
{
3687
 
        nframes_t ret;
 
3754
        nframes64_t ret;
3688
3755
 
3689
3756
        ret = nudge_clock.current_duration (pos);
3690
3757
        next = ret + 1; /* XXXX fix me */
3736
3803
}
3737
3804
 
3738
3805
bool
3739
 
Editor::audio_region_selection_covers (nframes_t where)
 
3806
Editor::audio_region_selection_covers (nframes64_t where)
3740
3807
{
3741
3808
        for (RegionSelection::iterator a = selection->regions.begin(); a != selection->regions.end(); ++a) {
3742
3809
                if ((*a)->region()->covers (where)) {
3755
3822
 
3756
3823
        selection->clear_regions ();
3757
3824
        selection->clear_playlists ();
 
3825
 
 
3826
        no_region_list_redisplay = true;
 
3827
}
 
3828
 
 
3829
void
 
3830
Editor::finish_cleanup ()
 
3831
{
 
3832
        no_region_list_redisplay = false;
 
3833
        redisplay_regions ();
3758
3834
}
3759
3835
 
3760
3836
Location*
3973
4049
                post_maximal_pane_position = edit_pane.get_width();
3974
4050
        }
3975
4051
 
3976
 
 
3977
4052
        fullscreen();
 
4053
 
3978
4054
        if(post_maximal_editor_width) {
3979
4055
                edit_pane.set_position (post_maximal_pane_position - 
3980
4056
                        abs(post_maximal_editor_width - pre_maximal_editor_width));
4081
4157
}
4082
4158
 
4083
4159
void
4084
 
Editor::reset_x_origin (nframes_t frame)
 
4160
Editor::reset_x_origin (nframes64_t frame)
4085
4161
{
4086
4162
        queue_visual_change (frame);
4087
4163
}
4093
4169
}
4094
4170
 
4095
4171
void
4096
 
Editor::reposition_and_zoom (nframes_t frame, double fpu)
 
4172
Editor::reposition_and_zoom (nframes64_t frame, double fpu)
4097
4173
{
 
4174
        //cerr << "Editor::reposition_and_zoom () called ha v:l:u:ps:fpu = " << horizontal_adjustment.get_value() << ":" << horizontal_adjustment.get_lower() << ":" << horizontal_adjustment.get_upper() << ":" << horizontal_adjustment.get_page_size() << ":" << frames_per_unit << endl;//DEBUG
4098
4175
        reset_x_origin (frame);
4099
4176
        reset_zoom (fpu);
 
4177
 
 
4178
        if (!no_save_visual) {
 
4179
                undo_visual_stack.push_back (current_visual_state(false));
 
4180
        }
 
4181
}
 
4182
 
 
4183
Editor::VisualState*
 
4184
Editor::current_visual_state (bool with_tracks)
 
4185
{
 
4186
        VisualState* vs = new VisualState;
 
4187
        vs->y_position = vertical_adjustment.get_value();
 
4188
        vs->frames_per_unit = frames_per_unit;
 
4189
        vs->leftmost_frame = leftmost_frame;
 
4190
        vs->zoom_focus = zoom_focus;
 
4191
        vs->zoomed_to_region = zoomed_to_region;
 
4192
 
 
4193
        if (with_tracks) {
 
4194
                for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
 
4195
                        vs->track_states.push_back (TAVState ((*i), &(*i)->get_state()));
 
4196
                }
 
4197
        }
 
4198
        
 
4199
        return vs;
 
4200
}
 
4201
 
 
4202
void
 
4203
Editor::undo_visual_state ()
 
4204
{
 
4205
        if (undo_visual_stack.empty()) {
 
4206
                return;
 
4207
        }
 
4208
 
 
4209
        VisualState* vs = undo_visual_stack.back();
 
4210
        undo_visual_stack.pop_back();
 
4211
        use_visual_state (*vs);
 
4212
        redo_visual_stack.push_back (vs);
 
4213
}
 
4214
 
 
4215
void
 
4216
Editor::redo_visual_state ()
 
4217
{
 
4218
        if (redo_visual_stack.empty()) {
 
4219
                return;
 
4220
        }
 
4221
 
 
4222
        VisualState* vs = redo_visual_stack.back();
 
4223
        redo_visual_stack.pop_back();
 
4224
        use_visual_state (*vs);
 
4225
        undo_visual_stack.push_back (vs);
4100
4226
}
4101
4227
 
4102
4228
void
4103
4229
Editor::swap_visual_state ()
4104
4230
{
4105
 
        if (last_visual_state.frames_per_unit == 0) {
4106
 
                // never set
4107
 
                return;
4108
 
        }
4109
 
 
4110
 
        /* note: the correct functionality here is very dependent on the ordering of 
4111
 
           setting zoom focus, horizontal position and finally zoom. this is because
4112
 
           it is set_frames_per_unit() that overwrites last_visual_state.
4113
 
        */
4114
 
 
4115
 
        set_zoom_focus (last_visual_state.zoom_focus);
4116
 
        reposition_and_zoom (last_visual_state.leftmost_frame, last_visual_state.frames_per_unit);
4117
 
        zoomed_to_region = false;
 
4231
        if (undo_visual_stack.empty()) {
 
4232
                redo_visual_state ();
 
4233
        } else {
 
4234
                undo_visual_state ();
 
4235
        }
 
4236
}
 
4237
 
 
4238
void
 
4239
Editor::use_visual_state (VisualState& vs)
 
4240
{
 
4241
        no_save_visual = true;
 
4242
 
 
4243
        vertical_adjustment.set_value (vs.y_position);
 
4244
 
 
4245
        set_zoom_focus (vs.zoom_focus);
 
4246
        reposition_and_zoom (vs.leftmost_frame, vs.frames_per_unit);
 
4247
 
 
4248
        for (list<TAVState>::iterator i = vs.track_states.begin(); i != vs.track_states.end(); ++i) {
 
4249
                TrackViewList::iterator t;
 
4250
 
 
4251
                /* check if the track still exists - it could have been deleted */
 
4252
 
 
4253
                if ((t = find (track_views.begin(), track_views.end(), i->first)) != track_views.end()) {
 
4254
                        (*t)->set_state (*(i->second));
 
4255
                }
 
4256
        }
 
4257
 
 
4258
        if (!vs.track_states.empty()) {
 
4259
                update_route_visibility ();
 
4260
        } 
 
4261
        
 
4262
        no_save_visual = false;
4118
4263
}
4119
4264
 
4120
4265
void
4144
4289
        if (fpu == frames_per_unit) {
4145
4290
                return;
4146
4291
        }
4147
 
        
4148
 
        last_visual_state.frames_per_unit = frames_per_unit;
4149
 
        last_visual_state.leftmost_frame = leftmost_frame;
4150
 
        last_visual_state.zoom_focus = zoom_focus;
4151
4292
 
4152
4293
        frames_per_unit = fpu;
4153
4294
        post_zoom ();
4158
4299
{
4159
4300
        // convert fpu to frame count
4160
4301
 
4161
 
        nframes_t frames = (nframes_t) floor (frames_per_unit * canvas_width);
 
4302
        nframes64_t frames = (nframes64_t) floor (frames_per_unit * canvas_width);
4162
4303
 
4163
4304
        if (frames_per_unit != zoom_range_clock.current_duration()) {
4164
4305
                zoom_range_clock.set (frames);
4187
4328
}
4188
4329
 
4189
4330
void
4190
 
Editor::queue_visual_change (nframes_t where)
 
4331
Editor::queue_visual_change (nframes64_t where)
4191
4332
{
4192
4333
        pending_visual_change.pending = VisualChange::Type (pending_visual_change.pending | VisualChange::TimeOrigin);
4193
4334
        pending_visual_change.time_origin = where;
4194
 
        
 
4335
 
4195
4336
        if (pending_visual_change.idle_handler_id < 0) {
4196
4337
                pending_visual_change.idle_handler_id = g_idle_add (_idle_visual_changer, this);
4197
4338
        }
4218
4359
Editor::idle_visual_changer ()
4219
4360
{
4220
4361
        VisualChange::Type p = pending_visual_change.pending;
 
4362
        nframes64_t csf, cef;
 
4363
 
 
4364
        if (session) {
 
4365
                csf = session->current_start_frame();
 
4366
                cef = session->current_end_frame() + (current_page_frames() / 24);// Add a little extra so we can see the end marker
 
4367
        }
4221
4368
 
4222
4369
        pending_visual_change.pending = (VisualChange::Type) 0;
4223
4370
        pending_visual_change.idle_handler_id = -1;
4228
4375
 
4229
4376
        if (p & VisualChange::TimeOrigin) {
4230
4377
                
4231
 
                nframes_t time_origin = (nframes_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
 
4378
                nframes64_t time_origin = (nframes64_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
 
4379
 
 
4380
                /* if we seek beyond the current end of the canvas, move the end */
4232
4381
 
4233
4382
                if (time_origin != pending_visual_change.time_origin) {
 
4383
                        
 
4384
                        if (horizontal_adjustment.get_upper() < pending_visual_change.time_origin) {
 
4385
                                last_canvas_frame = (cef > (pending_visual_change.time_origin + current_page_frames())) ? cef : pending_visual_change.time_origin + current_page_frames();
 
4386
                                horizontal_adjustment.set_upper ((cef - csf) / frames_per_unit);
 
4387
                                reset_scrolling_region ();
 
4388
                        }
 
4389
                        
4234
4390
                        horizontal_adjustment.set_value (pending_visual_change.time_origin/frames_per_unit);
4235
4391
                } else {
4236
4392
                        update_fixed_rulers();
4237
4393
                        redisplay_tempo (true);
4238
4394
                }
4239
4395
        }
4240
 
 
 
4396
        //cerr << "Editor::idle_visual_changer () called ha v:l:u:ps:fpu = " << horizontal_adjustment.get_value() << ":" << horizontal_adjustment.get_lower() << ":" << horizontal_adjustment.get_upper() << ":" << horizontal_adjustment.get_page_size() << ":" << frames_per_unit << endl;//DEBUG
4241
4397
        return 0; /* this is always a one-shot call */
4242
4398
}
4243
4399
 
4308
4464
}
4309
4465
 
4310
4466
void
4311
 
Editor::set_loop_range (nframes_t start, nframes_t end, string cmd)
 
4467
Editor::set_loop_range (nframes64_t start, nframes64_t end, string cmd)
4312
4468
{
4313
4469
        if (!session) return;
4314
4470
 
4335
4491
}
4336
4492
 
4337
4493
void
4338
 
Editor::set_punch_range (nframes_t start, nframes_t end, string cmd)
 
4494
Editor::set_punch_range (nframes64_t start, nframes64_t end, string cmd)
4339
4495
{
4340
4496
        if (!session) return;
4341
4497
 
4383
4539
                        
4384
4540
                        if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()))) {
4385
4541
 
4386
 
                                Playlist::RegionList* regions = pl->regions_at ((nframes_t) floor ( (double)where * ds->speed()));
 
4542
                                Playlist::RegionList* regions = pl->regions_at ((nframes64_t) floor ( (double)where * ds->speed()));
4387
4543
 
4388
4544
                                for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
4389
4545
 
4390
4546
                                        RegionView* rv = atv->audio_view()->find_view (*i);
4391
4547
 
4392
4548
                                        if (rv) {
4393
 
                                                rs.push_back (rv);
 
4549
                                                rs.add (rv);
4394
4550
                                        }
4395
4551
                                }
4396
4552
 
4421
4577
                        
4422
4578
                        if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()))) {
4423
4579
 
4424
 
                                Playlist::RegionList* regions = pl->regions_touched ((nframes_t) floor ( (double)where * ds->speed()), max_frames);
 
4580
                                Playlist::RegionList* regions = pl->regions_touched ((nframes64_t) floor ( (double)where * ds->speed()), max_frames);
4425
4581
 
4426
4582
                                for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
4427
4583
 
4567
4723
 
4568
4724
        _have_idled = true;
4569
4725
}
 
4726
 
 
4727
void
 
4728
Editor::start_resize_line_ops ()
 
4729
{
 
4730
#if 0
 
4731
        old_resize_line_y = -1;
 
4732
        resize_line_y = -1;
 
4733
        need_resize_line = true;
 
4734
#endif  
 
4735
}
 
4736
 
 
4737
void
 
4738
Editor::end_resize_line_ops ()
 
4739
{
 
4740
#if 0
 
4741
        need_resize_line = false;
 
4742
 
 
4743
        if (old_resize_line_y >= 0) {
 
4744
                Gdk::Rectangle r (0, old_resize_line_y, (int) canvas_width, 3);
 
4745
                Glib::RefPtr<Gdk::Window> win = get_window();
 
4746
                cerr << "Final invalidation at " << old_resize_line_y << endl;
 
4747
                win->invalidate_rect (r, false);
 
4748
        }
 
4749
#endif
 
4750
}
 
4751
 
 
4752
void
 
4753
Editor::queue_draw_resize_line (int at)
 
4754
{
 
4755
#if 0   
 
4756
        Glib::RefPtr<Gdk::Window> win = get_window();
 
4757
 
 
4758
        resize_line_y = at;
 
4759
 
 
4760
        if (win && canvas_width) {
 
4761
 
 
4762
                int controls_width = controls_layout.get_width();
 
4763
                int xroot, discard;
 
4764
                
 
4765
                controls_layout.get_window()->get_origin (xroot, discard);
 
4766
 
 
4767
                if (old_resize_line_y >= 0) {
 
4768
                        
 
4769
                        /* redraw where it used to be */
 
4770
                        
 
4771
                        
 
4772
                        Gdk::Rectangle r (xroot, old_resize_line_y - 1, controls_width + (int) canvas_width, 3);
 
4773
                        win->invalidate_rect (r, true);
 
4774
                        cerr << "invalidate " << xroot << "," << old_resize_line_y - 1 << ' ' 
 
4775
                             << controls_width + canvas_width << " x 3\n";
 
4776
                }
 
4777
 
 
4778
                /* draw where it is */
 
4779
 
 
4780
                Gdk::Rectangle r (xroot, at - 1, controls_width + (int) canvas_width, 3);
 
4781
                win->invalidate_rect (r, true);
 
4782
        }
 
4783
#endif
 
4784
}
 
4785
 
 
4786
bool
 
4787
Editor::on_expose_event (GdkEventExpose* ev)
 
4788
{
 
4789
        /* cerr << "+++ editor expose "
 
4790
             << ev->area.x << ',' << ev->area.y
 
4791
             << ' '
 
4792
             << ev->area.width << " x " << ev->area.height
 
4793
             << " need reize ? " << need_resize_line
 
4794
             << endl;
 
4795
        */
 
4796
        bool ret = Window::on_expose_event (ev);
 
4797
 
 
4798
#if 0
 
4799
        if (need_resize_line) {
 
4800
                
 
4801
                int xroot, yroot, discard;
 
4802
                int controls_width;
 
4803
 
 
4804
                /* Our root coordinates for drawing the line will be the left edge 
 
4805
                   of the track controls, and the upper left edge of our own window.
 
4806
                */
 
4807
 
 
4808
                get_window()->get_origin (discard, yroot);
 
4809
                controls_layout.get_window()->get_origin (xroot, discard);
 
4810
                controls_width = controls_layout.get_width();
 
4811
                
 
4812
                GdkRectangle lr;
 
4813
                GdkRectangle intersection;
 
4814
 
 
4815
                lr.x = xroot;
 
4816
                lr.y = resize_line_y;
 
4817
                lr.width = controls_width + (int) canvas_width;
 
4818
                lr.height = 3;
 
4819
 
 
4820
                if (gdk_rectangle_intersect (&lr, &ev->area, &intersection)) {
 
4821
                        
 
4822
                        Glib::RefPtr<Gtk::Style> style (get_style());
 
4823
                        Glib::RefPtr<Gdk::GC> black_gc (style->get_black_gc ());
 
4824
                        Glib::RefPtr<Gdk::GC> gc = wrap (black_gc->gobj_copy(), false);
 
4825
 
 
4826
                        /* draw on root window */
 
4827
 
 
4828
                        GdkWindow* win = gdk_get_default_root_window();
 
4829
                        
 
4830
                        gc->set_subwindow (Gdk::INCLUDE_INFERIORS);
 
4831
                        gc->set_line_attributes (3, Gdk::LINE_SOLID, 
 
4832
                                                 Gdk::CAP_NOT_LAST,
 
4833
                                                 Gdk::JOIN_MITER);
 
4834
                        
 
4835
                        gdk_draw_line (win, gc->gobj(), 
 
4836
                                       xroot,
 
4837
                                       yroot + resize_line_y, 
 
4838
                                       xroot + (int) canvas_width + controls_width,
 
4839
                                       yroot + resize_line_y);
 
4840
                        cerr << "drew line @ " << xroot << ", " << yroot + resize_line_y 
 
4841
                             << " to " << xroot + (int) canvas_width + controls_width
 
4842
                             << ", " << yroot + resize_line_y
 
4843
                             << endl;
 
4844
                        old_resize_line_y = yroot + resize_line_y;
 
4845
                        cerr << "NEXT EXPOSE SHOULD BE AT " << old_resize_line_y << endl;
 
4846
                } else {
 
4847
                        cerr << "no intersect with "
 
4848
                             << lr.x << ',' << lr.y
 
4849
                             << ' '
 
4850
                             << lr.width << " x " << lr.height
 
4851
                             << endl;
 
4852
                }
 
4853
        }
 
4854
 
 
4855
        //cerr << "--- editor expose\n";
 
4856
#endif
 
4857
 
 
4858
        return ret;
 
4859
}
 
4860
 
 
4861
static gboolean
 
4862
_idle_resizer (gpointer arg)
 
4863
{
 
4864
        return ((Editor*)arg)->idle_resize ();
 
4865
}
 
4866
 
 
4867
void
 
4868
Editor::add_to_idle_resize (TimeAxisView* view, uint32_t h)
 
4869
{
 
4870
        if (resize_idle_id < 0) {
 
4871
                resize_idle_id = g_idle_add (_idle_resizer, this);
 
4872
        }
 
4873
 
 
4874
        resize_idle_target = h;
 
4875
 
 
4876
        pending_resizes.push_back (view);
 
4877
 
 
4878
        if (!selection->tracks.empty()) {
 
4879
                pending_resizes.insert (pending_resizes.end(), selection->tracks.begin(), selection->tracks.end());
 
4880
        }
 
4881
}
 
4882
 
 
4883
bool
 
4884
Editor::idle_resize ()
 
4885
{
 
4886
        for (vector<TimeAxisView*>::iterator i = pending_resizes.begin(); i != pending_resizes.end(); ++i) {
 
4887
                (*i)->idle_resize (resize_idle_target);
 
4888
        }
 
4889
        pending_resizes.clear();
 
4890
        resize_idle_id = -1;
 
4891
        return false;
 
4892
}