From f60794f0352a1e48f28c9eb5b20c819cbfa1507b Mon Sep 17 00:00:00 2001 From: Mattia Basaglia Date: Sun, 19 Jul 2015 09:36:05 +0200 Subject: [PATCH] Add flip buttons to the patch texture dialog --- radiant/patchdialog.cpp | 34 ++++++++++++++++++++++++++++++---- radiant/patchmanip.h | 2 ++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/radiant/patchdialog.cpp b/radiant/patchdialog.cpp index db3c4ebb..6bacd9f8 100644 --- a/radiant/patchdialog.cpp +++ b/radiant/patchdialog.cpp @@ -391,6 +391,14 @@ static void OnBtnPatchreset( GtkWidget *widget, gpointer data ){ Patch_ResetTexture(); } +static void OnBtnPatchFlipX( GtkWidget *widget, gpointer data ){ + Patch_FlipTextureX(); +} + +static void OnBtnPatchFlipY( GtkWidget *widget, gpointer data ){ + Patch_FlipTextureY(); +} + struct PatchRotateTexture { float m_angle; @@ -815,7 +823,7 @@ GtkWindow* PatchInspector::BuildDialog(){ g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 ); } { - GtkTable* table = GTK_TABLE( gtk_table_new( 5, 3, FALSE ) ); + GtkTable* table = GTK_TABLE( gtk_table_new( 5, 4, FALSE ) ); gtk_widget_show( GTK_WIDGET( table ) ); gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); gtk_table_set_row_spacings( table, 5 ); @@ -823,7 +831,7 @@ GtkWindow* PatchInspector::BuildDialog(){ { GtkLabel* label = GTK_LABEL( gtk_label_new( "Horizontal Shift Step" ) ); gtk_widget_show( GTK_WIDGET( label ) ); - gtk_table_attach( table, GTK_WIDGET( label ), 2, 3, 0, 1, + gtk_table_attach( table, GTK_WIDGET( label ), 2, 4, 0, 1, (GtkAttachOptions)( GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); @@ -831,7 +839,7 @@ GtkWindow* PatchInspector::BuildDialog(){ { GtkLabel* label = GTK_LABEL( gtk_label_new( "Vertical Shift Step" ) ); gtk_widget_show( GTK_WIDGET( label ) ); - gtk_table_attach( table, GTK_WIDGET( label ), 2, 3, 1, 2, + gtk_table_attach( table, GTK_WIDGET( label ), 2, 4, 1, 2, (GtkAttachOptions)( GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); @@ -844,6 +852,15 @@ GtkWindow* PatchInspector::BuildDialog(){ (GtkAttachOptions)( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } + { + GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "Flip" ) ); + gtk_widget_show( GTK_WIDGET( button ) ); + gtk_table_attach( table, GTK_WIDGET( button ), 3, 4, 2, 3, + (GtkAttachOptions)( GTK_FILL ), + (GtkAttachOptions)( 0 ), 0, 0 ); + g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchFlipX ), 0 ); + gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 ); + } { GtkLabel* label = GTK_LABEL( gtk_label_new( "Vertical Stretch Step" ) ); gtk_widget_show( GTK_WIDGET( label ) ); @@ -852,10 +869,19 @@ GtkWindow* PatchInspector::BuildDialog(){ (GtkAttachOptions)( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } + { + GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "Flip" ) ); + gtk_widget_show( GTK_WIDGET( button ) ); + gtk_table_attach( table, GTK_WIDGET( button ), 3, 4, 3, 4, + (GtkAttachOptions)( GTK_FILL ), + (GtkAttachOptions)( 0 ), 0, 0 ); + g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchFlipY ), 0 ); + gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 ); + } { GtkLabel* label = GTK_LABEL( gtk_label_new( "Rotate Step" ) ); gtk_widget_show( GTK_WIDGET( label ) ); - gtk_table_attach( table, GTK_WIDGET( label ), 2, 3, 4, 5, + gtk_table_attach( table, GTK_WIDGET( label ), 2, 4, 4, 5, (GtkAttachOptions)( GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); diff --git a/radiant/patchmanip.h b/radiant/patchmanip.h index c6646898..d6d8764c 100644 --- a/radiant/patchmanip.h +++ b/radiant/patchmanip.h @@ -55,6 +55,8 @@ void Patch_NaturalTexture(); void Patch_CapTexture(); void Patch_ResetTexture(); void Patch_FitTexture(); +void Patch_FlipTextureX(); +void Patch_FlipTextureY(); class PatchCreator; extern PatchCreator* g_patchCreator; -- 2.39.2