1
Fork 0

show cursor & proper reset on load

This commit is contained in:
Leonard Ritter 2010-02-16 07:40:50 +01:00
parent 6a6c362dca
commit 0f87559c31
5 changed files with 38 additions and 1 deletions

View File

@ -210,6 +210,8 @@ public:
}
void model_changed() {
pattern_view->reset();
song_view->reset();
pattern_view->set_song_event(model.song.end());
song_view->set_loop(model.loop);
update_measures();

View File

@ -1109,6 +1109,10 @@ void PatternView::set_cursor(const PatternCursor &new_cursor, bool select/*=fals
update_navigation_status();
}
void PatternView::reset() {
song_event = model->song.end();
}
void PatternView::show_cursor(const PatternCursor &cur, bool page_jump/*=false*/) {
if (hadjustment) {
int channel = cur.get_channel();

View File

@ -302,7 +302,7 @@ public:
void cycle_block_selection();
void move_frames(int step, bool all_channels=false);
void reset();
type_play_event_request signal_play_event_request();
type_return_request signal_return_request();

View File

@ -665,6 +665,8 @@ void SongView::do_move(int ofs_frame, int ofs_track) {
selection = new_selection;
invalidate_selection();
}
show_selection();
}
void SongView::apply_move() {
@ -687,6 +689,7 @@ void SongView::do_resize(int ofs_frame) {
}
invalidate();
show_selection();
}
void SongView::apply_resize() {
@ -721,6 +724,7 @@ void SongView::select_first(bool increment) {
if (!increment)
clear_selection();
select_event(model->song.begin());
show_selection();
}
void SongView::select_last(bool increment) {
@ -731,6 +735,12 @@ void SongView::select_last(bool increment) {
if (!increment)
clear_selection();
select_event(iter);
show_selection();
}
void SongView::reset() {
selection.clear();
invalidate();
}
Song::iterator SongView::get_left_event(Song::iterator start) {
@ -815,6 +825,8 @@ void SongView::navigate(int dir_x, int dir_y, bool increment) {
clear_selection();
select_event(iter);
}
show_selection();
}
bool SongView::get_selection_range(int &frame_begin, int &frame_end,
@ -987,6 +999,21 @@ void SongView::on_size_allocate(Gtk::Allocation& allocation) {
}
}
void SongView::show_selection() {
int f0,f1,t0,t1;
if (!get_selection_range(f0,f1,t0,t1))
return;
int step = model->get_frames_per_bar()*4;
if (hadjustment) {
int value = hadjustment->get_value();
int page_size = hadjustment->get_page_size();
if (f0 < value)
hadjustment->clamp_page(f0-step,f1);
else if (f1 >= (value+page_size))
hadjustment->clamp_page(f0,f1+step);
}
}
int absmod(int x, int m) {
return (x >= 0)?(x%m):((m-x)%m);
}

View File

@ -135,6 +135,8 @@ public:
void set_loop_begin();
void set_loop_end();
void reset();
type_pattern_edit_request signal_pattern_edit_request();
type_context_menu signal_context_menu();
type_loop_changed signal_loop_changed();
@ -177,6 +179,8 @@ protected:
void clone_selection(bool references=false);
void join_selection();
void show_selection();
// zoomlevel (0=1:1, 1=1:2, 2=1:4, etc.)
int zoomlevel;