2 Copyright (C) 1999-2006 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
25 // Leonardo Zide (leo@lokigames.com)
28 #include "patchdialog.h"
32 #include "debugging/debugging.h"
34 #include <gtk/gtkvbox.h>
35 #include <gtk/gtkhbox.h>
36 #include <gtk/gtkframe.h>
37 #include <gtk/gtklabel.h>
38 #include <gtk/gtktable.h>
39 #include <gtk/gtkcombobox.h>
40 #include <gtk/gtkbutton.h>
41 #include <gtk/gtkspinbutton.h>
42 #include <gtk/gtkcheckbutton.h>
44 #include "gtkutil/idledraw.h"
45 #include "gtkutil/entry.h"
46 #include "gtkutil/button.h"
47 #include "gtkutil/nonmodal.h"
50 #include "mainframe.h"
51 #include "patchmanip.h"
54 #include "preferences.h"
55 #include "signal/isignal.h"
58 #include <gdk/gdkkeysyms.h>
60 // the increment we are using for the patch inspector (this is saved in the prefs)
76 pi_globals_t g_pi_globals;
78 class PatchFixedSubdivisions
81 PatchFixedSubdivisions() : m_enabled( false ), m_x( 0 ), m_y( 0 ){
83 PatchFixedSubdivisions( bool enabled, std::size_t x, std::size_t y ) : m_enabled( enabled ), m_x( x ), m_y( y ){
90 void Patch_getFixedSubdivisions( const Patch& patch, PatchFixedSubdivisions& subdivisions ){
91 subdivisions.m_enabled = patch.m_patchDef3;
92 subdivisions.m_x = patch.m_subdivisions_x;
93 subdivisions.m_y = patch.m_subdivisions_y;
96 const std::size_t MAX_PATCH_SUBDIVISIONS = 32;
98 void Patch_setFixedSubdivisions( Patch& patch, const PatchFixedSubdivisions& subdivisions ){
101 patch.m_patchDef3 = subdivisions.m_enabled;
102 patch.m_subdivisions_x = subdivisions.m_x;
103 patch.m_subdivisions_y = subdivisions.m_y;
105 if ( patch.m_subdivisions_x == 0 ) {
106 patch.m_subdivisions_x = 4;
108 else if ( patch.m_subdivisions_x > MAX_PATCH_SUBDIVISIONS ) {
109 patch.m_subdivisions_x = MAX_PATCH_SUBDIVISIONS;
111 if ( patch.m_subdivisions_y == 0 ) {
112 patch.m_subdivisions_y = 4;
114 else if ( patch.m_subdivisions_y > MAX_PATCH_SUBDIVISIONS ) {
115 patch.m_subdivisions_y = MAX_PATCH_SUBDIVISIONS;
119 Patch_textureChanged();
120 patch.controlPointsChanged();
123 class PatchGetFixedSubdivisions
125 PatchFixedSubdivisions& m_subdivisions;
127 PatchGetFixedSubdivisions( PatchFixedSubdivisions& subdivisions ) : m_subdivisions( subdivisions ){
129 void operator()( Patch& patch ){
130 Patch_getFixedSubdivisions( patch, m_subdivisions );
135 void Scene_PatchGetFixedSubdivisions( PatchFixedSubdivisions& subdivisions ){
137 if ( GlobalSelectionSystem().countSelected() != 0 ) {
138 Patch* patch = Node_getPatch( GlobalSelectionSystem().ultimateSelected().path().top() );
140 Patch_getFixedSubdivisions( *patch, subdivisions );
144 Scene_forEachVisibleSelectedPatch( PatchGetFixedSubdivisions( subdivisions ) );
148 class PatchSetFixedSubdivisions
150 const PatchFixedSubdivisions& m_subdivisions;
152 PatchSetFixedSubdivisions( const PatchFixedSubdivisions& subdivisions ) : m_subdivisions( subdivisions ){
154 void operator()( Patch& patch ) const {
155 Patch_setFixedSubdivisions( patch, m_subdivisions );
159 void Scene_PatchSetFixedSubdivisions( const PatchFixedSubdivisions& subdivisions ){
160 UndoableCommand command( "patchSetFixedSubdivisions" );
161 Scene_forEachVisibleSelectedPatch( PatchSetFixedSubdivisions( subdivisions ) );
164 typedef struct _GtkCheckButton GtkCheckButton;
169 GtkCheckButton* m_enabled;
170 GtkEntry* m_horizontal;
171 GtkEntry* m_vertical;
172 Subdivisions() : m_enabled( 0 ), m_horizontal( 0 ), m_vertical( 0 ){
175 PatchFixedSubdivisions subdivisions;
176 Scene_PatchGetFixedSubdivisions( subdivisions );
178 toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( m_enabled ), subdivisions.m_enabled );
180 if ( subdivisions.m_enabled ) {
181 entry_set_int( m_horizontal, static_cast<int>( subdivisions.m_x ) );
182 entry_set_int( m_vertical, static_cast<int>( subdivisions.m_y ) );
183 gtk_widget_set_sensitive( GTK_WIDGET( m_horizontal ), TRUE );
184 gtk_widget_set_sensitive( GTK_WIDGET( m_vertical ), TRUE );
188 gtk_entry_set_text( m_horizontal, "" );
189 gtk_entry_set_text( m_vertical, "" );
190 gtk_widget_set_sensitive( GTK_WIDGET( m_horizontal ), FALSE );
191 gtk_widget_set_sensitive( GTK_WIDGET( m_vertical ), FALSE );
197 typedef MemberCaller<Subdivisions, &Subdivisions::cancel> CancelCaller;
199 Scene_PatchSetFixedSubdivisions(
200 PatchFixedSubdivisions(
201 gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( m_enabled ) ) != FALSE,
202 static_cast<std::size_t>( entry_get_int( m_horizontal ) ),
203 static_cast<std::size_t>( entry_get_int( m_vertical ) )
207 typedef MemberCaller<Subdivisions, &Subdivisions::apply> ApplyCaller;
208 static void applyGtk( GtkToggleButton* toggle, Subdivisions* self ){
213 class PatchInspector : public Dialog
215 GtkWindow* BuildDialog();
216 Subdivisions m_subdivisions;
217 NonModalEntry m_horizontalSubdivisionsEntry;
218 NonModalEntry m_verticalSubdivisionsEntry;
221 WindowPositionTracker m_position_tracker;
225 CopiedString m_strName;
238 GtkComboBox *m_pRowCombo;
239 GtkComboBox *m_pColCombo;
240 std::size_t m_countRows;
241 std::size_t m_countCols;
243 // turn on/off processing of the "changed" "value_changed" messages
244 // (need to turn off when we are feeding data in)
245 // NOTE: much more simple than blocking signals
246 bool m_bListenChanged;
249 m_horizontalSubdivisionsEntry( Subdivisions::ApplyCaller( m_subdivisions ), Subdivisions::CancelCaller( m_subdivisions ) ),
250 m_verticalSubdivisionsEntry( Subdivisions::ApplyCaller( m_subdivisions ), Subdivisions::CancelCaller( m_subdivisions ) ),
251 m_idleDraw( MemberCaller<PatchInspector, &PatchInspector::GetPatchInfo>( *this ) ){
262 m_bListenChanged = true;
264 m_position_tracker.setPosition( c_default_window_pos );
268 return GTK_WIDGET_VISIBLE( GetWidget() );
271 // void UpdateInfo();
272 // void SetPatchInfo();
274 void UpdateSpinners( bool bUp, int nID );
275 // read the current patch on map and initialize m_fX m_fY accordingly
276 void UpdateRowColInfo();
277 // sync the dialog our internal data structures
278 // depending on the flag it will read or write
279 // we use m_nCol m_nRow m_fX m_fY m_fZ m_fS m_fT m_strName
280 // (NOTE: this doesn't actually commit stuff to the map or read from it)
285 PatchInspector g_PatchInspector;
287 void PatchInspector_constructWindow( GtkWindow* main_window ){
288 g_PatchInspector.m_parent = main_window;
289 g_PatchInspector.Create();
291 void PatchInspector_destroyWindow(){
292 g_PatchInspector.Destroy();
295 void PatchInspector_queueDraw(){
296 if ( g_PatchInspector.visible() ) {
297 g_PatchInspector.m_idleDraw.queueDraw();
301 void DoPatchInspector(){
302 g_PatchInspector.GetPatchInfo();
303 if ( !g_PatchInspector.visible() ) {
304 g_PatchInspector.ShowDlg();
308 void PatchInspector_toggleShown(){
309 if ( g_PatchInspector.visible() ) {
310 g_PatchInspector.m_Patch = 0;
311 g_PatchInspector.HideDlg();
319 // =============================================================================
322 // memorize the current state (that is don't try to undo our do before changing something else)
323 static void OnApply( GtkWidget *widget, gpointer data ){
324 g_PatchInspector.exportData();
325 if ( g_PatchInspector.m_Patch != 0 ) {
326 UndoableCommand command( "patchSetTexture" );
327 g_PatchInspector.m_Patch->undoSave();
329 if ( !texdef_name_valid( g_PatchInspector.m_strName.c_str() ) ) {
330 globalErrorStream() << "invalid texture name '" << g_PatchInspector.m_strName.c_str() << "'\n";
331 g_PatchInspector.m_strName = texdef_name_default();
333 g_PatchInspector.m_Patch->SetShader( g_PatchInspector.m_strName.c_str() );
335 std::size_t r = g_PatchInspector.m_nRow;
336 std::size_t c = g_PatchInspector.m_nCol;
337 if ( r < g_PatchInspector.m_Patch->getHeight()
338 && c < g_PatchInspector.m_Patch->getWidth() ) {
339 PatchControl& p = g_PatchInspector.m_Patch->ctrlAt( r,c );
340 p.m_vertex[0] = g_PatchInspector.m_fX;
341 p.m_vertex[1] = g_PatchInspector.m_fY;
342 p.m_vertex[2] = g_PatchInspector.m_fZ;
343 p.m_texcoord[0] = g_PatchInspector.m_fS;
344 p.m_texcoord[1] = g_PatchInspector.m_fT;
345 g_PatchInspector.m_Patch->controlPointsChanged();
350 static void OnSelchangeComboColRow( GtkWidget *widget, gpointer data ){
351 if ( !g_PatchInspector.m_bListenChanged ) {
354 // retrieve the current m_nRow and m_nCol, other params are not relevant
355 g_PatchInspector.exportData();
356 // read the changed values ourselves
357 g_PatchInspector.UpdateRowColInfo();
358 // now reflect our changes
359 g_PatchInspector.importData();
362 class PatchSetTextureRepeat
366 PatchSetTextureRepeat( float s, float t ) : m_s( s ), m_t( t ){
368 void operator()( Patch& patch ) const {
369 patch.SetTextureRepeat( m_s, m_t );
373 void Scene_PatchTileTexture_Selected( scene::Graph& graph, float s, float t ){
374 Scene_forEachVisibleSelectedPatch( PatchSetTextureRepeat( s, t ) );
378 static void OnBtnPatchdetails( GtkWidget *widget, gpointer data ){
382 static void OnBtnPatchfit( GtkWidget *widget, gpointer data ){
386 static void OnBtnPatchnatural( GtkWidget *widget, gpointer data ){
387 Patch_NaturalTexture();
390 static void OnBtnPatchreset( GtkWidget *widget, gpointer data ){
391 Patch_ResetTexture();
394 static void OnBtnPatchFlipX( GtkWidget *widget, gpointer data ){
395 Patch_FlipTextureX();
398 static void OnBtnPatchFlipY( GtkWidget *widget, gpointer data ){
399 Patch_FlipTextureY();
402 struct PatchRotateTexture
406 PatchRotateTexture( float angle ) : m_angle( angle ){
408 void operator()( Patch& patch ) const {
409 patch.RotateTexture( m_angle );
413 void Scene_PatchRotateTexture_Selected( scene::Graph& graph, float angle ){
414 Scene_forEachVisibleSelectedPatch( PatchRotateTexture( angle ) );
417 class PatchScaleTexture
421 PatchScaleTexture( float s, float t ) : m_s( s ), m_t( t ){
423 void operator()( Patch& patch ) const {
424 patch.ScaleTexture( m_s, m_t );
428 float Patch_convertScale( float scale ){
438 void Scene_PatchScaleTexture_Selected( scene::Graph& graph, float s, float t ){
439 Scene_forEachVisibleSelectedPatch( PatchScaleTexture( Patch_convertScale( s ), Patch_convertScale( t ) ) );
442 class PatchTranslateTexture
446 PatchTranslateTexture( float s, float t )
447 : m_s( s ), m_t( t ){
449 void operator()( Patch& patch ) const {
450 patch.TranslateTexture( m_s, m_t );
454 void Scene_PatchTranslateTexture_Selected( scene::Graph& graph, float s, float t ){
455 Scene_forEachVisibleSelectedPatch( PatchTranslateTexture( s, t ) );
458 static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){
462 td.scale[0] = td.scale[1] = 0;
463 td.shift[0] = td.shift[1] = 0;
465 if ( adj->value == 0 ) {
469 if ( adj == g_object_get_data( G_OBJECT( g_PatchInspector.GetWidget() ), "hshift_adj" ) ) {
470 g_pi_globals.shift[0] = static_cast<float>( atof( gtk_entry_get_text( GTK_ENTRY( data ) ) ) );
472 if ( adj->value > 0 ) {
473 td.shift[0] = g_pi_globals.shift[0];
476 td.shift[0] = -g_pi_globals.shift[0];
479 else if ( adj == g_object_get_data( G_OBJECT( g_PatchInspector.GetWidget() ), "vshift_adj" ) ) {
480 g_pi_globals.shift[1] = static_cast<float>( atof( gtk_entry_get_text( GTK_ENTRY( data ) ) ) );
482 if ( adj->value > 0 ) {
483 td.shift[1] = g_pi_globals.shift[1];
486 td.shift[1] = -g_pi_globals.shift[1];
489 else if ( adj == g_object_get_data( G_OBJECT( g_PatchInspector.GetWidget() ), "hscale_adj" ) ) {
490 g_pi_globals.scale[0] = static_cast<float>( atof( gtk_entry_get_text( GTK_ENTRY( data ) ) ) );
491 if ( g_pi_globals.scale[0] == 0.0f ) {
494 if ( adj->value > 0 ) {
495 td.scale[0] = g_pi_globals.scale[0];
498 td.scale[0] = -g_pi_globals.scale[0];
501 else if ( adj == g_object_get_data( G_OBJECT( g_PatchInspector.GetWidget() ), "vscale_adj" ) ) {
502 g_pi_globals.scale[1] = static_cast<float>( atof( gtk_entry_get_text( GTK_ENTRY( data ) ) ) );
503 if ( g_pi_globals.scale[1] == 0.0f ) {
506 if ( adj->value > 0 ) {
507 td.scale[1] = g_pi_globals.scale[1];
510 td.scale[1] = -g_pi_globals.scale[1];
513 else if ( adj == g_object_get_data( G_OBJECT( g_PatchInspector.GetWidget() ), "rotate_adj" ) ) {
514 g_pi_globals.rotate = static_cast<float>( atof( gtk_entry_get_text( GTK_ENTRY( data ) ) ) );
516 if ( adj->value > 0 ) {
517 td.rotate = g_pi_globals.rotate;
520 td.rotate = -g_pi_globals.rotate;
526 // will scale shift rotate the patch accordingly
529 if ( td.shift[0] || td.shift[1] ) {
530 UndoableCommand command( "patchTranslateTexture" );
531 Scene_PatchTranslateTexture_Selected( GlobalSceneGraph(), td.shift[0], td.shift[1] );
533 else if ( td.scale[0] || td.scale[1] ) {
534 UndoableCommand command( "patchScaleTexture" );
535 Scene_PatchScaleTexture_Selected( GlobalSceneGraph(), td.scale[0], td.scale[1] );
537 else if ( td.rotate ) {
538 UndoableCommand command( "patchRotateTexture" );
539 Scene_PatchRotateTexture_Selected( GlobalSceneGraph(), td.rotate );
542 // update the point-by-point view
543 OnSelchangeComboColRow( 0,0 );
546 static gint OnDialogKey( GtkWidget* widget, GdkEventKey* event, gpointer data ){
547 if ( event->keyval == GDK_Return ) {
551 else if ( event->keyval == GDK_Escape ) {
552 g_PatchInspector.GetPatchInfo();
558 // =============================================================================
559 // PatchInspector class
561 GtkWindow* PatchInspector::BuildDialog(){
562 GtkWindow* window = create_floating_window( "Patch Properties", m_parent );
564 m_position_tracker.connect( window );
566 global_accel_connect_window( window );
568 window_connect_focus_in_clear_focus_widget( window );
572 GtkVBox* vbox = GTK_VBOX( gtk_vbox_new( FALSE, 5 ) );
573 gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 );
574 gtk_widget_show( GTK_WIDGET( vbox ) );
575 gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox ) );
577 GtkHBox* hbox = GTK_HBOX( gtk_hbox_new( FALSE, 5 ) );
578 gtk_widget_show( GTK_WIDGET( hbox ) );
579 gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox ), TRUE, TRUE, 0 );
581 GtkVBox* vbox2 = GTK_VBOX( gtk_vbox_new( FALSE, 0 ) );
582 gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 0 );
583 gtk_widget_show( GTK_WIDGET( vbox2 ) );
584 gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox2 ), TRUE, TRUE, 0 );
586 GtkFrame* frame = GTK_FRAME( gtk_frame_new( "Details" ) );
587 gtk_widget_show( GTK_WIDGET( frame ) );
588 gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( frame ), TRUE, TRUE, 0 );
590 GtkVBox* vbox3 = GTK_VBOX( gtk_vbox_new( FALSE, 5 ) );
591 gtk_container_set_border_width( GTK_CONTAINER( vbox3 ), 5 );
592 gtk_widget_show( GTK_WIDGET( vbox3 ) );
593 gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) );
595 GtkTable* table = GTK_TABLE( gtk_table_new( 2, 2, FALSE ) );
596 gtk_widget_show( GTK_WIDGET( table ) );
597 gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
598 gtk_table_set_row_spacings( table, 5 );
599 gtk_table_set_col_spacings( table, 5 );
601 GtkLabel* label = GTK_LABEL( gtk_label_new( "Row:" ) );
602 gtk_widget_show( GTK_WIDGET( label ) );
603 gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1,
604 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
605 (GtkAttachOptions)( 0 ), 0, 0 );
608 GtkLabel* label = GTK_LABEL( gtk_label_new( "Column:" ) );
609 gtk_widget_show( GTK_WIDGET( label ) );
610 gtk_table_attach( table, GTK_WIDGET( label ), 1, 2, 0, 1,
611 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
612 (GtkAttachOptions)( 0 ), 0, 0 );
615 GtkComboBox* combo = GTK_COMBO_BOX( gtk_combo_box_new_text() );
616 g_signal_connect( G_OBJECT( combo ), "changed", G_CALLBACK( OnSelchangeComboColRow ), this );
617 AddDialogData( *combo, m_nRow );
619 gtk_widget_show( GTK_WIDGET( combo ) );
620 gtk_table_attach( table, GTK_WIDGET( combo ), 0, 1, 1, 2,
621 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
622 (GtkAttachOptions)( 0 ), 0, 0 );
623 gtk_widget_set_usize( GTK_WIDGET( combo ), 60, -1 );
628 GtkComboBox* combo = GTK_COMBO_BOX( gtk_combo_box_new_text() );
629 g_signal_connect( G_OBJECT( combo ), "changed", G_CALLBACK( OnSelchangeComboColRow ), this );
630 AddDialogData( *combo, m_nCol );
632 gtk_widget_show( GTK_WIDGET( combo ) );
633 gtk_table_attach( table, GTK_WIDGET( combo ), 1, 2, 1, 2,
634 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
635 (GtkAttachOptions)( 0 ), 0, 0 );
636 gtk_widget_set_usize( GTK_WIDGET( combo ), 60, -1 );
640 GtkTable* table = GTK_TABLE( gtk_table_new( 5, 2, FALSE ) );
641 gtk_widget_show( GTK_WIDGET( table ) );
642 gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
643 gtk_table_set_row_spacings( table, 5 );
644 gtk_table_set_col_spacings( table, 5 );
646 GtkLabel* label = GTK_LABEL( gtk_label_new( "X:" ) );
647 gtk_widget_show( GTK_WIDGET( label ) );
648 gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1,
649 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
650 (GtkAttachOptions)( 0 ), 0, 0 );
653 GtkLabel* label = GTK_LABEL( gtk_label_new( "Y:" ) );
654 gtk_widget_show( GTK_WIDGET( label ) );
655 gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2,
656 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
657 (GtkAttachOptions)( 0 ), 0, 0 );
660 GtkLabel* label = GTK_LABEL( gtk_label_new( "Z:" ) );
661 gtk_widget_show( GTK_WIDGET( label ) );
662 gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 2, 3,
663 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
664 (GtkAttachOptions)( 0 ), 0, 0 );
667 GtkLabel* label = GTK_LABEL( gtk_label_new( "S:" ) );
668 gtk_widget_show( GTK_WIDGET( label ) );
669 gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 3, 4,
670 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
671 (GtkAttachOptions)( 0 ), 0, 0 );
674 GtkLabel* label = GTK_LABEL( gtk_label_new( "T:" ) );
675 gtk_widget_show( GTK_WIDGET( label ) );
676 gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 4, 5,
677 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
678 (GtkAttachOptions)( 0 ), 0, 0 );
681 GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
682 gtk_widget_show( GTK_WIDGET( entry ) );
683 gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 0, 1,
684 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
685 (GtkAttachOptions)( 0 ), 0, 0 );
686 AddDialogData( *entry, m_fX );
688 g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 );
691 GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
692 gtk_widget_show( GTK_WIDGET( entry ) );
693 gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 1, 2,
694 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
695 (GtkAttachOptions)( 0 ), 0, 0 );
696 AddDialogData( *entry, m_fY );
698 g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 );
701 GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
702 gtk_widget_show( GTK_WIDGET( entry ) );
703 gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 2, 3,
704 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
705 (GtkAttachOptions)( 0 ), 0, 0 );
706 AddDialogData( *entry, m_fZ );
708 g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 );
711 GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
712 gtk_widget_show( GTK_WIDGET( entry ) );
713 gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 3, 4,
714 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
715 (GtkAttachOptions)( 0 ), 0, 0 );
716 AddDialogData( *entry, m_fS );
718 g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 );
721 GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
722 gtk_widget_show( GTK_WIDGET( entry ) );
723 gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 4, 5,
724 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
725 (GtkAttachOptions)( 0 ), 0, 0 );
726 AddDialogData( *entry, m_fT );
728 g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 );
732 if ( g_pGameDescription->mGameType == "doom3" ) {
733 GtkFrame* frame = GTK_FRAME( gtk_frame_new( "Tesselation" ) );
734 gtk_widget_show( GTK_WIDGET( frame ) );
735 gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( frame ), TRUE, TRUE, 0 );
737 GtkVBox* vbox3 = GTK_VBOX( gtk_vbox_new( FALSE, 5 ) );
738 gtk_container_set_border_width( GTK_CONTAINER( vbox3 ), 5 );
739 gtk_widget_show( GTK_WIDGET( vbox3 ) );
740 gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) );
742 GtkTable* table = GTK_TABLE( gtk_table_new( 3, 2, FALSE ) );
743 gtk_widget_show( GTK_WIDGET( table ) );
744 gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
745 gtk_table_set_row_spacings( table, 5 );
746 gtk_table_set_col_spacings( table, 5 );
748 GtkLabel* label = GTK_LABEL( gtk_label_new( "Fixed" ) );
749 gtk_widget_show( GTK_WIDGET( label ) );
750 gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1,
751 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
752 (GtkAttachOptions)( 0 ), 0, 0 );
755 GtkCheckButton* check = GTK_CHECK_BUTTON( gtk_check_button_new() );
756 gtk_widget_show( GTK_WIDGET( check ) );
757 gtk_table_attach( table, GTK_WIDGET( check ), 1, 2, 0, 1,
758 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
759 (GtkAttachOptions)( 0 ), 0, 0 );
760 m_subdivisions.m_enabled = check;
761 guint handler_id = g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( &Subdivisions::applyGtk ), &m_subdivisions );
762 g_object_set_data( G_OBJECT( check ), "handler", gint_to_pointer( handler_id ) );
765 GtkLabel* label = GTK_LABEL( gtk_label_new( "Horizontal" ) );
766 gtk_widget_show( GTK_WIDGET( label ) );
767 gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2,
768 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
769 (GtkAttachOptions)( 0 ), 0, 0 );
772 GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
773 gtk_widget_show( GTK_WIDGET( entry ) );
774 gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 1, 2,
775 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
776 (GtkAttachOptions)( 0 ), 0, 0 );
777 m_subdivisions.m_horizontal = entry;
778 m_horizontalSubdivisionsEntry.connect( entry );
781 GtkLabel* label = GTK_LABEL( gtk_label_new( "Vertical" ) );
782 gtk_widget_show( GTK_WIDGET( label ) );
783 gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 2, 3,
784 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
785 (GtkAttachOptions)( 0 ), 0, 0 );
788 GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
789 gtk_widget_show( GTK_WIDGET( entry ) );
790 gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 2, 3,
791 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
792 (GtkAttachOptions)( 0 ), 0, 0 );
793 m_subdivisions.m_vertical = entry;
794 m_verticalSubdivisionsEntry.connect( entry );
801 GtkFrame* frame = GTK_FRAME( gtk_frame_new( "Texturing" ) );
802 gtk_widget_show( GTK_WIDGET( frame ) );
803 gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( frame ), TRUE, TRUE, 0 );
805 GtkVBox* vbox2 = GTK_VBOX( gtk_vbox_new( FALSE, 5 ) );
806 gtk_widget_show( GTK_WIDGET( vbox2 ) );
807 gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox2 ) );
808 gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 );
810 GtkLabel* label = GTK_LABEL( gtk_label_new( "Name:" ) );
811 gtk_widget_show( GTK_WIDGET( label ) );
812 gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( label ), TRUE, TRUE, 0 );
813 gtk_label_set_justify( label, GTK_JUSTIFY_LEFT );
814 gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
817 GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
818 // gtk_entry_set_editable (GTK_ENTRY (entry), false);
819 gtk_widget_show( GTK_WIDGET( entry ) );
820 gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( entry ), TRUE, TRUE, 0 );
821 AddDialogData( *entry, m_strName );
823 g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 );
826 GtkTable* table = GTK_TABLE( gtk_table_new( 5, 4, FALSE ) );
827 gtk_widget_show( GTK_WIDGET( table ) );
828 gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
829 gtk_table_set_row_spacings( table, 5 );
830 gtk_table_set_col_spacings( table, 5 );
832 GtkLabel* label = GTK_LABEL( gtk_label_new( "Horizontal Shift Step" ) );
833 gtk_widget_show( GTK_WIDGET( label ) );
834 gtk_table_attach( table, GTK_WIDGET( label ), 2, 4, 0, 1,
835 (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ),
836 (GtkAttachOptions)( 0 ), 0, 0 );
837 gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
840 GtkLabel* label = GTK_LABEL( gtk_label_new( "Vertical Shift Step" ) );
841 gtk_widget_show( GTK_WIDGET( label ) );
842 gtk_table_attach( table, GTK_WIDGET( label ), 2, 4, 1, 2,
843 (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ),
844 (GtkAttachOptions)( 0 ), 0, 0 );
845 gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
848 GtkLabel* label = GTK_LABEL( gtk_label_new( "Horizontal Stretch Step" ) );
849 gtk_widget_show( GTK_WIDGET( label ) );
850 gtk_table_attach( table, GTK_WIDGET( label ), 2, 3, 2, 3,
851 (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ),
852 (GtkAttachOptions)( 0 ), 0, 0 );
853 gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
856 GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "FlipX" ) );
857 gtk_widget_show( GTK_WIDGET( button ) );
858 gtk_table_attach( table, GTK_WIDGET( button ), 3, 4, 2, 3,
859 (GtkAttachOptions)( GTK_FILL ),
860 (GtkAttachOptions)( 0 ), 0, 0 );
861 g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchFlipX ), 0 );
862 gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 );
865 GtkLabel* label = GTK_LABEL( gtk_label_new( "Vertical Stretch Step" ) );
866 gtk_widget_show( GTK_WIDGET( label ) );
867 gtk_table_attach( table, GTK_WIDGET( label ), 2, 3, 3, 4,
868 (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ),
869 (GtkAttachOptions)( 0 ), 0, 0 );
870 gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
873 GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "FlipY" ) );
874 gtk_widget_show( GTK_WIDGET( button ) );
875 gtk_table_attach( table, GTK_WIDGET( button ), 3, 4, 3, 4,
876 (GtkAttachOptions)( GTK_FILL ),
877 (GtkAttachOptions)( 0 ), 0, 0 );
878 g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchFlipY ), 0 );
879 gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 );
882 GtkLabel* label = GTK_LABEL( gtk_label_new( "Rotate Step" ) );
883 gtk_widget_show( GTK_WIDGET( label ) );
884 gtk_table_attach( table, GTK_WIDGET( label ), 2, 4, 4, 5,
885 (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ),
886 (GtkAttachOptions)( 0 ), 0, 0 );
887 gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
890 GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
891 gtk_widget_show( GTK_WIDGET( entry ) );
892 gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 0, 1,
893 (GtkAttachOptions)( GTK_FILL ),
894 (GtkAttachOptions)( 0 ), 0, 0 );
895 gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 );
896 g_object_set_data( G_OBJECT( window ), "hshift_entry", entry );
897 // we fill in this data, if no patch is selected the widgets are unmodified when the inspector is raised
898 // so we need to have at least one initialisation somewhere
899 entry_set_float( entry, g_pi_globals.shift[0] );
901 GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 1, 1, 0 ) );
902 g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry );
903 g_object_set_data( G_OBJECT( window ), "hshift_adj", adj );
905 GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) );
906 gtk_widget_show( GTK_WIDGET( spin ) );
907 gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 0, 1,
908 (GtkAttachOptions)( 0 ),
909 (GtkAttachOptions)( 0 ), 0, 0 );
910 gtk_widget_set_usize( GTK_WIDGET( spin ), 10, -2 );
911 GTK_WIDGET_UNSET_FLAGS( spin, GTK_CAN_FOCUS );
914 GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
915 gtk_widget_show( GTK_WIDGET( entry ) );
916 gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 1, 2,
917 (GtkAttachOptions)( GTK_FILL ),
918 (GtkAttachOptions)( 0 ), 0, 0 );
919 gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 );
920 entry_set_float( entry, g_pi_globals.shift[1] );
922 GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 1, 1, 0 ) );
923 g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry );
924 g_object_set_data( G_OBJECT( window ), "vshift_adj", adj );
926 GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) );
927 gtk_widget_show( GTK_WIDGET( spin ) );
928 gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 1, 2,
929 (GtkAttachOptions)( 0 ),
930 (GtkAttachOptions)( 0 ), 0, 0 );
931 gtk_widget_set_usize( GTK_WIDGET( spin ), 10, -2 );
932 GTK_WIDGET_UNSET_FLAGS( spin, GTK_CAN_FOCUS );
935 GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
936 gtk_widget_show( GTK_WIDGET( entry ) );
937 gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 2, 3,
938 (GtkAttachOptions)( GTK_FILL ),
939 (GtkAttachOptions)( 0 ), 0, 0 );
940 gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 );
941 entry_set_float( entry, g_pi_globals.scale[0] );
943 GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -1000, 1000, 1, 1, 0 ) );
944 g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry );
945 g_object_set_data( G_OBJECT( window ), "hscale_adj", adj );
947 GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) );
948 gtk_widget_show( GTK_WIDGET( spin ) );
949 gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 2, 3,
950 (GtkAttachOptions)( 0 ),
951 (GtkAttachOptions)( 0 ), 0, 0 );
952 gtk_widget_set_usize( GTK_WIDGET( spin ), 10, -2 );
953 GTK_WIDGET_UNSET_FLAGS( spin, GTK_CAN_FOCUS );
956 GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
957 gtk_widget_show( GTK_WIDGET( entry ) );
958 gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 3, 4,
959 (GtkAttachOptions)( GTK_FILL ),
960 (GtkAttachOptions)( 0 ), 0, 0 );
961 gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 );
962 entry_set_float( entry, g_pi_globals.scale[1] );
964 GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -1000, 1000, 1, 1, 0 ) );
965 g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry );
966 g_object_set_data( G_OBJECT( window ), "vscale_adj", adj );
968 GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) );
969 gtk_widget_show( GTK_WIDGET( spin ) );
970 gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 3, 4,
971 (GtkAttachOptions)( 0 ),
972 (GtkAttachOptions)( 0 ), 0, 0 );
973 gtk_widget_set_usize( GTK_WIDGET( spin ), 10, -2 );
974 GTK_WIDGET_UNSET_FLAGS( spin, GTK_CAN_FOCUS );
977 GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
978 gtk_widget_show( GTK_WIDGET( entry ) );
979 gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 4, 5,
980 (GtkAttachOptions)( GTK_FILL ),
981 (GtkAttachOptions)( 0 ), 0, 0 );
982 gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 );
983 entry_set_float( entry, g_pi_globals.rotate );
985 GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -1000, 1000, 1, 1, 0 ) ); // NOTE: Arnout - this really should be 360 but can't change it anymore as it could break existing maps
986 g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry );
987 g_object_set_data( G_OBJECT( window ), "rotate_adj", adj );
989 GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) );
990 gtk_widget_show( GTK_WIDGET( spin ) );
991 gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 4, 5,
992 (GtkAttachOptions)( 0 ),
993 (GtkAttachOptions)( 0 ), 0, 0 );
994 gtk_widget_set_usize( GTK_WIDGET( spin ), 10, -2 );
995 GTK_WIDGET_UNSET_FLAGS( spin, GTK_CAN_FOCUS );
998 GtkHBox* hbox2 = GTK_HBOX( gtk_hbox_new( TRUE, 5 ) );
999 gtk_widget_show( GTK_WIDGET( hbox2 ) );
1000 gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( hbox2 ), TRUE, FALSE, 0 );
1002 GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "CAP" ) );
1003 gtk_widget_show( GTK_WIDGET( button ) );
1004 gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 );
1005 g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchdetails ), 0 );
1006 gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 );
1009 GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "Set..." ) );
1010 gtk_widget_show( GTK_WIDGET( button ) );
1011 gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 );
1012 g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchreset ), 0 );
1013 gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 );
1016 GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "Natural" ) );
1017 gtk_widget_show( GTK_WIDGET( button ) );
1018 gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 );
1019 g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchnatural ), 0 );
1020 gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 );
1023 GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "Fit" ) );
1024 gtk_widget_show( GTK_WIDGET( button ) );
1025 gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 );
1026 g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchfit ), 0 );
1027 gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 );
1037 // sync the dialog our internal data structures
1038 void PatchInspector::exportData(){
1039 m_bListenChanged = false;
1040 Dialog::exportData();
1041 m_bListenChanged = true;
1043 void PatchInspector::importData(){
1044 m_bListenChanged = false;
1045 Dialog::importData();
1046 m_bListenChanged = true;
1049 // read the map and feed in the stuff to the dialog box
1050 void PatchInspector::GetPatchInfo(){
1051 if ( g_pGameDescription->mGameType == "doom3" ) {
1052 m_subdivisions.update();
1055 if ( GlobalSelectionSystem().countSelected() == 0 ) {
1060 m_Patch = Node_getPatch( GlobalSelectionSystem().ultimateSelected().path().top() );
1063 if ( m_Patch != 0 ) {
1064 m_strName = m_Patch->GetShader();
1066 // fill in the numbers for Row / Col selection
1067 m_bListenChanged = false;
1070 gtk_combo_box_set_active( m_pRowCombo, 0 );
1072 for ( std::size_t i = 0; i < m_countRows; ++i )
1074 gtk_combo_box_remove_text( m_pRowCombo, gint( m_countRows - i - 1 ) );
1077 m_countRows = m_Patch->getHeight();
1078 for ( std::size_t i = 0; i < m_countRows; ++i )
1081 sprintf( buffer, "%u", Unsigned( i ) );
1082 gtk_combo_box_append_text( m_pRowCombo, buffer );
1085 gtk_combo_box_set_active( m_pRowCombo, 0 );
1089 gtk_combo_box_set_active( m_pColCombo, 0 );
1091 for ( std::size_t i = 0; i < m_countCols; ++i )
1093 gtk_combo_box_remove_text( m_pColCombo, gint( m_countCols - i - 1 ) );
1096 m_countCols = m_Patch->getWidth();
1097 for ( std::size_t i = 0; i < m_countCols; ++i )
1100 sprintf( buffer, "%u", Unsigned( i ) );
1101 gtk_combo_box_append_text( m_pColCombo, buffer );
1104 gtk_combo_box_set_active( m_pColCombo, 0 );
1107 m_bListenChanged = true;
1112 //globalOutputStream() << "WARNING: no patch\n";
1114 // fill in our internal structs
1115 m_nRow = 0; m_nCol = 0;
1117 // now update the dialog box
1121 // read the current patch on map and initialize m_fX m_fY accordingly
1122 // NOTE: don't call UpdateData in there, it's not meant for
1123 void PatchInspector::UpdateRowColInfo(){
1124 m_fX = m_fY = m_fZ = m_fS = m_fT = 0.0;
1126 if ( m_Patch != 0 ) {
1127 // we rely on whatever active row/column has been set before we get called
1128 std::size_t r = m_nRow;
1129 std::size_t c = m_nCol;
1130 if ( r < m_Patch->getHeight()
1131 && c < m_Patch->getWidth() ) {
1132 const PatchControl& p = m_Patch->ctrlAt( r,c );
1133 m_fX = p.m_vertex[0];
1134 m_fY = p.m_vertex[1];
1135 m_fZ = p.m_vertex[2];
1136 m_fS = p.m_texcoord[0];
1137 m_fT = p.m_texcoord[1];
1143 void PatchInspector_SelectionChanged( const Selectable& selectable ){
1144 PatchInspector_queueDraw();
1148 #include "preferencesystem.h"
1151 void PatchInspector_Construct(){
1152 GlobalCommands_insert( "PatchInspector", FreeCaller<PatchInspector_toggleShown>(), Accelerator( 'S', (GdkModifierType)GDK_SHIFT_MASK ) );
1154 GlobalPreferenceSystem().registerPreference( "PatchWnd", WindowPositionTrackerImportStringCaller( g_PatchInspector.m_position_tracker ), WindowPositionTrackerExportStringCaller( g_PatchInspector.m_position_tracker ) );
1155 GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Scale1", FloatImportStringCaller( g_pi_globals.scale[0] ), FloatExportStringCaller( g_pi_globals.scale[0] ) );
1156 GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Scale2", FloatImportStringCaller( g_pi_globals.scale[1] ), FloatExportStringCaller( g_pi_globals.scale[1] ) );
1157 GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Shift1", FloatImportStringCaller( g_pi_globals.shift[0] ), FloatExportStringCaller( g_pi_globals.shift[0] ) );
1158 GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Shift2", FloatImportStringCaller( g_pi_globals.shift[1] ), FloatExportStringCaller( g_pi_globals.shift[1] ) );
1159 GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Rotate", FloatImportStringCaller( g_pi_globals.rotate ), FloatExportStringCaller( g_pi_globals.rotate ) );
1161 typedef FreeCaller1<const Selectable&, PatchInspector_SelectionChanged> PatchInspectorSelectionChangedCaller;
1162 GlobalSelectionSystem().addSelectionChangeCallback( PatchInspectorSelectionChangedCaller() );
1163 typedef FreeCaller<PatchInspector_queueDraw> PatchInspectorQueueDrawCaller;
1164 Patch_addTextureChangedCallback( PatchInspectorQueueDrawCaller() );
1166 void PatchInspector_Destroy(){