Skip to content

Commit

Permalink
Opening a layer map that is already opened activates the correspondin…
Browse files Browse the repository at this point in the history
…g tab instead of adding a new one.
  • Loading branch information
aferrero2707 committed Aug 30, 2015
1 parent b2c2964 commit f7ec7a8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/gui/layerwidget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,12 @@ void PF::LayerWidget::on_row_activated( const Gtk::TreeModel::Path& path, Gtk::T
std::cout<<"Activated IMap column of row "<<l->get_name()<<std::endl;
//Gtk::ScrolledWindow* frame = new Gtk::ScrolledWindow();

int tab_id = get_map_tab( &(l->get_imap_layers()) );
if( tab_id >= 0 ) {
notebook.set_current_page( tab_id );
return;
}

LayerTree* view = new LayerTree( editor, true );
//frame->add( *view );

Expand Down Expand Up @@ -374,6 +380,12 @@ void PF::LayerWidget::on_row_activated( const Gtk::TreeModel::Path& path, Gtk::T
std::cout<<"Activated OMap column of row "<<l->get_name()<<std::endl;
//Gtk::ScrolledWindow* frame = new Gtk::ScrolledWindow();

int tab_id = get_map_tab( &(l->get_omap_layers()) );
if( tab_id >= 0 ) {
notebook.set_current_page( tab_id );
return;
}

LayerTree* view = new LayerTree( editor, true );
//frame->add( *view );

Expand Down Expand Up @@ -677,6 +689,19 @@ void PF::LayerWidget::insert_preset( std::string filename )
}


int PF::LayerWidget::get_map_tab( std::list<Layer*>* map_layers )
{
for( int i = notebook.get_n_pages()-1; i>=1; i-- ) {
Widget* page = notebook.get_nth_page(i);
LayerTree* view = dynamic_cast<LayerTree*>( page );
if( !view ) continue;
std::list<Layer*>* view_layers = view->get_layers();
if( view_layers == map_layers ) return i;
}
return -1;
}



void PF::LayerWidget::close_map_tabs( Layer* l )
{
Expand Down
1 change: 1 addition & 0 deletions src/gui/layerwidget.hh
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class LayerWidget : public Gtk::VBox

void detach_controls( Layer* l );
void detach_controls( std::list<Layer*>& layers );
int get_map_tab( std::list<Layer*>* map_layers );
void close_map_tabs( Layer* l );

public:
Expand Down

0 comments on commit f7ec7a8

Please sign in to comment.