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 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();
86 // 0 is invalid, otherwise it's the Id of the last 'do' we are responsible for
90 texturewin_t *texturewin;
91 texdef_t *l_pIncrement;
92 texdef_t texdef_offset;
93 texdef_t texdef_SI_values;
95 // For Texture Entry, activate only on entry change
96 char old_texture_entry[128];
98 // the texdef to switch back to when the OnCancel is called
99 texdef_t g_old_texdef;
101 // when TRUE, this thing means the surface inspector is currently being displayed
102 bool g_surfwin = FALSE;
103 // turn on/off processing of the "changed" "value_changed" messages
104 // (need to turn off when we are feeding data in)
105 bool g_bListenChanged = true;
106 // turn on/off listening of the update messages
107 bool g_bListenUpdate = true;
109 GtkWidget* create_SurfaceInspector (void);
110 GtkWidget *SurfaceInspector = NULL;
112 GtkWidget *m_pWidget;
113 GtkWidget *GetWidget () { return SurfaceInspector; }
114 GtkWidget *Get_SI_Module_Widget () { return SurfaceInspector; }
115 void SetWidget(GtkWidget *new_widget) { m_pWidget = new_widget; }
116 GtkWidget *GetDlgWidget (const char* name)
117 { return GTK_WIDGET (g_object_get_data (G_OBJECT (SurfaceInspector), name)); }
119 // Spins for FitTexture
120 GtkWidget *spin_width;
121 GtkWidget *spin_height;
124 GtkWidget *texture_combo;
125 GtkWidget *texture_combo_entry;
127 GtkWidget *match_grid_button;
128 GtkWidget *lock_valuechange_togglebutton;
130 GtkObject *hshift_value_spinbutton_adj;
131 GtkWidget *hshift_value_spinbutton;
132 GtkObject *vshift_value_spinbutton_adj;
133 GtkWidget *vshift_value_spinbutton;
134 GtkObject *hscale_value_spinbutton_adj;
135 GtkWidget *hscale_value_spinbutton;
136 GtkObject *vscale_value_spinbutton_adj;
137 GtkWidget *vscale_value_spinbutton;
138 GtkObject *rotate_value_spinbutton_adj;
139 GtkWidget *rotate_value_spinbutton;
141 GtkObject *hshift_offset_spinbutton_adj;
142 GtkWidget *hshift_offset_spinbutton;
143 GtkObject *vshift_offset_spinbutton_adj;
144 GtkWidget *vshift_offset_spinbutton;
145 GtkObject *hscale_offset_spinbutton_adj;
146 GtkWidget *hscale_offset_spinbutton;
147 GtkObject *vscale_offset_spinbutton_adj;
148 GtkWidget *vscale_offset_spinbutton;
149 GtkObject *rotate_offset_spinbutton_adj;
150 GtkWidget *rotate_offset_spinbutton;
152 GtkObject *hshift_step_spinbutton_adj;
153 GtkWidget *hshift_step_spinbutton;
154 GtkObject *vshift_step_spinbutton_adj;
155 GtkWidget *vshift_step_spinbutton;
156 GtkObject *hscale_step_spinbutton_adj;
157 GtkWidget *hscale_step_spinbutton;
158 GtkObject *vscale_step_spinbutton_adj;
159 GtkWidget *vscale_step_spinbutton;
160 GtkObject *rotate_step_spinbutton_adj;
161 GtkWidget *rotate_step_spinbutton;
163 GtkObject *fit_width_spinbutton_adj;
164 GtkWidget *fit_width_spinbutton;
165 GtkObject *fit_height_spinbutton_adj;
166 GtkWidget *fit_height_spinbutton;
167 GtkWidget *fit_button;
168 GtkWidget *axial_button;
170 GtkWidget *done_button;
171 GtkWidget *apply_button;
172 GtkWidget *cancel_button;
175 gboolean on_texture_combo_entry_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data);
176 void on_texture_combo_entry_activate (GtkEntry *entry, gpointer user_data);
178 static void on_match_grid_button_clicked (GtkButton *button, gpointer user_data);
179 static void on_lock_valuechange_togglebutton_toggled (GtkToggleButton *togglebutton, gpointer user_data);
181 static void on_hshift_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
182 static void on_vshift_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
183 static void on_hscale_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
184 static void on_vscale_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
185 static void on_rotate_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
187 static void on_hshift_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
188 static void on_vshift_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
189 static void on_hscale_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
190 static void on_vscale_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
191 static void on_rotate_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
193 static void on_hshift_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
194 static void on_vshift_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
195 static void on_hscale_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
196 static void on_vscale_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
197 static void on_rotate_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
199 static void on_fit_width_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
200 static void on_fit_height_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
201 static void on_fit_button_clicked (GtkButton *button, gpointer user_data);
202 static void on_axial_button_clicked (GtkButton *button, gpointer user_data);
204 static void on_done_button_clicked (GtkButton *button, gpointer user_data);
205 static void on_apply_button_clicked (GtkButton *button, gpointer user_data);
206 static void on_cancel_button_clicked (GtkButton *button, gpointer user_data);
210 ===================================================
214 ===================================================
218 void IsFaceConflicting()
220 texdef_t* tmp_texdef;
221 texdef_to_face_t* temp_texdef_face_list;
223 char texture_name[128];
225 if (texdef_face_list_empty())
227 gtk_entry_set_text( GTK_ENTRY (hshift_value_spinbutton), "");
228 gtk_entry_set_text( GTK_ENTRY (vshift_value_spinbutton), "");
229 gtk_entry_set_text( GTK_ENTRY (hscale_value_spinbutton), "");
230 gtk_entry_set_text( GTK_ENTRY (vscale_value_spinbutton), "");
231 gtk_entry_set_text( GTK_ENTRY (rotate_value_spinbutton), "");
232 gtk_entry_set_text( GTK_ENTRY (texture_combo_entry), "");
236 g_bListenChanged = FALSE;
238 tmp_texdef = &get_texdef_face_list()->texdef;
240 strcpy(texture_name, tmp_texdef->GetName() );
242 texdef_SI_values.shift[0] = tmp_texdef->shift[0];
243 texdef_SI_values.shift[1] = tmp_texdef->shift[1];
244 texdef_SI_values.scale[0] = tmp_texdef->scale[0];
245 texdef_SI_values.scale[1] = tmp_texdef->scale[1];
246 texdef_SI_values.rotate = tmp_texdef->rotate;
247 texdef_SI_values.SetName( texture_name );
249 is_HShift_conflicting = FALSE;
250 is_VShift_conflicting = FALSE;
251 is_HScale_conflicting = FALSE;
252 is_VScale_conflicting = FALSE;
253 is_Rotate_conflicting = FALSE;
254 is_TextureName_conflicting = FALSE;
256 if (texdef_face_list_size() > 1)
258 temp_texdef_face_list = get_texdef_face_list()->next;
260 for (; temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
262 tmp_texdef = &temp_texdef_face_list->texdef;
263 if ( texdef_SI_values.shift[0] != tmp_texdef->shift[0] )
264 is_HShift_conflicting = TRUE;
266 if ( texdef_SI_values.shift[1] != tmp_texdef->shift[1] )
267 is_VShift_conflicting = TRUE;
269 if ( texdef_SI_values.scale[0] != tmp_texdef->scale[0] )
270 is_HScale_conflicting = TRUE;
272 if ( texdef_SI_values.scale[1] != tmp_texdef->scale[1] )
273 is_VScale_conflicting = TRUE;
275 if ( texdef_SI_values.rotate != tmp_texdef->rotate )
276 is_Rotate_conflicting = TRUE;
278 if ( strcmp( texture_name, tmp_texdef->GetName() ) )
279 is_TextureName_conflicting = TRUE;
283 if(is_HShift_conflicting)
284 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] );
288 if(is_VShift_conflicting)
289 gtk_entry_set_text( GTK_ENTRY (vshift_value_spinbutton), "");
291 gtk_spin_button_set_value( GTK_SPIN_BUTTON(vshift_value_spinbutton) , texdef_SI_values.shift[1] );
293 if(is_HScale_conflicting)
294 gtk_entry_set_text( GTK_ENTRY (hscale_value_spinbutton), "");
296 gtk_spin_button_set_value( GTK_SPIN_BUTTON(hscale_value_spinbutton) , texdef_SI_values.scale[0] );
298 if(is_VScale_conflicting)
299 gtk_entry_set_text( GTK_ENTRY (vscale_value_spinbutton), "");
301 gtk_spin_button_set_value( GTK_SPIN_BUTTON(vscale_value_spinbutton) , texdef_SI_values.scale[1] );
303 if(is_Rotate_conflicting)
304 gtk_entry_set_text( GTK_ENTRY (rotate_value_spinbutton), "");
306 gtk_spin_button_set_value( GTK_SPIN_BUTTON(rotate_value_spinbutton) , texdef_SI_values.rotate );
308 g_bListenChanged = TRUE;
311 #define MAX_NUM_LIST_ITEMS 15
312 static void PopulateTextureComboList()
314 texdef_t* tmp_texdef;
315 texdef_to_face_t* temp_texdef_face_list;
319 int num_of_list_items = 0;
323 if (texdef_face_list_empty())
325 items = g_list_append (items, (gpointer) blank);
326 // For Texture Entry, activate only on entry change
327 strcpy (old_texture_entry, blank);
329 else if ( !is_TextureName_conflicting )
331 temp_texdef_face_list = get_texdef_face_list();
332 tmp_texdef = (texdef_t *) &get_texdef_face_list()->texdef;
333 items = g_list_append( items, (gpointer) tmp_texdef->GetName() );
334 // For Texture Entry, activate only on entry change
335 strcpy (old_texture_entry, tmp_texdef->GetName());
339 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
341 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
342 // Need to do a string compare, hence the custom search
343 if (!( g_list_find_custom (items, tmp_texdef->GetName(), (GCompareFunc) strcmp ) ))
345 items = g_list_append( items, (gpointer) tmp_texdef->GetName() );
348 // Make sure the combo list isn't too long
349 if (num_of_list_items >= MAX_NUM_LIST_ITEMS)
352 // If this isn't added last (to the top of the list), g_list_find freaks.
353 items = g_list_prepend (items, (gpointer) blank);
354 // For Texture Entry, activate only on entry change
355 strcpy (old_texture_entry, blank);
358 gtk_combo_set_popdown_strings (GTK_COMBO (texture_combo), items);
363 static void ZeroOffsetValues()
365 texdef_offset.shift[0] = 0.0;
366 texdef_offset.shift[1] = 0.0;
367 texdef_offset.scale[0] = 0.0;
368 texdef_offset.scale[1] = 0.0;
369 texdef_offset.rotate = 0.0;
372 static void GetTexdefInfo_from_Radiant()
374 g_texdef_face_vector.clear();
376 unsigned int count = GetSelectedFaceCountfromBrushes();
378 count = GetSelectedFaceCount();
380 g_texdef_face_vector.resize(count);
382 if (!texdef_face_list_empty())
384 // texdef_to_face_t* p = get_texdef_face_list();
385 GetSelFacesTexdef( get_texdef_face_list() );
389 PopulateTextureComboList();
393 static gint delete_event_callback(GtkWidget *widget, GdkEvent* event, gpointer data)
399 // make the shift increments match the grid settings
400 // the objective being that the shift+arrows shortcuts move the texture by the corresponding grid size
401 // this depends on a scale value if you have selected a particular texture on which you want it to work:
402 // we move the textures in pixels, not world units. (i.e. increment values are in pixel)
403 // depending on the texture scale it doesn't take the same amount of pixels to move of g_qeglobals.d_gridsize
404 // increment * scale = gridsize
405 // hscale and vscale are optional parameters, if they are zero they will be set to the default scale
406 // NOTE: the default scale depends if you are using BP mode or regular.
407 // For regular it's 0.5f (128 pixels cover 64 world units), for BP it's simply 1.0f
409 void DoSnapTToGrid(float hscale, float vscale)
411 l_pIncrement = Get_SI_Inc();
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()
433 if (!g_bListenUpdate)
436 if (!SurfaceInspector)
439 // avoid long delays on slow computers
440 while (gtk_events_pending ())
441 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)
459 Sys_Printf("DoSurface\n");
461 if (!SurfaceInspector)
462 create_SurfaceInspector ();
471 Sys_Printf("ToggleSurface Module\n");
476 on_cancel_button_clicked(NULL, NULL);
479 // NOTE: will raise and show the Surface inspector and exec fit for patches and brushes
480 void SurfaceDlgFitAll()
486 // =============================================================================
487 // SurfaceDialog class
492 if(!SurfaceInspector)
493 create_SurfaceInspector();
495 gtk_widget_show (SurfaceInspector);
497 GetTexdefInfo_from_Radiant();
498 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)
516 tex->scale[0] = 0.25;
517 tex->scale[1] = 0.25;
523 if ( !SurfaceInspector )
524 create_SurfaceInspector();
531 Set the fields to the current texdef (i.e. map/texdef -> dialog widgets)
539 GtkAdjustment *adjust;
541 texturewin = Texturewin ();
542 l_pIncrement = Get_SI_Inc();
545 Sys_Printf("SurfaceDlg SetTexMods\n");
551 pt = &texturewin->texdef;
553 g_bListenChanged = false;
555 if(strncmp(pt->GetName(), "textures/", 9) != 0)
556 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)
631 Sys_Printf("SurfaceDlg GetTexMods\n");
634 if ( !texdef_face_list_empty() )
636 g_bListenUpdate=FALSE;
637 SetTexdef_FaceList( get_texdef_face_list(), b_SetUndoPoint, false );
638 g_bListenUpdate=TRUE;
641 m_nUndoId = Undo_GetUndoId();
647 on_fit_button_clicked(NULL, NULL);
651 ////////////////////////////////////////////////////////////////////
655 ////////////////////////////////////////////////////////////////////
657 GtkWidget* create_SurfaceInspector (void)
661 GtkWidget *hseparator;
664 GtkWidget *viewport8;
665 GtkWidget *viewport9;
666 GtkWidget *viewport2;
667 GtkWidget *viewport7;
668 GtkWidget *viewport5;
669 GtkWidget *viewport6;
670 GtkWidget *viewport10;
677 GtkWidget *alignment1;
678 GtkWidget *alignment2;
679 GtkWidget *alignment3;
692 GtkWidget *hbuttonbox1;
694 SurfaceInspector = gtk_window_new (GTK_WINDOW_TOPLEVEL);
695 gtk_container_set_border_width (GTK_CONTAINER (SurfaceInspector), 4);
696 gtk_window_set_title (GTK_WINDOW (SurfaceInspector), "Surface Inspector");
698 SetWinPos_from_Prefs(SurfaceInspector);
700 viewport8 = gtk_viewport_new (NULL, NULL);
701 gtk_widget_show (viewport8);
702 gtk_container_add (GTK_CONTAINER (SurfaceInspector), viewport8);
703 gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport8), GTK_SHADOW_NONE);
705 vbox7 = gtk_vbox_new (FALSE, 0);
706 gtk_widget_show (vbox7);
707 gtk_container_add (GTK_CONTAINER (viewport8), vbox7);
709 viewport9 = gtk_viewport_new (NULL, NULL);
710 gtk_widget_show (viewport9);
711 gtk_box_pack_start (GTK_BOX (vbox7), viewport9, FALSE, FALSE, 0);
712 gtk_container_set_border_width (GTK_CONTAINER (viewport9), 2);
713 gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport9), GTK_SHADOW_ETCHED_IN);
715 hbox1 = gtk_hbox_new (FALSE, 0);
716 gtk_widget_show (hbox1);
717 gtk_container_add (GTK_CONTAINER (viewport9), hbox1);
718 gtk_container_set_border_width (GTK_CONTAINER (hbox1), 4);
720 label = gtk_label_new ("Texture: ");
721 gtk_widget_show (label);
722 gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
723 gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
725 texture_combo = gtk_combo_new ();
726 g_object_set_data (G_OBJECT (GTK_COMBO (texture_combo)->popwin),
727 "KeepMeAround", texture_combo);
728 gtk_combo_disable_activate ( (GtkCombo*) texture_combo);
729 gtk_widget_show (texture_combo);
730 gtk_box_pack_start (GTK_BOX (hbox1), texture_combo, TRUE, TRUE, 0);
732 texture_combo_entry = GTK_COMBO (texture_combo)->entry;
733 gtk_widget_show (texture_combo_entry);
734 gtk_entry_set_max_length (GTK_ENTRY (texture_combo_entry), 128);
736 viewport2 = gtk_viewport_new (NULL, NULL);
737 gtk_widget_show (viewport2);
738 gtk_box_pack_start (GTK_BOX (vbox7), viewport2, FALSE, TRUE, 0);
739 gtk_container_set_border_width (GTK_CONTAINER (viewport2), 2);
740 gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport2), GTK_SHADOW_ETCHED_IN);
742 table1 = gtk_table_new (13, 4, FALSE);
743 gtk_widget_show (table1);
744 gtk_container_add (GTK_CONTAINER (viewport2), table1);
746 hseparator = gtk_hseparator_new ();
747 gtk_widget_show (hseparator);
748 gtk_table_attach (GTK_TABLE (table1), hseparator, 1, 2, 1, 2,
749 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
750 (GtkAttachOptions) (GTK_FILL), 0, 0);
752 hseparator = gtk_hseparator_new ();
753 gtk_widget_show (hseparator);
754 gtk_table_attach (GTK_TABLE (table1), hseparator, 2, 3, 1, 2,
755 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
756 (GtkAttachOptions) (GTK_FILL), 0, 0);
758 hseparator = gtk_hseparator_new ();
759 gtk_widget_show (hseparator);
760 gtk_table_attach (GTK_TABLE (table1), hseparator, 3, 4, 1, 2,
761 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
762 (GtkAttachOptions) (GTK_FILL), 0, 0);
764 hseparator = gtk_hseparator_new ();
765 gtk_widget_show (hseparator);
766 gtk_table_attach (GTK_TABLE (table1), hseparator, 1, 2, 3, 4,
767 (GtkAttachOptions) (GTK_FILL),
768 (GtkAttachOptions) (GTK_FILL), 0, 0);
770 hseparator = gtk_hseparator_new ();
771 gtk_widget_show (hseparator);
772 gtk_table_attach (GTK_TABLE (table1), hseparator, 2, 3, 3, 4,
773 (GtkAttachOptions) (GTK_FILL),
774 (GtkAttachOptions) (GTK_FILL), 0, 0);
776 hseparator = gtk_hseparator_new ();
777 gtk_widget_show (hseparator);
778 gtk_table_attach (GTK_TABLE (table1), hseparator, 3, 4, 3, 4,
779 (GtkAttachOptions) (GTK_FILL),
780 (GtkAttachOptions) (GTK_FILL), 0, 0);
782 hseparator = gtk_hseparator_new ();
783 gtk_widget_show (hseparator);
784 gtk_table_attach (GTK_TABLE (table1), hseparator, 1, 2, 5, 6,
785 (GtkAttachOptions) (GTK_FILL),
786 (GtkAttachOptions) (GTK_FILL), 0, 0);
788 hseparator = gtk_hseparator_new ();
789 gtk_widget_show (hseparator);
790 gtk_table_attach (GTK_TABLE (table1), hseparator, 2, 3, 5, 6,
791 (GtkAttachOptions) (GTK_FILL),
792 (GtkAttachOptions) (GTK_FILL), 0, 0);
794 hseparator = gtk_hseparator_new ();
795 gtk_widget_show (hseparator);
796 gtk_table_attach (GTK_TABLE (table1), hseparator, 3, 4, 5, 6,
797 (GtkAttachOptions) (GTK_FILL),
798 (GtkAttachOptions) (GTK_FILL), 0, 0);
800 hseparator = gtk_hseparator_new ();
801 gtk_widget_show (hseparator);
802 gtk_table_attach (GTK_TABLE (table1), hseparator, 1, 2, 7, 8,
803 (GtkAttachOptions) (GTK_FILL),
804 (GtkAttachOptions) (GTK_FILL), 0, 0);
806 hseparator = gtk_hseparator_new ();
807 gtk_widget_show (hseparator);
808 gtk_table_attach (GTK_TABLE (table1), hseparator, 2, 3, 7, 8,
809 (GtkAttachOptions) (GTK_FILL),
810 (GtkAttachOptions) (GTK_FILL), 0, 0);
812 hseparator = gtk_hseparator_new ();
813 gtk_widget_show (hseparator);
814 gtk_table_attach (GTK_TABLE (table1), hseparator, 3, 4, 7, 8,
815 (GtkAttachOptions) (GTK_FILL),
816 (GtkAttachOptions) (GTK_FILL), 0, 0);
818 hseparator = gtk_hseparator_new ();
819 gtk_widget_show (hseparator);
820 gtk_table_attach (GTK_TABLE (table1), hseparator, 1, 2, 9, 10,
821 (GtkAttachOptions) (GTK_FILL),
822 (GtkAttachOptions) (GTK_FILL), 0, 0);
824 hseparator = gtk_hseparator_new ();
825 gtk_widget_show (hseparator);
826 gtk_table_attach (GTK_TABLE (table1), hseparator, 2, 3, 9, 10,
827 (GtkAttachOptions) (GTK_FILL),
828 (GtkAttachOptions) (GTK_FILL), 0, 0);
830 hseparator = gtk_hseparator_new ();
831 gtk_widget_show (hseparator);
832 gtk_table_attach (GTK_TABLE (table1), hseparator, 3, 4, 9, 10,
833 (GtkAttachOptions) (GTK_FILL),
834 (GtkAttachOptions) (GTK_FILL), 0, 0);
836 hseparator = gtk_hseparator_new ();
837 gtk_widget_show (hseparator);
838 gtk_table_attach (GTK_TABLE (table1), hseparator, 1, 2, 11, 12,
839 (GtkAttachOptions) (GTK_FILL),
840 (GtkAttachOptions) (GTK_FILL), 0, 0);
842 hseparator = gtk_hseparator_new ();
843 gtk_widget_show (hseparator);
844 gtk_table_attach (GTK_TABLE (table1), hseparator, 2, 3, 11, 12,
845 (GtkAttachOptions) (GTK_FILL),
846 (GtkAttachOptions) (GTK_FILL), 0, 0);
848 hseparator = gtk_hseparator_new ();
849 gtk_widget_show (hseparator);
850 gtk_table_attach (GTK_TABLE (table1), hseparator, 3, 4, 11, 12,
851 (GtkAttachOptions) (GTK_FILL),
852 (GtkAttachOptions) (GTK_FILL), 0, 0);
854 label = gtk_label_new ("Offset");
855 gtk_widget_show (label);
856 gtk_table_attach (GTK_TABLE (table1), label, 2, 3, 0, 1,
857 (GtkAttachOptions) (GTK_FILL),
858 (GtkAttachOptions) (0), 0, 0);
860 label = gtk_label_new ("Step");
861 gtk_widget_show (label);
862 gtk_table_attach (GTK_TABLE (table1), label, 3, 4, 0, 1,
863 (GtkAttachOptions) (GTK_FILL),
864 (GtkAttachOptions) (0), 0, 0);
866 eventbox = gtk_event_box_new ();
867 gtk_widget_show (eventbox);
868 gtk_table_attach (GTK_TABLE (table1), eventbox, 3, 4, 12, 13,
869 (GtkAttachOptions) (GTK_FILL),
870 (GtkAttachOptions) (GTK_FILL), 0, 0);
872 match_grid_button = gtk_button_new_with_mnemonic ("Match Grid");
873 gtk_widget_show (match_grid_button);
874 gtk_container_add (GTK_CONTAINER (eventbox), match_grid_button);
876 label = gtk_label_new ("Value");
877 gtk_widget_show (label);
878 gtk_table_attach (GTK_TABLE (table1), label, 1, 2, 0, 1,
879 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
880 (GtkAttachOptions) (0), 0, 0);
881 gtk_misc_set_alignment (GTK_MISC (label), 0.5, 1);
883 hseparator = gtk_hseparator_new ();
884 gtk_widget_show (hseparator);
885 gtk_table_attach (GTK_TABLE (table1), hseparator, 0, 1, 3, 4,
886 (GtkAttachOptions) (GTK_SHRINK | GTK_FILL),
887 (GtkAttachOptions) (GTK_FILL), 0, 0);
889 hseparator = gtk_hseparator_new ();
890 gtk_widget_show (hseparator);
891 gtk_table_attach (GTK_TABLE (table1), hseparator, 0, 1, 5, 6,
892 (GtkAttachOptions) (GTK_FILL),
893 (GtkAttachOptions) (GTK_FILL), 0, 0);
895 hseparator = gtk_hseparator_new ();
896 gtk_widget_show (hseparator);
897 gtk_table_attach (GTK_TABLE (table1), hseparator, 0, 1, 7, 8,
898 (GtkAttachOptions) (GTK_FILL),
899 (GtkAttachOptions) (GTK_FILL), 0, 0);
901 hseparator = gtk_hseparator_new ();
902 gtk_widget_show (hseparator);
903 gtk_table_attach (GTK_TABLE (table1), hseparator, 0, 1, 9, 10,
904 (GtkAttachOptions) (GTK_FILL),
905 (GtkAttachOptions) (GTK_FILL), 0, 0);
907 hseparator = gtk_hseparator_new ();
908 gtk_widget_show (hseparator);
909 gtk_table_attach (GTK_TABLE (table1), hseparator, 0, 1, 11, 12,
910 (GtkAttachOptions) (GTK_FILL),
911 (GtkAttachOptions) (GTK_FILL), 0, 0);
913 eventbox = gtk_event_box_new ();
914 gtk_widget_show (eventbox);
915 gtk_table_attach (GTK_TABLE (table1), eventbox, 0, 1, 4, 5,
916 (GtkAttachOptions) (GTK_FILL),
917 (GtkAttachOptions) (GTK_FILL), 0, 0);
919 label = gtk_label_new ("V Shift: ");
920 gtk_widget_show (label);
921 gtk_container_add (GTK_CONTAINER (eventbox), label);
922 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
923 gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
925 eventbox = gtk_event_box_new ();
926 gtk_widget_show (eventbox);
927 gtk_table_attach (GTK_TABLE (table1), eventbox, 0, 1, 6, 7,
928 (GtkAttachOptions) (GTK_FILL),
929 (GtkAttachOptions) (GTK_FILL), 0, 0);
931 label = gtk_label_new (" H Scale: ");
932 gtk_widget_show (label);
933 gtk_container_add (GTK_CONTAINER (eventbox), label);
934 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
935 gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
937 eventbox = gtk_event_box_new ();
938 gtk_widget_show (eventbox);
939 gtk_table_attach (GTK_TABLE (table1), eventbox, 0, 1, 8, 9,
940 (GtkAttachOptions) (GTK_FILL),
941 (GtkAttachOptions) (GTK_FILL), 0, 0);
943 label = gtk_label_new ("V Scale: ");
944 gtk_widget_show (label);
945 gtk_container_add (GTK_CONTAINER (eventbox), label);
946 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
947 gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
949 eventbox = gtk_event_box_new ();
950 gtk_widget_show (eventbox);
951 gtk_table_attach (GTK_TABLE (table1), eventbox, 0, 1, 10, 11,
952 (GtkAttachOptions) (GTK_FILL),
953 (GtkAttachOptions) (GTK_FILL), 0, 0);
955 label = gtk_label_new ("Rotate: ");
956 gtk_widget_show (label);
957 gtk_container_add (GTK_CONTAINER (eventbox), label);
958 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
959 gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
961 eventbox = gtk_event_box_new ();
962 gtk_widget_show (eventbox);
963 gtk_table_attach (GTK_TABLE (table1), eventbox, 0, 1, 2, 3,
964 (GtkAttachOptions) (GTK_FILL),
965 (GtkAttachOptions) (GTK_FILL), 0, 0);
967 label = gtk_label_new ("H Shift: ");
968 gtk_widget_show (label);
969 gtk_container_add (GTK_CONTAINER (eventbox), label);
970 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
971 gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
973 hseparator = gtk_hseparator_new ();
974 gtk_widget_show (hseparator);
975 gtk_table_attach (GTK_TABLE (table1), hseparator, 0, 1, 1, 2,
976 (GtkAttachOptions) (GTK_FILL),
977 (GtkAttachOptions) (GTK_FILL), 0, 0);
979 eventbox = gtk_event_box_new ();
980 gtk_widget_show (eventbox);
981 gtk_table_attach (GTK_TABLE (table1), eventbox, 1, 2, 12, 13,
982 (GtkAttachOptions) (GTK_FILL),
983 (GtkAttachOptions) (GTK_FILL), 0, 0);
985 lock_valuechange_togglebutton = gtk_toggle_button_new_with_mnemonic ("UNLOCK");
986 gtk_widget_show (lock_valuechange_togglebutton);
987 gtk_container_add (GTK_CONTAINER (eventbox), lock_valuechange_togglebutton);
990 hshift_value_spinbutton_adj = gtk_adjustment_new (0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0);
991 hshift_value_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (hshift_value_spinbutton_adj), 1, 2);
992 gtk_widget_show (hshift_value_spinbutton);
993 gtk_table_attach (GTK_TABLE (table1), hshift_value_spinbutton, 1, 2, 2, 3,
994 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
995 (GtkAttachOptions) (0), 0, 0);
996 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (hshift_value_spinbutton), GTK_UPDATE_IF_VALID);
997 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (hshift_value_spinbutton), TRUE);
998 gtk_widget_set_sensitive( GTK_WIDGET( hshift_value_spinbutton ), FALSE );
1000 vshift_value_spinbutton_adj = gtk_adjustment_new (0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0);
1001 vshift_value_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (vshift_value_spinbutton_adj), 1, 2);
1002 gtk_widget_show (vshift_value_spinbutton);
1003 gtk_table_attach (GTK_TABLE (table1), vshift_value_spinbutton, 1, 2, 4, 5,
1004 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1005 (GtkAttachOptions) (0), 0, 0);
1006 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (vshift_value_spinbutton), GTK_UPDATE_IF_VALID);
1007 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (vshift_value_spinbutton), TRUE);
1008 gtk_widget_set_sensitive( GTK_WIDGET( vshift_value_spinbutton ), FALSE );
1010 hscale_value_spinbutton_adj = gtk_adjustment_new (0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0);
1011 hscale_value_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (hscale_value_spinbutton_adj), 1, 4);
1012 gtk_widget_show (hscale_value_spinbutton);
1013 gtk_table_attach (GTK_TABLE (table1), hscale_value_spinbutton, 1, 2, 6, 7,
1014 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1015 (GtkAttachOptions) (0), 0, 0);
1016 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (hscale_value_spinbutton), GTK_UPDATE_IF_VALID);
1017 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (hscale_value_spinbutton), TRUE);
1018 gtk_widget_set_sensitive( GTK_WIDGET( hscale_value_spinbutton ), FALSE );
1020 vscale_value_spinbutton_adj = gtk_adjustment_new (0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0);
1021 vscale_value_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (vscale_value_spinbutton_adj), 1, 4);
1022 gtk_widget_show (vscale_value_spinbutton);
1023 gtk_table_attach (GTK_TABLE (table1), vscale_value_spinbutton, 1, 2, 8, 9,
1024 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1025 (GtkAttachOptions) (0), 0, 0);
1026 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (vscale_value_spinbutton), GTK_UPDATE_IF_VALID);
1027 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (vscale_value_spinbutton), TRUE);
1028 gtk_widget_set_sensitive( GTK_WIDGET( vscale_value_spinbutton ), FALSE );
1030 rotate_value_spinbutton_adj = gtk_adjustment_new (0.0, -360.0, 360.0, 1.0, 10.0, 10.0);
1031 rotate_value_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (rotate_value_spinbutton_adj), 1, 0);
1032 gtk_widget_show (rotate_value_spinbutton);
1033 gtk_table_attach (GTK_TABLE (table1), rotate_value_spinbutton, 1, 2, 10, 11,
1034 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1035 (GtkAttachOptions) (0), 0, 0);
1036 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (rotate_value_spinbutton), GTK_UPDATE_IF_VALID);
1037 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (rotate_value_spinbutton), TRUE);
1038 gtk_widget_set_sensitive( GTK_WIDGET( rotate_value_spinbutton ), FALSE );
1041 hshift_offset_spinbutton_adj = gtk_adjustment_new (0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0);
1042 hshift_offset_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (hshift_offset_spinbutton_adj), 0, 2);
1043 gtk_widget_show (hshift_offset_spinbutton);
1044 gtk_table_attach (GTK_TABLE (table1), hshift_offset_spinbutton, 2, 3, 2, 3,
1045 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1046 (GtkAttachOptions) (0), 4, 0);
1047 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (hshift_offset_spinbutton), TRUE);
1048 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (hshift_offset_spinbutton), GTK_UPDATE_IF_VALID);
1049 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (hshift_offset_spinbutton), TRUE);
1051 vshift_offset_spinbutton_adj = gtk_adjustment_new (0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0);
1052 vshift_offset_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (vshift_offset_spinbutton_adj), 0, 2);
1053 gtk_widget_show (vshift_offset_spinbutton);
1054 gtk_table_attach (GTK_TABLE (table1), vshift_offset_spinbutton, 2, 3, 4, 5,
1055 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1056 (GtkAttachOptions) (0), 4, 0);
1057 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (vshift_offset_spinbutton), TRUE);
1058 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (vshift_offset_spinbutton), GTK_UPDATE_IF_VALID);
1059 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (vshift_offset_spinbutton), TRUE);
1061 hscale_offset_spinbutton_adj = gtk_adjustment_new (0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0);
1062 hscale_offset_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (hscale_offset_spinbutton_adj), 0, 4);
1063 gtk_widget_show (hscale_offset_spinbutton);
1064 gtk_table_attach (GTK_TABLE (table1), hscale_offset_spinbutton, 2, 3, 6, 7,
1065 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1066 (GtkAttachOptions) (0), 4, 0);
1067 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (hscale_offset_spinbutton), TRUE);
1068 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (hscale_offset_spinbutton), GTK_UPDATE_IF_VALID);
1069 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (hscale_offset_spinbutton), TRUE);
1071 vscale_offset_spinbutton_adj = gtk_adjustment_new (0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0);
1072 vscale_offset_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (vscale_offset_spinbutton_adj), 0, 4);
1073 gtk_widget_show (vscale_offset_spinbutton);
1074 gtk_table_attach (GTK_TABLE (table1), vscale_offset_spinbutton, 2, 3, 8, 9,
1075 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1076 (GtkAttachOptions) (0), 4, 0);
1077 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (vscale_offset_spinbutton), TRUE);
1078 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (vscale_offset_spinbutton), GTK_UPDATE_IF_VALID);
1079 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (vscale_offset_spinbutton), TRUE);
1081 rotate_offset_spinbutton_adj = gtk_adjustment_new (0.0, -360.0, 360.0, 1.0, 10.0, 10.0);
1082 rotate_offset_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (rotate_offset_spinbutton_adj), 0, 2);
1083 gtk_widget_show (rotate_offset_spinbutton);
1084 gtk_table_attach (GTK_TABLE (table1), rotate_offset_spinbutton, 2, 3, 10, 11,
1085 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1086 (GtkAttachOptions) (0), 4, 0);
1087 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (rotate_offset_spinbutton), TRUE);
1088 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (rotate_offset_spinbutton), GTK_UPDATE_IF_VALID);
1089 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (rotate_offset_spinbutton), TRUE);
1092 hshift_step_spinbutton_adj = gtk_adjustment_new (0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0);
1093 hshift_step_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (hshift_step_spinbutton_adj), 1, 2);
1094 gtk_widget_show (hshift_step_spinbutton);
1095 gtk_table_attach (GTK_TABLE (table1), hshift_step_spinbutton, 3, 4, 2, 3,
1096 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1097 (GtkAttachOptions) (0), 0, 0);
1098 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (hshift_step_spinbutton), GTK_UPDATE_IF_VALID);
1100 vshift_step_spinbutton_adj = gtk_adjustment_new (0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0);
1101 vshift_step_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (vshift_step_spinbutton_adj), 1, 2);
1102 gtk_widget_show (vshift_step_spinbutton);
1103 gtk_table_attach (GTK_TABLE (table1), vshift_step_spinbutton, 3, 4, 4, 5,
1104 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1105 (GtkAttachOptions) (0), 0, 0);
1106 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (vshift_step_spinbutton), GTK_UPDATE_IF_VALID);
1108 hscale_step_spinbutton_adj = gtk_adjustment_new (0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0);
1109 hscale_step_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (hscale_step_spinbutton_adj), 1, 4);
1110 gtk_widget_show (hscale_step_spinbutton);
1111 gtk_table_attach (GTK_TABLE (table1), hscale_step_spinbutton, 3, 4, 6, 7,
1112 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1113 (GtkAttachOptions) (0), 0, 0);
1114 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (hscale_step_spinbutton), GTK_UPDATE_IF_VALID);
1116 vscale_step_spinbutton_adj = gtk_adjustment_new (0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0);
1117 vscale_step_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (vscale_step_spinbutton_adj), 1, 4);
1118 gtk_widget_show (vscale_step_spinbutton);
1119 gtk_table_attach (GTK_TABLE (table1), vscale_step_spinbutton, 3, 4, 8, 9,
1120 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1121 (GtkAttachOptions) (0), 0, 0);
1122 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (vscale_step_spinbutton), GTK_UPDATE_IF_VALID);
1124 rotate_step_spinbutton_adj = gtk_adjustment_new (0.0, -360.0, 360.0, 1.0, 10.0, 10.0);
1125 rotate_step_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (rotate_step_spinbutton_adj), 1, 2);
1126 gtk_widget_show (rotate_step_spinbutton);
1127 gtk_table_attach (GTK_TABLE (table1), rotate_step_spinbutton, 3, 4, 10, 11,
1128 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1129 (GtkAttachOptions) (0), 0, 0);
1130 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (rotate_step_spinbutton), GTK_UPDATE_IF_VALID);
1132 eventbox = gtk_event_box_new ();
1133 gtk_widget_show (eventbox);
1134 gtk_table_attach (GTK_TABLE (table1), eventbox, 2, 3, 12, 13,
1135 (GtkAttachOptions) (0),
1136 (GtkAttachOptions) (0), 0, 0);
1138 eventbox = gtk_event_box_new ();
1139 gtk_widget_show (eventbox);
1140 gtk_table_attach (GTK_TABLE (table1), eventbox, 0, 1, 12, 13,
1141 (GtkAttachOptions) (0),
1142 (GtkAttachOptions) (0), 0, 0);
1144 eventbox = gtk_event_box_new ();
1145 gtk_widget_show (eventbox);
1146 gtk_table_attach (GTK_TABLE (table1), eventbox, 0, 1, 0, 1,
1147 (GtkAttachOptions) (0),
1148 (GtkAttachOptions) (0), 0, 0);
1150 viewport7 = gtk_viewport_new (NULL, NULL);
1151 gtk_widget_show (viewport7);
1152 gtk_box_pack_start (GTK_BOX (vbox7), viewport7, FALSE, TRUE, 0);
1153 gtk_container_set_border_width (GTK_CONTAINER (viewport7), 2);
1154 gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport7), GTK_SHADOW_ETCHED_IN);
1156 table4 = gtk_table_new (4, 7, FALSE);
1157 gtk_widget_show (table4);
1158 gtk_container_add (GTK_CONTAINER (viewport7), table4);
1160 viewport5 = gtk_viewport_new (NULL, NULL);
1161 gtk_widget_show (viewport5);
1162 gtk_table_attach (GTK_TABLE (table4), viewport5, 1, 7, 0, 4,
1163 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1164 (GtkAttachOptions) (0), 0, 0);
1165 gtk_container_set_border_width (GTK_CONTAINER (viewport5), 6);
1166 gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport5), GTK_SHADOW_ETCHED_OUT);
1168 table5 = gtk_table_new (2, 3, FALSE);
1169 gtk_widget_show (table5);
1170 gtk_container_add (GTK_CONTAINER (viewport5), table5);
1171 gtk_container_set_border_width (GTK_CONTAINER (table5), 5);
1172 gtk_table_set_col_spacings (GTK_TABLE (table5), 2);
1174 label = gtk_label_new ("Height");
1175 gtk_widget_show (label);
1176 gtk_table_attach (GTK_TABLE (table5), label, 2, 3, 0, 1,
1177 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1178 (GtkAttachOptions) (GTK_FILL), 0, 0);
1179 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1180 gtk_misc_set_alignment (GTK_MISC (label), 0.5, 1);
1182 label = gtk_label_new ("Width");
1183 gtk_widget_show (label);
1184 gtk_table_attach (GTK_TABLE (table5), label, 1, 2, 0, 1,
1185 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1186 (GtkAttachOptions) (GTK_FILL), 0, 0);
1187 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1188 gtk_misc_set_alignment (GTK_MISC (label), 0.5, 1);
1190 fit_width_spinbutton_adj = gtk_adjustment_new (1, 1, 32, 1, 10, 10);
1191 fit_width_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (fit_width_spinbutton_adj), 1, 0);
1192 gtk_widget_show (fit_width_spinbutton);
1193 gtk_table_attach (GTK_TABLE (table5), fit_width_spinbutton, 1, 2, 1, 2,
1194 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1195 (GtkAttachOptions) (GTK_FILL), 0, 0);
1196 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (fit_width_spinbutton), TRUE);
1197 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (fit_width_spinbutton), GTK_UPDATE_IF_VALID);
1199 fit_height_spinbutton_adj = gtk_adjustment_new (1, 1, 32, 1, 10, 10);
1200 fit_height_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (fit_height_spinbutton_adj), 1, 0);
1201 gtk_widget_show (fit_height_spinbutton);
1202 gtk_table_attach (GTK_TABLE (table5), fit_height_spinbutton, 2, 3, 1, 2,
1203 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1204 (GtkAttachOptions) (GTK_FILL), 3, 0);
1205 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (fit_height_spinbutton), TRUE);
1206 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (fit_height_spinbutton), GTK_UPDATE_IF_VALID);
1208 eventbox = gtk_event_box_new ();
1209 gtk_widget_show (eventbox);
1210 gtk_table_attach (GTK_TABLE (table5), eventbox, 0, 1, 0, 1,
1211 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1212 (GtkAttachOptions) (GTK_FILL), 0, 0);
1214 eventbox = gtk_event_box_new ();
1215 gtk_widget_show (eventbox);
1216 gtk_table_attach (GTK_TABLE (table5), eventbox, 0, 1, 1, 2,
1217 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1218 (GtkAttachOptions) (GTK_FILL), 4, 0);
1220 fit_button = gtk_button_new_with_mnemonic (" Fit ");
1221 gtk_widget_show (fit_button);
1222 gtk_container_add (GTK_CONTAINER (eventbox), fit_button);
1224 viewport6 = gtk_viewport_new (NULL, NULL);
1225 gtk_widget_show (viewport6);
1226 gtk_table_attach (GTK_TABLE (table4), viewport6, 0, 1, 0, 4,
1227 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1228 (GtkAttachOptions) (0), 0, 0);
1229 gtk_container_set_border_width (GTK_CONTAINER (viewport6), 4);
1230 gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport6), GTK_SHADOW_NONE);
1232 table7 = gtk_table_new (2, 1, FALSE);
1233 gtk_widget_show (table7);
1234 gtk_container_add (GTK_CONTAINER (viewport6), table7);
1236 eventbox = gtk_event_box_new ();
1237 gtk_widget_show (eventbox);
1238 gtk_table_attach (GTK_TABLE (table7), eventbox, 0, 1, 0, 2,
1239 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1240 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0);
1242 axial_button = gtk_button_new_with_mnemonic ("Axial");
1243 gtk_widget_show (axial_button);
1244 gtk_container_add (GTK_CONTAINER (eventbox), axial_button);
1245 gtk_widget_set_size_request (axial_button, 56, 29);
1246 gtk_container_set_border_width (GTK_CONTAINER (axial_button), 4);
1248 viewport10 = gtk_viewport_new (NULL, NULL);
1249 gtk_widget_show (viewport10);
1250 gtk_box_pack_start (GTK_BOX (vbox7), viewport10, FALSE, TRUE, 0);
1251 gtk_container_set_border_width (GTK_CONTAINER (viewport10), 2);
1252 gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport10), GTK_SHADOW_ETCHED_IN);
1254 hbuttonbox1 = gtk_hbutton_box_new ();
1255 gtk_widget_show (hbuttonbox1);
1256 gtk_container_add (GTK_CONTAINER (viewport10), hbuttonbox1);
1257 gtk_container_set_border_width (GTK_CONTAINER (hbuttonbox1), 4);
1258 gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox1), GTK_BUTTONBOX_SPREAD);
1260 done_button = gtk_button_new ();
1261 gtk_widget_show (done_button);
1262 gtk_container_add (GTK_CONTAINER (hbuttonbox1), done_button);
1263 GTK_WIDGET_SET_FLAGS (done_button, GTK_CAN_DEFAULT);
1265 alignment1 = gtk_alignment_new (0.5, 0.5, 0, 0);
1266 gtk_widget_show (alignment1);
1267 gtk_container_add (GTK_CONTAINER (done_button), alignment1);
1269 hbox2 = gtk_hbox_new (FALSE, 2);
1270 gtk_widget_show (hbox2);
1271 gtk_container_add (GTK_CONTAINER (alignment1), hbox2);
1273 image1 = gtk_image_new_from_stock ("gtk-yes", GTK_ICON_SIZE_BUTTON);
1274 gtk_widget_show (image1);
1275 gtk_box_pack_start (GTK_BOX (hbox2), image1, FALSE, FALSE, 0);
1277 label = gtk_label_new_with_mnemonic ("Done");
1278 gtk_widget_show (label);
1279 gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);
1280 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1282 apply_button = gtk_button_new ();
1283 gtk_widget_show (apply_button);
1284 gtk_container_add (GTK_CONTAINER (hbuttonbox1), apply_button);
1285 GTK_WIDGET_SET_FLAGS (apply_button, GTK_CAN_DEFAULT);
1287 alignment3 = gtk_alignment_new (0.5, 0.5, 0, 0);
1288 gtk_widget_show (alignment3);
1289 gtk_container_add (GTK_CONTAINER (apply_button), alignment3);
1291 hbox4 = gtk_hbox_new (FALSE, 2);
1292 gtk_widget_show (hbox4);
1293 gtk_container_add (GTK_CONTAINER (alignment3), hbox4);
1295 image3 = gtk_image_new_from_stock ("gtk-apply", GTK_ICON_SIZE_BUTTON);
1296 gtk_widget_show (image3);
1297 gtk_box_pack_start (GTK_BOX (hbox4), image3, FALSE, FALSE, 0);
1299 label = gtk_label_new_with_mnemonic ("Apply");
1300 gtk_widget_show (label);
1301 gtk_box_pack_start (GTK_BOX (hbox4), label, FALSE, FALSE, 0);
1302 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1304 cancel_button = gtk_button_new ();
1305 gtk_widget_show (cancel_button);
1306 gtk_container_add (GTK_CONTAINER (hbuttonbox1), cancel_button);
1307 GTK_WIDGET_SET_FLAGS (cancel_button, GTK_CAN_DEFAULT);
1309 alignment2 = gtk_alignment_new (0.5, 0.5, 0, 0);
1310 gtk_widget_show (alignment2);
1311 gtk_container_add (GTK_CONTAINER (cancel_button), alignment2);
1313 hbox3 = gtk_hbox_new (FALSE, 2);
1314 gtk_widget_show (hbox3);
1315 gtk_container_add (GTK_CONTAINER (alignment2), hbox3);
1317 image2 = gtk_image_new_from_stock ("gtk-no", GTK_ICON_SIZE_BUTTON);
1318 gtk_widget_show (image2);
1319 gtk_box_pack_start (GTK_BOX (hbox3), image2, FALSE, FALSE, 0);
1321 label = gtk_label_new_with_mnemonic ("Cancel");
1322 gtk_widget_show (label);
1323 gtk_box_pack_start (GTK_BOX (hbox3), label, FALSE, FALSE, 0);
1324 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1327 g_signal_connect ( (gpointer) SurfaceInspector,
1329 G_CALLBACK (delete_event_callback),
1331 g_signal_connect ((gpointer) SurfaceInspector, "destroy",
1332 G_CALLBACK (gtk_widget_destroy),
1335 g_signal_connect ((gpointer) texture_combo_entry, "key_press_event",
1336 G_CALLBACK (on_texture_combo_entry_key_press_event),
1338 g_signal_connect ((gpointer) texture_combo_entry, "activate",
1339 G_CALLBACK (on_texture_combo_entry_activate),
1343 g_signal_connect ((gpointer) hshift_offset_spinbutton, "value_changed",
1344 G_CALLBACK (on_hshift_offset_spinbutton_value_changed),
1346 g_signal_connect ((gpointer) vshift_offset_spinbutton, "value_changed",
1347 G_CALLBACK (on_vshift_offset_spinbutton_value_changed),
1349 g_signal_connect ((gpointer) hscale_offset_spinbutton, "value_changed",
1350 G_CALLBACK (on_hscale_offset_spinbutton_value_changed),
1352 g_signal_connect ((gpointer) vscale_offset_spinbutton, "value_changed",
1353 G_CALLBACK (on_vscale_offset_spinbutton_value_changed),
1355 g_signal_connect ((gpointer) rotate_offset_spinbutton, "value_changed",
1356 G_CALLBACK (on_rotate_offset_spinbutton_value_changed),
1359 g_signal_connect ((gpointer) hshift_value_spinbutton, "value_changed",
1360 G_CALLBACK (on_hshift_value_spinbutton_value_changed),
1362 g_signal_connect ((gpointer) vshift_value_spinbutton, "value_changed",
1363 G_CALLBACK (on_vshift_value_spinbutton_value_changed),
1365 g_signal_connect ((gpointer) hscale_value_spinbutton, "value_changed",
1366 G_CALLBACK (on_hscale_value_spinbutton_value_changed),
1368 g_signal_connect ((gpointer) vscale_value_spinbutton, "value_changed",
1369 G_CALLBACK (on_vscale_value_spinbutton_value_changed),
1371 g_signal_connect ((gpointer) rotate_value_spinbutton, "value_changed",
1372 G_CALLBACK (on_rotate_value_spinbutton_value_changed),
1375 g_signal_connect ((gpointer) hshift_step_spinbutton, "value_changed",
1376 G_CALLBACK (on_hshift_step_spinbutton_value_changed),
1378 g_signal_connect ((gpointer) vshift_step_spinbutton, "value_changed",
1379 G_CALLBACK (on_vshift_step_spinbutton_value_changed),
1381 g_signal_connect ((gpointer) hscale_step_spinbutton, "value_changed",
1382 G_CALLBACK (on_hscale_step_spinbutton_value_changed),
1384 g_signal_connect ((gpointer) vscale_step_spinbutton, "value_changed",
1385 G_CALLBACK (on_vscale_step_spinbutton_value_changed),
1387 g_signal_connect ((gpointer) rotate_step_spinbutton, "value_changed",
1388 G_CALLBACK (on_rotate_step_spinbutton_value_changed),
1391 g_signal_connect ((gpointer) match_grid_button, "clicked",
1392 G_CALLBACK (on_match_grid_button_clicked),
1394 g_signal_connect ((gpointer) lock_valuechange_togglebutton, "toggled",
1395 G_CALLBACK (on_lock_valuechange_togglebutton_toggled),
1398 g_signal_connect ((gpointer) fit_width_spinbutton, "value_changed",
1399 G_CALLBACK (on_fit_width_spinbutton_value_changed),
1401 g_signal_connect ((gpointer) fit_height_spinbutton, "value_changed",
1402 G_CALLBACK (on_fit_height_spinbutton_value_changed),
1404 g_signal_connect ((gpointer) fit_button, "clicked",
1405 G_CALLBACK (on_fit_button_clicked),
1408 g_signal_connect ((gpointer) axial_button, "clicked",
1409 G_CALLBACK (on_axial_button_clicked),
1412 g_signal_connect ((gpointer) done_button, "clicked",
1413 G_CALLBACK (on_done_button_clicked),
1415 g_signal_connect ((gpointer) apply_button, "clicked",
1416 G_CALLBACK (on_apply_button_clicked),
1418 g_signal_connect ((gpointer) cancel_button, "clicked",
1419 G_CALLBACK (on_cancel_button_clicked),
1423 return SurfaceInspector;
1428 gboolean on_texture_combo_entry_key_press_event (GtkWidget *widget, GdkEventKey *event,
1431 // Have Tab activate selection as well as Return
1432 if (event->keyval == GDK_Tab)
1433 g_signal_emit_by_name ( texture_combo_entry, "activate" );
1438 void on_texture_combo_entry_activate (GtkEntry *entry, gpointer user_data)
1440 texdef_t* tmp_texdef;
1441 texdef_t* tmp_orig_texdef;
1442 texdef_to_face_t* temp_texdef_face_list;
1443 char text[128] = { 0 };
1445 if (!texdef_face_list_empty() && g_bListenChanged)
1447 // activate only on entry change
1448 strcpy( text, gtk_entry_get_text(entry));
1449 if ( strcmp( old_texture_entry, text ))
1451 // Check for spaces in shader name
1452 if (text[0] <= ' ' || strchr(text, ' '))
1453 Sys_FPrintf(SYS_WRN, "WARNING: spaces in shader names are not allowed, ignoring '%s'\n", text);
1456 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1458 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1459 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1460 strcpy( old_texture_entry, text );
1461 tmp_texdef->SetName( text );
1470 static void on_hshift_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1472 texdef_t* tmp_texdef;
1473 texdef_t* tmp_orig_texdef;
1474 texdef_to_face_t* temp_texdef_face_list;
1476 texdef_offset.shift[0] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hshift_offset_spinbutton) );
1478 if (!texdef_face_list_empty() && g_bListenChanged)
1480 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1482 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1483 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1484 if (is_HShift_conflicting)
1485 tmp_texdef->shift[0] = tmp_orig_texdef->shift[0] + texdef_offset.shift[0];
1487 tmp_texdef->shift[0] = texdef_SI_values.shift[0] + texdef_offset.shift[0];
1493 static void on_vshift_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1495 texdef_t* tmp_texdef;
1496 texdef_t* tmp_orig_texdef;
1497 texdef_to_face_t* temp_texdef_face_list;
1499 texdef_offset.shift[1] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vshift_offset_spinbutton) );
1501 if (!texdef_face_list_empty() && g_bListenChanged)
1503 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1505 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1506 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1507 if (is_VShift_conflicting)
1508 tmp_texdef->shift[1] = tmp_orig_texdef->shift[1] + texdef_offset.shift[1];
1510 tmp_texdef->shift[1] = texdef_SI_values.shift[1] + texdef_offset.shift[1];
1517 static void on_hscale_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1519 texdef_t* tmp_texdef;
1520 texdef_t* tmp_orig_texdef;
1521 texdef_to_face_t* temp_texdef_face_list;
1523 texdef_offset.scale[0] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hscale_offset_spinbutton) );
1525 if (!texdef_face_list_empty() && g_bListenChanged)
1527 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1529 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1530 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1531 if (is_HScale_conflicting)
1532 tmp_texdef->scale[0] = tmp_orig_texdef->scale[0] + texdef_offset.scale[0];
1534 tmp_texdef->scale[0] = texdef_SI_values.scale[0] + texdef_offset.scale[0];
1542 static void on_vscale_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1544 texdef_t* tmp_texdef;
1545 texdef_t* tmp_orig_texdef;
1546 texdef_to_face_t* temp_texdef_face_list;
1548 texdef_offset.scale[1] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vscale_offset_spinbutton) );
1550 if (!texdef_face_list_empty() && g_bListenChanged)
1552 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1554 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1555 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1556 if (is_VScale_conflicting)
1557 tmp_texdef->scale[1] = tmp_orig_texdef->scale[1] + texdef_offset.scale[1];
1559 tmp_texdef->scale[1] = texdef_SI_values.scale[1] + texdef_offset.scale[1];
1566 static void on_rotate_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1568 texdef_t* tmp_texdef;
1569 texdef_t* tmp_orig_texdef;
1570 texdef_to_face_t* temp_texdef_face_list;
1572 texdef_offset.rotate = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(rotate_offset_spinbutton) );
1574 if (!texdef_face_list_empty() && g_bListenChanged)
1576 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1578 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1579 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1580 if (is_Rotate_conflicting)
1581 tmp_texdef->rotate = tmp_orig_texdef->rotate + texdef_offset.rotate;
1583 tmp_texdef->rotate = texdef_SI_values.rotate + texdef_offset.rotate;
1592 static void on_match_grid_button_clicked (GtkButton *button, gpointer user_data)
1594 float hscale, vscale;
1596 if( !strcmp(gtk_entry_get_text (GTK_ENTRY (hscale_value_spinbutton)), "") )
1599 hscale = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hscale_value_spinbutton) );
1601 if( !strcmp( gtk_entry_get_text (GTK_ENTRY (vscale_value_spinbutton)), "") )
1604 vscale = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vscale_value_spinbutton) );
1605 DoSnapTToGrid (hscale, vscale);
1609 // Lock out changes to Value
1610 static void on_lock_valuechange_togglebutton_toggled (GtkToggleButton *togglebutton, gpointer user_data)
1614 is_Locked = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lock_valuechange_togglebutton));
1616 gtk_widget_set_sensitive( GTK_WIDGET( hscale_value_spinbutton ), is_Locked );
1617 gtk_widget_set_sensitive( GTK_WIDGET( vscale_value_spinbutton ), is_Locked );
1618 gtk_widget_set_sensitive( GTK_WIDGET( hshift_value_spinbutton ), is_Locked );
1619 gtk_widget_set_sensitive( GTK_WIDGET( vshift_value_spinbutton ), is_Locked );
1620 gtk_widget_set_sensitive( GTK_WIDGET( rotate_value_spinbutton ), is_Locked );
1625 static void on_hshift_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1627 texdef_t* tmp_texdef;
1628 texdef_t* tmp_orig_texdef;
1629 texdef_to_face_t* temp_texdef_face_list;
1631 texdef_SI_values.shift[0] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hshift_value_spinbutton) );
1633 if (!texdef_face_list_empty() && g_bListenChanged)
1635 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1637 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1638 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1639 tmp_texdef->shift[0] = texdef_SI_values.shift[0] + texdef_offset.shift[0];
1640 is_HShift_conflicting = FALSE;
1646 static void on_vshift_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1648 texdef_t* tmp_texdef;
1649 texdef_t* tmp_orig_texdef;
1650 texdef_to_face_t* temp_texdef_face_list;
1652 texdef_SI_values.shift[1] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vshift_value_spinbutton) );
1654 if (!texdef_face_list_empty() && g_bListenChanged)
1656 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1658 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1659 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1660 tmp_texdef->shift[1] = texdef_SI_values.shift[1] + texdef_offset.shift[1];
1661 is_VShift_conflicting = FALSE;
1667 static void on_hscale_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1669 texdef_t* tmp_texdef;
1670 texdef_t* tmp_orig_texdef;
1671 texdef_to_face_t* temp_texdef_face_list;
1673 texdef_SI_values.scale[0] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hscale_value_spinbutton) );
1675 if (!texdef_face_list_empty() && g_bListenChanged)
1677 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1679 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1680 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1681 tmp_texdef->scale[0] = texdef_SI_values.scale[0] + texdef_offset.scale[0];
1682 is_HScale_conflicting = FALSE;
1688 static void on_vscale_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1690 texdef_t* tmp_texdef;
1691 texdef_t* tmp_orig_texdef;
1692 texdef_to_face_t* temp_texdef_face_list;
1694 texdef_SI_values.scale[1] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vscale_value_spinbutton) );
1696 if (!texdef_face_list_empty() && g_bListenChanged)
1698 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1700 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1701 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1702 tmp_texdef->scale[1] = texdef_SI_values.scale[1] + texdef_offset.scale[1];
1703 is_VScale_conflicting = FALSE;
1709 static void on_rotate_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1711 texdef_t* tmp_texdef;
1712 texdef_t* tmp_orig_texdef;
1713 texdef_to_face_t* temp_texdef_face_list;
1715 texdef_SI_values.rotate = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(rotate_value_spinbutton) );
1717 if (!texdef_face_list_empty() && g_bListenChanged)
1719 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1721 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1722 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1723 tmp_texdef->rotate = texdef_SI_values.rotate + texdef_offset.rotate;
1724 is_Rotate_conflicting = FALSE;
1732 static void on_hshift_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1735 GtkAdjustment * adjust;
1737 if (!g_bListenChanged)
1740 l_pIncrement = Get_SI_Inc();
1743 Sys_Printf("OnIncrementChanged HShift\n");
1746 val = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hshift_step_spinbutton) ) ;
1747 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( hshift_offset_spinbutton ));
1748 adjust->step_increment = val;
1749 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( hshift_value_spinbutton ));
1750 adjust->step_increment = val;
1751 l_pIncrement->shift[0] = val;
1754 static void on_vshift_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1757 GtkAdjustment * adjust;
1759 if (!g_bListenChanged)
1762 l_pIncrement = Get_SI_Inc();
1765 Sys_Printf("OnIncrementChanged VShift\n");
1768 val = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vshift_step_spinbutton) ) ;
1769 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( vshift_offset_spinbutton ));
1770 adjust->step_increment = val;
1771 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( vshift_value_spinbutton ));
1772 adjust->step_increment = val;
1773 l_pIncrement->shift[1] = val;
1776 static void on_hscale_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1779 GtkAdjustment * adjust;
1781 if (!g_bListenChanged)
1784 l_pIncrement = Get_SI_Inc();
1787 Sys_Printf("OnIncrementChanged HShift\n");
1790 val = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hscale_step_spinbutton) ) ;
1791 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( hscale_offset_spinbutton ));
1792 adjust->step_increment = val;
1793 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( hscale_value_spinbutton ));
1794 adjust->step_increment = val;
1795 l_pIncrement->scale[0] = val;
1798 static void on_vscale_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1801 GtkAdjustment * adjust;
1803 if (!g_bListenChanged)
1806 l_pIncrement = Get_SI_Inc();
1809 Sys_Printf("OnIncrementChanged HShift\n");
1812 val = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vscale_step_spinbutton) ) ;
1813 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( vscale_offset_spinbutton ));
1814 adjust->step_increment = val;
1815 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( vscale_value_spinbutton ));
1816 adjust->step_increment = val;
1817 l_pIncrement->scale[1] = val;
1820 static void on_rotate_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1823 GtkAdjustment * adjust;
1825 if (!g_bListenChanged)
1828 l_pIncrement = Get_SI_Inc();
1831 Sys_Printf("OnIncrementChanged HShift\n");
1834 val = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(rotate_step_spinbutton) ) ;
1835 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( rotate_offset_spinbutton ));
1836 adjust->step_increment = val;
1837 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( rotate_value_spinbutton ));
1838 adjust->step_increment = val;
1839 l_pIncrement->rotate = val;
1844 static void on_fit_width_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1846 m_nWidth = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(fit_width_spinbutton) );
1849 static void on_fit_height_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1851 m_nHeight = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(fit_height_spinbutton) );
1854 static void on_fit_button_clicked (GtkButton *button, gpointer user_data)
1856 FaceList_FitTexture(get_texdef_face_list(), m_nHeight, m_nWidth);
1857 Sys_UpdateWindows(W_ALL);
1862 static void on_axial_button_clicked (GtkButton *button, gpointer user_data)
1864 texdef_t* tmp_texdef;
1865 // texdef_t* tmp_orig_texdef;
1866 texdef_to_face_t* temp_texdef_face_list;
1868 if (!texdef_face_list_empty() && g_bListenChanged)
1870 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1872 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1873 tmp_texdef->shift[0] = 0.0;
1874 tmp_texdef->shift[1] = 0.0;
1875 tmp_texdef->scale[0] = 0.5;
1876 tmp_texdef->scale[1] = 0.5;
1877 tmp_texdef->rotate = 0.0;
1881 SetTexdef_FaceList( get_texdef_face_list(), FALSE, TRUE );
1882 Sys_UpdateWindows(W_ALL);
1887 static void on_done_button_clicked (GtkButton *button, gpointer user_data)
1889 if ( !texdef_face_list_empty() )
1892 Sys_UpdateWindows(W_ALL);
1895 static void on_apply_button_clicked (GtkButton *button, gpointer user_data)
1897 if (!g_bListenChanged)
1899 if ( !texdef_face_list_empty() )
1902 Sys_UpdateWindows(W_CAMERA);
1903 GetTexdefInfo_from_Radiant();
1908 static void on_cancel_button_clicked (GtkButton *button, gpointer user_data)
1910 texturewin = Texturewin ();
1911 texturewin->texdef = g_old_texdef;
1912 // cancel the last do if we own it
1913 if ( (m_nUndoId == Undo_GetUndoId()) && ( m_nUndoId != 0 ))
1916 Sys_Printf("OnCancel calling Undo_Undo\n");
1918 g_bListenUpdate = false;
1920 g_bListenUpdate = true;