Adjusting Focus 2d View for multiselect

This commit is contained in:
Pan7 2017-07-06 21:47:16 +02:00
parent e23b567c7f
commit 8ea1da552a

View file

@ -1174,36 +1174,23 @@ static void entitylist_multiselect( GtkWidget *widget, gpointer data ) {
Sys_UpdateWindows( W_ALL ); Sys_UpdateWindows( W_ALL );
} }
static void entitylist_focus( GtkWidget *widget, gpointer data ){ static void entity_focus_2d( entity_t *pEntity ) {
GtkTreeView* view = GTK_TREE_VIEW( g_object_get_data( G_OBJECT( data ), "entities" ) );
GtkTreeSelection* selection = gtk_tree_view_get_selection( view );
GtkTreeModel* model;
GtkTreeIter selected;
if ( gtk_tree_selection_get_selected( selection, &model, &selected ) ) {
entity_t* pEntity;
gtk_tree_model_get( model, &selected, 1, &pEntity, -1 );
if ( pEntity ) { if ( pEntity ) {
for ( epair_t* pEpair = pEntity->epairs; pEpair; pEpair = pEpair->next ) for ( epair_t* pEpair = pEntity->epairs; pEpair; pEpair = pEpair->next )
{ {
brush_t *b; brush_t *b;
b = pEntity->brushes.onext; b = pEntity->brushes.onext;
if( b ) if ( b ) {
{
int i; int i;
for ( i = 0; i < 3; i++ ) for ( i = 0; i < 3; i++ )
{ {
if ( g_pParentWnd->GetXYWnd() ) { if ( g_pParentWnd->GetXYWnd() ) {
g_pParentWnd->GetXYWnd()->GetOrigin()[i] = ( b->mins[i] + b->maxs[i] ) / 2; g_pParentWnd->GetXYWnd()->GetOrigin()[i] = ( b->mins[i] + b->maxs[i] ) / 2;
} }
if ( g_pParentWnd->GetXZWnd() ) { if ( g_pParentWnd->GetXZWnd() ) {
g_pParentWnd->GetXZWnd()->GetOrigin()[i] = ( b->mins[i] + b->maxs[i] ) / 2; g_pParentWnd->GetXZWnd()->GetOrigin()[i] = ( b->mins[i] + b->maxs[i] ) / 2;
} }
if ( g_pParentWnd->GetYZWnd() ) { if ( g_pParentWnd->GetYZWnd() ) {
g_pParentWnd->GetYZWnd()->GetOrigin()[i] = ( b->mins[i] + b->maxs[i] ) / 2; g_pParentWnd->GetYZWnd()->GetOrigin()[i] = ( b->mins[i] + b->maxs[i] ) / 2;
} }
@ -1213,11 +1200,40 @@ static void entitylist_focus( GtkWidget *widget, gpointer data ){
} }
} }
} }
static void entitylist_focus( GtkWidget *widget, gpointer data ){
GtkTreeView* view = GTK_TREE_VIEW( g_object_get_data( G_OBJECT( data ), "entities" ) );
GtkTreeSelection* selection = gtk_tree_view_get_selection( view );
GtkTreeModel* model;
GtkTreeIter selected;
entity_t* pEntity;
if ( gtk_tree_selection_get_mode( selection ) == GTK_SELECTION_MULTIPLE ) {
GList *rows, *first;
rows = gtk_tree_selection_get_selected_rows( selection, &model );
//only the keys/values of the last selected node with entity
first = g_list_first( rows );
if ( first ) {
if ( gtk_tree_model_get_iter( model, &selected, (GtkTreePath *)first->data ) == TRUE ) {
gtk_tree_model_get( model, &selected, 1, &pEntity, -1 );
entity_focus_2d( pEntity );
}
}
g_list_free_full( rows, (GDestroyNotify)gtk_tree_path_free );
} else if ( gtk_tree_selection_get_selected( selection, &model, &selected ) ) {
gtk_tree_model_get( model, &selected, 1, &pEntity, -1 );
entity_focus_2d( pEntity );
}
} }
static gint entitylist_click( GtkWidget *widget, GdkEventButton *event, gpointer data ){ static gint entitylist_click( GtkWidget *widget, GdkEventButton *event, gpointer data ){
if ( event->type == GDK_2BUTTON_PRESS ) { if ( event->type == GDK_2BUTTON_PRESS ) {
entitylist_select( NULL, data ); entitylist_multiselect( NULL, data );
return TRUE; return TRUE;
} }
return FALSE; return FALSE;