2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 // Surface Dialog Module
27 // Nurail: Implemented to Module from the main Radiant Surface Dialog code
32 #include <gdk/gdkkeysyms.h>
34 #include "surfdlg_plugin.h"
42 #include "gtkr_vector.h"
44 vector<texdef_to_face_t> g_texdef_face_vector;
46 inline texdef_to_face_t* get_texdef_face_list(){
47 return &( *g_texdef_face_vector.begin() );
50 inline unsigned int texdef_face_list_empty(){
51 return g_texdef_face_vector.empty();
54 inline unsigned int texdef_face_list_size(){
55 return g_texdef_face_vector.size();
58 // For different faces having different values
59 bool is_HShift_conflicting;
60 bool is_VShift_conflicting;
61 bool is_HScale_conflicting;
62 bool is_VScale_conflicting;
63 bool is_Rotate_conflicting;
64 bool is_TextureName_conflicting;
69 void GetTexMods( bool b_SetUndoPoint = FALSE );
72 void InitDefaultIncrement( texdef_t * );
73 void DoSnapTToGrid( float hscale, float vscale );
74 // called to perform a fitting from the outside (shortcut key)
75 void SurfaceDialogFitAll();
82 // 0 is invalid, otherwise it's the Id of the last 'do' we are responsible for
86 texturewin_t *texturewin;
87 texdef_t *l_pIncrement;
88 texdef_t texdef_offset;
89 texdef_t texdef_SI_values;
91 // For Texture Entry, activate only on entry change
92 char old_texture_entry[128];
94 // the texdef to switch back to when the OnCancel is called
95 texdef_t g_old_texdef;
97 // when TRUE, this thing means the surface inspector is currently being displayed
98 bool g_surfwin = FALSE;
99 // turn on/off processing of the "changed" "value_changed" messages
100 // (need to turn off when we are feeding data in)
101 bool g_bListenChanged = true;
102 // turn on/off listening of the update messages
103 bool g_bListenUpdate = true;
105 GtkWidget* create_SurfaceInspector( void );
106 GtkWidget *SurfaceInspector = NULL;
108 GtkWidget *m_pWidget;
109 GtkWidget *GetWidget() { return SurfaceInspector; }
110 GtkWidget *Get_SI_Module_Widget() { return SurfaceInspector; }
111 void SetWidget( GtkWidget *new_widget ) { m_pWidget = new_widget; }
112 GtkWidget *GetDlgWidget( const char* name )
113 { return GTK_WIDGET( g_object_get_data( G_OBJECT( SurfaceInspector ), name ) ); }
115 // Spins for FitTexture
116 GtkWidget *spin_width;
117 GtkWidget *spin_height;
120 GtkWidget *texture_combo;
121 GtkWidget *texture_combo_entry;
123 GtkWidget *match_grid_button;
124 GtkWidget *lock_valuechange_togglebutton;
126 GtkObject *hshift_value_spinbutton_adj;
127 GtkWidget *hshift_value_spinbutton;
128 GtkObject *vshift_value_spinbutton_adj;
129 GtkWidget *vshift_value_spinbutton;
130 GtkObject *hscale_value_spinbutton_adj;
131 GtkWidget *hscale_value_spinbutton;
132 GtkObject *vscale_value_spinbutton_adj;
133 GtkWidget *vscale_value_spinbutton;
134 GtkObject *rotate_value_spinbutton_adj;
135 GtkWidget *rotate_value_spinbutton;
137 GtkObject *hshift_offset_spinbutton_adj;
138 GtkWidget *hshift_offset_spinbutton;
139 GtkObject *vshift_offset_spinbutton_adj;
140 GtkWidget *vshift_offset_spinbutton;
141 GtkObject *hscale_offset_spinbutton_adj;
142 GtkWidget *hscale_offset_spinbutton;
143 GtkObject *vscale_offset_spinbutton_adj;
144 GtkWidget *vscale_offset_spinbutton;
145 GtkObject *rotate_offset_spinbutton_adj;
146 GtkWidget *rotate_offset_spinbutton;
148 GtkObject *hshift_step_spinbutton_adj;
149 GtkWidget *hshift_step_spinbutton;
150 GtkObject *vshift_step_spinbutton_adj;
151 GtkWidget *vshift_step_spinbutton;
152 GtkObject *hscale_step_spinbutton_adj;
153 GtkWidget *hscale_step_spinbutton;
154 GtkObject *vscale_step_spinbutton_adj;
155 GtkWidget *vscale_step_spinbutton;
156 GtkObject *rotate_step_spinbutton_adj;
157 GtkWidget *rotate_step_spinbutton;
159 GtkObject *fit_width_spinbutton_adj;
160 GtkWidget *fit_width_spinbutton;
161 GtkObject *fit_height_spinbutton_adj;
162 GtkWidget *fit_height_spinbutton;
163 GtkWidget *fit_button;
164 GtkWidget *axial_button;
166 GtkWidget *done_button;
167 GtkWidget *apply_button;
168 GtkWidget *cancel_button;
171 gboolean on_texture_combo_entry_key_press_event( GtkWidget *widget, GdkEventKey *event, gpointer user_data );
172 void on_texture_combo_entry_activate( GtkEntry *entry, gpointer user_data );
174 static void on_match_grid_button_clicked( GtkButton *button, gpointer user_data );
175 static void on_lock_valuechange_togglebutton_toggled( GtkToggleButton *togglebutton, gpointer user_data );
177 static void on_hshift_value_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data );
178 static void on_vshift_value_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data );
179 static void on_hscale_value_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data );
180 static void on_vscale_value_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data );
181 static void on_rotate_value_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data );
183 static void on_hshift_offset_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data );
184 static void on_vshift_offset_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data );
185 static void on_hscale_offset_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data );
186 static void on_vscale_offset_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data );
187 static void on_rotate_offset_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data );
189 static void on_hshift_step_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data );
190 static void on_vshift_step_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data );
191 static void on_hscale_step_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data );
192 static void on_vscale_step_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data );
193 static void on_rotate_step_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data );
195 static void on_fit_width_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data );
196 static void on_fit_height_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data );
197 static void on_fit_button_clicked( GtkButton *button, gpointer user_data );
198 static void on_axial_button_clicked( GtkButton *button, gpointer user_data );
200 static void on_done_button_clicked( GtkButton *button, gpointer user_data );
201 static void on_apply_button_clicked( GtkButton *button, gpointer user_data );
202 static void on_cancel_button_clicked( GtkButton *button, gpointer user_data );
206 ===================================================
210 ===================================================
214 void IsFaceConflicting(){
215 texdef_t* tmp_texdef;
216 texdef_to_face_t* temp_texdef_face_list;
218 char texture_name[128];
220 if ( texdef_face_list_empty() ) {
221 gtk_entry_set_text( GTK_ENTRY( hshift_value_spinbutton ), "" );
222 gtk_entry_set_text( GTK_ENTRY( vshift_value_spinbutton ), "" );
223 gtk_entry_set_text( GTK_ENTRY( hscale_value_spinbutton ), "" );
224 gtk_entry_set_text( GTK_ENTRY( vscale_value_spinbutton ), "" );
225 gtk_entry_set_text( GTK_ENTRY( rotate_value_spinbutton ), "" );
226 gtk_entry_set_text( GTK_ENTRY( texture_combo_entry ), "" );
230 g_bListenChanged = FALSE;
232 tmp_texdef = &get_texdef_face_list()->texdef;
234 strcpy( texture_name, tmp_texdef->GetName() );
236 texdef_SI_values.shift[0] = tmp_texdef->shift[0];
237 texdef_SI_values.shift[1] = tmp_texdef->shift[1];
238 texdef_SI_values.scale[0] = tmp_texdef->scale[0];
239 texdef_SI_values.scale[1] = tmp_texdef->scale[1];
240 texdef_SI_values.rotate = tmp_texdef->rotate;
241 texdef_SI_values.SetName( texture_name );
243 is_HShift_conflicting = FALSE;
244 is_VShift_conflicting = FALSE;
245 is_HScale_conflicting = FALSE;
246 is_VScale_conflicting = FALSE;
247 is_Rotate_conflicting = FALSE;
248 is_TextureName_conflicting = FALSE;
250 if ( texdef_face_list_size() > 1 ) {
251 temp_texdef_face_list = get_texdef_face_list()->next;
253 for (; temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next )
255 tmp_texdef = &temp_texdef_face_list->texdef;
256 if ( texdef_SI_values.shift[0] != tmp_texdef->shift[0] ) {
257 is_HShift_conflicting = TRUE;
260 if ( texdef_SI_values.shift[1] != tmp_texdef->shift[1] ) {
261 is_VShift_conflicting = TRUE;
264 if ( texdef_SI_values.scale[0] != tmp_texdef->scale[0] ) {
265 is_HScale_conflicting = TRUE;
268 if ( texdef_SI_values.scale[1] != tmp_texdef->scale[1] ) {
269 is_VScale_conflicting = TRUE;
272 if ( texdef_SI_values.rotate != tmp_texdef->rotate ) {
273 is_Rotate_conflicting = TRUE;
276 if ( strcmp( texture_name, tmp_texdef->GetName() ) ) {
277 is_TextureName_conflicting = TRUE;
282 if ( is_HShift_conflicting ) {
283 gtk_entry_set_text( GTK_ENTRY( hshift_value_spinbutton ), "" );
286 gtk_spin_button_set_value( GTK_SPIN_BUTTON( hshift_value_spinbutton ), texdef_SI_values.shift[0] );
289 if ( is_VShift_conflicting ) {
290 gtk_entry_set_text( GTK_ENTRY( vshift_value_spinbutton ), "" );
293 gtk_spin_button_set_value( GTK_SPIN_BUTTON( vshift_value_spinbutton ), texdef_SI_values.shift[1] );
296 if ( is_HScale_conflicting ) {
297 gtk_entry_set_text( GTK_ENTRY( hscale_value_spinbutton ), "" );
300 gtk_spin_button_set_value( GTK_SPIN_BUTTON( hscale_value_spinbutton ), texdef_SI_values.scale[0] );
303 if ( is_VScale_conflicting ) {
304 gtk_entry_set_text( GTK_ENTRY( vscale_value_spinbutton ), "" );
307 gtk_spin_button_set_value( GTK_SPIN_BUTTON( vscale_value_spinbutton ), texdef_SI_values.scale[1] );
310 if ( is_Rotate_conflicting ) {
311 gtk_entry_set_text( GTK_ENTRY( rotate_value_spinbutton ), "" );
314 gtk_spin_button_set_value( GTK_SPIN_BUTTON( rotate_value_spinbutton ), texdef_SI_values.rotate );
317 g_bListenChanged = TRUE;
320 #define MAX_NUM_LIST_ITEMS 15
321 static void PopulateTextureComboList(){
322 texdef_t* tmp_texdef;
323 texdef_to_face_t* temp_texdef_face_list;
327 int num_of_list_items = 0;
331 if ( texdef_face_list_empty() ) {
332 items = g_list_append( items, (gpointer) blank );
333 // For Texture Entry, activate only on entry change
334 strcpy( old_texture_entry, blank );
336 else if ( !is_TextureName_conflicting ) {
337 temp_texdef_face_list = get_texdef_face_list();
338 tmp_texdef = (texdef_t *) &get_texdef_face_list()->texdef;
339 items = g_list_append( items, (gpointer) tmp_texdef->GetName() );
340 // For Texture Entry, activate only on entry change
341 strcpy( old_texture_entry, tmp_texdef->GetName() );
345 for ( temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next )
347 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
348 // Need to do a string compare, hence the custom search
349 if ( !( g_list_find_custom( items, tmp_texdef->GetName(), (GCompareFunc) strcmp ) ) ) {
350 items = g_list_append( items, (gpointer) tmp_texdef->GetName() );
353 // Make sure the combo list isn't too long
354 if ( num_of_list_items >= MAX_NUM_LIST_ITEMS ) {
358 // If this isn't added last (to the top of the list), g_list_find freaks.
359 items = g_list_prepend( items, (gpointer) blank );
360 // For Texture Entry, activate only on entry change
361 strcpy( old_texture_entry, blank );
364 gtk_combo_set_popdown_strings( GTK_COMBO( texture_combo ), items );
365 g_list_free( items );
369 static void ZeroOffsetValues(){
370 texdef_offset.shift[0] = 0.0;
371 texdef_offset.shift[1] = 0.0;
372 texdef_offset.scale[0] = 0.0;
373 texdef_offset.scale[1] = 0.0;
374 texdef_offset.rotate = 0.0;
377 static void GetTexdefInfo_from_Radiant(){
378 g_texdef_face_vector.clear();
380 unsigned int count = GetSelectedFaceCountfromBrushes();
382 count = GetSelectedFaceCount();
385 g_texdef_face_vector.resize( count );
387 if ( !texdef_face_list_empty() ) {
388 // texdef_to_face_t* p = get_texdef_face_list();
389 GetSelFacesTexdef( get_texdef_face_list() );
393 PopulateTextureComboList();
397 static gint delete_event_callback( GtkWidget *widget, GdkEvent* event, gpointer data ){
402 // make the shift increments match the grid settings
403 // the objective being that the shift+arrows shortcuts move the texture by the corresponding grid size
404 // this depends on a scale value if you have selected a particular texture on which you want it to work:
405 // we move the textures in pixels, not world units. (i.e. increment values are in pixel)
406 // depending on the texture scale it doesn't take the same amount of pixels to move of g_qeglobals.d_gridsize
407 // increment * scale = gridsize
408 // hscale and vscale are optional parameters, if they are zero they will be set to the default scale
409 // NOTE: the default scale depends if you are using BP mode or regular.
410 // For regular it's 0.5f (128 pixels cover 64 world units), for BP it's simply 1.0f
412 void DoSnapTToGrid( float hscale, float vscale ){
413 l_pIncrement = Get_SI_Inc();
415 if ( hscale == 0.0f ) {
418 if ( vscale == 0.0f ) {
422 Sys_Printf( "DoSnapTToGrid: hscale %g vscale %g\n", hscale, vscale );
424 l_pIncrement->shift[0] = GridSize() / hscale;
425 l_pIncrement->shift[1] = GridSize() / vscale;
426 // now some update work
427 // FIXME: doesn't look good here, seems to be called several times
431 void UpdateSurfaceDialog(){
432 if ( !g_bListenUpdate ) {
436 if ( !SurfaceInspector ) {
440 // avoid long delays on slow computers
441 while ( gtk_events_pending() )
442 gtk_main_iteration();
446 Sys_Printf( "UpdateSurfaceDialog\n" );
448 GetTexdefInfo_from_Radiant();
454 // DoSurface will always try to show the surface inspector
455 // or update it because something new has been selected
456 void DoSurface( void ){
458 Sys_Printf( "DoSurface\n" );
460 if ( !SurfaceInspector ) {
461 create_SurfaceInspector();
468 void ToggleSurface(){
470 Sys_Printf( "ToggleSurface Module\n" );
476 on_cancel_button_clicked( NULL, NULL );
480 // NOTE: will raise and show the Surface inspector and exec fit for patches and brushes
481 void SurfaceDlgFitAll(){
486 // =============================================================================
487 // SurfaceDialog class
491 if ( !SurfaceInspector ) {
492 create_SurfaceInspector();
495 gtk_widget_show( SurfaceInspector );
498 GetTexdefInfo_from_Radiant();
499 GetTexMods( TRUE ); // Set Initial Undo Point
505 gtk_widget_hide( SurfaceInspector );
509 // set default values for increments (shift scale and rot)
510 // this is called by the prefs code if can't find the values
511 void InitDefaultIncrement( texdef_t *tex ){
512 tex->SetName( "foo" );
515 tex->scale[0] = 0.25;
516 tex->scale[1] = 0.25;
521 if ( !SurfaceInspector ) {
522 create_SurfaceInspector();
530 Set the fields to the current texdef (i.e. map/texdef -> dialog widgets)
537 GtkAdjustment *adjust;
539 texturewin = Texturewin();
540 l_pIncrement = Get_SI_Inc();
543 Sys_Printf( "SurfaceDlg SetTexMods\n" );
550 pt = &texturewin->texdef;
552 g_bListenChanged = false;
554 if ( strncmp( pt->GetName(), "textures/", 9 ) != 0 ) {
555 texdef_offset.SetName( SHADER_NOT_FOUND );
559 spin = GTK_SPIN_BUTTON( hshift_offset_spinbutton );
560 gtk_spin_button_set_value( spin, texdef_offset.shift[0] );
561 adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
562 adjust->step_increment = l_pIncrement->shift[0];
563 gtk_spin_button_set_value( GTK_SPIN_BUTTON( hshift_step_spinbutton ), l_pIncrement->shift[0] );
565 spin = GTK_SPIN_BUTTON( hshift_value_spinbutton );
566 adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
567 adjust->step_increment = l_pIncrement->shift[0];
570 spin = GTK_SPIN_BUTTON( vshift_offset_spinbutton );
571 gtk_spin_button_set_value( spin, texdef_offset.shift[1] );
572 adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
573 adjust->step_increment = l_pIncrement->shift[1];
574 gtk_spin_button_set_value( GTK_SPIN_BUTTON( vshift_step_spinbutton ), l_pIncrement->shift[1] );
576 spin = GTK_SPIN_BUTTON( vshift_value_spinbutton );
577 adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
578 adjust->step_increment = l_pIncrement->shift[1];
581 spin = GTK_SPIN_BUTTON( hscale_offset_spinbutton );
582 gtk_spin_button_set_value( spin, texdef_offset.scale[0] );
583 adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
584 adjust->step_increment = l_pIncrement->scale[0];
585 gtk_spin_button_set_value( GTK_SPIN_BUTTON( hscale_step_spinbutton ), l_pIncrement->scale[0] );
587 spin = GTK_SPIN_BUTTON( hscale_value_spinbutton );
588 adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
589 adjust->step_increment = l_pIncrement->scale[0];
592 spin = GTK_SPIN_BUTTON( vscale_offset_spinbutton );
593 gtk_spin_button_set_value( spin, texdef_offset.scale[1] );
594 adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
595 adjust->step_increment = l_pIncrement->scale[1];
596 gtk_spin_button_set_value( GTK_SPIN_BUTTON( vscale_step_spinbutton ), l_pIncrement->scale[1] );
598 spin = GTK_SPIN_BUTTON( vscale_value_spinbutton );
599 adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
600 adjust->step_increment = l_pIncrement->scale[1];
603 spin = GTK_SPIN_BUTTON( rotate_offset_spinbutton );
604 gtk_spin_button_set_value( spin, texdef_offset.rotate );
605 adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
606 adjust->step_increment = l_pIncrement->rotate;
607 gtk_spin_button_set_value( GTK_SPIN_BUTTON( rotate_step_spinbutton ), l_pIncrement->rotate );
609 spin = GTK_SPIN_BUTTON( rotate_value_spinbutton );
610 adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
611 adjust->step_increment = l_pIncrement->rotate;
614 g_bListenChanged = true;
616 // store the current texdef as our escape route if user hits OnCancel
617 g_old_texdef = texturewin->texdef;
624 Shows any changes to the main Radiant windows
627 void GetTexMods( bool b_SetUndoPoint ){
630 Sys_Printf( "SurfaceDlg GetTexMods\n" );
633 if ( !texdef_face_list_empty() ) {
634 g_bListenUpdate = FALSE;
635 SetTexdef_FaceList( get_texdef_face_list(), b_SetUndoPoint, false );
636 g_bListenUpdate = TRUE;
638 if ( b_SetUndoPoint ) {
639 m_nUndoId = Undo_GetUndoId();
645 on_fit_button_clicked( NULL, NULL );
649 ////////////////////////////////////////////////////////////////////
653 ////////////////////////////////////////////////////////////////////
655 GtkWidget* create_SurfaceInspector( void ){
658 GtkWidget *hseparator;
661 GtkWidget *viewport8;
662 GtkWidget *viewport9;
663 GtkWidget *viewport2;
664 GtkWidget *viewport7;
665 GtkWidget *viewport5;
666 GtkWidget *viewport6;
667 GtkWidget *viewport10;
674 GtkWidget *alignment1;
675 GtkWidget *alignment2;
676 GtkWidget *alignment3;
689 GtkWidget *hbuttonbox1;
691 SurfaceInspector = gtk_window_new( GTK_WINDOW_TOPLEVEL );
692 gtk_container_set_border_width( GTK_CONTAINER( SurfaceInspector ), 4 );
693 gtk_window_set_title( GTK_WINDOW( SurfaceInspector ), "Surface Inspector" );
695 SetWinPos_from_Prefs( SurfaceInspector );
697 viewport8 = gtk_viewport_new( NULL, NULL );
698 gtk_widget_show( viewport8 );
699 gtk_container_add( GTK_CONTAINER( SurfaceInspector ), viewport8 );
700 gtk_viewport_set_shadow_type( GTK_VIEWPORT( viewport8 ), GTK_SHADOW_NONE );
702 vbox7 = gtk_vbox_new( FALSE, 0 );
703 gtk_widget_show( vbox7 );
704 gtk_container_add( GTK_CONTAINER( viewport8 ), vbox7 );
706 viewport9 = gtk_viewport_new( NULL, NULL );
707 gtk_widget_show( viewport9 );
708 gtk_box_pack_start( GTK_BOX( vbox7 ), viewport9, FALSE, FALSE, 0 );
709 gtk_container_set_border_width( GTK_CONTAINER( viewport9 ), 2 );
710 gtk_viewport_set_shadow_type( GTK_VIEWPORT( viewport9 ), GTK_SHADOW_ETCHED_IN );
712 hbox1 = gtk_hbox_new( FALSE, 0 );
713 gtk_widget_show( hbox1 );
714 gtk_container_add( GTK_CONTAINER( viewport9 ), hbox1 );
715 gtk_container_set_border_width( GTK_CONTAINER( hbox1 ), 4 );
717 label = gtk_label_new( "Texture: " );
718 gtk_widget_show( label );
719 gtk_box_pack_start( GTK_BOX( hbox1 ), label, FALSE, FALSE, 0 );
720 gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
722 texture_combo = gtk_combo_new();
723 g_object_set_data( G_OBJECT( GTK_COMBO( texture_combo )->popwin ),
724 "KeepMeAround", texture_combo );
725 gtk_combo_disable_activate( (GtkCombo*) texture_combo );
726 gtk_widget_show( texture_combo );
727 gtk_box_pack_start( GTK_BOX( hbox1 ), texture_combo, TRUE, TRUE, 0 );
729 texture_combo_entry = GTK_COMBO( texture_combo )->entry;
730 gtk_widget_show( texture_combo_entry );
731 gtk_entry_set_max_length( GTK_ENTRY( texture_combo_entry ), 128 );
733 viewport2 = gtk_viewport_new( NULL, NULL );
734 gtk_widget_show( viewport2 );
735 gtk_box_pack_start( GTK_BOX( vbox7 ), viewport2, FALSE, TRUE, 0 );
736 gtk_container_set_border_width( GTK_CONTAINER( viewport2 ), 2 );
737 gtk_viewport_set_shadow_type( GTK_VIEWPORT( viewport2 ), GTK_SHADOW_ETCHED_IN );
739 table1 = gtk_table_new( 13, 4, FALSE );
740 gtk_widget_show( table1 );
741 gtk_container_add( GTK_CONTAINER( viewport2 ), table1 );
743 hseparator = gtk_hseparator_new();
744 gtk_widget_show( hseparator );
745 gtk_table_attach( GTK_TABLE( table1 ), hseparator, 1, 2, 1, 2,
746 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
747 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
749 hseparator = gtk_hseparator_new();
750 gtk_widget_show( hseparator );
751 gtk_table_attach( GTK_TABLE( table1 ), hseparator, 2, 3, 1, 2,
752 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
753 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
755 hseparator = gtk_hseparator_new();
756 gtk_widget_show( hseparator );
757 gtk_table_attach( GTK_TABLE( table1 ), hseparator, 3, 4, 1, 2,
758 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
759 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
761 hseparator = gtk_hseparator_new();
762 gtk_widget_show( hseparator );
763 gtk_table_attach( GTK_TABLE( table1 ), hseparator, 1, 2, 3, 4,
764 (GtkAttachOptions) ( GTK_FILL ),
765 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
767 hseparator = gtk_hseparator_new();
768 gtk_widget_show( hseparator );
769 gtk_table_attach( GTK_TABLE( table1 ), hseparator, 2, 3, 3, 4,
770 (GtkAttachOptions) ( GTK_FILL ),
771 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
773 hseparator = gtk_hseparator_new();
774 gtk_widget_show( hseparator );
775 gtk_table_attach( GTK_TABLE( table1 ), hseparator, 3, 4, 3, 4,
776 (GtkAttachOptions) ( GTK_FILL ),
777 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
779 hseparator = gtk_hseparator_new();
780 gtk_widget_show( hseparator );
781 gtk_table_attach( GTK_TABLE( table1 ), hseparator, 1, 2, 5, 6,
782 (GtkAttachOptions) ( GTK_FILL ),
783 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
785 hseparator = gtk_hseparator_new();
786 gtk_widget_show( hseparator );
787 gtk_table_attach( GTK_TABLE( table1 ), hseparator, 2, 3, 5, 6,
788 (GtkAttachOptions) ( GTK_FILL ),
789 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
791 hseparator = gtk_hseparator_new();
792 gtk_widget_show( hseparator );
793 gtk_table_attach( GTK_TABLE( table1 ), hseparator, 3, 4, 5, 6,
794 (GtkAttachOptions) ( GTK_FILL ),
795 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
797 hseparator = gtk_hseparator_new();
798 gtk_widget_show( hseparator );
799 gtk_table_attach( GTK_TABLE( table1 ), hseparator, 1, 2, 7, 8,
800 (GtkAttachOptions) ( GTK_FILL ),
801 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
803 hseparator = gtk_hseparator_new();
804 gtk_widget_show( hseparator );
805 gtk_table_attach( GTK_TABLE( table1 ), hseparator, 2, 3, 7, 8,
806 (GtkAttachOptions) ( GTK_FILL ),
807 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
809 hseparator = gtk_hseparator_new();
810 gtk_widget_show( hseparator );
811 gtk_table_attach( GTK_TABLE( table1 ), hseparator, 3, 4, 7, 8,
812 (GtkAttachOptions) ( GTK_FILL ),
813 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
815 hseparator = gtk_hseparator_new();
816 gtk_widget_show( hseparator );
817 gtk_table_attach( GTK_TABLE( table1 ), hseparator, 1, 2, 9, 10,
818 (GtkAttachOptions) ( GTK_FILL ),
819 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
821 hseparator = gtk_hseparator_new();
822 gtk_widget_show( hseparator );
823 gtk_table_attach( GTK_TABLE( table1 ), hseparator, 2, 3, 9, 10,
824 (GtkAttachOptions) ( GTK_FILL ),
825 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
827 hseparator = gtk_hseparator_new();
828 gtk_widget_show( hseparator );
829 gtk_table_attach( GTK_TABLE( table1 ), hseparator, 3, 4, 9, 10,
830 (GtkAttachOptions) ( GTK_FILL ),
831 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
833 hseparator = gtk_hseparator_new();
834 gtk_widget_show( hseparator );
835 gtk_table_attach( GTK_TABLE( table1 ), hseparator, 1, 2, 11, 12,
836 (GtkAttachOptions) ( GTK_FILL ),
837 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
839 hseparator = gtk_hseparator_new();
840 gtk_widget_show( hseparator );
841 gtk_table_attach( GTK_TABLE( table1 ), hseparator, 2, 3, 11, 12,
842 (GtkAttachOptions) ( GTK_FILL ),
843 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
845 hseparator = gtk_hseparator_new();
846 gtk_widget_show( hseparator );
847 gtk_table_attach( GTK_TABLE( table1 ), hseparator, 3, 4, 11, 12,
848 (GtkAttachOptions) ( GTK_FILL ),
849 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
851 label = gtk_label_new( "Offset" );
852 gtk_widget_show( label );
853 gtk_table_attach( GTK_TABLE( table1 ), label, 2, 3, 0, 1,
854 (GtkAttachOptions) ( GTK_FILL ),
855 (GtkAttachOptions) ( 0 ), 0, 0 );
857 label = gtk_label_new( "Step" );
858 gtk_widget_show( label );
859 gtk_table_attach( GTK_TABLE( table1 ), label, 3, 4, 0, 1,
860 (GtkAttachOptions) ( GTK_FILL ),
861 (GtkAttachOptions) ( 0 ), 0, 0 );
863 eventbox = gtk_event_box_new();
864 gtk_widget_show( eventbox );
865 gtk_table_attach( GTK_TABLE( table1 ), eventbox, 3, 4, 12, 13,
866 (GtkAttachOptions) ( GTK_FILL ),
867 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
869 match_grid_button = gtk_button_new_with_mnemonic( "Match Grid" );
870 gtk_widget_show( match_grid_button );
871 gtk_container_add( GTK_CONTAINER( eventbox ), match_grid_button );
873 label = gtk_label_new( "Value" );
874 gtk_widget_show( label );
875 gtk_table_attach( GTK_TABLE( table1 ), label, 1, 2, 0, 1,
876 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
877 (GtkAttachOptions) ( 0 ), 0, 0 );
878 gtk_misc_set_alignment( GTK_MISC( label ), 0.5, 1 );
880 hseparator = gtk_hseparator_new();
881 gtk_widget_show( hseparator );
882 gtk_table_attach( GTK_TABLE( table1 ), hseparator, 0, 1, 3, 4,
883 (GtkAttachOptions) ( GTK_SHRINK | GTK_FILL ),
884 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
886 hseparator = gtk_hseparator_new();
887 gtk_widget_show( hseparator );
888 gtk_table_attach( GTK_TABLE( table1 ), hseparator, 0, 1, 5, 6,
889 (GtkAttachOptions) ( GTK_FILL ),
890 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
892 hseparator = gtk_hseparator_new();
893 gtk_widget_show( hseparator );
894 gtk_table_attach( GTK_TABLE( table1 ), hseparator, 0, 1, 7, 8,
895 (GtkAttachOptions) ( GTK_FILL ),
896 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
898 hseparator = gtk_hseparator_new();
899 gtk_widget_show( hseparator );
900 gtk_table_attach( GTK_TABLE( table1 ), hseparator, 0, 1, 9, 10,
901 (GtkAttachOptions) ( GTK_FILL ),
902 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
904 hseparator = gtk_hseparator_new();
905 gtk_widget_show( hseparator );
906 gtk_table_attach( GTK_TABLE( table1 ), hseparator, 0, 1, 11, 12,
907 (GtkAttachOptions) ( GTK_FILL ),
908 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
910 eventbox = gtk_event_box_new();
911 gtk_widget_show( eventbox );
912 gtk_table_attach( GTK_TABLE( table1 ), eventbox, 0, 1, 4, 5,
913 (GtkAttachOptions) ( GTK_FILL ),
914 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
916 label = gtk_label_new( "V Shift: " );
917 gtk_widget_show( label );
918 gtk_container_add( GTK_CONTAINER( eventbox ), label );
919 gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT );
920 gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
922 eventbox = gtk_event_box_new();
923 gtk_widget_show( eventbox );
924 gtk_table_attach( GTK_TABLE( table1 ), eventbox, 0, 1, 6, 7,
925 (GtkAttachOptions) ( GTK_FILL ),
926 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
928 label = gtk_label_new( " H Scale: " );
929 gtk_widget_show( label );
930 gtk_container_add( GTK_CONTAINER( eventbox ), label );
931 gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT );
932 gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
934 eventbox = gtk_event_box_new();
935 gtk_widget_show( eventbox );
936 gtk_table_attach( GTK_TABLE( table1 ), eventbox, 0, 1, 8, 9,
937 (GtkAttachOptions) ( GTK_FILL ),
938 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
940 label = gtk_label_new( "V Scale: " );
941 gtk_widget_show( label );
942 gtk_container_add( GTK_CONTAINER( eventbox ), label );
943 gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT );
944 gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
946 eventbox = gtk_event_box_new();
947 gtk_widget_show( eventbox );
948 gtk_table_attach( GTK_TABLE( table1 ), eventbox, 0, 1, 10, 11,
949 (GtkAttachOptions) ( GTK_FILL ),
950 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
952 label = gtk_label_new( "Rotate: " );
953 gtk_widget_show( label );
954 gtk_container_add( GTK_CONTAINER( eventbox ), label );
955 gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT );
956 gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
958 eventbox = gtk_event_box_new();
959 gtk_widget_show( eventbox );
960 gtk_table_attach( GTK_TABLE( table1 ), eventbox, 0, 1, 2, 3,
961 (GtkAttachOptions) ( GTK_FILL ),
962 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
964 label = gtk_label_new( "H Shift: " );
965 gtk_widget_show( label );
966 gtk_container_add( GTK_CONTAINER( eventbox ), label );
967 gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT );
968 gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
970 hseparator = gtk_hseparator_new();
971 gtk_widget_show( hseparator );
972 gtk_table_attach( GTK_TABLE( table1 ), hseparator, 0, 1, 1, 2,
973 (GtkAttachOptions) ( GTK_FILL ),
974 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
976 eventbox = gtk_event_box_new();
977 gtk_widget_show( eventbox );
978 gtk_table_attach( GTK_TABLE( table1 ), eventbox, 1, 2, 12, 13,
979 (GtkAttachOptions) ( GTK_FILL ),
980 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
982 lock_valuechange_togglebutton = gtk_toggle_button_new_with_mnemonic( "UNLOCK" );
983 gtk_widget_show( lock_valuechange_togglebutton );
984 gtk_container_add( GTK_CONTAINER( eventbox ), lock_valuechange_togglebutton );
987 hshift_value_spinbutton_adj = gtk_adjustment_new( 0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0 );
988 hshift_value_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( hshift_value_spinbutton_adj ), 1, 2 );
989 gtk_widget_show( hshift_value_spinbutton );
990 gtk_table_attach( GTK_TABLE( table1 ), hshift_value_spinbutton, 1, 2, 2, 3,
991 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
992 (GtkAttachOptions) ( 0 ), 0, 0 );
993 gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( hshift_value_spinbutton ), GTK_UPDATE_IF_VALID );
994 gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( hshift_value_spinbutton ), TRUE );
995 gtk_widget_set_sensitive( GTK_WIDGET( hshift_value_spinbutton ), FALSE );
997 vshift_value_spinbutton_adj = gtk_adjustment_new( 0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0 );
998 vshift_value_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( vshift_value_spinbutton_adj ), 1, 2 );
999 gtk_widget_show( vshift_value_spinbutton );
1000 gtk_table_attach( GTK_TABLE( table1 ), vshift_value_spinbutton, 1, 2, 4, 5,
1001 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1002 (GtkAttachOptions) ( 0 ), 0, 0 );
1003 gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( vshift_value_spinbutton ), GTK_UPDATE_IF_VALID );
1004 gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( vshift_value_spinbutton ), TRUE );
1005 gtk_widget_set_sensitive( GTK_WIDGET( vshift_value_spinbutton ), FALSE );
1007 hscale_value_spinbutton_adj = gtk_adjustment_new( 0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0 );
1008 hscale_value_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( hscale_value_spinbutton_adj ), 1, 4 );
1009 gtk_widget_show( hscale_value_spinbutton );
1010 gtk_table_attach( GTK_TABLE( table1 ), hscale_value_spinbutton, 1, 2, 6, 7,
1011 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1012 (GtkAttachOptions) ( 0 ), 0, 0 );
1013 gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( hscale_value_spinbutton ), GTK_UPDATE_IF_VALID );
1014 gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( hscale_value_spinbutton ), TRUE );
1015 gtk_widget_set_sensitive( GTK_WIDGET( hscale_value_spinbutton ), FALSE );
1017 vscale_value_spinbutton_adj = gtk_adjustment_new( 0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0 );
1018 vscale_value_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( vscale_value_spinbutton_adj ), 1, 4 );
1019 gtk_widget_show( vscale_value_spinbutton );
1020 gtk_table_attach( GTK_TABLE( table1 ), vscale_value_spinbutton, 1, 2, 8, 9,
1021 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1022 (GtkAttachOptions) ( 0 ), 0, 0 );
1023 gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( vscale_value_spinbutton ), GTK_UPDATE_IF_VALID );
1024 gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( vscale_value_spinbutton ), TRUE );
1025 gtk_widget_set_sensitive( GTK_WIDGET( vscale_value_spinbutton ), FALSE );
1027 rotate_value_spinbutton_adj = gtk_adjustment_new( 0.0, -360.0, 360.0, 1.0, 10.0, 10.0 );
1028 rotate_value_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( rotate_value_spinbutton_adj ), 1, 4 );
1029 gtk_widget_show( rotate_value_spinbutton );
1030 gtk_table_attach( GTK_TABLE( table1 ), rotate_value_spinbutton, 1, 2, 10, 11,
1031 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1032 (GtkAttachOptions) ( 0 ), 0, 0 );
1033 gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( rotate_value_spinbutton ), GTK_UPDATE_IF_VALID );
1034 gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( rotate_value_spinbutton ), TRUE );
1035 gtk_widget_set_sensitive( GTK_WIDGET( rotate_value_spinbutton ), FALSE );
1038 hshift_offset_spinbutton_adj = gtk_adjustment_new( 0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0 );
1039 hshift_offset_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( hshift_offset_spinbutton_adj ), 0, 2 );
1040 gtk_widget_show( hshift_offset_spinbutton );
1041 gtk_table_attach( GTK_TABLE( table1 ), hshift_offset_spinbutton, 2, 3, 2, 3,
1042 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1043 (GtkAttachOptions) ( 0 ), 4, 0 );
1044 gtk_spin_button_set_numeric( GTK_SPIN_BUTTON( hshift_offset_spinbutton ), TRUE );
1045 gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( hshift_offset_spinbutton ), GTK_UPDATE_IF_VALID );
1046 gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( hshift_offset_spinbutton ), TRUE );
1048 vshift_offset_spinbutton_adj = gtk_adjustment_new( 0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0 );
1049 vshift_offset_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( vshift_offset_spinbutton_adj ), 0, 2 );
1050 gtk_widget_show( vshift_offset_spinbutton );
1051 gtk_table_attach( GTK_TABLE( table1 ), vshift_offset_spinbutton, 2, 3, 4, 5,
1052 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1053 (GtkAttachOptions) ( 0 ), 4, 0 );
1054 gtk_spin_button_set_numeric( GTK_SPIN_BUTTON( vshift_offset_spinbutton ), TRUE );
1055 gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( vshift_offset_spinbutton ), GTK_UPDATE_IF_VALID );
1056 gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( vshift_offset_spinbutton ), TRUE );
1058 hscale_offset_spinbutton_adj = gtk_adjustment_new( 0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0 );
1059 hscale_offset_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( hscale_offset_spinbutton_adj ), 0, 4 );
1060 gtk_widget_show( hscale_offset_spinbutton );
1061 gtk_table_attach( GTK_TABLE( table1 ), hscale_offset_spinbutton, 2, 3, 6, 7,
1062 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1063 (GtkAttachOptions) ( 0 ), 4, 0 );
1064 gtk_spin_button_set_numeric( GTK_SPIN_BUTTON( hscale_offset_spinbutton ), TRUE );
1065 gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( hscale_offset_spinbutton ), GTK_UPDATE_IF_VALID );
1066 gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( hscale_offset_spinbutton ), TRUE );
1068 vscale_offset_spinbutton_adj = gtk_adjustment_new( 0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0 );
1069 vscale_offset_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( vscale_offset_spinbutton_adj ), 0, 4 );
1070 gtk_widget_show( vscale_offset_spinbutton );
1071 gtk_table_attach( GTK_TABLE( table1 ), vscale_offset_spinbutton, 2, 3, 8, 9,
1072 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1073 (GtkAttachOptions) ( 0 ), 4, 0 );
1074 gtk_spin_button_set_numeric( GTK_SPIN_BUTTON( vscale_offset_spinbutton ), TRUE );
1075 gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( vscale_offset_spinbutton ), GTK_UPDATE_IF_VALID );
1076 gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( vscale_offset_spinbutton ), TRUE );
1078 rotate_offset_spinbutton_adj = gtk_adjustment_new( 0.0, -360.0, 360.0, 1.0, 10.0, 10.0 );
1079 rotate_offset_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( rotate_offset_spinbutton_adj ), 0, 4 );
1080 gtk_widget_show( rotate_offset_spinbutton );
1081 gtk_table_attach( GTK_TABLE( table1 ), rotate_offset_spinbutton, 2, 3, 10, 11,
1082 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1083 (GtkAttachOptions) ( 0 ), 4, 0 );
1084 gtk_spin_button_set_numeric( GTK_SPIN_BUTTON( rotate_offset_spinbutton ), TRUE );
1085 gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( rotate_offset_spinbutton ), GTK_UPDATE_IF_VALID );
1086 gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( rotate_offset_spinbutton ), TRUE );
1089 hshift_step_spinbutton_adj = gtk_adjustment_new( 0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0 );
1090 hshift_step_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( hshift_step_spinbutton_adj ), 1, 2 );
1091 gtk_widget_show( hshift_step_spinbutton );
1092 gtk_table_attach( GTK_TABLE( table1 ), hshift_step_spinbutton, 3, 4, 2, 3,
1093 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1094 (GtkAttachOptions) ( 0 ), 0, 0 );
1095 gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( hshift_step_spinbutton ), GTK_UPDATE_IF_VALID );
1097 vshift_step_spinbutton_adj = gtk_adjustment_new( 0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0 );
1098 vshift_step_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( vshift_step_spinbutton_adj ), 1, 2 );
1099 gtk_widget_show( vshift_step_spinbutton );
1100 gtk_table_attach( GTK_TABLE( table1 ), vshift_step_spinbutton, 3, 4, 4, 5,
1101 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1102 (GtkAttachOptions) ( 0 ), 0, 0 );
1103 gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( vshift_step_spinbutton ), GTK_UPDATE_IF_VALID );
1105 hscale_step_spinbutton_adj = gtk_adjustment_new( 0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0 );
1106 hscale_step_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( hscale_step_spinbutton_adj ), 1, 4 );
1107 gtk_widget_show( hscale_step_spinbutton );
1108 gtk_table_attach( GTK_TABLE( table1 ), hscale_step_spinbutton, 3, 4, 6, 7,
1109 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1110 (GtkAttachOptions) ( 0 ), 0, 0 );
1111 gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( hscale_step_spinbutton ), GTK_UPDATE_IF_VALID );
1113 vscale_step_spinbutton_adj = gtk_adjustment_new( 0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0 );
1114 vscale_step_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( vscale_step_spinbutton_adj ), 1, 4 );
1115 gtk_widget_show( vscale_step_spinbutton );
1116 gtk_table_attach( GTK_TABLE( table1 ), vscale_step_spinbutton, 3, 4, 8, 9,
1117 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1118 (GtkAttachOptions) ( 0 ), 0, 0 );
1119 gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( vscale_step_spinbutton ), GTK_UPDATE_IF_VALID );
1121 rotate_step_spinbutton_adj = gtk_adjustment_new( 0.0, -360.0, 360.0, 1.0, 10.0, 10.0 );
1122 rotate_step_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( rotate_step_spinbutton_adj ), 1, 4 );
1123 gtk_widget_show( rotate_step_spinbutton );
1124 gtk_table_attach( GTK_TABLE( table1 ), rotate_step_spinbutton, 3, 4, 10, 11,
1125 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1126 (GtkAttachOptions) ( 0 ), 0, 0 );
1127 gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( rotate_step_spinbutton ), GTK_UPDATE_IF_VALID );
1129 eventbox = gtk_event_box_new();
1130 gtk_widget_show( eventbox );
1131 gtk_table_attach( GTK_TABLE( table1 ), eventbox, 2, 3, 12, 13,
1132 (GtkAttachOptions) ( 0 ),
1133 (GtkAttachOptions) ( 0 ), 0, 0 );
1135 eventbox = gtk_event_box_new();
1136 gtk_widget_show( eventbox );
1137 gtk_table_attach( GTK_TABLE( table1 ), eventbox, 0, 1, 12, 13,
1138 (GtkAttachOptions) ( 0 ),
1139 (GtkAttachOptions) ( 0 ), 0, 0 );
1141 eventbox = gtk_event_box_new();
1142 gtk_widget_show( eventbox );
1143 gtk_table_attach( GTK_TABLE( table1 ), eventbox, 0, 1, 0, 1,
1144 (GtkAttachOptions) ( 0 ),
1145 (GtkAttachOptions) ( 0 ), 0, 0 );
1147 viewport7 = gtk_viewport_new( NULL, NULL );
1148 gtk_widget_show( viewport7 );
1149 gtk_box_pack_start( GTK_BOX( vbox7 ), viewport7, FALSE, TRUE, 0 );
1150 gtk_container_set_border_width( GTK_CONTAINER( viewport7 ), 2 );
1151 gtk_viewport_set_shadow_type( GTK_VIEWPORT( viewport7 ), GTK_SHADOW_ETCHED_IN );
1153 table4 = gtk_table_new( 4, 7, FALSE );
1154 gtk_widget_show( table4 );
1155 gtk_container_add( GTK_CONTAINER( viewport7 ), table4 );
1157 viewport5 = gtk_viewport_new( NULL, NULL );
1158 gtk_widget_show( viewport5 );
1159 gtk_table_attach( GTK_TABLE( table4 ), viewport5, 1, 7, 0, 4,
1160 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1161 (GtkAttachOptions) ( 0 ), 0, 0 );
1162 gtk_container_set_border_width( GTK_CONTAINER( viewport5 ), 6 );
1163 gtk_viewport_set_shadow_type( GTK_VIEWPORT( viewport5 ), GTK_SHADOW_ETCHED_OUT );
1165 table5 = gtk_table_new( 2, 3, FALSE );
1166 gtk_widget_show( table5 );
1167 gtk_container_add( GTK_CONTAINER( viewport5 ), table5 );
1168 gtk_container_set_border_width( GTK_CONTAINER( table5 ), 5 );
1169 gtk_table_set_col_spacings( GTK_TABLE( table5 ), 2 );
1171 label = gtk_label_new( "Height" );
1172 gtk_widget_show( label );
1173 gtk_table_attach( GTK_TABLE( table5 ), label, 2, 3, 0, 1,
1174 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1175 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
1176 gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT );
1177 gtk_misc_set_alignment( GTK_MISC( label ), 0.5, 1 );
1179 label = gtk_label_new( "Width" );
1180 gtk_widget_show( label );
1181 gtk_table_attach( GTK_TABLE( table5 ), label, 1, 2, 0, 1,
1182 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1183 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
1184 gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT );
1185 gtk_misc_set_alignment( GTK_MISC( label ), 0.5, 1 );
1187 fit_width_spinbutton_adj = gtk_adjustment_new( 1, 1, 32, 1, 10, 10 );
1188 fit_width_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( fit_width_spinbutton_adj ), 1, 0 );
1189 gtk_widget_show( fit_width_spinbutton );
1190 gtk_table_attach( GTK_TABLE( table5 ), fit_width_spinbutton, 1, 2, 1, 2,
1191 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1192 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
1193 gtk_spin_button_set_numeric( GTK_SPIN_BUTTON( fit_width_spinbutton ), TRUE );
1194 gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( fit_width_spinbutton ), GTK_UPDATE_IF_VALID );
1196 fit_height_spinbutton_adj = gtk_adjustment_new( 1, 1, 32, 1, 10, 10 );
1197 fit_height_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( fit_height_spinbutton_adj ), 1, 0 );
1198 gtk_widget_show( fit_height_spinbutton );
1199 gtk_table_attach( GTK_TABLE( table5 ), fit_height_spinbutton, 2, 3, 1, 2,
1200 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1201 (GtkAttachOptions) ( GTK_FILL ), 3, 0 );
1202 gtk_spin_button_set_numeric( GTK_SPIN_BUTTON( fit_height_spinbutton ), TRUE );
1203 gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( fit_height_spinbutton ), GTK_UPDATE_IF_VALID );
1205 eventbox = gtk_event_box_new();
1206 gtk_widget_show( eventbox );
1207 gtk_table_attach( GTK_TABLE( table5 ), eventbox, 0, 1, 0, 1,
1208 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1209 (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
1211 eventbox = gtk_event_box_new();
1212 gtk_widget_show( eventbox );
1213 gtk_table_attach( GTK_TABLE( table5 ), eventbox, 0, 1, 1, 2,
1214 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1215 (GtkAttachOptions) ( GTK_FILL ), 4, 0 );
1217 fit_button = gtk_button_new_with_mnemonic( " Fit " );
1218 gtk_widget_show( fit_button );
1219 gtk_container_add( GTK_CONTAINER( eventbox ), fit_button );
1221 viewport6 = gtk_viewport_new( NULL, NULL );
1222 gtk_widget_show( viewport6 );
1223 gtk_table_attach( GTK_TABLE( table4 ), viewport6, 0, 1, 0, 4,
1224 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1225 (GtkAttachOptions) ( 0 ), 0, 0 );
1226 gtk_container_set_border_width( GTK_CONTAINER( viewport6 ), 4 );
1227 gtk_viewport_set_shadow_type( GTK_VIEWPORT( viewport6 ), GTK_SHADOW_NONE );
1229 table7 = gtk_table_new( 2, 1, FALSE );
1230 gtk_widget_show( table7 );
1231 gtk_container_add( GTK_CONTAINER( viewport6 ), table7 );
1233 eventbox = gtk_event_box_new();
1234 gtk_widget_show( eventbox );
1235 gtk_table_attach( GTK_TABLE( table7 ), eventbox, 0, 1, 0, 2,
1236 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1237 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1239 axial_button = gtk_button_new_with_mnemonic( "Axial" );
1240 gtk_widget_show( axial_button );
1241 gtk_container_add( GTK_CONTAINER( eventbox ), axial_button );
1242 gtk_widget_set_size_request( axial_button, 56, 29 );
1243 gtk_container_set_border_width( GTK_CONTAINER( axial_button ), 4 );
1245 viewport10 = gtk_viewport_new( NULL, NULL );
1246 gtk_widget_show( viewport10 );
1247 gtk_box_pack_start( GTK_BOX( vbox7 ), viewport10, FALSE, TRUE, 0 );
1248 gtk_container_set_border_width( GTK_CONTAINER( viewport10 ), 2 );
1249 gtk_viewport_set_shadow_type( GTK_VIEWPORT( viewport10 ), GTK_SHADOW_ETCHED_IN );
1251 hbuttonbox1 = gtk_hbutton_box_new();
1252 gtk_widget_show( hbuttonbox1 );
1253 gtk_container_add( GTK_CONTAINER( viewport10 ), hbuttonbox1 );
1254 gtk_container_set_border_width( GTK_CONTAINER( hbuttonbox1 ), 4 );
1255 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox1 ), GTK_BUTTONBOX_SPREAD );
1257 done_button = gtk_button_new();
1258 gtk_widget_show( done_button );
1259 gtk_container_add( GTK_CONTAINER( hbuttonbox1 ), done_button );
1260 GTK_WIDGET_SET_FLAGS( done_button, GTK_CAN_DEFAULT );
1262 alignment1 = gtk_alignment_new( 0.5, 0.5, 0, 0 );
1263 gtk_widget_show( alignment1 );
1264 gtk_container_add( GTK_CONTAINER( done_button ), alignment1 );
1266 hbox2 = gtk_hbox_new( FALSE, 2 );
1267 gtk_widget_show( hbox2 );
1268 gtk_container_add( GTK_CONTAINER( alignment1 ), hbox2 );
1270 image1 = gtk_image_new_from_stock( "gtk-yes", GTK_ICON_SIZE_BUTTON );
1271 gtk_widget_show( image1 );
1272 gtk_box_pack_start( GTK_BOX( hbox2 ), image1, FALSE, FALSE, 0 );
1274 label = gtk_label_new_with_mnemonic( "Done" );
1275 gtk_widget_show( label );
1276 gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, FALSE, 0 );
1277 gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT );
1279 apply_button = gtk_button_new();
1280 gtk_widget_show( apply_button );
1281 gtk_container_add( GTK_CONTAINER( hbuttonbox1 ), apply_button );
1282 GTK_WIDGET_SET_FLAGS( apply_button, GTK_CAN_DEFAULT );
1284 alignment3 = gtk_alignment_new( 0.5, 0.5, 0, 0 );
1285 gtk_widget_show( alignment3 );
1286 gtk_container_add( GTK_CONTAINER( apply_button ), alignment3 );
1288 hbox4 = gtk_hbox_new( FALSE, 2 );
1289 gtk_widget_show( hbox4 );
1290 gtk_container_add( GTK_CONTAINER( alignment3 ), hbox4 );
1292 image3 = gtk_image_new_from_stock( "gtk-apply", GTK_ICON_SIZE_BUTTON );
1293 gtk_widget_show( image3 );
1294 gtk_box_pack_start( GTK_BOX( hbox4 ), image3, FALSE, FALSE, 0 );
1296 label = gtk_label_new_with_mnemonic( "Apply" );
1297 gtk_widget_show( label );
1298 gtk_box_pack_start( GTK_BOX( hbox4 ), label, FALSE, FALSE, 0 );
1299 gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT );
1301 cancel_button = gtk_button_new();
1302 gtk_widget_show( cancel_button );
1303 gtk_container_add( GTK_CONTAINER( hbuttonbox1 ), cancel_button );
1304 GTK_WIDGET_SET_FLAGS( cancel_button, GTK_CAN_DEFAULT );
1306 alignment2 = gtk_alignment_new( 0.5, 0.5, 0, 0 );
1307 gtk_widget_show( alignment2 );
1308 gtk_container_add( GTK_CONTAINER( cancel_button ), alignment2 );
1310 hbox3 = gtk_hbox_new( FALSE, 2 );
1311 gtk_widget_show( hbox3 );
1312 gtk_container_add( GTK_CONTAINER( alignment2 ), hbox3 );
1314 image2 = gtk_image_new_from_stock( "gtk-no", GTK_ICON_SIZE_BUTTON );
1315 gtk_widget_show( image2 );
1316 gtk_box_pack_start( GTK_BOX( hbox3 ), image2, FALSE, FALSE, 0 );
1318 label = gtk_label_new_with_mnemonic( "Cancel" );
1319 gtk_widget_show( label );
1320 gtk_box_pack_start( GTK_BOX( hbox3 ), label, FALSE, FALSE, 0 );
1321 gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT );
1324 g_signal_connect( (gpointer) SurfaceInspector,
1326 G_CALLBACK( delete_event_callback ),
1328 g_signal_connect( (gpointer) SurfaceInspector, "destroy",
1329 G_CALLBACK( gtk_widget_destroy ),
1332 g_signal_connect( (gpointer) texture_combo_entry, "key_press_event",
1333 G_CALLBACK( on_texture_combo_entry_key_press_event ),
1335 g_signal_connect( (gpointer) texture_combo_entry, "activate",
1336 G_CALLBACK( on_texture_combo_entry_activate ),
1340 g_signal_connect( (gpointer) hshift_offset_spinbutton, "value_changed",
1341 G_CALLBACK( on_hshift_offset_spinbutton_value_changed ),
1343 g_signal_connect( (gpointer) vshift_offset_spinbutton, "value_changed",
1344 G_CALLBACK( on_vshift_offset_spinbutton_value_changed ),
1346 g_signal_connect( (gpointer) hscale_offset_spinbutton, "value_changed",
1347 G_CALLBACK( on_hscale_offset_spinbutton_value_changed ),
1349 g_signal_connect( (gpointer) vscale_offset_spinbutton, "value_changed",
1350 G_CALLBACK( on_vscale_offset_spinbutton_value_changed ),
1352 g_signal_connect( (gpointer) rotate_offset_spinbutton, "value_changed",
1353 G_CALLBACK( on_rotate_offset_spinbutton_value_changed ),
1356 g_signal_connect( (gpointer) hshift_value_spinbutton, "value_changed",
1357 G_CALLBACK( on_hshift_value_spinbutton_value_changed ),
1359 g_signal_connect( (gpointer) vshift_value_spinbutton, "value_changed",
1360 G_CALLBACK( on_vshift_value_spinbutton_value_changed ),
1362 g_signal_connect( (gpointer) hscale_value_spinbutton, "value_changed",
1363 G_CALLBACK( on_hscale_value_spinbutton_value_changed ),
1365 g_signal_connect( (gpointer) vscale_value_spinbutton, "value_changed",
1366 G_CALLBACK( on_vscale_value_spinbutton_value_changed ),
1368 g_signal_connect( (gpointer) rotate_value_spinbutton, "value_changed",
1369 G_CALLBACK( on_rotate_value_spinbutton_value_changed ),
1372 g_signal_connect( (gpointer) hshift_step_spinbutton, "value_changed",
1373 G_CALLBACK( on_hshift_step_spinbutton_value_changed ),
1375 g_signal_connect( (gpointer) vshift_step_spinbutton, "value_changed",
1376 G_CALLBACK( on_vshift_step_spinbutton_value_changed ),
1378 g_signal_connect( (gpointer) hscale_step_spinbutton, "value_changed",
1379 G_CALLBACK( on_hscale_step_spinbutton_value_changed ),
1381 g_signal_connect( (gpointer) vscale_step_spinbutton, "value_changed",
1382 G_CALLBACK( on_vscale_step_spinbutton_value_changed ),
1384 g_signal_connect( (gpointer) rotate_step_spinbutton, "value_changed",
1385 G_CALLBACK( on_rotate_step_spinbutton_value_changed ),
1388 g_signal_connect( (gpointer) match_grid_button, "clicked",
1389 G_CALLBACK( on_match_grid_button_clicked ),
1391 g_signal_connect( (gpointer) lock_valuechange_togglebutton, "toggled",
1392 G_CALLBACK( on_lock_valuechange_togglebutton_toggled ),
1395 g_signal_connect( (gpointer) fit_width_spinbutton, "value_changed",
1396 G_CALLBACK( on_fit_width_spinbutton_value_changed ),
1398 g_signal_connect( (gpointer) fit_height_spinbutton, "value_changed",
1399 G_CALLBACK( on_fit_height_spinbutton_value_changed ),
1401 g_signal_connect( (gpointer) fit_button, "clicked",
1402 G_CALLBACK( on_fit_button_clicked ),
1405 g_signal_connect( (gpointer) axial_button, "clicked",
1406 G_CALLBACK( on_axial_button_clicked ),
1409 g_signal_connect( (gpointer) done_button, "clicked",
1410 G_CALLBACK( on_done_button_clicked ),
1412 g_signal_connect( (gpointer) apply_button, "clicked",
1413 G_CALLBACK( on_apply_button_clicked ),
1415 g_signal_connect( (gpointer) cancel_button, "clicked",
1416 G_CALLBACK( on_cancel_button_clicked ),
1420 return SurfaceInspector;
1425 gboolean on_texture_combo_entry_key_press_event( GtkWidget *widget, GdkEventKey *event,
1426 gpointer user_data ){
1427 // Have Tab activate selection as well as Return
1428 if ( event->keyval == GDK_Tab ) {
1429 g_signal_emit_by_name( texture_combo_entry, "activate" );
1435 void on_texture_combo_entry_activate( GtkEntry *entry, gpointer user_data ){
1436 texdef_t* tmp_texdef;
1437 texdef_t* tmp_orig_texdef;
1438 texdef_to_face_t* temp_texdef_face_list;
1439 char text[128] = { 0 };
1441 if ( !texdef_face_list_empty() && g_bListenChanged ) {
1442 // activate only on entry change
1443 strcpy( text, gtk_entry_get_text( entry ) );
1444 if ( strcmp( old_texture_entry, text ) ) {
1445 // Check for spaces in shader name
1446 if ( text[0] <= ' ' || strchr( text, ' ' ) ) {
1447 Sys_FPrintf( SYS_WRN, "WARNING: spaces in shader names are not allowed, ignoring '%s'\n", text );
1451 for ( temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next )
1453 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1454 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1455 strcpy( old_texture_entry, text );
1456 tmp_texdef->SetName( text );
1465 static void on_hshift_offset_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data ){
1466 texdef_t* tmp_texdef;
1467 texdef_t* tmp_orig_texdef;
1468 texdef_to_face_t* temp_texdef_face_list;
1470 texdef_offset.shift[0] = gtk_spin_button_get_value( GTK_SPIN_BUTTON( hshift_offset_spinbutton ) );
1472 if ( !texdef_face_list_empty() && g_bListenChanged ) {
1473 for ( temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next )
1475 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1476 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1477 if ( is_HShift_conflicting ) {
1478 tmp_texdef->shift[0] = tmp_orig_texdef->shift[0] + texdef_offset.shift[0];
1481 tmp_texdef->shift[0] = texdef_SI_values.shift[0] + texdef_offset.shift[0];
1488 static void on_vshift_offset_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data ){
1489 texdef_t* tmp_texdef;
1490 texdef_t* tmp_orig_texdef;
1491 texdef_to_face_t* temp_texdef_face_list;
1493 texdef_offset.shift[1] = gtk_spin_button_get_value( GTK_SPIN_BUTTON( vshift_offset_spinbutton ) );
1495 if ( !texdef_face_list_empty() && g_bListenChanged ) {
1496 for ( temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next )
1498 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1499 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1500 if ( is_VShift_conflicting ) {
1501 tmp_texdef->shift[1] = tmp_orig_texdef->shift[1] + texdef_offset.shift[1];
1504 tmp_texdef->shift[1] = texdef_SI_values.shift[1] + texdef_offset.shift[1];
1512 static void on_hscale_offset_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data ){
1513 texdef_t* tmp_texdef;
1514 texdef_t* tmp_orig_texdef;
1515 texdef_to_face_t* temp_texdef_face_list;
1517 texdef_offset.scale[0] = gtk_spin_button_get_value( GTK_SPIN_BUTTON( hscale_offset_spinbutton ) );
1519 if ( !texdef_face_list_empty() && g_bListenChanged ) {
1520 for ( temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next )
1522 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1523 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1524 if ( is_HScale_conflicting ) {
1525 tmp_texdef->scale[0] = tmp_orig_texdef->scale[0] + texdef_offset.scale[0];
1528 tmp_texdef->scale[0] = texdef_SI_values.scale[0] + texdef_offset.scale[0];
1537 static void on_vscale_offset_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data ){
1538 texdef_t* tmp_texdef;
1539 texdef_t* tmp_orig_texdef;
1540 texdef_to_face_t* temp_texdef_face_list;
1542 texdef_offset.scale[1] = gtk_spin_button_get_value( GTK_SPIN_BUTTON( vscale_offset_spinbutton ) );
1544 if ( !texdef_face_list_empty() && g_bListenChanged ) {
1545 for ( temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next )
1547 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1548 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1549 if ( is_VScale_conflicting ) {
1550 tmp_texdef->scale[1] = tmp_orig_texdef->scale[1] + texdef_offset.scale[1];
1553 tmp_texdef->scale[1] = texdef_SI_values.scale[1] + texdef_offset.scale[1];
1561 static void on_rotate_offset_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data ){
1562 texdef_t* tmp_texdef;
1563 texdef_t* tmp_orig_texdef;
1564 texdef_to_face_t* temp_texdef_face_list;
1566 texdef_offset.rotate = gtk_spin_button_get_value( GTK_SPIN_BUTTON( rotate_offset_spinbutton ) );
1568 if ( !texdef_face_list_empty() && g_bListenChanged ) {
1569 for ( temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next )
1571 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1572 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1573 if ( is_Rotate_conflicting ) {
1574 tmp_texdef->rotate = tmp_orig_texdef->rotate + texdef_offset.rotate;
1577 tmp_texdef->rotate = texdef_SI_values.rotate + texdef_offset.rotate;
1587 static void on_match_grid_button_clicked( GtkButton *button, gpointer user_data ){
1588 float hscale, vscale;
1590 if ( !strcmp( gtk_entry_get_text( GTK_ENTRY( hscale_value_spinbutton ) ), "" ) ) {
1594 hscale = gtk_spin_button_get_value( GTK_SPIN_BUTTON( hscale_value_spinbutton ) );
1597 if ( !strcmp( gtk_entry_get_text( GTK_ENTRY( vscale_value_spinbutton ) ), "" ) ) {
1601 vscale = gtk_spin_button_get_value( GTK_SPIN_BUTTON( vscale_value_spinbutton ) );
1603 DoSnapTToGrid( hscale, vscale );
1607 // Lock out changes to Value
1608 static void on_lock_valuechange_togglebutton_toggled( GtkToggleButton *togglebutton, gpointer user_data ){
1611 is_Locked = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( lock_valuechange_togglebutton ) ) != false;
1613 gtk_widget_set_sensitive( GTK_WIDGET( hscale_value_spinbutton ), is_Locked );
1614 gtk_widget_set_sensitive( GTK_WIDGET( vscale_value_spinbutton ), is_Locked );
1615 gtk_widget_set_sensitive( GTK_WIDGET( hshift_value_spinbutton ), is_Locked );
1616 gtk_widget_set_sensitive( GTK_WIDGET( vshift_value_spinbutton ), is_Locked );
1617 gtk_widget_set_sensitive( GTK_WIDGET( rotate_value_spinbutton ), is_Locked );
1622 static void on_hshift_value_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data ){
1623 texdef_t* tmp_texdef;
1624 texdef_t* tmp_orig_texdef;
1625 texdef_to_face_t* temp_texdef_face_list;
1627 texdef_SI_values.shift[0] = gtk_spin_button_get_value( GTK_SPIN_BUTTON( hshift_value_spinbutton ) );
1629 if ( !texdef_face_list_empty() && g_bListenChanged ) {
1630 for ( temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next )
1632 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1633 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1634 tmp_texdef->shift[0] = texdef_SI_values.shift[0] + texdef_offset.shift[0];
1635 is_HShift_conflicting = FALSE;
1641 static void on_vshift_value_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data ){
1642 texdef_t* tmp_texdef;
1643 texdef_t* tmp_orig_texdef;
1644 texdef_to_face_t* temp_texdef_face_list;
1646 texdef_SI_values.shift[1] = gtk_spin_button_get_value( GTK_SPIN_BUTTON( vshift_value_spinbutton ) );
1648 if ( !texdef_face_list_empty() && g_bListenChanged ) {
1649 for ( temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next )
1651 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1652 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1653 tmp_texdef->shift[1] = texdef_SI_values.shift[1] + texdef_offset.shift[1];
1654 is_VShift_conflicting = FALSE;
1660 static void on_hscale_value_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data ){
1661 texdef_t* tmp_texdef;
1662 texdef_t* tmp_orig_texdef;
1663 texdef_to_face_t* temp_texdef_face_list;
1665 texdef_SI_values.scale[0] = gtk_spin_button_get_value( GTK_SPIN_BUTTON( hscale_value_spinbutton ) );
1667 if ( !texdef_face_list_empty() && g_bListenChanged ) {
1668 for ( temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next )
1670 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1671 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1672 tmp_texdef->scale[0] = texdef_SI_values.scale[0] + texdef_offset.scale[0];
1673 is_HScale_conflicting = FALSE;
1679 static void on_vscale_value_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data ){
1680 texdef_t* tmp_texdef;
1681 texdef_t* tmp_orig_texdef;
1682 texdef_to_face_t* temp_texdef_face_list;
1684 texdef_SI_values.scale[1] = gtk_spin_button_get_value( GTK_SPIN_BUTTON( vscale_value_spinbutton ) );
1686 if ( !texdef_face_list_empty() && g_bListenChanged ) {
1687 for ( temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next )
1689 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1690 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1691 tmp_texdef->scale[1] = texdef_SI_values.scale[1] + texdef_offset.scale[1];
1692 is_VScale_conflicting = FALSE;
1698 static void on_rotate_value_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data ){
1699 texdef_t* tmp_texdef;
1700 texdef_t* tmp_orig_texdef;
1701 texdef_to_face_t* temp_texdef_face_list;
1703 texdef_SI_values.rotate = gtk_spin_button_get_value( GTK_SPIN_BUTTON( rotate_value_spinbutton ) );
1705 if ( !texdef_face_list_empty() && g_bListenChanged ) {
1706 for ( temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next )
1708 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1709 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1710 tmp_texdef->rotate = texdef_SI_values.rotate + texdef_offset.rotate;
1711 is_Rotate_conflicting = FALSE;
1719 static void on_hshift_step_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data ){
1721 GtkAdjustment * adjust;
1723 if ( !g_bListenChanged ) {
1727 l_pIncrement = Get_SI_Inc();
1730 Sys_Printf( "OnIncrementChanged HShift\n" );
1733 val = gtk_spin_button_get_value( GTK_SPIN_BUTTON( hshift_step_spinbutton ) ) ;
1734 adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( hshift_offset_spinbutton ) );
1735 adjust->step_increment = val;
1736 adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( hshift_value_spinbutton ) );
1737 adjust->step_increment = val;
1738 l_pIncrement->shift[0] = val;
1741 static void on_vshift_step_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data ){
1743 GtkAdjustment * adjust;
1745 if ( !g_bListenChanged ) {
1749 l_pIncrement = Get_SI_Inc();
1752 Sys_Printf( "OnIncrementChanged VShift\n" );
1755 val = gtk_spin_button_get_value( GTK_SPIN_BUTTON( vshift_step_spinbutton ) ) ;
1756 adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( vshift_offset_spinbutton ) );
1757 adjust->step_increment = val;
1758 adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( vshift_value_spinbutton ) );
1759 adjust->step_increment = val;
1760 l_pIncrement->shift[1] = val;
1763 static void on_hscale_step_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data ){
1765 GtkAdjustment * adjust;
1767 if ( !g_bListenChanged ) {
1771 l_pIncrement = Get_SI_Inc();
1774 Sys_Printf( "OnIncrementChanged HShift\n" );
1777 val = gtk_spin_button_get_value( GTK_SPIN_BUTTON( hscale_step_spinbutton ) ) ;
1778 adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( hscale_offset_spinbutton ) );
1779 adjust->step_increment = val;
1780 adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( hscale_value_spinbutton ) );
1781 adjust->step_increment = val;
1782 l_pIncrement->scale[0] = val;
1785 static void on_vscale_step_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data ){
1787 GtkAdjustment * adjust;
1789 if ( !g_bListenChanged ) {
1793 l_pIncrement = Get_SI_Inc();
1796 Sys_Printf( "OnIncrementChanged HShift\n" );
1799 val = gtk_spin_button_get_value( GTK_SPIN_BUTTON( vscale_step_spinbutton ) ) ;
1800 adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( vscale_offset_spinbutton ) );
1801 adjust->step_increment = val;
1802 adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( vscale_value_spinbutton ) );
1803 adjust->step_increment = val;
1804 l_pIncrement->scale[1] = val;
1807 static void on_rotate_step_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data ){
1809 GtkAdjustment * adjust;
1811 if ( !g_bListenChanged ) {
1815 l_pIncrement = Get_SI_Inc();
1818 Sys_Printf( "OnIncrementChanged HShift\n" );
1821 val = gtk_spin_button_get_value( GTK_SPIN_BUTTON( rotate_step_spinbutton ) ) ;
1822 adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( rotate_offset_spinbutton ) );
1823 adjust->step_increment = val;
1824 adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( rotate_value_spinbutton ) );
1825 adjust->step_increment = val;
1826 l_pIncrement->rotate = val;
1831 static void on_fit_width_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data ){
1832 m_nWidth = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON( fit_width_spinbutton ) );
1835 static void on_fit_height_spinbutton_value_changed( GtkSpinButton *spinbutton, gpointer user_data ){
1836 m_nHeight = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON( fit_height_spinbutton ) );
1839 static void on_fit_button_clicked( GtkButton *button, gpointer user_data ){
1840 FaceList_FitTexture( get_texdef_face_list(), m_nHeight, m_nWidth );
1841 Sys_UpdateWindows( W_ALL );
1846 static void on_axial_button_clicked( GtkButton *button, gpointer user_data ){
1847 texdef_t* tmp_texdef;
1848 // texdef_t* tmp_orig_texdef;
1849 texdef_to_face_t* temp_texdef_face_list;
1851 if ( !texdef_face_list_empty() && g_bListenChanged ) {
1852 for ( temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next )
1854 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1855 tmp_texdef->shift[0] = 0.0;
1856 tmp_texdef->shift[1] = 0.0;
1857 tmp_texdef->scale[0] = 0.5;
1858 tmp_texdef->scale[1] = 0.5;
1859 tmp_texdef->rotate = 0.0;
1863 SetTexdef_FaceList( get_texdef_face_list(), FALSE, TRUE );
1864 Sys_UpdateWindows( W_ALL );
1869 static void on_done_button_clicked( GtkButton *button, gpointer user_data ){
1870 if ( !texdef_face_list_empty() ) {
1874 Sys_UpdateWindows( W_ALL );
1877 static void on_apply_button_clicked( GtkButton *button, gpointer user_data ){
1878 if ( !g_bListenChanged ) {
1881 if ( !texdef_face_list_empty() ) {
1883 Sys_UpdateWindows( W_CAMERA );
1884 GetTexdefInfo_from_Radiant();
1889 static void on_cancel_button_clicked( GtkButton *button, gpointer user_data ){
1890 texturewin = Texturewin();
1891 texturewin->texdef = g_old_texdef;
1892 // cancel the last do if we own it
1893 if ( ( m_nUndoId == Undo_GetUndoId() ) && ( m_nUndoId != 0 ) ) {
1895 Sys_Printf( "OnCancel calling Undo_Undo\n" );
1897 g_bListenUpdate = false;
1899 g_bListenUpdate = true;