2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 // Surface Dialog Module
27 // Nurail: Implemented to Module from the main Radiant Surface Dialog code
32 #include <gdk/gdkkeysyms.h>
34 #include "surfdlg_plugin.h"
42 #include "gtkr_vector.h"
44 vector<texdef_to_face_t> g_texdef_face_vector;
46 inline texdef_to_face_t* get_texdef_face_list()
48 return &(*g_texdef_face_vector.begin());
51 inline unsigned int texdef_face_list_empty()
53 return g_texdef_face_vector.empty();
56 inline unsigned int texdef_face_list_size()
58 return g_texdef_face_vector.size();
61 // For different faces having different values
62 bool is_HShift_conflicting;
63 bool is_VShift_conflicting;
64 bool is_HScale_conflicting;
65 bool is_VScale_conflicting;
66 bool is_Rotate_conflicting;
67 bool is_TextureName_conflicting;
72 void GetTexMods(bool b_SetUndoPoint = FALSE);
75 void InitDefaultIncrement(texdef_t *);
76 void DoSnapTToGrid(float hscale, float vscale);
77 // called to perform a fitting from the outside (shortcut key)
78 void SurfaceDialogFitAll();
85 // 0 is invalid, otherwise it's the Id of the last 'do' we are responsible for
89 texturewin_t *texturewin;
90 texdef_t *l_pIncrement;
91 texdef_t texdef_offset;
92 texdef_t texdef_SI_values;
94 // For Texture Entry, activate only on entry change
95 char old_texture_entry[128];
97 // the texdef to switch back to when the OnCancel is called
98 texdef_t g_old_texdef;
100 // when TRUE, this thing means the surface inspector is currently being displayed
101 bool g_surfwin = FALSE;
102 // turn on/off processing of the "changed" "value_changed" messages
103 // (need to turn off when we are feeding data in)
104 bool g_bListenChanged = true;
105 // turn on/off listening of the update messages
106 bool g_bListenUpdate = true;
108 GtkWidget* create_SurfaceInspector (void);
109 GtkWidget *SurfaceInspector = NULL;
111 GtkWidget *m_pWidget;
112 GtkWidget *GetWidget () { return SurfaceInspector; }
113 GtkWidget *Get_SI_Module_Widget () { return SurfaceInspector; }
114 void SetWidget(GtkWidget *new_widget) { m_pWidget = new_widget; }
115 GtkWidget *GetDlgWidget (const char* name)
116 { return GTK_WIDGET (g_object_get_data (G_OBJECT (SurfaceInspector), name)); }
118 // Spins for FitTexture
119 GtkWidget *spin_width;
120 GtkWidget *spin_height;
123 GtkWidget *texture_combo;
124 GtkWidget *texture_combo_entry;
126 GtkWidget *match_grid_button;
127 GtkWidget *lock_valuechange_togglebutton;
129 GtkObject *hshift_value_spinbutton_adj;
130 GtkWidget *hshift_value_spinbutton;
131 GtkObject *vshift_value_spinbutton_adj;
132 GtkWidget *vshift_value_spinbutton;
133 GtkObject *hscale_value_spinbutton_adj;
134 GtkWidget *hscale_value_spinbutton;
135 GtkObject *vscale_value_spinbutton_adj;
136 GtkWidget *vscale_value_spinbutton;
137 GtkObject *rotate_value_spinbutton_adj;
138 GtkWidget *rotate_value_spinbutton;
140 GtkObject *hshift_offset_spinbutton_adj;
141 GtkWidget *hshift_offset_spinbutton;
142 GtkObject *vshift_offset_spinbutton_adj;
143 GtkWidget *vshift_offset_spinbutton;
144 GtkObject *hscale_offset_spinbutton_adj;
145 GtkWidget *hscale_offset_spinbutton;
146 GtkObject *vscale_offset_spinbutton_adj;
147 GtkWidget *vscale_offset_spinbutton;
148 GtkObject *rotate_offset_spinbutton_adj;
149 GtkWidget *rotate_offset_spinbutton;
151 GtkObject *hshift_step_spinbutton_adj;
152 GtkWidget *hshift_step_spinbutton;
153 GtkObject *vshift_step_spinbutton_adj;
154 GtkWidget *vshift_step_spinbutton;
155 GtkObject *hscale_step_spinbutton_adj;
156 GtkWidget *hscale_step_spinbutton;
157 GtkObject *vscale_step_spinbutton_adj;
158 GtkWidget *vscale_step_spinbutton;
159 GtkObject *rotate_step_spinbutton_adj;
160 GtkWidget *rotate_step_spinbutton;
162 GtkObject *fit_width_spinbutton_adj;
163 GtkWidget *fit_width_spinbutton;
164 GtkObject *fit_height_spinbutton_adj;
165 GtkWidget *fit_height_spinbutton;
166 GtkWidget *fit_button;
167 GtkWidget *axial_button;
169 GtkWidget *done_button;
170 GtkWidget *apply_button;
171 GtkWidget *cancel_button;
174 gboolean on_texture_combo_entry_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data);
175 void on_texture_combo_entry_activate (GtkEntry *entry, gpointer user_data);
177 static void on_match_grid_button_clicked (GtkButton *button, gpointer user_data);
178 static void on_lock_valuechange_togglebutton_toggled (GtkToggleButton *togglebutton, gpointer user_data);
180 static void on_hshift_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
181 static void on_vshift_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
182 static void on_hscale_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
183 static void on_vscale_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
184 static void on_rotate_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
186 static void on_hshift_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
187 static void on_vshift_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
188 static void on_hscale_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
189 static void on_vscale_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
190 static void on_rotate_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
192 static void on_hshift_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
193 static void on_vshift_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
194 static void on_hscale_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
195 static void on_vscale_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
196 static void on_rotate_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
198 static void on_fit_width_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
199 static void on_fit_height_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
200 static void on_fit_button_clicked (GtkButton *button, gpointer user_data);
201 static void on_axial_button_clicked (GtkButton *button, gpointer user_data);
203 static void on_done_button_clicked (GtkButton *button, gpointer user_data);
204 static void on_apply_button_clicked (GtkButton *button, gpointer user_data);
205 static void on_cancel_button_clicked (GtkButton *button, gpointer user_data);
209 ===================================================
213 ===================================================
217 void IsFaceConflicting()
219 texdef_t* tmp_texdef;
220 texdef_to_face_t* temp_texdef_face_list;
222 char texture_name[128];
224 if (texdef_face_list_empty())
226 gtk_entry_set_text( GTK_ENTRY (hshift_value_spinbutton), "");
227 gtk_entry_set_text( GTK_ENTRY (vshift_value_spinbutton), "");
228 gtk_entry_set_text( GTK_ENTRY (hscale_value_spinbutton), "");
229 gtk_entry_set_text( GTK_ENTRY (vscale_value_spinbutton), "");
230 gtk_entry_set_text( GTK_ENTRY (rotate_value_spinbutton), "");
231 gtk_entry_set_text( GTK_ENTRY (texture_combo_entry), "");
235 g_bListenChanged = FALSE;
237 tmp_texdef = &get_texdef_face_list()->texdef;
239 strcpy(texture_name, tmp_texdef->GetName() );
241 texdef_SI_values.shift[0] = tmp_texdef->shift[0];
242 texdef_SI_values.shift[1] = tmp_texdef->shift[1];
243 texdef_SI_values.scale[0] = tmp_texdef->scale[0];
244 texdef_SI_values.scale[1] = tmp_texdef->scale[1];
245 texdef_SI_values.rotate = tmp_texdef->rotate;
246 texdef_SI_values.SetName( texture_name );
248 is_HShift_conflicting = FALSE;
249 is_VShift_conflicting = FALSE;
250 is_HScale_conflicting = FALSE;
251 is_VScale_conflicting = FALSE;
252 is_Rotate_conflicting = FALSE;
253 is_TextureName_conflicting = FALSE;
255 if (texdef_face_list_size() > 1)
257 temp_texdef_face_list = get_texdef_face_list()->next;
259 for (; temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
261 tmp_texdef = &temp_texdef_face_list->texdef;
262 if ( texdef_SI_values.shift[0] != tmp_texdef->shift[0] )
263 is_HShift_conflicting = TRUE;
265 if ( texdef_SI_values.shift[1] != tmp_texdef->shift[1] )
266 is_VShift_conflicting = TRUE;
268 if ( texdef_SI_values.scale[0] != tmp_texdef->scale[0] )
269 is_HScale_conflicting = TRUE;
271 if ( texdef_SI_values.scale[1] != tmp_texdef->scale[1] )
272 is_VScale_conflicting = TRUE;
274 if ( texdef_SI_values.rotate != tmp_texdef->rotate )
275 is_Rotate_conflicting = TRUE;
277 if ( strcmp( texture_name, tmp_texdef->GetName() ) )
278 is_TextureName_conflicting = TRUE;
282 if(is_HShift_conflicting)
283 gtk_entry_set_text( GTK_ENTRY (hshift_value_spinbutton), "");
285 gtk_spin_button_set_value( GTK_SPIN_BUTTON(hshift_value_spinbutton) , texdef_SI_values.shift[0] );
287 if(is_VShift_conflicting)
288 gtk_entry_set_text( GTK_ENTRY (vshift_value_spinbutton), "");
290 gtk_spin_button_set_value( GTK_SPIN_BUTTON(vshift_value_spinbutton) , texdef_SI_values.shift[1] );
292 if(is_HScale_conflicting)
293 gtk_entry_set_text( GTK_ENTRY (hscale_value_spinbutton), "");
295 gtk_spin_button_set_value( GTK_SPIN_BUTTON(hscale_value_spinbutton) , texdef_SI_values.scale[0] );
297 if(is_VScale_conflicting)
298 gtk_entry_set_text( GTK_ENTRY (vscale_value_spinbutton), "");
300 gtk_spin_button_set_value( GTK_SPIN_BUTTON(vscale_value_spinbutton) , texdef_SI_values.scale[1] );
302 if(is_Rotate_conflicting)
303 gtk_entry_set_text( GTK_ENTRY (rotate_value_spinbutton), "");
305 gtk_spin_button_set_value( GTK_SPIN_BUTTON(rotate_value_spinbutton) , texdef_SI_values.rotate );
307 g_bListenChanged = TRUE;
310 #define MAX_NUM_LIST_ITEMS 15
311 static void PopulateTextureComboList()
313 texdef_t* tmp_texdef;
314 texdef_to_face_t* temp_texdef_face_list;
318 int num_of_list_items = 0;
322 if (texdef_face_list_empty())
324 items = g_list_append (items, (gpointer) blank);
325 // For Texture Entry, activate only on entry change
326 strcpy (old_texture_entry, blank);
328 else if ( !is_TextureName_conflicting )
330 temp_texdef_face_list = get_texdef_face_list();
331 tmp_texdef = (texdef_t *) &get_texdef_face_list()->texdef;
332 items = g_list_append( items, (gpointer) tmp_texdef->GetName() );
333 // For Texture Entry, activate only on entry change
334 strcpy (old_texture_entry, tmp_texdef->GetName());
338 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
340 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
341 // Need to do a string compare, hence the custom search
342 if (!( g_list_find_custom (items, tmp_texdef->GetName(), (GCompareFunc) strcmp ) ))
344 items = g_list_append( items, (gpointer) tmp_texdef->GetName() );
347 // Make sure the combo list isn't too long
348 if (num_of_list_items >= MAX_NUM_LIST_ITEMS)
351 // If this isn't added last (to the top of the list), g_list_find freaks.
352 items = g_list_prepend (items, (gpointer) blank);
353 // For Texture Entry, activate only on entry change
354 strcpy (old_texture_entry, blank);
357 gtk_combo_set_popdown_strings (GTK_COMBO (texture_combo), items);
362 static void ZeroOffsetValues()
364 texdef_offset.shift[0] = 0.0;
365 texdef_offset.shift[1] = 0.0;
366 texdef_offset.scale[0] = 0.0;
367 texdef_offset.scale[1] = 0.0;
368 texdef_offset.rotate = 0.0;
371 static void GetTexdefInfo_from_Radiant()
373 g_texdef_face_vector.clear();
375 unsigned int count = GetSelectedFaceCountfromBrushes();
377 count = GetSelectedFaceCount();
379 g_texdef_face_vector.resize(count);
381 if (!texdef_face_list_empty())
383 // texdef_to_face_t* p = get_texdef_face_list();
384 GetSelFacesTexdef( get_texdef_face_list() );
388 PopulateTextureComboList();
392 static gint delete_event_callback(GtkWidget *widget, GdkEvent* event, gpointer data)
398 // make the shift increments match the grid settings
399 // the objective being that the shift+arrows shortcuts move the texture by the corresponding grid size
400 // this depends on a scale value if you have selected a particular texture on which you want it to work:
401 // we move the textures in pixels, not world units. (i.e. increment values are in pixel)
402 // depending on the texture scale it doesn't take the same amount of pixels to move of g_qeglobals.d_gridsize
403 // increment * scale = gridsize
404 // hscale and vscale are optional parameters, if they are zero they will be set to the default scale
405 // NOTE: the default scale depends if you are using BP mode or regular.
406 // For regular it's 0.5f (128 pixels cover 64 world units), for BP it's simply 1.0f
408 void DoSnapTToGrid(float hscale, float vscale)
410 l_pIncrement = Get_SI_Inc();
421 Sys_Printf ("DoSnapTToGrid: hscale %g vscale %g\n", hscale, vscale);
423 l_pIncrement->shift[0] = GridSize() / hscale;
424 l_pIncrement->shift[1] = GridSize() / vscale;
425 // now some update work
426 // FIXME: doesn't look good here, seems to be called several times
430 void UpdateSurfaceDialog()
432 if (!g_bListenUpdate)
435 if (!SurfaceInspector)
438 // avoid long delays on slow computers
439 while (gtk_events_pending ())
440 gtk_main_iteration ();
445 Sys_Printf("UpdateSurfaceDialog\n");
447 GetTexdefInfo_from_Radiant();
453 // DoSurface will always try to show the surface inspector
454 // or update it because something new has been selected
455 void DoSurface (void)
458 Sys_Printf("DoSurface\n");
460 if (!SurfaceInspector)
461 create_SurfaceInspector ();
470 Sys_Printf("ToggleSurface Module\n");
475 on_cancel_button_clicked(NULL, NULL);
478 // NOTE: will raise and show the Surface inspector and exec fit for patches and brushes
479 void SurfaceDlgFitAll()
485 // =============================================================================
486 // SurfaceDialog class
491 if(!SurfaceInspector)
492 create_SurfaceInspector();
494 gtk_widget_show (SurfaceInspector);
496 GetTexdefInfo_from_Radiant();
497 GetTexMods(TRUE); // Set Initial Undo Point
504 gtk_widget_hide (SurfaceInspector);
508 // set default values for increments (shift scale and rot)
509 // this is called by the prefs code if can't find the values
510 void InitDefaultIncrement(texdef_t *tex)
515 tex->scale[0] = 0.25;
516 tex->scale[1] = 0.25;
522 if ( !SurfaceInspector )
523 create_SurfaceInspector();
530 Set the fields to the current texdef (i.e. map/texdef -> dialog widgets)
538 GtkAdjustment *adjust;
540 texturewin = Texturewin ();
541 l_pIncrement = Get_SI_Inc();
544 Sys_Printf("SurfaceDlg SetTexMods\n");
550 pt = &texturewin->texdef;
552 g_bListenChanged = false;
554 if(strncmp(pt->GetName(), "textures/", 9) != 0)
555 texdef_offset.SetName(SHADER_NOT_FOUND);
558 spin = GTK_SPIN_BUTTON (hshift_offset_spinbutton);
559 gtk_spin_button_set_value (spin, texdef_offset.shift[0]);
560 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
561 adjust->step_increment = l_pIncrement->shift[0];
562 gtk_spin_button_set_value (GTK_SPIN_BUTTON(hshift_step_spinbutton), l_pIncrement->shift[0]);
564 spin = GTK_SPIN_BUTTON (hshift_value_spinbutton);
565 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
566 adjust->step_increment = l_pIncrement->shift[0];
569 spin = GTK_SPIN_BUTTON (vshift_offset_spinbutton);
570 gtk_spin_button_set_value (spin, texdef_offset.shift[1]);
571 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
572 adjust->step_increment = l_pIncrement->shift[1];
573 gtk_spin_button_set_value (GTK_SPIN_BUTTON(vshift_step_spinbutton), l_pIncrement->shift[1]);
575 spin = GTK_SPIN_BUTTON (vshift_value_spinbutton);
576 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
577 adjust->step_increment = l_pIncrement->shift[1];
580 spin = GTK_SPIN_BUTTON (hscale_offset_spinbutton);
581 gtk_spin_button_set_value (spin, texdef_offset.scale[0]);
582 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
583 adjust->step_increment = l_pIncrement->scale[0];
584 gtk_spin_button_set_value (GTK_SPIN_BUTTON(hscale_step_spinbutton), l_pIncrement->scale[0]);
586 spin = GTK_SPIN_BUTTON (hscale_value_spinbutton);
587 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
588 adjust->step_increment = l_pIncrement->scale[0];
591 spin = GTK_SPIN_BUTTON (vscale_offset_spinbutton);
592 gtk_spin_button_set_value (spin, texdef_offset.scale[1]);
593 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
594 adjust->step_increment = l_pIncrement->scale[1];
595 gtk_spin_button_set_value (GTK_SPIN_BUTTON(vscale_step_spinbutton), l_pIncrement->scale[1]);
597 spin = GTK_SPIN_BUTTON (vscale_value_spinbutton);
598 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
599 adjust->step_increment = l_pIncrement->scale[1];
602 spin = GTK_SPIN_BUTTON (rotate_offset_spinbutton);
603 gtk_spin_button_set_value (spin, texdef_offset.rotate);
604 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
605 adjust->step_increment = l_pIncrement->rotate;
606 gtk_spin_button_set_value (GTK_SPIN_BUTTON(rotate_step_spinbutton), l_pIncrement->rotate);
608 spin = GTK_SPIN_BUTTON (rotate_value_spinbutton);
609 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
610 adjust->step_increment = l_pIncrement->rotate;
613 g_bListenChanged = true;
615 // store the current texdef as our escape route if user hits OnCancel
616 g_old_texdef = texturewin->texdef;
623 Shows any changes to the main Radiant windows
626 void GetTexMods(bool b_SetUndoPoint)
630 Sys_Printf("SurfaceDlg GetTexMods\n");
633 if ( !texdef_face_list_empty() )
635 g_bListenUpdate=FALSE;
636 SetTexdef_FaceList( get_texdef_face_list(), b_SetUndoPoint, false );
637 g_bListenUpdate=TRUE;
640 m_nUndoId = Undo_GetUndoId();
646 on_fit_button_clicked(NULL, NULL);
650 ////////////////////////////////////////////////////////////////////
654 ////////////////////////////////////////////////////////////////////
656 GtkWidget* create_SurfaceInspector (void)
660 GtkWidget *hseparator;
663 GtkWidget *viewport8;
664 GtkWidget *viewport9;
665 GtkWidget *viewport2;
666 GtkWidget *viewport7;
667 GtkWidget *viewport5;
668 GtkWidget *viewport6;
669 GtkWidget *viewport10;
676 GtkWidget *alignment1;
677 GtkWidget *alignment2;
678 GtkWidget *alignment3;
691 GtkWidget *hbuttonbox1;
693 SurfaceInspector = gtk_window_new (GTK_WINDOW_TOPLEVEL);
694 gtk_container_set_border_width (GTK_CONTAINER (SurfaceInspector), 4);
695 gtk_window_set_title (GTK_WINDOW (SurfaceInspector), "Surface Inspector");
697 SetWinPos_from_Prefs(SurfaceInspector);
699 viewport8 = gtk_viewport_new (NULL, NULL);
700 gtk_widget_show (viewport8);
701 gtk_container_add (GTK_CONTAINER (SurfaceInspector), viewport8);
702 gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport8), GTK_SHADOW_NONE);
704 vbox7 = gtk_vbox_new (FALSE, 0);
705 gtk_widget_show (vbox7);
706 gtk_container_add (GTK_CONTAINER (viewport8), vbox7);
708 viewport9 = gtk_viewport_new (NULL, NULL);
709 gtk_widget_show (viewport9);
710 gtk_box_pack_start (GTK_BOX (vbox7), viewport9, FALSE, FALSE, 0);
711 gtk_container_set_border_width (GTK_CONTAINER (viewport9), 2);
712 gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport9), GTK_SHADOW_ETCHED_IN);
714 hbox1 = gtk_hbox_new (FALSE, 0);
715 gtk_widget_show (hbox1);
716 gtk_container_add (GTK_CONTAINER (viewport9), hbox1);
717 gtk_container_set_border_width (GTK_CONTAINER (hbox1), 4);
719 label = gtk_label_new ("Texture: ");
720 gtk_widget_show (label);
721 gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
722 gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
724 texture_combo = gtk_combo_new ();
725 g_object_set_data (G_OBJECT (GTK_COMBO (texture_combo)->popwin),
726 "KeepMeAround", texture_combo);
727 gtk_combo_disable_activate ( (GtkCombo*) texture_combo);
728 gtk_widget_show (texture_combo);
729 gtk_box_pack_start (GTK_BOX (hbox1), texture_combo, TRUE, TRUE, 0);
731 texture_combo_entry = GTK_COMBO (texture_combo)->entry;
732 gtk_widget_show (texture_combo_entry);
733 gtk_entry_set_max_length (GTK_ENTRY (texture_combo_entry), 128);
735 viewport2 = gtk_viewport_new (NULL, NULL);
736 gtk_widget_show (viewport2);
737 gtk_box_pack_start (GTK_BOX (vbox7), viewport2, FALSE, TRUE, 0);
738 gtk_container_set_border_width (GTK_CONTAINER (viewport2), 2);
739 gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport2), GTK_SHADOW_ETCHED_IN);
741 table1 = gtk_table_new (13, 4, FALSE);
742 gtk_widget_show (table1);
743 gtk_container_add (GTK_CONTAINER (viewport2), table1);
745 hseparator = gtk_hseparator_new ();
746 gtk_widget_show (hseparator);
747 gtk_table_attach (GTK_TABLE (table1), hseparator, 1, 2, 1, 2,
748 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
749 (GtkAttachOptions) (GTK_FILL), 0, 0);
751 hseparator = gtk_hseparator_new ();
752 gtk_widget_show (hseparator);
753 gtk_table_attach (GTK_TABLE (table1), hseparator, 2, 3, 1, 2,
754 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
755 (GtkAttachOptions) (GTK_FILL), 0, 0);
757 hseparator = gtk_hseparator_new ();
758 gtk_widget_show (hseparator);
759 gtk_table_attach (GTK_TABLE (table1), hseparator, 3, 4, 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, 1, 2, 3, 4,
766 (GtkAttachOptions) (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, 2, 3, 3, 4,
772 (GtkAttachOptions) (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, 3, 4, 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, 1, 2, 5, 6,
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, 2, 3, 5, 6,
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, 3, 4, 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, 1, 2, 7, 8,
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, 2, 3, 7, 8,
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, 3, 4, 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, 1, 2, 9, 10,
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, 2, 3, 9, 10,
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, 3, 4, 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, 1, 2, 11, 12,
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, 2, 3, 11, 12,
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, 3, 4, 11, 12,
850 (GtkAttachOptions) (GTK_FILL),
851 (GtkAttachOptions) (GTK_FILL), 0, 0);
853 label = gtk_label_new ("Offset");
854 gtk_widget_show (label);
855 gtk_table_attach (GTK_TABLE (table1), label, 2, 3, 0, 1,
856 (GtkAttachOptions) (GTK_FILL),
857 (GtkAttachOptions) (0), 0, 0);
859 label = gtk_label_new ("Step");
860 gtk_widget_show (label);
861 gtk_table_attach (GTK_TABLE (table1), label, 3, 4, 0, 1,
862 (GtkAttachOptions) (GTK_FILL),
863 (GtkAttachOptions) (0), 0, 0);
865 eventbox = gtk_event_box_new ();
866 gtk_widget_show (eventbox);
867 gtk_table_attach (GTK_TABLE (table1), eventbox, 3, 4, 12, 13,
868 (GtkAttachOptions) (GTK_FILL),
869 (GtkAttachOptions) (GTK_FILL), 0, 0);
871 match_grid_button = gtk_button_new_with_mnemonic ("Match Grid");
872 gtk_widget_show (match_grid_button);
873 gtk_container_add (GTK_CONTAINER (eventbox), match_grid_button);
875 label = gtk_label_new ("Value");
876 gtk_widget_show (label);
877 gtk_table_attach (GTK_TABLE (table1), label, 1, 2, 0, 1,
878 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
879 (GtkAttachOptions) (0), 0, 0);
880 gtk_misc_set_alignment (GTK_MISC (label), 0.5, 1);
882 hseparator = gtk_hseparator_new ();
883 gtk_widget_show (hseparator);
884 gtk_table_attach (GTK_TABLE (table1), hseparator, 0, 1, 3, 4,
885 (GtkAttachOptions) (GTK_SHRINK | GTK_FILL),
886 (GtkAttachOptions) (GTK_FILL), 0, 0);
888 hseparator = gtk_hseparator_new ();
889 gtk_widget_show (hseparator);
890 gtk_table_attach (GTK_TABLE (table1), hseparator, 0, 1, 5, 6,
891 (GtkAttachOptions) (GTK_FILL),
892 (GtkAttachOptions) (GTK_FILL), 0, 0);
894 hseparator = gtk_hseparator_new ();
895 gtk_widget_show (hseparator);
896 gtk_table_attach (GTK_TABLE (table1), hseparator, 0, 1, 7, 8,
897 (GtkAttachOptions) (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, 9, 10,
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, 11, 12,
909 (GtkAttachOptions) (GTK_FILL),
910 (GtkAttachOptions) (GTK_FILL), 0, 0);
912 eventbox = gtk_event_box_new ();
913 gtk_widget_show (eventbox);
914 gtk_table_attach (GTK_TABLE (table1), eventbox, 0, 1, 4, 5,
915 (GtkAttachOptions) (GTK_FILL),
916 (GtkAttachOptions) (GTK_FILL), 0, 0);
918 label = gtk_label_new ("V Shift: ");
919 gtk_widget_show (label);
920 gtk_container_add (GTK_CONTAINER (eventbox), label);
921 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
922 gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
924 eventbox = gtk_event_box_new ();
925 gtk_widget_show (eventbox);
926 gtk_table_attach (GTK_TABLE (table1), eventbox, 0, 1, 6, 7,
927 (GtkAttachOptions) (GTK_FILL),
928 (GtkAttachOptions) (GTK_FILL), 0, 0);
930 label = gtk_label_new (" H Scale: ");
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, 8, 9,
939 (GtkAttachOptions) (GTK_FILL),
940 (GtkAttachOptions) (GTK_FILL), 0, 0);
942 label = gtk_label_new ("V 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, 10, 11,
951 (GtkAttachOptions) (GTK_FILL),
952 (GtkAttachOptions) (GTK_FILL), 0, 0);
954 label = gtk_label_new ("Rotate: ");
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, 2, 3,
963 (GtkAttachOptions) (GTK_FILL),
964 (GtkAttachOptions) (GTK_FILL), 0, 0);
966 label = gtk_label_new ("H Shift: ");
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 hseparator = gtk_hseparator_new ();
973 gtk_widget_show (hseparator);
974 gtk_table_attach (GTK_TABLE (table1), hseparator, 0, 1, 1, 2,
975 (GtkAttachOptions) (GTK_FILL),
976 (GtkAttachOptions) (GTK_FILL), 0, 0);
978 eventbox = gtk_event_box_new ();
979 gtk_widget_show (eventbox);
980 gtk_table_attach (GTK_TABLE (table1), eventbox, 1, 2, 12, 13,
981 (GtkAttachOptions) (GTK_FILL),
982 (GtkAttachOptions) (GTK_FILL), 0, 0);
984 lock_valuechange_togglebutton = gtk_toggle_button_new_with_mnemonic ("UNLOCK");
985 gtk_widget_show (lock_valuechange_togglebutton);
986 gtk_container_add (GTK_CONTAINER (eventbox), lock_valuechange_togglebutton);
989 hshift_value_spinbutton_adj = gtk_adjustment_new (0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0);
990 hshift_value_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (hshift_value_spinbutton_adj), 1, 2);
991 gtk_widget_show (hshift_value_spinbutton);
992 gtk_table_attach (GTK_TABLE (table1), hshift_value_spinbutton, 1, 2, 2, 3,
993 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
994 (GtkAttachOptions) (0), 0, 0);
995 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (hshift_value_spinbutton), GTK_UPDATE_IF_VALID);
996 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (hshift_value_spinbutton), TRUE);
997 gtk_widget_set_sensitive( GTK_WIDGET( hshift_value_spinbutton ), FALSE );
999 vshift_value_spinbutton_adj = gtk_adjustment_new (0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0);
1000 vshift_value_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (vshift_value_spinbutton_adj), 1, 2);
1001 gtk_widget_show (vshift_value_spinbutton);
1002 gtk_table_attach (GTK_TABLE (table1), vshift_value_spinbutton, 1, 2, 4, 5,
1003 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1004 (GtkAttachOptions) (0), 0, 0);
1005 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (vshift_value_spinbutton), GTK_UPDATE_IF_VALID);
1006 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (vshift_value_spinbutton), TRUE);
1007 gtk_widget_set_sensitive( GTK_WIDGET( vshift_value_spinbutton ), FALSE );
1009 hscale_value_spinbutton_adj = gtk_adjustment_new (0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0);
1010 hscale_value_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (hscale_value_spinbutton_adj), 1, 4);
1011 gtk_widget_show (hscale_value_spinbutton);
1012 gtk_table_attach (GTK_TABLE (table1), hscale_value_spinbutton, 1, 2, 6, 7,
1013 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1014 (GtkAttachOptions) (0), 0, 0);
1015 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (hscale_value_spinbutton), GTK_UPDATE_IF_VALID);
1016 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (hscale_value_spinbutton), TRUE);
1017 gtk_widget_set_sensitive( GTK_WIDGET( hscale_value_spinbutton ), FALSE );
1019 vscale_value_spinbutton_adj = gtk_adjustment_new (0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0);
1020 vscale_value_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (vscale_value_spinbutton_adj), 1, 4);
1021 gtk_widget_show (vscale_value_spinbutton);
1022 gtk_table_attach (GTK_TABLE (table1), vscale_value_spinbutton, 1, 2, 8, 9,
1023 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1024 (GtkAttachOptions) (0), 0, 0);
1025 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (vscale_value_spinbutton), GTK_UPDATE_IF_VALID);
1026 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (vscale_value_spinbutton), TRUE);
1027 gtk_widget_set_sensitive( GTK_WIDGET( vscale_value_spinbutton ), FALSE );
1029 rotate_value_spinbutton_adj = gtk_adjustment_new (0.0, -360.0, 360.0, 1.0, 10.0, 10.0);
1030 rotate_value_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (rotate_value_spinbutton_adj), 1, 4);
1031 gtk_widget_show (rotate_value_spinbutton);
1032 gtk_table_attach (GTK_TABLE (table1), rotate_value_spinbutton, 1, 2, 10, 11,
1033 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1034 (GtkAttachOptions) (0), 0, 0);
1035 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (rotate_value_spinbutton), GTK_UPDATE_IF_VALID);
1036 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (rotate_value_spinbutton), TRUE);
1037 gtk_widget_set_sensitive( GTK_WIDGET( rotate_value_spinbutton ), FALSE );
1040 hshift_offset_spinbutton_adj = gtk_adjustment_new (0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0);
1041 hshift_offset_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (hshift_offset_spinbutton_adj), 0, 2);
1042 gtk_widget_show (hshift_offset_spinbutton);
1043 gtk_table_attach (GTK_TABLE (table1), hshift_offset_spinbutton, 2, 3, 2, 3,
1044 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1045 (GtkAttachOptions) (0), 4, 0);
1046 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (hshift_offset_spinbutton), TRUE);
1047 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (hshift_offset_spinbutton), GTK_UPDATE_IF_VALID);
1048 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (hshift_offset_spinbutton), TRUE);
1050 vshift_offset_spinbutton_adj = gtk_adjustment_new (0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0);
1051 vshift_offset_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (vshift_offset_spinbutton_adj), 0, 2);
1052 gtk_widget_show (vshift_offset_spinbutton);
1053 gtk_table_attach (GTK_TABLE (table1), vshift_offset_spinbutton, 2, 3, 4, 5,
1054 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1055 (GtkAttachOptions) (0), 4, 0);
1056 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (vshift_offset_spinbutton), TRUE);
1057 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (vshift_offset_spinbutton), GTK_UPDATE_IF_VALID);
1058 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (vshift_offset_spinbutton), TRUE);
1060 hscale_offset_spinbutton_adj = gtk_adjustment_new (0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0);
1061 hscale_offset_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (hscale_offset_spinbutton_adj), 0, 4);
1062 gtk_widget_show (hscale_offset_spinbutton);
1063 gtk_table_attach (GTK_TABLE (table1), hscale_offset_spinbutton, 2, 3, 6, 7,
1064 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1065 (GtkAttachOptions) (0), 4, 0);
1066 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (hscale_offset_spinbutton), TRUE);
1067 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (hscale_offset_spinbutton), GTK_UPDATE_IF_VALID);
1068 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (hscale_offset_spinbutton), TRUE);
1070 vscale_offset_spinbutton_adj = gtk_adjustment_new (0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0);
1071 vscale_offset_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (vscale_offset_spinbutton_adj), 0, 4);
1072 gtk_widget_show (vscale_offset_spinbutton);
1073 gtk_table_attach (GTK_TABLE (table1), vscale_offset_spinbutton, 2, 3, 8, 9,
1074 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1075 (GtkAttachOptions) (0), 4, 0);
1076 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (vscale_offset_spinbutton), TRUE);
1077 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (vscale_offset_spinbutton), GTK_UPDATE_IF_VALID);
1078 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (vscale_offset_spinbutton), TRUE);
1080 rotate_offset_spinbutton_adj = gtk_adjustment_new (0.0, -360.0, 360.0, 1.0, 10.0, 10.0);
1081 rotate_offset_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (rotate_offset_spinbutton_adj), 0, 4);
1082 gtk_widget_show (rotate_offset_spinbutton);
1083 gtk_table_attach (GTK_TABLE (table1), rotate_offset_spinbutton, 2, 3, 10, 11,
1084 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1085 (GtkAttachOptions) (0), 4, 0);
1086 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (rotate_offset_spinbutton), TRUE);
1087 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (rotate_offset_spinbutton), GTK_UPDATE_IF_VALID);
1088 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (rotate_offset_spinbutton), TRUE);
1091 hshift_step_spinbutton_adj = gtk_adjustment_new (0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0);
1092 hshift_step_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (hshift_step_spinbutton_adj), 1, 2);
1093 gtk_widget_show (hshift_step_spinbutton);
1094 gtk_table_attach (GTK_TABLE (table1), hshift_step_spinbutton, 3, 4, 2, 3,
1095 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1096 (GtkAttachOptions) (0), 0, 0);
1097 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (hshift_step_spinbutton), GTK_UPDATE_IF_VALID);
1099 vshift_step_spinbutton_adj = gtk_adjustment_new (0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0);
1100 vshift_step_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (vshift_step_spinbutton_adj), 1, 2);
1101 gtk_widget_show (vshift_step_spinbutton);
1102 gtk_table_attach (GTK_TABLE (table1), vshift_step_spinbutton, 3, 4, 4, 5,
1103 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1104 (GtkAttachOptions) (0), 0, 0);
1105 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (vshift_step_spinbutton), GTK_UPDATE_IF_VALID);
1107 hscale_step_spinbutton_adj = gtk_adjustment_new (0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0);
1108 hscale_step_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (hscale_step_spinbutton_adj), 1, 4);
1109 gtk_widget_show (hscale_step_spinbutton);
1110 gtk_table_attach (GTK_TABLE (table1), hscale_step_spinbutton, 3, 4, 6, 7,
1111 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1112 (GtkAttachOptions) (0), 0, 0);
1113 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (hscale_step_spinbutton), GTK_UPDATE_IF_VALID);
1115 vscale_step_spinbutton_adj = gtk_adjustment_new (0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0);
1116 vscale_step_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (vscale_step_spinbutton_adj), 1, 4);
1117 gtk_widget_show (vscale_step_spinbutton);
1118 gtk_table_attach (GTK_TABLE (table1), vscale_step_spinbutton, 3, 4, 8, 9,
1119 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1120 (GtkAttachOptions) (0), 0, 0);
1121 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (vscale_step_spinbutton), GTK_UPDATE_IF_VALID);
1123 rotate_step_spinbutton_adj = gtk_adjustment_new (0.0, -360.0, 360.0, 1.0, 10.0, 10.0);
1124 rotate_step_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (rotate_step_spinbutton_adj), 1, 4);
1125 gtk_widget_show (rotate_step_spinbutton);
1126 gtk_table_attach (GTK_TABLE (table1), rotate_step_spinbutton, 3, 4, 10, 11,
1127 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1128 (GtkAttachOptions) (0), 0, 0);
1129 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (rotate_step_spinbutton), GTK_UPDATE_IF_VALID);
1131 eventbox = gtk_event_box_new ();
1132 gtk_widget_show (eventbox);
1133 gtk_table_attach (GTK_TABLE (table1), eventbox, 2, 3, 12, 13,
1134 (GtkAttachOptions) (0),
1135 (GtkAttachOptions) (0), 0, 0);
1137 eventbox = gtk_event_box_new ();
1138 gtk_widget_show (eventbox);
1139 gtk_table_attach (GTK_TABLE (table1), eventbox, 0, 1, 12, 13,
1140 (GtkAttachOptions) (0),
1141 (GtkAttachOptions) (0), 0, 0);
1143 eventbox = gtk_event_box_new ();
1144 gtk_widget_show (eventbox);
1145 gtk_table_attach (GTK_TABLE (table1), eventbox, 0, 1, 0, 1,
1146 (GtkAttachOptions) (0),
1147 (GtkAttachOptions) (0), 0, 0);
1149 viewport7 = gtk_viewport_new (NULL, NULL);
1150 gtk_widget_show (viewport7);
1151 gtk_box_pack_start (GTK_BOX (vbox7), viewport7, FALSE, TRUE, 0);
1152 gtk_container_set_border_width (GTK_CONTAINER (viewport7), 2);
1153 gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport7), GTK_SHADOW_ETCHED_IN);
1155 table4 = gtk_table_new (4, 7, FALSE);
1156 gtk_widget_show (table4);
1157 gtk_container_add (GTK_CONTAINER (viewport7), table4);
1159 viewport5 = gtk_viewport_new (NULL, NULL);
1160 gtk_widget_show (viewport5);
1161 gtk_table_attach (GTK_TABLE (table4), viewport5, 1, 7, 0, 4,
1162 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1163 (GtkAttachOptions) (0), 0, 0);
1164 gtk_container_set_border_width (GTK_CONTAINER (viewport5), 6);
1165 gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport5), GTK_SHADOW_ETCHED_OUT);
1167 table5 = gtk_table_new (2, 3, FALSE);
1168 gtk_widget_show (table5);
1169 gtk_container_add (GTK_CONTAINER (viewport5), table5);
1170 gtk_container_set_border_width (GTK_CONTAINER (table5), 5);
1171 gtk_table_set_col_spacings (GTK_TABLE (table5), 2);
1173 label = gtk_label_new ("Height");
1174 gtk_widget_show (label);
1175 gtk_table_attach (GTK_TABLE (table5), label, 2, 3, 0, 1,
1176 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1177 (GtkAttachOptions) (GTK_FILL), 0, 0);
1178 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1179 gtk_misc_set_alignment (GTK_MISC (label), 0.5, 1);
1181 label = gtk_label_new ("Width");
1182 gtk_widget_show (label);
1183 gtk_table_attach (GTK_TABLE (table5), label, 1, 2, 0, 1,
1184 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1185 (GtkAttachOptions) (GTK_FILL), 0, 0);
1186 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1187 gtk_misc_set_alignment (GTK_MISC (label), 0.5, 1);
1189 fit_width_spinbutton_adj = gtk_adjustment_new (1, 1, 32, 1, 10, 10);
1190 fit_width_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (fit_width_spinbutton_adj), 1, 0);
1191 gtk_widget_show (fit_width_spinbutton);
1192 gtk_table_attach (GTK_TABLE (table5), fit_width_spinbutton, 1, 2, 1, 2,
1193 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1194 (GtkAttachOptions) (GTK_FILL), 0, 0);
1195 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (fit_width_spinbutton), TRUE);
1196 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (fit_width_spinbutton), GTK_UPDATE_IF_VALID);
1198 fit_height_spinbutton_adj = gtk_adjustment_new (1, 1, 32, 1, 10, 10);
1199 fit_height_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (fit_height_spinbutton_adj), 1, 0);
1200 gtk_widget_show (fit_height_spinbutton);
1201 gtk_table_attach (GTK_TABLE (table5), fit_height_spinbutton, 2, 3, 1, 2,
1202 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1203 (GtkAttachOptions) (GTK_FILL), 3, 0);
1204 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (fit_height_spinbutton), TRUE);
1205 gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (fit_height_spinbutton), GTK_UPDATE_IF_VALID);
1207 eventbox = gtk_event_box_new ();
1208 gtk_widget_show (eventbox);
1209 gtk_table_attach (GTK_TABLE (table5), eventbox, 0, 1, 0, 1,
1210 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1211 (GtkAttachOptions) (GTK_FILL), 0, 0);
1213 eventbox = gtk_event_box_new ();
1214 gtk_widget_show (eventbox);
1215 gtk_table_attach (GTK_TABLE (table5), eventbox, 0, 1, 1, 2,
1216 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1217 (GtkAttachOptions) (GTK_FILL), 4, 0);
1219 fit_button = gtk_button_new_with_mnemonic (" Fit ");
1220 gtk_widget_show (fit_button);
1221 gtk_container_add (GTK_CONTAINER (eventbox), fit_button);
1223 viewport6 = gtk_viewport_new (NULL, NULL);
1224 gtk_widget_show (viewport6);
1225 gtk_table_attach (GTK_TABLE (table4), viewport6, 0, 1, 0, 4,
1226 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1227 (GtkAttachOptions) (0), 0, 0);
1228 gtk_container_set_border_width (GTK_CONTAINER (viewport6), 4);
1229 gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport6), GTK_SHADOW_NONE);
1231 table7 = gtk_table_new (2, 1, FALSE);
1232 gtk_widget_show (table7);
1233 gtk_container_add (GTK_CONTAINER (viewport6), table7);
1235 eventbox = gtk_event_box_new ();
1236 gtk_widget_show (eventbox);
1237 gtk_table_attach (GTK_TABLE (table7), eventbox, 0, 1, 0, 2,
1238 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1239 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0);
1241 axial_button = gtk_button_new_with_mnemonic ("Axial");
1242 gtk_widget_show (axial_button);
1243 gtk_container_add (GTK_CONTAINER (eventbox), axial_button);
1244 gtk_widget_set_size_request (axial_button, 56, 29);
1245 gtk_container_set_border_width (GTK_CONTAINER (axial_button), 4);
1247 viewport10 = gtk_viewport_new (NULL, NULL);
1248 gtk_widget_show (viewport10);
1249 gtk_box_pack_start (GTK_BOX (vbox7), viewport10, FALSE, TRUE, 0);
1250 gtk_container_set_border_width (GTK_CONTAINER (viewport10), 2);
1251 gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport10), GTK_SHADOW_ETCHED_IN);
1253 hbuttonbox1 = gtk_hbutton_box_new ();
1254 gtk_widget_show (hbuttonbox1);
1255 gtk_container_add (GTK_CONTAINER (viewport10), hbuttonbox1);
1256 gtk_container_set_border_width (GTK_CONTAINER (hbuttonbox1), 4);
1257 gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox1), GTK_BUTTONBOX_SPREAD);
1259 done_button = gtk_button_new ();
1260 gtk_widget_show (done_button);
1261 gtk_container_add (GTK_CONTAINER (hbuttonbox1), done_button);
1262 GTK_WIDGET_SET_FLAGS (done_button, GTK_CAN_DEFAULT);
1264 alignment1 = gtk_alignment_new (0.5, 0.5, 0, 0);
1265 gtk_widget_show (alignment1);
1266 gtk_container_add (GTK_CONTAINER (done_button), alignment1);
1268 hbox2 = gtk_hbox_new (FALSE, 2);
1269 gtk_widget_show (hbox2);
1270 gtk_container_add (GTK_CONTAINER (alignment1), hbox2);
1272 image1 = gtk_image_new_from_stock ("gtk-yes", GTK_ICON_SIZE_BUTTON);
1273 gtk_widget_show (image1);
1274 gtk_box_pack_start (GTK_BOX (hbox2), image1, FALSE, FALSE, 0);
1276 label = gtk_label_new_with_mnemonic ("Done");
1277 gtk_widget_show (label);
1278 gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);
1279 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1281 apply_button = gtk_button_new ();
1282 gtk_widget_show (apply_button);
1283 gtk_container_add (GTK_CONTAINER (hbuttonbox1), apply_button);
1284 GTK_WIDGET_SET_FLAGS (apply_button, GTK_CAN_DEFAULT);
1286 alignment3 = gtk_alignment_new (0.5, 0.5, 0, 0);
1287 gtk_widget_show (alignment3);
1288 gtk_container_add (GTK_CONTAINER (apply_button), alignment3);
1290 hbox4 = gtk_hbox_new (FALSE, 2);
1291 gtk_widget_show (hbox4);
1292 gtk_container_add (GTK_CONTAINER (alignment3), hbox4);
1294 image3 = gtk_image_new_from_stock ("gtk-apply", GTK_ICON_SIZE_BUTTON);
1295 gtk_widget_show (image3);
1296 gtk_box_pack_start (GTK_BOX (hbox4), image3, FALSE, FALSE, 0);
1298 label = gtk_label_new_with_mnemonic ("Apply");
1299 gtk_widget_show (label);
1300 gtk_box_pack_start (GTK_BOX (hbox4), label, FALSE, FALSE, 0);
1301 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1303 cancel_button = gtk_button_new ();
1304 gtk_widget_show (cancel_button);
1305 gtk_container_add (GTK_CONTAINER (hbuttonbox1), cancel_button);
1306 GTK_WIDGET_SET_FLAGS (cancel_button, GTK_CAN_DEFAULT);
1308 alignment2 = gtk_alignment_new (0.5, 0.5, 0, 0);
1309 gtk_widget_show (alignment2);
1310 gtk_container_add (GTK_CONTAINER (cancel_button), alignment2);
1312 hbox3 = gtk_hbox_new (FALSE, 2);
1313 gtk_widget_show (hbox3);
1314 gtk_container_add (GTK_CONTAINER (alignment2), hbox3);
1316 image2 = gtk_image_new_from_stock ("gtk-no", GTK_ICON_SIZE_BUTTON);
1317 gtk_widget_show (image2);
1318 gtk_box_pack_start (GTK_BOX (hbox3), image2, FALSE, FALSE, 0);
1320 label = gtk_label_new_with_mnemonic ("Cancel");
1321 gtk_widget_show (label);
1322 gtk_box_pack_start (GTK_BOX (hbox3), label, FALSE, FALSE, 0);
1323 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1326 g_signal_connect ( (gpointer) SurfaceInspector,
1328 G_CALLBACK (delete_event_callback),
1330 g_signal_connect ((gpointer) SurfaceInspector, "destroy",
1331 G_CALLBACK (gtk_widget_destroy),
1334 g_signal_connect ((gpointer) texture_combo_entry, "key_press_event",
1335 G_CALLBACK (on_texture_combo_entry_key_press_event),
1337 g_signal_connect ((gpointer) texture_combo_entry, "activate",
1338 G_CALLBACK (on_texture_combo_entry_activate),
1342 g_signal_connect ((gpointer) hshift_offset_spinbutton, "value_changed",
1343 G_CALLBACK (on_hshift_offset_spinbutton_value_changed),
1345 g_signal_connect ((gpointer) vshift_offset_spinbutton, "value_changed",
1346 G_CALLBACK (on_vshift_offset_spinbutton_value_changed),
1348 g_signal_connect ((gpointer) hscale_offset_spinbutton, "value_changed",
1349 G_CALLBACK (on_hscale_offset_spinbutton_value_changed),
1351 g_signal_connect ((gpointer) vscale_offset_spinbutton, "value_changed",
1352 G_CALLBACK (on_vscale_offset_spinbutton_value_changed),
1354 g_signal_connect ((gpointer) rotate_offset_spinbutton, "value_changed",
1355 G_CALLBACK (on_rotate_offset_spinbutton_value_changed),
1358 g_signal_connect ((gpointer) hshift_value_spinbutton, "value_changed",
1359 G_CALLBACK (on_hshift_value_spinbutton_value_changed),
1361 g_signal_connect ((gpointer) vshift_value_spinbutton, "value_changed",
1362 G_CALLBACK (on_vshift_value_spinbutton_value_changed),
1364 g_signal_connect ((gpointer) hscale_value_spinbutton, "value_changed",
1365 G_CALLBACK (on_hscale_value_spinbutton_value_changed),
1367 g_signal_connect ((gpointer) vscale_value_spinbutton, "value_changed",
1368 G_CALLBACK (on_vscale_value_spinbutton_value_changed),
1370 g_signal_connect ((gpointer) rotate_value_spinbutton, "value_changed",
1371 G_CALLBACK (on_rotate_value_spinbutton_value_changed),
1374 g_signal_connect ((gpointer) hshift_step_spinbutton, "value_changed",
1375 G_CALLBACK (on_hshift_step_spinbutton_value_changed),
1377 g_signal_connect ((gpointer) vshift_step_spinbutton, "value_changed",
1378 G_CALLBACK (on_vshift_step_spinbutton_value_changed),
1380 g_signal_connect ((gpointer) hscale_step_spinbutton, "value_changed",
1381 G_CALLBACK (on_hscale_step_spinbutton_value_changed),
1383 g_signal_connect ((gpointer) vscale_step_spinbutton, "value_changed",
1384 G_CALLBACK (on_vscale_step_spinbutton_value_changed),
1386 g_signal_connect ((gpointer) rotate_step_spinbutton, "value_changed",
1387 G_CALLBACK (on_rotate_step_spinbutton_value_changed),
1390 g_signal_connect ((gpointer) match_grid_button, "clicked",
1391 G_CALLBACK (on_match_grid_button_clicked),
1393 g_signal_connect ((gpointer) lock_valuechange_togglebutton, "toggled",
1394 G_CALLBACK (on_lock_valuechange_togglebutton_toggled),
1397 g_signal_connect ((gpointer) fit_width_spinbutton, "value_changed",
1398 G_CALLBACK (on_fit_width_spinbutton_value_changed),
1400 g_signal_connect ((gpointer) fit_height_spinbutton, "value_changed",
1401 G_CALLBACK (on_fit_height_spinbutton_value_changed),
1403 g_signal_connect ((gpointer) fit_button, "clicked",
1404 G_CALLBACK (on_fit_button_clicked),
1407 g_signal_connect ((gpointer) axial_button, "clicked",
1408 G_CALLBACK (on_axial_button_clicked),
1411 g_signal_connect ((gpointer) done_button, "clicked",
1412 G_CALLBACK (on_done_button_clicked),
1414 g_signal_connect ((gpointer) apply_button, "clicked",
1415 G_CALLBACK (on_apply_button_clicked),
1417 g_signal_connect ((gpointer) cancel_button, "clicked",
1418 G_CALLBACK (on_cancel_button_clicked),
1422 return SurfaceInspector;
1427 gboolean on_texture_combo_entry_key_press_event (GtkWidget *widget, GdkEventKey *event,
1430 // Have Tab activate selection as well as Return
1431 if (event->keyval == GDK_Tab)
1432 g_signal_emit_by_name ( texture_combo_entry, "activate" );
1437 void on_texture_combo_entry_activate (GtkEntry *entry, gpointer user_data)
1439 texdef_t* tmp_texdef;
1440 texdef_t* tmp_orig_texdef;
1441 texdef_to_face_t* temp_texdef_face_list;
1442 char text[128] = { 0 };
1444 if (!texdef_face_list_empty() && g_bListenChanged)
1446 // activate only on entry change
1447 strcpy( text, gtk_entry_get_text(entry));
1448 if ( strcmp( old_texture_entry, text ))
1450 // Check for spaces in shader name
1451 if (text[0] <= ' ' || strchr(text, ' '))
1452 Sys_FPrintf(SYS_WRN, "WARNING: spaces in shader names are not allowed, ignoring '%s'\n", text);
1455 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1457 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1458 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1459 strcpy( old_texture_entry, text );
1460 tmp_texdef->SetName( text );
1469 static void on_hshift_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1471 texdef_t* tmp_texdef;
1472 texdef_t* tmp_orig_texdef;
1473 texdef_to_face_t* temp_texdef_face_list;
1475 texdef_offset.shift[0] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hshift_offset_spinbutton) );
1477 if (!texdef_face_list_empty() && g_bListenChanged)
1479 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1481 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1482 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1483 if (is_HShift_conflicting)
1484 tmp_texdef->shift[0] = tmp_orig_texdef->shift[0] + texdef_offset.shift[0];
1486 tmp_texdef->shift[0] = texdef_SI_values.shift[0] + texdef_offset.shift[0];
1492 static void on_vshift_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1494 texdef_t* tmp_texdef;
1495 texdef_t* tmp_orig_texdef;
1496 texdef_to_face_t* temp_texdef_face_list;
1498 texdef_offset.shift[1] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vshift_offset_spinbutton) );
1500 if (!texdef_face_list_empty() && g_bListenChanged)
1502 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1504 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1505 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1506 if (is_VShift_conflicting)
1507 tmp_texdef->shift[1] = tmp_orig_texdef->shift[1] + texdef_offset.shift[1];
1509 tmp_texdef->shift[1] = texdef_SI_values.shift[1] + texdef_offset.shift[1];
1516 static void on_hscale_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1518 texdef_t* tmp_texdef;
1519 texdef_t* tmp_orig_texdef;
1520 texdef_to_face_t* temp_texdef_face_list;
1522 texdef_offset.scale[0] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hscale_offset_spinbutton) );
1524 if (!texdef_face_list_empty() && g_bListenChanged)
1526 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1528 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1529 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1530 if (is_HScale_conflicting)
1531 tmp_texdef->scale[0] = tmp_orig_texdef->scale[0] + texdef_offset.scale[0];
1533 tmp_texdef->scale[0] = texdef_SI_values.scale[0] + texdef_offset.scale[0];
1541 static void on_vscale_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1543 texdef_t* tmp_texdef;
1544 texdef_t* tmp_orig_texdef;
1545 texdef_to_face_t* temp_texdef_face_list;
1547 texdef_offset.scale[1] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vscale_offset_spinbutton) );
1549 if (!texdef_face_list_empty() && g_bListenChanged)
1551 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1553 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1554 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1555 if (is_VScale_conflicting)
1556 tmp_texdef->scale[1] = tmp_orig_texdef->scale[1] + texdef_offset.scale[1];
1558 tmp_texdef->scale[1] = texdef_SI_values.scale[1] + texdef_offset.scale[1];
1565 static void on_rotate_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1567 texdef_t* tmp_texdef;
1568 texdef_t* tmp_orig_texdef;
1569 texdef_to_face_t* temp_texdef_face_list;
1571 texdef_offset.rotate = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(rotate_offset_spinbutton) );
1573 if (!texdef_face_list_empty() && g_bListenChanged)
1575 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1577 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1578 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1579 if (is_Rotate_conflicting)
1580 tmp_texdef->rotate = tmp_orig_texdef->rotate + texdef_offset.rotate;
1582 tmp_texdef->rotate = texdef_SI_values.rotate + texdef_offset.rotate;
1591 static void on_match_grid_button_clicked (GtkButton *button, gpointer user_data)
1593 float hscale, vscale;
1595 if( !strcmp(gtk_entry_get_text (GTK_ENTRY (hscale_value_spinbutton)), "") )
1598 hscale = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hscale_value_spinbutton) );
1600 if( !strcmp( gtk_entry_get_text (GTK_ENTRY (vscale_value_spinbutton)), "") )
1603 vscale = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vscale_value_spinbutton) );
1604 DoSnapTToGrid (hscale, vscale);
1608 // Lock out changes to Value
1609 static void on_lock_valuechange_togglebutton_toggled (GtkToggleButton *togglebutton, gpointer user_data)
1613 is_Locked = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lock_valuechange_togglebutton)) != false;
1615 gtk_widget_set_sensitive( GTK_WIDGET( hscale_value_spinbutton ), is_Locked );
1616 gtk_widget_set_sensitive( GTK_WIDGET( vscale_value_spinbutton ), is_Locked );
1617 gtk_widget_set_sensitive( GTK_WIDGET( hshift_value_spinbutton ), is_Locked );
1618 gtk_widget_set_sensitive( GTK_WIDGET( vshift_value_spinbutton ), is_Locked );
1619 gtk_widget_set_sensitive( GTK_WIDGET( rotate_value_spinbutton ), is_Locked );
1624 static void on_hshift_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1626 texdef_t* tmp_texdef;
1627 texdef_t* tmp_orig_texdef;
1628 texdef_to_face_t* temp_texdef_face_list;
1630 texdef_SI_values.shift[0] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hshift_value_spinbutton) );
1632 if (!texdef_face_list_empty() && g_bListenChanged)
1634 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1636 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1637 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1638 tmp_texdef->shift[0] = texdef_SI_values.shift[0] + texdef_offset.shift[0];
1639 is_HShift_conflicting = FALSE;
1645 static void on_vshift_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1647 texdef_t* tmp_texdef;
1648 texdef_t* tmp_orig_texdef;
1649 texdef_to_face_t* temp_texdef_face_list;
1651 texdef_SI_values.shift[1] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vshift_value_spinbutton) );
1653 if (!texdef_face_list_empty() && g_bListenChanged)
1655 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1657 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1658 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1659 tmp_texdef->shift[1] = texdef_SI_values.shift[1] + texdef_offset.shift[1];
1660 is_VShift_conflicting = FALSE;
1666 static void on_hscale_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1668 texdef_t* tmp_texdef;
1669 texdef_t* tmp_orig_texdef;
1670 texdef_to_face_t* temp_texdef_face_list;
1672 texdef_SI_values.scale[0] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hscale_value_spinbutton) );
1674 if (!texdef_face_list_empty() && g_bListenChanged)
1676 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1678 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1679 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1680 tmp_texdef->scale[0] = texdef_SI_values.scale[0] + texdef_offset.scale[0];
1681 is_HScale_conflicting = FALSE;
1687 static void on_vscale_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1689 texdef_t* tmp_texdef;
1690 texdef_t* tmp_orig_texdef;
1691 texdef_to_face_t* temp_texdef_face_list;
1693 texdef_SI_values.scale[1] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vscale_value_spinbutton) );
1695 if (!texdef_face_list_empty() && g_bListenChanged)
1697 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1699 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1700 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1701 tmp_texdef->scale[1] = texdef_SI_values.scale[1] + texdef_offset.scale[1];
1702 is_VScale_conflicting = FALSE;
1708 static void on_rotate_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1710 texdef_t* tmp_texdef;
1711 texdef_t* tmp_orig_texdef;
1712 texdef_to_face_t* temp_texdef_face_list;
1714 texdef_SI_values.rotate = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(rotate_value_spinbutton) );
1716 if (!texdef_face_list_empty() && g_bListenChanged)
1718 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1720 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1721 tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1722 tmp_texdef->rotate = texdef_SI_values.rotate + texdef_offset.rotate;
1723 is_Rotate_conflicting = FALSE;
1731 static void on_hshift_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1734 GtkAdjustment * adjust;
1736 if (!g_bListenChanged)
1739 l_pIncrement = Get_SI_Inc();
1742 Sys_Printf("OnIncrementChanged HShift\n");
1745 val = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hshift_step_spinbutton) ) ;
1746 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( hshift_offset_spinbutton ));
1747 adjust->step_increment = val;
1748 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( hshift_value_spinbutton ));
1749 adjust->step_increment = val;
1750 l_pIncrement->shift[0] = val;
1753 static void on_vshift_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1756 GtkAdjustment * adjust;
1758 if (!g_bListenChanged)
1761 l_pIncrement = Get_SI_Inc();
1764 Sys_Printf("OnIncrementChanged VShift\n");
1767 val = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vshift_step_spinbutton) ) ;
1768 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( vshift_offset_spinbutton ));
1769 adjust->step_increment = val;
1770 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( vshift_value_spinbutton ));
1771 adjust->step_increment = val;
1772 l_pIncrement->shift[1] = val;
1775 static void on_hscale_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1778 GtkAdjustment * adjust;
1780 if (!g_bListenChanged)
1783 l_pIncrement = Get_SI_Inc();
1786 Sys_Printf("OnIncrementChanged HShift\n");
1789 val = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hscale_step_spinbutton) ) ;
1790 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( hscale_offset_spinbutton ));
1791 adjust->step_increment = val;
1792 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( hscale_value_spinbutton ));
1793 adjust->step_increment = val;
1794 l_pIncrement->scale[0] = val;
1797 static void on_vscale_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1800 GtkAdjustment * adjust;
1802 if (!g_bListenChanged)
1805 l_pIncrement = Get_SI_Inc();
1808 Sys_Printf("OnIncrementChanged HShift\n");
1811 val = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vscale_step_spinbutton) ) ;
1812 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( vscale_offset_spinbutton ));
1813 adjust->step_increment = val;
1814 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( vscale_value_spinbutton ));
1815 adjust->step_increment = val;
1816 l_pIncrement->scale[1] = val;
1819 static void on_rotate_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1822 GtkAdjustment * adjust;
1824 if (!g_bListenChanged)
1827 l_pIncrement = Get_SI_Inc();
1830 Sys_Printf("OnIncrementChanged HShift\n");
1833 val = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(rotate_step_spinbutton) ) ;
1834 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( rotate_offset_spinbutton ));
1835 adjust->step_increment = val;
1836 adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( rotate_value_spinbutton ));
1837 adjust->step_increment = val;
1838 l_pIncrement->rotate = val;
1843 static void on_fit_width_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1845 m_nWidth = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(fit_width_spinbutton) );
1848 static void on_fit_height_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1850 m_nHeight = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(fit_height_spinbutton) );
1853 static void on_fit_button_clicked (GtkButton *button, gpointer user_data)
1855 FaceList_FitTexture(get_texdef_face_list(), m_nHeight, m_nWidth);
1856 Sys_UpdateWindows(W_ALL);
1861 static void on_axial_button_clicked (GtkButton *button, gpointer user_data)
1863 texdef_t* tmp_texdef;
1864 // texdef_t* tmp_orig_texdef;
1865 texdef_to_face_t* temp_texdef_face_list;
1867 if (!texdef_face_list_empty() && g_bListenChanged)
1869 for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1871 tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1872 tmp_texdef->shift[0] = 0.0;
1873 tmp_texdef->shift[1] = 0.0;
1874 tmp_texdef->scale[0] = 0.5;
1875 tmp_texdef->scale[1] = 0.5;
1876 tmp_texdef->rotate = 0.0;
1880 SetTexdef_FaceList( get_texdef_face_list(), FALSE, TRUE );
1881 Sys_UpdateWindows(W_ALL);
1886 static void on_done_button_clicked (GtkButton *button, gpointer user_data)
1888 if ( !texdef_face_list_empty() )
1891 Sys_UpdateWindows(W_ALL);
1894 static void on_apply_button_clicked (GtkButton *button, gpointer user_data)
1896 if (!g_bListenChanged)
1898 if ( !texdef_face_list_empty() )
1901 Sys_UpdateWindows(W_CAMERA);
1902 GetTexdefInfo_from_Radiant();
1907 static void on_cancel_button_clicked (GtkButton *button, gpointer user_data)
1909 texturewin = Texturewin ();
1910 texturewin->texdef = g_old_texdef;
1911 // cancel the last do if we own it
1912 if ( (m_nUndoId == Undo_GetUndoId()) && ( m_nUndoId != 0 ))
1915 Sys_Printf("OnCancel calling Undo_Undo\n");
1917 g_bListenUpdate = false;
1919 g_bListenUpdate = true;