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 <glib/gi18n.h>
33 #include <gdk/gdkkeysyms.h>
35 #include "surfdlg_plugin.h"
43 #include "gtkr_vector.h"
45 std::vector<texdef_to_face_t> g_texdef_face_vector;
47 inline texdef_to_face_t* get_texdef_face_list()
49 return &(*g_texdef_face_vector.begin());
52 inline unsigned int texdef_face_list_empty()
54 return g_texdef_face_vector.empty();
57 inline unsigned int texdef_face_list_size()
59 return g_texdef_face_vector.size();
62 // For different faces having different values
63 bool is_HShift_conflicting;
64 bool is_VShift_conflicting;
65 bool is_HScale_conflicting;
66 bool is_VScale_conflicting;
67 bool is_Rotate_conflicting;
68 bool is_TextureName_conflicting;
73 void GetTexMods(bool b_SetUndoPoint = FALSE);
76 void InitDefaultIncrement(texdef_t *);
77 void DoSnapTToGrid(float hscale, float vscale);
78 // called to perform a fitting from the outside (shortcut key)
79 void SurfaceDialogFitAll();
81 // Heretic2 Flags Functions
82 void SetFlagButtons_Heretic2(texdef_to_face_t *texdef_face_list, bool b_isListEmpty);
83 void SetChangeInFlags_Face_Heretic2 (texdef_to_face_t *texdef_face_list);
84 GtkWidget* Create_Heretic2FlagsDialog (GtkWidget* surfacedialog_widget);
91 // 0 is invalid, otherwise it's the Id of the last 'do' we are responsible for
95 texturewin_t *texturewin;
96 texdef_t *l_pIncrement;
97 texdef_t texdef_offset;
98 texdef_t texdef_SI_values;
100 // For Texture Entry, activate only on entry change
101 char old_texture_entry[128];
103 // the texdef to switch back to when the OnCancel is called
104 texdef_t g_old_texdef;
106 // when TRUE, this thing means the surface inspector is currently being displayed
107 bool g_surfwin = FALSE;
108 // turn on/off processing of the "changed" "value_changed" messages
109 // (need to turn off when we are feeding data in)
110 bool g_bListenChanged = true;
111 // turn on/off listening of the update messages
112 bool g_bListenUpdate = true;
114 GtkWidget* create_SurfaceInspector (void);
115 GtkWidget *SurfaceInspector = NULL;
117 GtkWidget *m_pWidget;
118 GtkWidget *GetWidget () { return SurfaceInspector; }
119 GtkWidget *Get_SI_Module_Widget () { return SurfaceInspector; }
120 void SetWidget(GtkWidget *new_widget) { m_pWidget = new_widget; }
121 GtkWidget *GetDlgWidget (const char* name)
122 { return GTK_WIDGET (g_object_get_data (G_OBJECT (SurfaceInspector), name)); }
124 // Spins for FitTexture
125 GtkWidget *spin_width;
126 GtkWidget *spin_height;
129 GtkWidget *texture_combo;
130 GtkWidget *texture_combo_entry;
132 GtkWidget *match_grid_button;
133 GtkWidget *lock_valuechange_togglebutton;
135 GtkObject *hshift_value_spinbutton_adj;
136 GtkWidget *hshift_value_spinbutton;
137 GtkObject *vshift_value_spinbutton_adj;
138 GtkWidget *vshift_value_spinbutton;
139 GtkObject *hscale_value_spinbutton_adj;
140 GtkWidget *hscale_value_spinbutton;
141 GtkObject *vscale_value_spinbutton_adj;
142 GtkWidget *vscale_value_spinbutton;
143 GtkObject *rotate_value_spinbutton_adj;
144 GtkWidget *rotate_value_spinbutton;
146 GtkObject *hshift_offset_spinbutton_adj;
147 GtkWidget *hshift_offset_spinbutton;
148 GtkObject *vshift_offset_spinbutton_adj;
149 GtkWidget *vshift_offset_spinbutton;
150 GtkObject *hscale_offset_spinbutton_adj;
151 GtkWidget *hscale_offset_spinbutton;
152 GtkObject *vscale_offset_spinbutton_adj;
153 GtkWidget *vscale_offset_spinbutton;
154 GtkObject *rotate_offset_spinbutton_adj;
155 GtkWidget *rotate_offset_spinbutton;
157 GtkObject *hshift_step_spinbutton_adj;
158 GtkWidget *hshift_step_spinbutton;
159 GtkObject *vshift_step_spinbutton_adj;
160 GtkWidget *vshift_step_spinbutton;
161 GtkObject *hscale_step_spinbutton_adj;
162 GtkWidget *hscale_step_spinbutton;
163 GtkObject *vscale_step_spinbutton_adj;
164 GtkWidget *vscale_step_spinbutton;
165 GtkObject *rotate_step_spinbutton_adj;
166 GtkWidget *rotate_step_spinbutton;
168 GtkObject *fit_width_spinbutton_adj;
169 GtkWidget *fit_width_spinbutton;
170 GtkObject *fit_height_spinbutton_adj;
171 GtkWidget *fit_height_spinbutton;
172 GtkWidget *fit_button;
173 GtkWidget *axial_button;
175 GtkWidget *done_button;
176 GtkWidget *apply_button;
177 GtkWidget *cancel_button;
180 gboolean on_texture_combo_entry_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data);
181 void on_texture_combo_entry_activate (GtkEntry *entry, gpointer user_data);
183 static void on_match_grid_button_clicked (GtkButton *button, gpointer user_data);
184 static void on_lock_valuechange_togglebutton_toggled (GtkToggleButton *togglebutton, gpointer user_data);
186 static void on_hshift_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
187 static void on_vshift_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
188 static void on_hscale_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
189 static void on_vscale_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
190 static void on_rotate_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
192 static void on_hshift_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
193 static void on_vshift_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
194 static void on_hscale_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
195 static void on_vscale_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
196 static void on_rotate_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
198 static void on_hshift_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
199 static void on_vshift_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
200 static void on_hscale_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
201 static void on_vscale_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
202 static void on_rotate_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
204 static void on_fit_width_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
205 static void on_fit_height_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
206 static void on_fit_button_clicked (GtkButton *button, gpointer user_data);
207 static void on_axial_button_clicked (GtkButton *button, gpointer user_data);
209 static void on_done_button_clicked (GtkButton *button, gpointer user_data);
210 static void on_apply_button_clicked (GtkButton *button, gpointer user_data);
211 static void on_cancel_button_clicked (GtkButton *button, gpointer user_data);
215 ===================================================
219 ===================================================
223 void IsFaceConflicting()
225 texdef_t* tmp_texdef;
226 texdef_to_face_t* temp_texdef_face_list;
228 char texture_name[128];
230 if (texdef_face_list_empty())
232 gtk_entry_set_text( GTK_ENTRY (hshift_value_spinbutton), "");
233 gtk_entry_set_text( GTK_ENTRY (vshift_value_spinbutton), "");
234 gtk_entry_set_text( GTK_ENTRY (hscale_value_spinbutton), "");
235 gtk_entry_set_text( GTK_ENTRY (vscale_value_spinbutton), "");
236 gtk_entry_set_text( GTK_ENTRY (rotate_value_spinbutton), "");
237 gtk_entry_set_text( GTK_ENTRY (texture_combo_entry), "");
241 g_bListenChanged = FALSE;
243 tmp_texdef = &get_texdef_face_list()->texdef;
245 strcpy(texture_name, tmp_texdef->GetName() );
247 texdef_SI_values.shift[0] = tmp_texdef->shift[0];
248 texdef_SI_values.shift[1] = tmp_texdef->shift[1];
249 texdef_SI_values.scale[0] = tmp_texdef->scale[0];
250 texdef_SI_values.scale[1] = tmp_texdef->scale[1];
251 texdef_SI_values.rotate = tmp_texdef->rotate;
252 texdef_SI_values.SetName( texture_name );
254 is_HShift_conflicting = FALSE;
255 is_VShift_conflicting = FALSE;
256 is_HScale_conflicting = FALSE;
257 is_VScale_conflicting = FALSE;
258 is_Rotate_conflicting = FALSE;
259 is_TextureName_conflicting = FALSE;
261 if (texdef_face_list_size() > 1)
263 temp_texdef_face_list = get_texdef_face_list()->next;
265 for (temp_texdef_face_list; temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
267 tmp_texdef = &temp_texdef_face_list->texdef;
268 if ( texdef_SI_values.shift[0] != tmp_texdef->shift[0] )
269 is_HShift_conflicting = TRUE;
271 if ( texdef_SI_values.shift[1] != tmp_texdef->shift[1] )
272 is_VShift_conflicting = TRUE;
274 if ( texdef_SI_values.scale[0] != tmp_texdef->scale[0] )
275 is_HScale_conflicting = TRUE;
277 if ( texdef_SI_values.scale[1] != tmp_texdef->scale[1] )
278 is_VScale_conflicting = TRUE;
280 if ( texdef_SI_values.rotate != tmp_texdef->rotate )
281 is_Rotate_conflicting = TRUE;
283 if ( strcmp( texture_name, tmp_texdef->GetName() ) )
284 is_TextureName_conflicting = TRUE;
288 if(is_HShift_conflicting)
289 gtk_entry_set_text( GTK_ENTRY (hshift_value_spinbutton), "");
291 gtk_spin_button_set_value( GTK_SPIN_BUTTON(hshift_value_spinbutton) , texdef_SI_values.shift[0] );
293 if(is_VShift_conflicting)
294 gtk_entry_set_text( GTK_ENTRY (vshift_value_spinbutton), "");
296 gtk_spin_button_set_value( GTK_SPIN_BUTTON(vshift_value_spinbutton) , texdef_SI_values.shift[1] );
298 if(is_HScale_conflicting)
299 gtk_entry_set_text( GTK_ENTRY (hscale_value_spinbutton), "");
301 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), "");
306 gtk_spin_button_set_value( GTK_SPIN_BUTTON(vscale_value_spinbutton) , texdef_SI_values.scale[1] );
308 if(is_Rotate_conflicting)
309 gtk_entry_set_text( GTK_ENTRY (rotate_value_spinbutton), "");
311 gtk_spin_button_set_value( GTK_SPIN_BUTTON(rotate_value_spinbutton) , texdef_SI_values.rotate );
313 g_bListenChanged = TRUE;
316 #define MAX_NUM_LIST_ITEMS 15
317 static void PopulateTextureComboList()
319 texdef_t* tmp_texdef;
320 texdef_to_face_t* temp_texdef_face_list;
324 int num_of_list_items = 0;
328 if (texdef_face_list_empty())
330 items = g_list_append (items, (gpointer) blank);
331 // For Texture Entry, activate only on entry change
332 strcpy (old_texture_entry, blank);
334 else if ( !is_TextureName_conflicting )
336 temp_texdef_face_list = get_texdef_face_list();
337 tmp_texdef = (texdef_t *) &get_texdef_face_list()->texdef;
338 items = g_list_append( items, (gpointer) tmp_texdef->GetName() );
339 // For Texture Entry, activate only on entry change
340 strcpy (old_texture_entry, tmp_texdef->GetName());
344 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
346 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
347 // Need to do a string compare, hence the custom search
348 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)
357 // If this isn't added last (to the top of the list), g_list_find freaks.
358 items = g_list_prepend (items, (gpointer) blank);
359 // For Texture Entry, activate only on entry change
360 strcpy (old_texture_entry, blank);
363 gtk_combo_set_popdown_strings (GTK_COMBO (texture_combo), items);
368 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()
379 g_texdef_face_vector.clear();
381 unsigned int count = GetSelectedFaceCountfromBrushes();
383 count = GetSelectedFaceCount();
385 g_texdef_face_vector.resize(count);
387 if (!texdef_face_list_empty())
389 texdef_to_face_t* p = get_texdef_face_list();
390 GetSelFacesTexdef( get_texdef_face_list() );
394 PopulateTextureComboList();
396 if ( texdef_face_list_empty() )
397 SetFlagButtons_Heretic2( get_texdef_face_list() , TRUE);
399 SetFlagButtons_Heretic2( get_texdef_face_list() , FALSE);
403 static gint delete_event_callback(GtkWidget *widget, GdkEvent* event, gpointer data)
409 // make the shift increments match the grid settings
410 // the objective being that the shift+arrows shortcuts move the texture by the corresponding grid size
411 // this depends on a scale value if you have selected a particular texture on which you want it to work:
412 // we move the textures in pixels, not world units. (i.e. increment values are in pixel)
413 // depending on the texture scale it doesn't take the same amount of pixels to move of g_qeglobals.d_gridsize
414 // increment * scale = gridsize
415 // hscale and vscale are optional parameters, if they are zero they will be set to the default scale
416 // NOTE: the default scale depends if you are using BP mode or regular.
417 // For regular it's 0.5f (128 pixels cover 64 world units), for BP it's simply 1.0f
419 void DoSnapTToGrid(float hscale, float vscale)
421 l_pIncrement = Get_SI_Inc();
432 Sys_Printf ("DoSnapTToGrid: hscale %g vscale %g\n", hscale, vscale);
434 l_pIncrement->shift[0] = GridSize() / hscale;
435 l_pIncrement->shift[1] = GridSize() / vscale;
436 // now some update work
437 // FIXME: doesn't look good here, seems to be called several times
441 void UpdateSurfaceDialog()
443 if (!g_bListenUpdate)
446 if (!SurfaceInspector)
449 // avoid long delays on slow computers
450 while (gtk_events_pending ())
451 gtk_main_iteration ();
456 Sys_Printf("UpdateSurfaceDialog\n");
458 GetTexdefInfo_from_Radiant();
464 // DoSurface will always try to show the surface inspector
465 // or update it because something new has been selected
466 void DoSurface (void)
469 Sys_Printf("DoSurface\n");
471 if (!SurfaceInspector)
472 create_SurfaceInspector ();
481 Sys_Printf("ToggleSurface Module\n");
486 on_cancel_button_clicked(NULL, NULL);
489 // NOTE: will raise and show the Surface inspector and exec fit for patches and brushes
490 void SurfaceDlgFitAll()
496 // =============================================================================
497 // SurfaceDialog class
502 if(!SurfaceInspector)
503 create_SurfaceInspector();
505 gtk_widget_show (SurfaceInspector);
507 GetTexdefInfo_from_Radiant();
508 GetTexMods(TRUE); // Set Initial Undo Point
515 gtk_widget_hide (SurfaceInspector);
519 // set default values for increments (shift scale and rot)
520 // this is called by the prefs code if can't find the values
521 void InitDefaultIncrement(texdef_t *tex)
526 tex->scale[0] = 0.25;
527 tex->scale[1] = 0.25;
533 if ( !SurfaceInspector )
534 create_SurfaceInspector();
541 Set the fields to the current texdef (i.e. map/texdef -> dialog widgets)
549 GtkAdjustment *adjust;
551 texturewin = Texturewin ();
552 l_pIncrement = Get_SI_Inc();
555 Sys_Printf("SurfaceDlg SetTexMods\n");
561 pt = &texturewin->texdef;
563 g_bListenChanged = false;
565 if(strncmp(pt->GetName(), "textures/", 9) != 0)
566 texdef_offset.SetName(SHADER_NOT_FOUND);
569 spin = GTK_SPIN_BUTTON (hshift_offset_spinbutton);
570 gtk_spin_button_set_value (spin, texdef_offset.shift[0]);
571 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
572 adjust->step_increment = l_pIncrement->shift[0];
573 gtk_spin_button_set_value (GTK_SPIN_BUTTON(hshift_step_spinbutton), l_pIncrement->shift[0]);
575 spin = GTK_SPIN_BUTTON (hshift_value_spinbutton);
576 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
577 adjust->step_increment = l_pIncrement->shift[0];
580 spin = GTK_SPIN_BUTTON (vshift_offset_spinbutton);
581 gtk_spin_button_set_value (spin, texdef_offset.shift[1]);
582 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
583 adjust->step_increment = l_pIncrement->shift[1];
584 gtk_spin_button_set_value (GTK_SPIN_BUTTON(vshift_step_spinbutton), l_pIncrement->shift[1]);
586 spin = GTK_SPIN_BUTTON (vshift_value_spinbutton);
587 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
588 adjust->step_increment = l_pIncrement->shift[1];
591 spin = GTK_SPIN_BUTTON (hscale_offset_spinbutton);
592 gtk_spin_button_set_value (spin, texdef_offset.scale[0]);
593 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
594 adjust->step_increment = l_pIncrement->scale[0];
595 gtk_spin_button_set_value (GTK_SPIN_BUTTON(hscale_step_spinbutton), l_pIncrement->scale[0]);
597 spin = GTK_SPIN_BUTTON (hscale_value_spinbutton);
598 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
599 adjust->step_increment = l_pIncrement->scale[0];
602 spin = GTK_SPIN_BUTTON (vscale_offset_spinbutton);
603 gtk_spin_button_set_value (spin, texdef_offset.scale[1]);
604 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
605 adjust->step_increment = l_pIncrement->scale[1];
606 gtk_spin_button_set_value (GTK_SPIN_BUTTON(vscale_step_spinbutton), l_pIncrement->scale[1]);
608 spin = GTK_SPIN_BUTTON (vscale_value_spinbutton);
609 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
610 adjust->step_increment = l_pIncrement->scale[1];
613 spin = GTK_SPIN_BUTTON (rotate_offset_spinbutton);
614 gtk_spin_button_set_value (spin, texdef_offset.rotate);
615 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
616 adjust->step_increment = l_pIncrement->rotate;
617 gtk_spin_button_set_value (GTK_SPIN_BUTTON(rotate_step_spinbutton), l_pIncrement->rotate);
619 spin = GTK_SPIN_BUTTON (rotate_value_spinbutton);
620 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
621 adjust->step_increment = l_pIncrement->rotate;
624 g_bListenChanged = true;
626 // store the current texdef as our escape route if user hits OnCancel
627 g_old_texdef = texturewin->texdef;
634 Shows any changes to the main Radiant windows
637 void GetTexMods(bool b_SetUndoPoint)
641 Sys_Printf("SurfaceDlg GetTexMods\n");
644 if ( !texdef_face_list_empty() )
646 g_bListenUpdate=FALSE;
647 SetChangeInFlags_Face_Heretic2 ( get_texdef_face_list() );
648 SetTexdef_FaceList( get_texdef_face_list(), b_SetUndoPoint, false );
649 g_bListenUpdate=TRUE;
652 m_nUndoId = Undo_GetUndoId();
658 on_fit_button_clicked(NULL, NULL);
662 ////////////////////////////////////////////////////////////////////
666 ////////////////////////////////////////////////////////////////////
668 GtkWidget* create_SurfaceInspector (void)
672 GtkWidget *hseparator;
675 GtkWidget *viewport8;
676 GtkWidget *viewport9;
677 GtkWidget *viewport2;
678 GtkWidget *viewport7;
679 GtkWidget *viewport5;
680 GtkWidget *viewport6;
681 GtkWidget *viewport10;
688 GtkWidget *alignment1;
689 GtkWidget *alignment2;
690 GtkWidget *alignment3;
703 GtkWidget *hbuttonbox1;
705 SurfaceInspector = gtk_window_new (GTK_WINDOW_TOPLEVEL);
706 gtk_container_set_border_width (GTK_CONTAINER (SurfaceInspector), 4);
707 gtk_window_set_title (GTK_WINDOW (SurfaceInspector), "Surface Inspector");
709 SetWinPos_from_Prefs(SurfaceInspector);
711 viewport8 = gtk_viewport_new (NULL, NULL);
712 gtk_widget_show (viewport8);
713 gtk_container_add (GTK_CONTAINER (SurfaceInspector), viewport8);
714 gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport8), GTK_SHADOW_NONE);
716 vbox7 = gtk_vbox_new (FALSE, 0);
717 gtk_widget_show (vbox7);
718 gtk_container_add (GTK_CONTAINER (viewport8), vbox7);
720 viewport9 = gtk_viewport_new (NULL, NULL);
721 gtk_widget_show (viewport9);
722 gtk_box_pack_start (GTK_BOX (vbox7), viewport9, FALSE, FALSE, 0);
723 gtk_container_set_border_width (GTK_CONTAINER (viewport9), 2);
724 gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport9), GTK_SHADOW_ETCHED_IN);
726 hbox1 = gtk_hbox_new (FALSE, 0);
727 gtk_widget_show (hbox1);
728 gtk_container_add (GTK_CONTAINER (viewport9), hbox1);
729 gtk_container_set_border_width (GTK_CONTAINER (hbox1), 4);
731 label = gtk_label_new ("Texture: ");
732 gtk_widget_show (label);
733 gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
734 gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
736 texture_combo = gtk_combo_new ();
737 g_object_set_data (G_OBJECT (GTK_COMBO (texture_combo)->popwin),
738 "KeepMeAround", texture_combo);
739 gtk_combo_disable_activate ( (GtkCombo*) texture_combo);
740 gtk_widget_show (texture_combo);
741 gtk_box_pack_start (GTK_BOX (hbox1), texture_combo, TRUE, TRUE, 0);
743 texture_combo_entry = GTK_COMBO (texture_combo)->entry;
744 gtk_widget_show (texture_combo_entry);
745 gtk_entry_set_max_length (GTK_ENTRY (texture_combo_entry), 128);
747 viewport2 = gtk_viewport_new (NULL, NULL);
748 gtk_widget_show (viewport2);
749 gtk_box_pack_start (GTK_BOX (vbox7), viewport2, FALSE, TRUE, 0);
750 gtk_container_set_border_width (GTK_CONTAINER (viewport2), 2);
751 gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport2), GTK_SHADOW_ETCHED_IN);
753 table1 = gtk_table_new (13, 4, FALSE);
754 gtk_widget_show (table1);
755 gtk_container_add (GTK_CONTAINER (viewport2), table1);
757 hseparator = gtk_hseparator_new ();
758 gtk_widget_show (hseparator);
759 gtk_table_attach (GTK_TABLE (table1), hseparator, 1, 2, 1, 2,
760 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
761 (GtkAttachOptions) (GTK_FILL), 0, 0);
763 hseparator = gtk_hseparator_new ();
764 gtk_widget_show (hseparator);
765 gtk_table_attach (GTK_TABLE (table1), hseparator, 2, 3, 1, 2,
766 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
767 (GtkAttachOptions) (GTK_FILL), 0, 0);
769 hseparator = gtk_hseparator_new ();
770 gtk_widget_show (hseparator);
771 gtk_table_attach (GTK_TABLE (table1), hseparator, 3, 4, 1, 2,
772 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
773 (GtkAttachOptions) (GTK_FILL), 0, 0);
775 hseparator = gtk_hseparator_new ();
776 gtk_widget_show (hseparator);
777 gtk_table_attach (GTK_TABLE (table1), hseparator, 1, 2, 3, 4,
778 (GtkAttachOptions) (GTK_FILL),
779 (GtkAttachOptions) (GTK_FILL), 0, 0);
781 hseparator = gtk_hseparator_new ();
782 gtk_widget_show (hseparator);
783 gtk_table_attach (GTK_TABLE (table1), hseparator, 2, 3, 3, 4,
784 (GtkAttachOptions) (GTK_FILL),
785 (GtkAttachOptions) (GTK_FILL), 0, 0);
787 hseparator = gtk_hseparator_new ();
788 gtk_widget_show (hseparator);
789 gtk_table_attach (GTK_TABLE (table1), hseparator, 3, 4, 3, 4,
790 (GtkAttachOptions) (GTK_FILL),
791 (GtkAttachOptions) (GTK_FILL), 0, 0);
793 hseparator = gtk_hseparator_new ();
794 gtk_widget_show (hseparator);
795 gtk_table_attach (GTK_TABLE (table1), hseparator, 1, 2, 5, 6,
796 (GtkAttachOptions) (GTK_FILL),
797 (GtkAttachOptions) (GTK_FILL), 0, 0);
799 hseparator = gtk_hseparator_new ();
800 gtk_widget_show (hseparator);
801 gtk_table_attach (GTK_TABLE (table1), hseparator, 2, 3, 5, 6,
802 (GtkAttachOptions) (GTK_FILL),
803 (GtkAttachOptions) (GTK_FILL), 0, 0);
805 hseparator = gtk_hseparator_new ();
806 gtk_widget_show (hseparator);
807 gtk_table_attach (GTK_TABLE (table1), hseparator, 3, 4, 5, 6,
808 (GtkAttachOptions) (GTK_FILL),
809 (GtkAttachOptions) (GTK_FILL), 0, 0);
811 hseparator = gtk_hseparator_new ();
812 gtk_widget_show (hseparator);
813 gtk_table_attach (GTK_TABLE (table1), hseparator, 1, 2, 7, 8,
814 (GtkAttachOptions) (GTK_FILL),
815 (GtkAttachOptions) (GTK_FILL), 0, 0);
817 hseparator = gtk_hseparator_new ();
818 gtk_widget_show (hseparator);
819 gtk_table_attach (GTK_TABLE (table1), hseparator, 2, 3, 7, 8,
820 (GtkAttachOptions) (GTK_FILL),
821 (GtkAttachOptions) (GTK_FILL), 0, 0);
823 hseparator = gtk_hseparator_new ();
824 gtk_widget_show (hseparator);
825 gtk_table_attach (GTK_TABLE (table1), hseparator, 3, 4, 7, 8,
826 (GtkAttachOptions) (GTK_FILL),
827 (GtkAttachOptions) (GTK_FILL), 0, 0);
829 hseparator = gtk_hseparator_new ();
830 gtk_widget_show (hseparator);
831 gtk_table_attach (GTK_TABLE (table1), hseparator, 1, 2, 9, 10,
832 (GtkAttachOptions) (GTK_FILL),
833 (GtkAttachOptions) (GTK_FILL), 0, 0);
835 hseparator = gtk_hseparator_new ();
836 gtk_widget_show (hseparator);
837 gtk_table_attach (GTK_TABLE (table1), hseparator, 2, 3, 9, 10,
838 (GtkAttachOptions) (GTK_FILL),
839 (GtkAttachOptions) (GTK_FILL), 0, 0);
841 hseparator = gtk_hseparator_new ();
842 gtk_widget_show (hseparator);
843 gtk_table_attach (GTK_TABLE (table1), hseparator, 3, 4, 9, 10,
844 (GtkAttachOptions) (GTK_FILL),
845 (GtkAttachOptions) (GTK_FILL), 0, 0);
847 hseparator = gtk_hseparator_new ();
848 gtk_widget_show (hseparator);
849 gtk_table_attach (GTK_TABLE (table1), hseparator, 1, 2, 11, 12,
850 (GtkAttachOptions) (GTK_FILL),
851 (GtkAttachOptions) (GTK_FILL), 0, 0);
853 hseparator = gtk_hseparator_new ();
854 gtk_widget_show (hseparator);
855 gtk_table_attach (GTK_TABLE (table1), hseparator, 2, 3, 11, 12,
856 (GtkAttachOptions) (GTK_FILL),
857 (GtkAttachOptions) (GTK_FILL), 0, 0);
859 hseparator = gtk_hseparator_new ();
860 gtk_widget_show (hseparator);
861 gtk_table_attach (GTK_TABLE (table1), hseparator, 3, 4, 11, 12,
862 (GtkAttachOptions) (GTK_FILL),
863 (GtkAttachOptions) (GTK_FILL), 0, 0);
865 label = gtk_label_new ("Offset");
866 gtk_widget_show (label);
867 gtk_table_attach (GTK_TABLE (table1), label, 2, 3, 0, 1,
868 (GtkAttachOptions) (GTK_FILL),
869 (GtkAttachOptions) (0), 0, 0);
871 label = gtk_label_new ("Step");
872 gtk_widget_show (label);
873 gtk_table_attach (GTK_TABLE (table1), label, 3, 4, 0, 1,
874 (GtkAttachOptions) (GTK_FILL),
875 (GtkAttachOptions) (0), 0, 0);
877 eventbox = gtk_event_box_new ();
878 gtk_widget_show (eventbox);
879 gtk_table_attach (GTK_TABLE (table1), eventbox, 3, 4, 12, 13,
880 (GtkAttachOptions) (GTK_FILL),
881 (GtkAttachOptions) (GTK_FILL), 0, 0);
883 match_grid_button = gtk_button_new_with_mnemonic ("Match Grid");
884 gtk_widget_show (match_grid_button);
885 gtk_container_add (GTK_CONTAINER (eventbox), match_grid_button);
887 label = gtk_label_new ("Value");
888 gtk_widget_show (label);
889 gtk_table_attach (GTK_TABLE (table1), label, 1, 2, 0, 1,
890 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
891 (GtkAttachOptions) (0), 0, 0);
892 gtk_misc_set_alignment (GTK_MISC (label), 0.5, 1);
894 hseparator = gtk_hseparator_new ();
895 gtk_widget_show (hseparator);
896 gtk_table_attach (GTK_TABLE (table1), hseparator, 0, 1, 3, 4,
897 (GtkAttachOptions) (GTK_SHRINK | GTK_FILL),
898 (GtkAttachOptions) (GTK_FILL), 0, 0);
900 hseparator = gtk_hseparator_new ();
901 gtk_widget_show (hseparator);
902 gtk_table_attach (GTK_TABLE (table1), hseparator, 0, 1, 5, 6,
903 (GtkAttachOptions) (GTK_FILL),
904 (GtkAttachOptions) (GTK_FILL), 0, 0);
906 hseparator = gtk_hseparator_new ();
907 gtk_widget_show (hseparator);
908 gtk_table_attach (GTK_TABLE (table1), hseparator, 0, 1, 7, 8,
909 (GtkAttachOptions) (GTK_FILL),
910 (GtkAttachOptions) (GTK_FILL), 0, 0);
912 hseparator = gtk_hseparator_new ();
913 gtk_widget_show (hseparator);
914 gtk_table_attach (GTK_TABLE (table1), hseparator, 0, 1, 9, 10,
915 (GtkAttachOptions) (GTK_FILL),
916 (GtkAttachOptions) (GTK_FILL), 0, 0);
918 hseparator = gtk_hseparator_new ();
919 gtk_widget_show (hseparator);
920 gtk_table_attach (GTK_TABLE (table1), hseparator, 0, 1, 11, 12,
921 (GtkAttachOptions) (GTK_FILL),
922 (GtkAttachOptions) (GTK_FILL), 0, 0);
924 eventbox = gtk_event_box_new ();
925 gtk_widget_show (eventbox);
926 gtk_table_attach (GTK_TABLE (table1), eventbox, 0, 1, 4, 5,
927 (GtkAttachOptions) (GTK_FILL),
928 (GtkAttachOptions) (GTK_FILL), 0, 0);
930 label = gtk_label_new ("V Shift: ");
931 gtk_widget_show (label);
932 gtk_container_add (GTK_CONTAINER (eventbox), label);
933 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
934 gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
936 eventbox = gtk_event_box_new ();
937 gtk_widget_show (eventbox);
938 gtk_table_attach (GTK_TABLE (table1), eventbox, 0, 1, 6, 7,
939 (GtkAttachOptions) (GTK_FILL),
940 (GtkAttachOptions) (GTK_FILL), 0, 0);
942 label = gtk_label_new (" H Scale: ");
943 gtk_widget_show (label);
944 gtk_container_add (GTK_CONTAINER (eventbox), label);
945 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
946 gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
948 eventbox = gtk_event_box_new ();
949 gtk_widget_show (eventbox);
950 gtk_table_attach (GTK_TABLE (table1), eventbox, 0, 1, 8, 9,
951 (GtkAttachOptions) (GTK_FILL),
952 (GtkAttachOptions) (GTK_FILL), 0, 0);
954 label = gtk_label_new ("V Scale: ");
955 gtk_widget_show (label);
956 gtk_container_add (GTK_CONTAINER (eventbox), label);
957 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
958 gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
960 eventbox = gtk_event_box_new ();
961 gtk_widget_show (eventbox);
962 gtk_table_attach (GTK_TABLE (table1), eventbox, 0, 1, 10, 11,
963 (GtkAttachOptions) (GTK_FILL),
964 (GtkAttachOptions) (GTK_FILL), 0, 0);
966 label = gtk_label_new ("Rotate: ");
967 gtk_widget_show (label);
968 gtk_container_add (GTK_CONTAINER (eventbox), label);
969 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
970 gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
972 eventbox = gtk_event_box_new ();
973 gtk_widget_show (eventbox);
974 gtk_table_attach (GTK_TABLE (table1), eventbox, 0, 1, 2, 3,
975 (GtkAttachOptions) (GTK_FILL),
976 (GtkAttachOptions) (GTK_FILL), 0, 0);
978 label = gtk_label_new ("H Shift: ");
979 gtk_widget_show (label);
980 gtk_container_add (GTK_CONTAINER (eventbox), label);
981 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
982 gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
984 hseparator = gtk_hseparator_new ();
985 gtk_widget_show (hseparator);
986 gtk_table_attach (GTK_TABLE (table1), hseparator, 0, 1, 1, 2,
987 (GtkAttachOptions) (GTK_FILL),
988 (GtkAttachOptions) (GTK_FILL), 0, 0);
990 eventbox = gtk_event_box_new ();
991 gtk_widget_show (eventbox);
992 gtk_table_attach (GTK_TABLE (table1), eventbox, 1, 2, 12, 13,
993 (GtkAttachOptions) (GTK_FILL),
994 (GtkAttachOptions) (GTK_FILL), 0, 0);
996 lock_valuechange_togglebutton = gtk_toggle_button_new_with_mnemonic ("UNLOCK");
997 gtk_widget_show (lock_valuechange_togglebutton);
998 gtk_container_add (GTK_CONTAINER (eventbox), lock_valuechange_togglebutton);
1001 hshift_value_spinbutton_adj = gtk_adjustment_new (0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0);
1002 hshift_value_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (hshift_value_spinbutton_adj), 1, 2);
1003 gtk_widget_show (hshift_value_spinbutton);
1004 gtk_table_attach (GTK_TABLE (table1), hshift_value_spinbutton, 1, 2, 2, 3,
1005 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1006 (GtkAttachOptions) (0), 0, 0);
1007 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (hshift_value_spinbutton), GTK_UPDATE_IF_VALID);
1008 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (hshift_value_spinbutton), TRUE);
1009 gtk_widget_set_sensitive( GTK_WIDGET( hshift_value_spinbutton ), FALSE );
1011 vshift_value_spinbutton_adj = gtk_adjustment_new (0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0);
1012 vshift_value_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (vshift_value_spinbutton_adj), 1, 2);
1013 gtk_widget_show (vshift_value_spinbutton);
1014 gtk_table_attach (GTK_TABLE (table1), vshift_value_spinbutton, 1, 2, 4, 5,
1015 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1016 (GtkAttachOptions) (0), 0, 0);
1017 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (vshift_value_spinbutton), GTK_UPDATE_IF_VALID);
1018 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (vshift_value_spinbutton), TRUE);
1019 gtk_widget_set_sensitive( GTK_WIDGET( vshift_value_spinbutton ), FALSE );
1021 hscale_value_spinbutton_adj = gtk_adjustment_new (0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0);
1022 hscale_value_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (hscale_value_spinbutton_adj), 1, 4);
1023 gtk_widget_show (hscale_value_spinbutton);
1024 gtk_table_attach (GTK_TABLE (table1), hscale_value_spinbutton, 1, 2, 6, 7,
1025 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1026 (GtkAttachOptions) (0), 0, 0);
1027 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (hscale_value_spinbutton), GTK_UPDATE_IF_VALID);
1028 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (hscale_value_spinbutton), TRUE);
1029 gtk_widget_set_sensitive( GTK_WIDGET( hscale_value_spinbutton ), FALSE );
1031 vscale_value_spinbutton_adj = gtk_adjustment_new (0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0);
1032 vscale_value_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (vscale_value_spinbutton_adj), 1, 4);
1033 gtk_widget_show (vscale_value_spinbutton);
1034 gtk_table_attach (GTK_TABLE (table1), vscale_value_spinbutton, 1, 2, 8, 9,
1035 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1036 (GtkAttachOptions) (0), 0, 0);
1037 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (vscale_value_spinbutton), GTK_UPDATE_IF_VALID);
1038 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (vscale_value_spinbutton), TRUE);
1039 gtk_widget_set_sensitive( GTK_WIDGET( vscale_value_spinbutton ), FALSE );
1041 rotate_value_spinbutton_adj = gtk_adjustment_new (0.0, -360.0, 360.0, 1.0, 10.0, 10.0);
1042 rotate_value_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (rotate_value_spinbutton_adj), 1, 0);
1043 gtk_widget_show (rotate_value_spinbutton);
1044 gtk_table_attach (GTK_TABLE (table1), rotate_value_spinbutton, 1, 2, 10, 11,
1045 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1046 (GtkAttachOptions) (0), 0, 0);
1047 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (rotate_value_spinbutton), GTK_UPDATE_IF_VALID);
1048 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (rotate_value_spinbutton), TRUE);
1049 gtk_widget_set_sensitive( GTK_WIDGET( rotate_value_spinbutton ), FALSE );
1052 hshift_offset_spinbutton_adj = gtk_adjustment_new (0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0);
1053 hshift_offset_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (hshift_offset_spinbutton_adj), 0, 2);
1054 gtk_widget_show (hshift_offset_spinbutton);
1055 gtk_table_attach (GTK_TABLE (table1), hshift_offset_spinbutton, 2, 3, 2, 3,
1056 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1057 (GtkAttachOptions) (0), 4, 0);
1058 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (hshift_offset_spinbutton), TRUE);
1059 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (hshift_offset_spinbutton), GTK_UPDATE_IF_VALID);
1060 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (hshift_offset_spinbutton), TRUE);
1062 vshift_offset_spinbutton_adj = gtk_adjustment_new (0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0);
1063 vshift_offset_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (vshift_offset_spinbutton_adj), 0, 2);
1064 gtk_widget_show (vshift_offset_spinbutton);
1065 gtk_table_attach (GTK_TABLE (table1), vshift_offset_spinbutton, 2, 3, 4, 5,
1066 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1067 (GtkAttachOptions) (0), 4, 0);
1068 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (vshift_offset_spinbutton), TRUE);
1069 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (vshift_offset_spinbutton), GTK_UPDATE_IF_VALID);
1070 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (vshift_offset_spinbutton), TRUE);
1072 hscale_offset_spinbutton_adj = gtk_adjustment_new (0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0);
1073 hscale_offset_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (hscale_offset_spinbutton_adj), 0, 4);
1074 gtk_widget_show (hscale_offset_spinbutton);
1075 gtk_table_attach (GTK_TABLE (table1), hscale_offset_spinbutton, 2, 3, 6, 7,
1076 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1077 (GtkAttachOptions) (0), 4, 0);
1078 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (hscale_offset_spinbutton), TRUE);
1079 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (hscale_offset_spinbutton), GTK_UPDATE_IF_VALID);
1080 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (hscale_offset_spinbutton), TRUE);
1082 vscale_offset_spinbutton_adj = gtk_adjustment_new (0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0);
1083 vscale_offset_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (vscale_offset_spinbutton_adj), 0, 4);
1084 gtk_widget_show (vscale_offset_spinbutton);
1085 gtk_table_attach (GTK_TABLE (table1), vscale_offset_spinbutton, 2, 3, 8, 9,
1086 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1087 (GtkAttachOptions) (0), 4, 0);
1088 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (vscale_offset_spinbutton), TRUE);
1089 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (vscale_offset_spinbutton), GTK_UPDATE_IF_VALID);
1090 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (vscale_offset_spinbutton), TRUE);
1092 rotate_offset_spinbutton_adj = gtk_adjustment_new (0.0, -360.0, 360.0, 1.0, 10.0, 10.0);
1093 rotate_offset_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (rotate_offset_spinbutton_adj), 0, 2);
1094 gtk_widget_show (rotate_offset_spinbutton);
1095 gtk_table_attach (GTK_TABLE (table1), rotate_offset_spinbutton, 2, 3, 10, 11,
1096 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1097 (GtkAttachOptions) (0), 4, 0);
1098 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (rotate_offset_spinbutton), TRUE);
1099 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (rotate_offset_spinbutton), GTK_UPDATE_IF_VALID);
1100 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (rotate_offset_spinbutton), TRUE);
1103 hshift_step_spinbutton_adj = gtk_adjustment_new (0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0);
1104 hshift_step_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (hshift_step_spinbutton_adj), 1, 2);
1105 gtk_widget_show (hshift_step_spinbutton);
1106 gtk_table_attach (GTK_TABLE (table1), hshift_step_spinbutton, 3, 4, 2, 3,
1107 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1108 (GtkAttachOptions) (0), 0, 0);
1109 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (hshift_step_spinbutton), GTK_UPDATE_IF_VALID);
1111 vshift_step_spinbutton_adj = gtk_adjustment_new (0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0);
1112 vshift_step_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (vshift_step_spinbutton_adj), 1, 2);
1113 gtk_widget_show (vshift_step_spinbutton);
1114 gtk_table_attach (GTK_TABLE (table1), vshift_step_spinbutton, 3, 4, 4, 5,
1115 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1116 (GtkAttachOptions) (0), 0, 0);
1117 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (vshift_step_spinbutton), GTK_UPDATE_IF_VALID);
1119 hscale_step_spinbutton_adj = gtk_adjustment_new (0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0);
1120 hscale_step_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (hscale_step_spinbutton_adj), 1, 4);
1121 gtk_widget_show (hscale_step_spinbutton);
1122 gtk_table_attach (GTK_TABLE (table1), hscale_step_spinbutton, 3, 4, 6, 7,
1123 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1124 (GtkAttachOptions) (0), 0, 0);
1125 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (hscale_step_spinbutton), GTK_UPDATE_IF_VALID);
1127 vscale_step_spinbutton_adj = gtk_adjustment_new (0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0);
1128 vscale_step_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (vscale_step_spinbutton_adj), 1, 4);
1129 gtk_widget_show (vscale_step_spinbutton);
1130 gtk_table_attach (GTK_TABLE (table1), vscale_step_spinbutton, 3, 4, 8, 9,
1131 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1132 (GtkAttachOptions) (0), 0, 0);
1133 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (vscale_step_spinbutton), GTK_UPDATE_IF_VALID);
1135 rotate_step_spinbutton_adj = gtk_adjustment_new (0.0, -360.0, 360.0, 1.0, 10.0, 10.0);
1136 rotate_step_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (rotate_step_spinbutton_adj), 1, 2);
1137 gtk_widget_show (rotate_step_spinbutton);
1138 gtk_table_attach (GTK_TABLE (table1), rotate_step_spinbutton, 3, 4, 10, 11,
1139 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1140 (GtkAttachOptions) (0), 0, 0);
1141 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (rotate_step_spinbutton), GTK_UPDATE_IF_VALID);
1143 eventbox = gtk_event_box_new ();
1144 gtk_widget_show (eventbox);
1145 gtk_table_attach (GTK_TABLE (table1), eventbox, 2, 3, 12, 13,
1146 (GtkAttachOptions) (0),
1147 (GtkAttachOptions) (0), 0, 0);
1149 eventbox = gtk_event_box_new ();
1150 gtk_widget_show (eventbox);
1151 gtk_table_attach (GTK_TABLE (table1), eventbox, 0, 1, 12, 13,
1152 (GtkAttachOptions) (0),
1153 (GtkAttachOptions) (0), 0, 0);
1155 eventbox = gtk_event_box_new ();
1156 gtk_widget_show (eventbox);
1157 gtk_table_attach (GTK_TABLE (table1), eventbox, 0, 1, 0, 1,
1158 (GtkAttachOptions) (0),
1159 (GtkAttachOptions) (0), 0, 0);
1161 viewport7 = gtk_viewport_new (NULL, NULL);
1162 gtk_widget_show (viewport7);
1163 gtk_box_pack_start (GTK_BOX (vbox7), viewport7, FALSE, TRUE, 0);
1164 gtk_container_set_border_width (GTK_CONTAINER (viewport7), 2);
1165 gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport7), GTK_SHADOW_ETCHED_IN);
1167 table4 = gtk_table_new (4, 7, FALSE);
1168 gtk_widget_show (table4);
1169 gtk_container_add (GTK_CONTAINER (viewport7), table4);
1171 viewport5 = gtk_viewport_new (NULL, NULL);
1172 gtk_widget_show (viewport5);
1173 gtk_table_attach (GTK_TABLE (table4), viewport5, 1, 7, 0, 4,
1174 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1175 (GtkAttachOptions) (0), 0, 0);
1176 gtk_container_set_border_width (GTK_CONTAINER (viewport5), 6);
1177 gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport5), GTK_SHADOW_ETCHED_OUT);
1179 table5 = gtk_table_new (2, 3, FALSE);
1180 gtk_widget_show (table5);
1181 gtk_container_add (GTK_CONTAINER (viewport5), table5);
1182 gtk_container_set_border_width (GTK_CONTAINER (table5), 5);
1183 gtk_table_set_col_spacings (GTK_TABLE (table5), 2);
1185 label = gtk_label_new ("Height");
1186 gtk_widget_show (label);
1187 gtk_table_attach (GTK_TABLE (table5), label, 2, 3, 0, 1,
1188 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1189 (GtkAttachOptions) (GTK_FILL), 0, 0);
1190 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1191 gtk_misc_set_alignment (GTK_MISC (label), 0.5, 1);
1193 label = gtk_label_new ("Width");
1194 gtk_widget_show (label);
1195 gtk_table_attach (GTK_TABLE (table5), label, 1, 2, 0, 1,
1196 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1197 (GtkAttachOptions) (GTK_FILL), 0, 0);
1198 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1199 gtk_misc_set_alignment (GTK_MISC (label), 0.5, 1);
1201 fit_width_spinbutton_adj = gtk_adjustment_new (1, 1, 32, 1, 10, 10);
1202 fit_width_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (fit_width_spinbutton_adj), 1, 0);
1203 gtk_widget_show (fit_width_spinbutton);
1204 gtk_table_attach (GTK_TABLE (table5), fit_width_spinbutton, 1, 2, 1, 2,
1205 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1206 (GtkAttachOptions) (GTK_FILL), 0, 0);
1207 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (fit_width_spinbutton), TRUE);
1208 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (fit_width_spinbutton), GTK_UPDATE_IF_VALID);
1210 fit_height_spinbutton_adj = gtk_adjustment_new (1, 1, 32, 1, 10, 10);
1211 fit_height_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (fit_height_spinbutton_adj), 1, 0);
1212 gtk_widget_show (fit_height_spinbutton);
1213 gtk_table_attach (GTK_TABLE (table5), fit_height_spinbutton, 2, 3, 1, 2,
1214 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1215 (GtkAttachOptions) (GTK_FILL), 3, 0);
1216 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (fit_height_spinbutton), TRUE);
1217 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (fit_height_spinbutton), GTK_UPDATE_IF_VALID);
1219 eventbox = gtk_event_box_new ();
1220 gtk_widget_show (eventbox);
1221 gtk_table_attach (GTK_TABLE (table5), eventbox, 0, 1, 0, 1,
1222 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1223 (GtkAttachOptions) (GTK_FILL), 0, 0);
1225 eventbox = gtk_event_box_new ();
1226 gtk_widget_show (eventbox);
1227 gtk_table_attach (GTK_TABLE (table5), eventbox, 0, 1, 1, 2,
1228 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1229 (GtkAttachOptions) (GTK_FILL), 4, 0);
1231 fit_button = gtk_button_new_with_mnemonic (" Fit ");
1232 gtk_widget_show (fit_button);
1233 gtk_container_add (GTK_CONTAINER (eventbox), fit_button);
1235 viewport6 = gtk_viewport_new (NULL, NULL);
1236 gtk_widget_show (viewport6);
1237 gtk_table_attach (GTK_TABLE (table4), viewport6, 0, 1, 0, 4,
1238 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1239 (GtkAttachOptions) (0), 0, 0);
1240 gtk_container_set_border_width (GTK_CONTAINER (viewport6), 4);
1241 gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport6), GTK_SHADOW_NONE);
1243 table7 = gtk_table_new (2, 1, FALSE);
1244 gtk_widget_show (table7);
1245 gtk_container_add (GTK_CONTAINER (viewport6), table7);
1247 eventbox = gtk_event_box_new ();
1248 gtk_widget_show (eventbox);
1249 gtk_table_attach (GTK_TABLE (table7), eventbox, 0, 1, 0, 2,
1250 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1251 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0);
1253 axial_button = gtk_button_new_with_mnemonic ("Axial");
1254 gtk_widget_show (axial_button);
1255 gtk_container_add (GTK_CONTAINER (eventbox), axial_button);
1256 gtk_widget_set_size_request (axial_button, 56, 29);
1257 gtk_container_set_border_width (GTK_CONTAINER (axial_button), 4);
1259 // Fit in Flags sub-dialog
1260 Create_Heretic2FlagsDialog(vbox7);
1262 viewport10 = gtk_viewport_new (NULL, NULL);
1263 gtk_widget_show (viewport10);
1264 gtk_box_pack_start (GTK_BOX (vbox7), viewport10, FALSE, TRUE, 0);
1265 gtk_container_set_border_width (GTK_CONTAINER (viewport10), 2);
1266 gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport10), GTK_SHADOW_ETCHED_IN);
1268 hbuttonbox1 = gtk_hbutton_box_new ();
1269 gtk_widget_show (hbuttonbox1);
1270 gtk_container_add (GTK_CONTAINER (viewport10), hbuttonbox1);
1271 gtk_container_set_border_width (GTK_CONTAINER (hbuttonbox1), 4);
1272 gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox1), GTK_BUTTONBOX_SPREAD);
1274 done_button = gtk_button_new ();
1275 gtk_widget_show (done_button);
1276 gtk_container_add (GTK_CONTAINER (hbuttonbox1), done_button);
1277 GTK_WIDGET_SET_FLAGS (done_button, GTK_CAN_DEFAULT);
1279 alignment1 = gtk_alignment_new (0.5, 0.5, 0, 0);
1280 gtk_widget_show (alignment1);
1281 gtk_container_add (GTK_CONTAINER (done_button), alignment1);
1283 hbox2 = gtk_hbox_new (FALSE, 2);
1284 gtk_widget_show (hbox2);
1285 gtk_container_add (GTK_CONTAINER (alignment1), hbox2);
1287 image1 = gtk_image_new_from_stock ("gtk-yes", GTK_ICON_SIZE_BUTTON);
1288 gtk_widget_show (image1);
1289 gtk_box_pack_start (GTK_BOX (hbox2), image1, FALSE, FALSE, 0);
1291 label = gtk_label_new_with_mnemonic ("Done");
1292 gtk_widget_show (label);
1293 gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);
1294 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1296 apply_button = gtk_button_new ();
1297 gtk_widget_show (apply_button);
1298 gtk_container_add (GTK_CONTAINER (hbuttonbox1), apply_button);
1299 GTK_WIDGET_SET_FLAGS (apply_button, GTK_CAN_DEFAULT);
1301 alignment3 = gtk_alignment_new (0.5, 0.5, 0, 0);
1302 gtk_widget_show (alignment3);
1303 gtk_container_add (GTK_CONTAINER (apply_button), alignment3);
1305 hbox4 = gtk_hbox_new (FALSE, 2);
1306 gtk_widget_show (hbox4);
1307 gtk_container_add (GTK_CONTAINER (alignment3), hbox4);
1309 image3 = gtk_image_new_from_stock ("gtk-apply", GTK_ICON_SIZE_BUTTON);
1310 gtk_widget_show (image3);
1311 gtk_box_pack_start (GTK_BOX (hbox4), image3, FALSE, FALSE, 0);
1313 label = gtk_label_new_with_mnemonic ("Apply");
1314 gtk_widget_show (label);
1315 gtk_box_pack_start (GTK_BOX (hbox4), label, FALSE, FALSE, 0);
1316 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1318 cancel_button = gtk_button_new ();
1319 gtk_widget_show (cancel_button);
1320 gtk_container_add (GTK_CONTAINER (hbuttonbox1), cancel_button);
1321 GTK_WIDGET_SET_FLAGS (cancel_button, GTK_CAN_DEFAULT);
1323 alignment2 = gtk_alignment_new (0.5, 0.5, 0, 0);
1324 gtk_widget_show (alignment2);
1325 gtk_container_add (GTK_CONTAINER (cancel_button), alignment2);
1327 hbox3 = gtk_hbox_new (FALSE, 2);
1328 gtk_widget_show (hbox3);
1329 gtk_container_add (GTK_CONTAINER (alignment2), hbox3);
1331 image2 = gtk_image_new_from_stock ("gtk-no", GTK_ICON_SIZE_BUTTON);
1332 gtk_widget_show (image2);
1333 gtk_box_pack_start (GTK_BOX (hbox3), image2, FALSE, FALSE, 0);
1335 label = gtk_label_new_with_mnemonic ("Cancel");
1336 gtk_widget_show (label);
1337 gtk_box_pack_start (GTK_BOX (hbox3), label, FALSE, FALSE, 0);
1338 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1341 g_signal_connect ( (gpointer) SurfaceInspector,
1343 G_CALLBACK (delete_event_callback),
1345 g_signal_connect ((gpointer) SurfaceInspector, "destroy",
1346 G_CALLBACK (gtk_widget_destroy),
1349 g_signal_connect ((gpointer) texture_combo_entry, "key_press_event",
1350 G_CALLBACK (on_texture_combo_entry_key_press_event),
1352 g_signal_connect ((gpointer) texture_combo_entry, "activate",
1353 G_CALLBACK (on_texture_combo_entry_activate),
1357 g_signal_connect ((gpointer) hshift_offset_spinbutton, "value_changed",
1358 G_CALLBACK (on_hshift_offset_spinbutton_value_changed),
1360 g_signal_connect ((gpointer) vshift_offset_spinbutton, "value_changed",
1361 G_CALLBACK (on_vshift_offset_spinbutton_value_changed),
1363 g_signal_connect ((gpointer) hscale_offset_spinbutton, "value_changed",
1364 G_CALLBACK (on_hscale_offset_spinbutton_value_changed),
1366 g_signal_connect ((gpointer) vscale_offset_spinbutton, "value_changed",
1367 G_CALLBACK (on_vscale_offset_spinbutton_value_changed),
1369 g_signal_connect ((gpointer) rotate_offset_spinbutton, "value_changed",
1370 G_CALLBACK (on_rotate_offset_spinbutton_value_changed),
1373 g_signal_connect ((gpointer) hshift_value_spinbutton, "value_changed",
1374 G_CALLBACK (on_hshift_value_spinbutton_value_changed),
1376 g_signal_connect ((gpointer) vshift_value_spinbutton, "value_changed",
1377 G_CALLBACK (on_vshift_value_spinbutton_value_changed),
1379 g_signal_connect ((gpointer) hscale_value_spinbutton, "value_changed",
1380 G_CALLBACK (on_hscale_value_spinbutton_value_changed),
1382 g_signal_connect ((gpointer) vscale_value_spinbutton, "value_changed",
1383 G_CALLBACK (on_vscale_value_spinbutton_value_changed),
1385 g_signal_connect ((gpointer) rotate_value_spinbutton, "value_changed",
1386 G_CALLBACK (on_rotate_value_spinbutton_value_changed),
1389 g_signal_connect ((gpointer) hshift_step_spinbutton, "value_changed",
1390 G_CALLBACK (on_hshift_step_spinbutton_value_changed),
1392 g_signal_connect ((gpointer) vshift_step_spinbutton, "value_changed",
1393 G_CALLBACK (on_vshift_step_spinbutton_value_changed),
1395 g_signal_connect ((gpointer) hscale_step_spinbutton, "value_changed",
1396 G_CALLBACK (on_hscale_step_spinbutton_value_changed),
1398 g_signal_connect ((gpointer) vscale_step_spinbutton, "value_changed",
1399 G_CALLBACK (on_vscale_step_spinbutton_value_changed),
1401 g_signal_connect ((gpointer) rotate_step_spinbutton, "value_changed",
1402 G_CALLBACK (on_rotate_step_spinbutton_value_changed),
1405 g_signal_connect ((gpointer) match_grid_button, "clicked",
1406 G_CALLBACK (on_match_grid_button_clicked),
1408 g_signal_connect ((gpointer) lock_valuechange_togglebutton, "toggled",
1409 G_CALLBACK (on_lock_valuechange_togglebutton_toggled),
1412 g_signal_connect ((gpointer) fit_width_spinbutton, "value_changed",
1413 G_CALLBACK (on_fit_width_spinbutton_value_changed),
1415 g_signal_connect ((gpointer) fit_height_spinbutton, "value_changed",
1416 G_CALLBACK (on_fit_height_spinbutton_value_changed),
1418 g_signal_connect ((gpointer) fit_button, "clicked",
1419 G_CALLBACK (on_fit_button_clicked),
1422 g_signal_connect ((gpointer) axial_button, "clicked",
1423 G_CALLBACK (on_axial_button_clicked),
1426 g_signal_connect ((gpointer) done_button, "clicked",
1427 G_CALLBACK (on_done_button_clicked),
1429 g_signal_connect ((gpointer) apply_button, "clicked",
1430 G_CALLBACK (on_apply_button_clicked),
1432 g_signal_connect ((gpointer) cancel_button, "clicked",
1433 G_CALLBACK (on_cancel_button_clicked),
1437 return SurfaceInspector;
1442 gboolean on_texture_combo_entry_key_press_event (GtkWidget *widget, GdkEventKey *event,
1445 // Have Tab activate selection as well as Return
1446 if (event->keyval == GDK_Tab)
1447 g_signal_emit_by_name ( texture_combo_entry, "activate" );
1452 void on_texture_combo_entry_activate (GtkEntry *entry, gpointer user_data)
1454 texdef_t* tmp_texdef;
1455 texdef_t* tmp_orig_texdef;
1456 texdef_to_face_t* temp_texdef_face_list;
1457 char text[128] = { 0 };
1459 if (!texdef_face_list_empty() && g_bListenChanged)
1461 // activate only on entry change
1462 strcpy( text, gtk_entry_get_text(entry));
1463 if ( strcmp( old_texture_entry, text ))
1465 // Check for spaces in shader name
1466 if (text[0] <= ' ' || strchr(text, ' '))
1467 Sys_FPrintf(SYS_WRN, "WARNING: spaces in shader names are not allowed, ignoring '%s'\n", text);
1470 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1472 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1473 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1474 strcpy( old_texture_entry, text );
1475 tmp_texdef->SetName( text );
1484 static void on_hshift_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1486 texdef_t* tmp_texdef;
1487 texdef_t* tmp_orig_texdef;
1488 texdef_to_face_t* temp_texdef_face_list;
1490 texdef_offset.shift[0] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hshift_offset_spinbutton) );
1492 if (!texdef_face_list_empty() && g_bListenChanged)
1494 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1496 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1497 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1498 if (is_HShift_conflicting)
1499 tmp_texdef->shift[0] = tmp_orig_texdef->shift[0] + texdef_offset.shift[0];
1501 tmp_texdef->shift[0] = texdef_SI_values.shift[0] + texdef_offset.shift[0];
1507 static void on_vshift_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1509 texdef_t* tmp_texdef;
1510 texdef_t* tmp_orig_texdef;
1511 texdef_to_face_t* temp_texdef_face_list;
1513 texdef_offset.shift[1] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vshift_offset_spinbutton) );
1515 if (!texdef_face_list_empty() && g_bListenChanged)
1517 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1519 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1520 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1521 if (is_VShift_conflicting)
1522 tmp_texdef->shift[1] = tmp_orig_texdef->shift[1] + texdef_offset.shift[1];
1524 tmp_texdef->shift[1] = texdef_SI_values.shift[1] + texdef_offset.shift[1];
1531 static void on_hscale_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1533 texdef_t* tmp_texdef;
1534 texdef_t* tmp_orig_texdef;
1535 texdef_to_face_t* temp_texdef_face_list;
1537 texdef_offset.scale[0] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hscale_offset_spinbutton) );
1539 if (!texdef_face_list_empty() && g_bListenChanged)
1541 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1543 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1544 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1545 if (is_HScale_conflicting)
1546 tmp_texdef->scale[0] = tmp_orig_texdef->scale[0] + texdef_offset.scale[0];
1548 tmp_texdef->scale[0] = texdef_SI_values.scale[0] + texdef_offset.scale[0];
1556 static void on_vscale_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1558 texdef_t* tmp_texdef;
1559 texdef_t* tmp_orig_texdef;
1560 texdef_to_face_t* temp_texdef_face_list;
1562 texdef_offset.scale[1] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vscale_offset_spinbutton) );
1564 if (!texdef_face_list_empty() && g_bListenChanged)
1566 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1568 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1569 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1570 if (is_VScale_conflicting)
1571 tmp_texdef->scale[1] = tmp_orig_texdef->scale[1] + texdef_offset.scale[1];
1573 tmp_texdef->scale[1] = texdef_SI_values.scale[1] + texdef_offset.scale[1];
1580 static void on_rotate_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1582 texdef_t* tmp_texdef;
1583 texdef_t* tmp_orig_texdef;
1584 texdef_to_face_t* temp_texdef_face_list;
1586 texdef_offset.rotate = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(rotate_offset_spinbutton) );
1588 if (!texdef_face_list_empty() && g_bListenChanged)
1590 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1592 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1593 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1594 if (is_Rotate_conflicting)
1595 tmp_texdef->rotate = tmp_orig_texdef->rotate + texdef_offset.rotate;
1597 tmp_texdef->rotate = texdef_SI_values.rotate + texdef_offset.rotate;
1606 static void on_match_grid_button_clicked (GtkButton *button, gpointer user_data)
1608 float hscale, vscale;
1610 if( !strcmp(gtk_entry_get_text (GTK_ENTRY (hscale_value_spinbutton)), "") )
1613 hscale = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hscale_value_spinbutton) );
1615 if( !strcmp( gtk_entry_get_text (GTK_ENTRY (vscale_value_spinbutton)), "") )
1618 vscale = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vscale_value_spinbutton) );
1619 DoSnapTToGrid (hscale, vscale);
1623 // Lock out changes to Value
1624 static void on_lock_valuechange_togglebutton_toggled (GtkToggleButton *togglebutton, gpointer user_data)
1628 is_Locked = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lock_valuechange_togglebutton));
1630 gtk_widget_set_sensitive( GTK_WIDGET( hscale_value_spinbutton ), is_Locked );
1631 gtk_widget_set_sensitive( GTK_WIDGET( vscale_value_spinbutton ), is_Locked );
1632 gtk_widget_set_sensitive( GTK_WIDGET( hshift_value_spinbutton ), is_Locked );
1633 gtk_widget_set_sensitive( GTK_WIDGET( vshift_value_spinbutton ), is_Locked );
1634 gtk_widget_set_sensitive( GTK_WIDGET( rotate_value_spinbutton ), is_Locked );
1639 static void on_hshift_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1641 texdef_t* tmp_texdef;
1642 texdef_t* tmp_orig_texdef;
1643 texdef_to_face_t* temp_texdef_face_list;
1645 texdef_SI_values.shift[0] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hshift_value_spinbutton) );
1647 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[0] = texdef_SI_values.shift[0] + texdef_offset.shift[0];
1654 is_HShift_conflicting = FALSE;
1660 static void on_vshift_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1662 texdef_t* tmp_texdef;
1663 texdef_t* tmp_orig_texdef;
1664 texdef_to_face_t* temp_texdef_face_list;
1666 texdef_SI_values.shift[1] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vshift_value_spinbutton) );
1668 if (!texdef_face_list_empty() && g_bListenChanged)
1670 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1672 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1673 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1674 tmp_texdef->shift[1] = texdef_SI_values.shift[1] + texdef_offset.shift[1];
1675 is_VShift_conflicting = FALSE;
1681 static void on_hscale_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1683 texdef_t* tmp_texdef;
1684 texdef_t* tmp_orig_texdef;
1685 texdef_to_face_t* temp_texdef_face_list;
1687 texdef_SI_values.scale[0] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hscale_value_spinbutton) );
1689 if (!texdef_face_list_empty() && g_bListenChanged)
1691 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1693 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1694 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1695 tmp_texdef->scale[0] = texdef_SI_values.scale[0] + texdef_offset.scale[0];
1696 is_HScale_conflicting = FALSE;
1702 static void on_vscale_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1704 texdef_t* tmp_texdef;
1705 texdef_t* tmp_orig_texdef;
1706 texdef_to_face_t* temp_texdef_face_list;
1708 texdef_SI_values.scale[1] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vscale_value_spinbutton) );
1710 if (!texdef_face_list_empty() && g_bListenChanged)
1712 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1714 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1715 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1716 tmp_texdef->scale[1] = texdef_SI_values.scale[1] + texdef_offset.scale[1];
1717 is_VScale_conflicting = FALSE;
1723 static void on_rotate_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1725 texdef_t* tmp_texdef;
1726 texdef_t* tmp_orig_texdef;
1727 texdef_to_face_t* temp_texdef_face_list;
1729 texdef_SI_values.rotate = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(rotate_value_spinbutton) );
1731 if (!texdef_face_list_empty() && g_bListenChanged)
1733 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1735 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1736 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1737 tmp_texdef->rotate = texdef_SI_values.rotate + texdef_offset.rotate;
1738 is_Rotate_conflicting = FALSE;
1746 static void on_hshift_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1749 GtkAdjustment * adjust;
1751 if (!g_bListenChanged)
1754 l_pIncrement = Get_SI_Inc();
1757 Sys_Printf("OnIncrementChanged HShift\n");
1760 val = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hshift_step_spinbutton) ) ;
1761 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( hshift_offset_spinbutton ));
1762 adjust->step_increment = val;
1763 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( hshift_value_spinbutton ));
1764 adjust->step_increment = val;
1765 l_pIncrement->shift[0] = val;
1768 static void on_vshift_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1771 GtkAdjustment * adjust;
1773 if (!g_bListenChanged)
1776 l_pIncrement = Get_SI_Inc();
1779 Sys_Printf("OnIncrementChanged VShift\n");
1782 val = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vshift_step_spinbutton) ) ;
1783 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( vshift_offset_spinbutton ));
1784 adjust->step_increment = val;
1785 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( vshift_value_spinbutton ));
1786 adjust->step_increment = val;
1787 l_pIncrement->shift[1] = val;
1790 static void on_hscale_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1793 GtkAdjustment * adjust;
1795 if (!g_bListenChanged)
1798 l_pIncrement = Get_SI_Inc();
1801 Sys_Printf("OnIncrementChanged HShift\n");
1804 val = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hscale_step_spinbutton) ) ;
1805 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( hscale_offset_spinbutton ));
1806 adjust->step_increment = val;
1807 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( hscale_value_spinbutton ));
1808 adjust->step_increment = val;
1809 l_pIncrement->scale[0] = val;
1812 static void on_vscale_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1815 GtkAdjustment * adjust;
1817 if (!g_bListenChanged)
1820 l_pIncrement = Get_SI_Inc();
1823 Sys_Printf("OnIncrementChanged HShift\n");
1826 val = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vscale_step_spinbutton) ) ;
1827 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( vscale_offset_spinbutton ));
1828 adjust->step_increment = val;
1829 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( vscale_value_spinbutton ));
1830 adjust->step_increment = val;
1831 l_pIncrement->scale[1] = val;
1834 static void on_rotate_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1837 GtkAdjustment * adjust;
1839 if (!g_bListenChanged)
1842 l_pIncrement = Get_SI_Inc();
1845 Sys_Printf("OnIncrementChanged HShift\n");
1848 val = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(rotate_step_spinbutton) ) ;
1849 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( rotate_offset_spinbutton ));
1850 adjust->step_increment = val;
1851 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( rotate_value_spinbutton ));
1852 adjust->step_increment = val;
1853 l_pIncrement->rotate = val;
1858 static void on_fit_width_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1860 m_nWidth = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(fit_width_spinbutton) );
1863 static void on_fit_height_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1865 m_nHeight = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(fit_height_spinbutton) );
1868 static void on_fit_button_clicked (GtkButton *button, gpointer user_data)
1870 FaceList_FitTexture(get_texdef_face_list(), m_nHeight, m_nWidth);
1871 Sys_UpdateWindows(W_ALL);
1876 static void on_axial_button_clicked (GtkButton *button, gpointer user_data)
1878 texdef_t* tmp_texdef;
1879 texdef_t* tmp_orig_texdef;
1880 texdef_to_face_t* temp_texdef_face_list;
1882 if (!texdef_face_list_empty() && g_bListenChanged)
1884 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1886 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1887 tmp_texdef->shift[0] = 0.0;
1888 tmp_texdef->shift[1] = 0.0;
1889 tmp_texdef->scale[0] = 0.5;
1890 tmp_texdef->scale[1] = 0.5;
1891 tmp_texdef->rotate = 0.0;
1895 SetTexdef_FaceList( get_texdef_face_list(), FALSE, TRUE );
1896 Sys_UpdateWindows(W_ALL);
1901 static void on_done_button_clicked (GtkButton *button, gpointer user_data)
1903 if ( !texdef_face_list_empty() )
1906 Sys_UpdateWindows(W_ALL);
1909 static void on_apply_button_clicked (GtkButton *button, gpointer user_data)
1911 if (!g_bListenChanged)
1914 if ( !texdef_face_list_empty() )
1917 Sys_UpdateWindows(W_CAMERA);
1918 GetTexdefInfo_from_Radiant();
1923 static void on_cancel_button_clicked (GtkButton *button, gpointer user_data)
1925 texturewin = Texturewin ();
1926 texturewin->texdef = g_old_texdef;
1927 // cancel the last do if we own it
1928 if ( (m_nUndoId == Undo_GetUndoId()) && ( m_nUndoId != 0 ))
1931 Sys_Printf("OnCancel calling Undo_Undo\n");
1933 g_bListenUpdate = false;
1935 g_bListenUpdate = true;