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"
36 #include "gtkutil/idledraw.h"
37 #include "gtkutil/entry.h"
38 #include "gtkutil/button.h"
39 #include "gtkutil/nonmodal.h"
42 #include "mainframe.h"
43 #include "patchmanip.h"
46 #include "preferences.h"
47 #include "signal/isignal.h"
50 #include <gdk/gdkkeysyms.h>
52 // the increment we are using for the patch inspector (this is saved in the prefs)
68 pi_globals_t g_pi_globals;
70 class PatchFixedSubdivisions
73 PatchFixedSubdivisions() : m_enabled( false ), m_x( 0 ), m_y( 0 ){
75 PatchFixedSubdivisions( bool enabled, std::size_t x, std::size_t y ) : m_enabled( enabled ), m_x( x ), m_y( y ){
82 void Patch_getFixedSubdivisions( const Patch& patch, PatchFixedSubdivisions& subdivisions ){
83 subdivisions.m_enabled = patch.m_patchDef3;
84 subdivisions.m_x = patch.m_subdivisions_x;
85 subdivisions.m_y = patch.m_subdivisions_y;
88 const std::size_t MAX_PATCH_SUBDIVISIONS = 32;
90 void Patch_setFixedSubdivisions( Patch& patch, const PatchFixedSubdivisions& subdivisions ){
93 patch.m_patchDef3 = subdivisions.m_enabled;
94 patch.m_subdivisions_x = subdivisions.m_x;
95 patch.m_subdivisions_y = subdivisions.m_y;
97 if ( patch.m_subdivisions_x == 0 ) {
98 patch.m_subdivisions_x = 4;
100 else if ( patch.m_subdivisions_x > MAX_PATCH_SUBDIVISIONS ) {
101 patch.m_subdivisions_x = MAX_PATCH_SUBDIVISIONS;
103 if ( patch.m_subdivisions_y == 0 ) {
104 patch.m_subdivisions_y = 4;
106 else if ( patch.m_subdivisions_y > MAX_PATCH_SUBDIVISIONS ) {
107 patch.m_subdivisions_y = MAX_PATCH_SUBDIVISIONS;
111 Patch_textureChanged();
112 patch.controlPointsChanged();
115 class PatchGetFixedSubdivisions
117 PatchFixedSubdivisions& m_subdivisions;
119 PatchGetFixedSubdivisions( PatchFixedSubdivisions& subdivisions ) : m_subdivisions( subdivisions ){
121 void operator()( Patch& patch ){
122 Patch_getFixedSubdivisions( patch, m_subdivisions );
127 void Scene_PatchGetFixedSubdivisions( PatchFixedSubdivisions& subdivisions ){
129 if ( GlobalSelectionSystem().countSelected() != 0 ) {
130 Patch* patch = Node_getPatch( GlobalSelectionSystem().ultimateSelected().path().top() );
132 Patch_getFixedSubdivisions( *patch, subdivisions );
136 Scene_forEachVisibleSelectedPatch( PatchGetFixedSubdivisions( subdivisions ) );
140 class PatchSetFixedSubdivisions
142 const PatchFixedSubdivisions& m_subdivisions;
144 PatchSetFixedSubdivisions( const PatchFixedSubdivisions& subdivisions ) : m_subdivisions( subdivisions ){
146 void operator()( Patch& patch ) const {
147 Patch_setFixedSubdivisions( patch, m_subdivisions );
151 void Scene_PatchSetFixedSubdivisions( const PatchFixedSubdivisions& subdivisions ){
152 UndoableCommand command( "patchSetFixedSubdivisions" );
153 Scene_forEachVisibleSelectedPatch( PatchSetFixedSubdivisions( subdivisions ) );
156 typedef struct _GtkCheckButton GtkCheckButton;
161 ui::CheckButton m_enabled;
162 ui::Entry m_horizontal;
163 ui::Entry m_vertical;
164 Subdivisions() : m_enabled( (GtkCheckButton *) 0 ), m_horizontal( nullptr ), m_vertical( nullptr ){
167 PatchFixedSubdivisions subdivisions;
168 Scene_PatchGetFixedSubdivisions( subdivisions );
170 toggle_button_set_active_no_signal( m_enabled, subdivisions.m_enabled );
172 if ( subdivisions.m_enabled ) {
173 entry_set_int( m_horizontal, static_cast<int>( subdivisions.m_x ) );
174 entry_set_int( m_vertical, static_cast<int>( subdivisions.m_y ) );
175 gtk_widget_set_sensitive( GTK_WIDGET( m_horizontal ), TRUE );
176 gtk_widget_set_sensitive( GTK_WIDGET( m_vertical ), TRUE );
180 gtk_entry_set_text( m_horizontal, "" );
181 gtk_entry_set_text( m_vertical, "" );
182 gtk_widget_set_sensitive( GTK_WIDGET( m_horizontal ), FALSE );
183 gtk_widget_set_sensitive( GTK_WIDGET( m_vertical ), FALSE );
189 typedef MemberCaller<Subdivisions, &Subdivisions::cancel> CancelCaller;
191 Scene_PatchSetFixedSubdivisions(
192 PatchFixedSubdivisions(
193 gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( m_enabled ) ) != FALSE,
194 static_cast<std::size_t>( entry_get_int( m_horizontal ) ),
195 static_cast<std::size_t>( entry_get_int( m_vertical ) )
199 typedef MemberCaller<Subdivisions, &Subdivisions::apply> ApplyCaller;
200 static void applyGtk( GtkToggleButton* toggle, Subdivisions* self ){
205 class PatchInspector : public Dialog
207 ui::Window BuildDialog();
208 Subdivisions m_subdivisions;
209 NonModalEntry m_horizontalSubdivisionsEntry;
210 NonModalEntry m_verticalSubdivisionsEntry;
213 WindowPositionTracker m_position_tracker;
217 CopiedString m_strName;
230 ui::ComboBoxText m_pRowCombo{nullptr};
231 ui::ComboBoxText m_pColCombo{nullptr};
232 std::size_t m_countRows;
233 std::size_t m_countCols;
235 // turn on/off processing of the "changed" "value_changed" messages
236 // (need to turn off when we are feeding data in)
237 // NOTE: much more simple than blocking signals
238 bool m_bListenChanged;
241 m_horizontalSubdivisionsEntry( Subdivisions::ApplyCaller( m_subdivisions ), Subdivisions::CancelCaller( m_subdivisions ) ),
242 m_verticalSubdivisionsEntry( Subdivisions::ApplyCaller( m_subdivisions ), Subdivisions::CancelCaller( m_subdivisions ) ),
243 m_idleDraw( MemberCaller<PatchInspector, &PatchInspector::GetPatchInfo>( *this ) ){
254 m_bListenChanged = true;
256 m_position_tracker.setPosition( c_default_window_pos );
260 return gtk_widget_get_visible( GetWidget() );
263 // void UpdateInfo();
264 // void SetPatchInfo();
266 void UpdateSpinners( bool bUp, int nID );
267 // read the current patch on map and initialize m_fX m_fY accordingly
268 void UpdateRowColInfo();
269 // sync the dialog our internal data structures
270 // depending on the flag it will read or write
271 // we use m_nCol m_nRow m_fX m_fY m_fZ m_fS m_fT m_strName
272 // (NOTE: this doesn't actually commit stuff to the map or read from it)
277 PatchInspector g_PatchInspector;
279 void PatchInspector_constructWindow( ui::Window main_window ){
280 g_PatchInspector.m_parent = main_window;
281 g_PatchInspector.Create();
283 void PatchInspector_destroyWindow(){
284 g_PatchInspector.Destroy();
287 void PatchInspector_queueDraw(){
288 if ( g_PatchInspector.visible() ) {
289 g_PatchInspector.m_idleDraw.queueDraw();
293 void DoPatchInspector(){
294 g_PatchInspector.GetPatchInfo();
295 if ( !g_PatchInspector.visible() ) {
296 g_PatchInspector.ShowDlg();
300 void PatchInspector_toggleShown(){
301 if ( g_PatchInspector.visible() ) {
302 g_PatchInspector.m_Patch = 0;
303 g_PatchInspector.HideDlg();
311 // =============================================================================
314 // memorize the current state (that is don't try to undo our do before changing something else)
315 static void OnApply( ui::Widget widget, gpointer data ){
316 g_PatchInspector.exportData();
317 if ( g_PatchInspector.m_Patch != 0 ) {
318 UndoableCommand command( "patchSetTexture" );
319 g_PatchInspector.m_Patch->undoSave();
321 if ( !texdef_name_valid( g_PatchInspector.m_strName.c_str() ) ) {
322 globalErrorStream() << "invalid texture name '" << g_PatchInspector.m_strName.c_str() << "'\n";
323 g_PatchInspector.m_strName = texdef_name_default();
325 g_PatchInspector.m_Patch->SetShader( g_PatchInspector.m_strName.c_str() );
327 std::size_t r = g_PatchInspector.m_nRow;
328 std::size_t c = g_PatchInspector.m_nCol;
329 if ( r < g_PatchInspector.m_Patch->getHeight()
330 && c < g_PatchInspector.m_Patch->getWidth() ) {
331 PatchControl& p = g_PatchInspector.m_Patch->ctrlAt( r,c );
332 p.m_vertex[0] = g_PatchInspector.m_fX;
333 p.m_vertex[1] = g_PatchInspector.m_fY;
334 p.m_vertex[2] = g_PatchInspector.m_fZ;
335 p.m_texcoord[0] = g_PatchInspector.m_fS;
336 p.m_texcoord[1] = g_PatchInspector.m_fT;
337 g_PatchInspector.m_Patch->controlPointsChanged();
342 static void OnSelchangeComboColRow( ui::Widget widget, gpointer data ){
343 if ( !g_PatchInspector.m_bListenChanged ) {
346 // retrieve the current m_nRow and m_nCol, other params are not relevant
347 g_PatchInspector.exportData();
348 // read the changed values ourselves
349 g_PatchInspector.UpdateRowColInfo();
350 // now reflect our changes
351 g_PatchInspector.importData();
354 class PatchSetTextureRepeat
358 PatchSetTextureRepeat( float s, float t ) : m_s( s ), m_t( t ){
360 void operator()( Patch& patch ) const {
361 patch.SetTextureRepeat( m_s, m_t );
365 void Scene_PatchTileTexture_Selected( scene::Graph& graph, float s, float t ){
366 Scene_forEachVisibleSelectedPatch( PatchSetTextureRepeat( s, t ) );
370 static void OnBtnPatchdetails( ui::Widget widget, gpointer data ){
374 static void OnBtnPatchfit( ui::Widget widget, gpointer data ){
378 static void OnBtnPatchnatural( ui::Widget widget, gpointer data ){
379 Patch_NaturalTexture();
382 static void OnBtnPatchreset( ui::Widget widget, gpointer data ){
383 Patch_ResetTexture();
386 static void OnBtnPatchFlipX( ui::Widget widget, gpointer data ){
387 Patch_FlipTextureX();
390 static void OnBtnPatchFlipY( ui::Widget widget, gpointer data ){
391 Patch_FlipTextureY();
394 struct PatchRotateTexture
398 PatchRotateTexture( float angle ) : m_angle( angle ){
400 void operator()( Patch& patch ) const {
401 patch.RotateTexture( m_angle );
405 void Scene_PatchRotateTexture_Selected( scene::Graph& graph, float angle ){
406 Scene_forEachVisibleSelectedPatch( PatchRotateTexture( angle ) );
409 class PatchScaleTexture
413 PatchScaleTexture( float s, float t ) : m_s( s ), m_t( t ){
415 void operator()( Patch& patch ) const {
416 patch.ScaleTexture( m_s, m_t );
420 float Patch_convertScale( float scale ){
430 void Scene_PatchScaleTexture_Selected( scene::Graph& graph, float s, float t ){
431 Scene_forEachVisibleSelectedPatch( PatchScaleTexture( Patch_convertScale( s ), Patch_convertScale( t ) ) );
434 class PatchTranslateTexture
438 PatchTranslateTexture( float s, float t )
439 : m_s( s ), m_t( t ){
441 void operator()( Patch& patch ) const {
442 patch.TranslateTexture( m_s, m_t );
446 void Scene_PatchTranslateTexture_Selected( scene::Graph& graph, float s, float t ){
447 Scene_forEachVisibleSelectedPatch( PatchTranslateTexture( s, t ) );
450 static void OnBtnPatchAutoCap( ui::Widget widget, gpointer data ){
451 Patch_AutoCapTexture();
454 static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){
458 td.scale[0] = td.scale[1] = 0;
459 td.shift[0] = td.shift[1] = 0;
461 if ( gtk_adjustment_get_value(adj) == 0 ) {
465 if ( adj == g_object_get_data( G_OBJECT( g_PatchInspector.GetWidget() ), "hshift_adj" ) ) {
466 g_pi_globals.shift[0] = static_cast<float>( atof( gtk_entry_get_text( GTK_ENTRY( data ) ) ) );
468 if ( gtk_adjustment_get_value(adj) > 0 ) {
469 td.shift[0] = g_pi_globals.shift[0];
472 td.shift[0] = -g_pi_globals.shift[0];
475 else if ( adj == g_object_get_data( G_OBJECT( g_PatchInspector.GetWidget() ), "vshift_adj" ) ) {
476 g_pi_globals.shift[1] = static_cast<float>( atof( gtk_entry_get_text( GTK_ENTRY( data ) ) ) );
478 if ( gtk_adjustment_get_value(adj) > 0 ) {
479 td.shift[1] = g_pi_globals.shift[1];
482 td.shift[1] = -g_pi_globals.shift[1];
485 else if ( adj == g_object_get_data( G_OBJECT( g_PatchInspector.GetWidget() ), "hscale_adj" ) ) {
486 g_pi_globals.scale[0] = static_cast<float>( atof( gtk_entry_get_text( GTK_ENTRY( data ) ) ) );
487 if ( g_pi_globals.scale[0] == 0.0f ) {
490 if ( gtk_adjustment_get_value(adj) > 0 ) {
491 td.scale[0] = g_pi_globals.scale[0];
494 td.scale[0] = -g_pi_globals.scale[0];
497 else if ( adj == g_object_get_data( G_OBJECT( g_PatchInspector.GetWidget() ), "vscale_adj" ) ) {
498 g_pi_globals.scale[1] = static_cast<float>( atof( gtk_entry_get_text( GTK_ENTRY( data ) ) ) );
499 if ( g_pi_globals.scale[1] == 0.0f ) {
502 if ( gtk_adjustment_get_value(adj) > 0 ) {
503 td.scale[1] = g_pi_globals.scale[1];
506 td.scale[1] = -g_pi_globals.scale[1];
509 else if ( adj == g_object_get_data( G_OBJECT( g_PatchInspector.GetWidget() ), "rotate_adj" ) ) {
510 g_pi_globals.rotate = static_cast<float>( atof( gtk_entry_get_text( GTK_ENTRY( data ) ) ) );
512 if ( gtk_adjustment_get_value(adj) > 0 ) {
513 td.rotate = g_pi_globals.rotate;
516 td.rotate = -g_pi_globals.rotate;
520 gtk_adjustment_set_value(adj, 0);
522 // will scale shift rotate the patch accordingly
525 if ( td.shift[0] || td.shift[1] ) {
526 UndoableCommand command( "patchTranslateTexture" );
527 Scene_PatchTranslateTexture_Selected( GlobalSceneGraph(), td.shift[0], td.shift[1] );
529 else if ( td.scale[0] || td.scale[1] ) {
530 UndoableCommand command( "patchScaleTexture" );
531 Scene_PatchScaleTexture_Selected( GlobalSceneGraph(), td.scale[0], td.scale[1] );
533 else if ( td.rotate ) {
534 UndoableCommand command( "patchRotateTexture" );
535 Scene_PatchRotateTexture_Selected( GlobalSceneGraph(), td.rotate );
538 // update the point-by-point view
539 OnSelchangeComboColRow( ui::root ,0 );
542 static gint OnDialogKey( ui::Widget widget, GdkEventKey* event, gpointer data ){
543 if ( event->keyval == GDK_Return ) {
544 OnApply( ui::root, 0 );
547 else if ( event->keyval == GDK_Escape ) {
548 g_PatchInspector.GetPatchInfo();
554 // =============================================================================
555 // PatchInspector class
557 ui::Window PatchInspector::BuildDialog(){
558 ui::Window window = ui::Window(create_floating_window( "Patch Properties", m_parent ));
560 m_position_tracker.connect( window );
562 global_accel_connect_window( window );
564 window_connect_focus_in_clear_focus_widget( window );
568 GtkVBox* vbox = ui::VBox( FALSE, 5 );
569 gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 );
570 gtk_widget_show( GTK_WIDGET( vbox ) );
571 gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox ) );
573 GtkHBox* hbox = ui::HBox( FALSE, 5 );
574 gtk_widget_show( GTK_WIDGET( hbox ) );
575 gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox ), TRUE, TRUE, 0 );
577 GtkVBox* vbox2 = ui::VBox( FALSE, 0 );
578 gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 0 );
579 gtk_widget_show( GTK_WIDGET( vbox2 ) );
580 gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox2 ), TRUE, TRUE, 0 );
582 GtkFrame* frame = ui::Frame( "Details" );
583 gtk_widget_show( GTK_WIDGET( frame ) );
584 gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( frame ), TRUE, TRUE, 0 );
586 GtkVBox* vbox3 = ui::VBox( FALSE, 5 );
587 gtk_container_set_border_width( GTK_CONTAINER( vbox3 ), 5 );
588 gtk_widget_show( GTK_WIDGET( vbox3 ) );
589 gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) );
591 GtkTable* table = ui::Table( 2, 2, FALSE );
592 gtk_widget_show( GTK_WIDGET( table ) );
593 gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
594 gtk_table_set_row_spacings( table, 5 );
595 gtk_table_set_col_spacings( table, 5 );
597 GtkLabel* label = GTK_LABEL( ui::Label( "Row:" ) );
598 gtk_widget_show( GTK_WIDGET( label ) );
599 gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1,
600 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
601 (GtkAttachOptions)( 0 ), 0, 0 );
604 GtkLabel* label = GTK_LABEL( ui::Label( "Column:" ) );
605 gtk_widget_show( GTK_WIDGET( label ) );
606 gtk_table_attach( table, GTK_WIDGET( label ), 1, 2, 0, 1,
607 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
608 (GtkAttachOptions)( 0 ), 0, 0 );
611 auto combo = ui::ComboBoxText();
612 g_signal_connect( G_OBJECT( combo ), "changed", G_CALLBACK( OnSelchangeComboColRow ), this );
613 AddDialogData( *GTK_COMBO_BOX(combo), m_nRow );
615 gtk_widget_show( GTK_WIDGET( combo ) );
616 gtk_table_attach( table, GTK_WIDGET( combo ), 0, 1, 1, 2,
617 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
618 (GtkAttachOptions)( 0 ), 0, 0 );
619 gtk_widget_set_size_request( GTK_WIDGET( combo ), 60, -1 );
624 auto combo = ui::ComboBoxText();
625 g_signal_connect( G_OBJECT( combo ), "changed", G_CALLBACK( OnSelchangeComboColRow ), this );
626 AddDialogData( *GTK_COMBO_BOX(combo), m_nCol );
628 gtk_widget_show( GTK_WIDGET( combo ) );
629 gtk_table_attach( table, GTK_WIDGET( combo ), 1, 2, 1, 2,
630 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
631 (GtkAttachOptions)( 0 ), 0, 0 );
632 gtk_widget_set_size_request( GTK_WIDGET( combo ), 60, -1 );
636 GtkTable* table = ui::Table( 5, 2, FALSE );
637 gtk_widget_show( GTK_WIDGET( table ) );
638 gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
639 gtk_table_set_row_spacings( table, 5 );
640 gtk_table_set_col_spacings( table, 5 );
642 GtkLabel* label = GTK_LABEL( ui::Label( "X:" ) );
643 gtk_widget_show( GTK_WIDGET( label ) );
644 gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1,
645 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
646 (GtkAttachOptions)( 0 ), 0, 0 );
649 GtkLabel* label = GTK_LABEL( ui::Label( "Y:" ) );
650 gtk_widget_show( GTK_WIDGET( label ) );
651 gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2,
652 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
653 (GtkAttachOptions)( 0 ), 0, 0 );
656 GtkLabel* label = GTK_LABEL( ui::Label( "Z:" ) );
657 gtk_widget_show( GTK_WIDGET( label ) );
658 gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 2, 3,
659 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
660 (GtkAttachOptions)( 0 ), 0, 0 );
663 GtkLabel* label = GTK_LABEL( ui::Label( "S:" ) );
664 gtk_widget_show( GTK_WIDGET( label ) );
665 gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 3, 4,
666 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
667 (GtkAttachOptions)( 0 ), 0, 0 );
670 GtkLabel* label = GTK_LABEL( ui::Label( "T:" ) );
671 gtk_widget_show( GTK_WIDGET( label ) );
672 gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 4, 5,
673 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
674 (GtkAttachOptions)( 0 ), 0, 0 );
677 GtkEntry* entry = ui::Entry();
678 gtk_widget_show( GTK_WIDGET( entry ) );
679 gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 0, 1,
680 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
681 (GtkAttachOptions)( 0 ), 0, 0 );
682 AddDialogData( *entry, m_fX );
684 g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 );
687 GtkEntry* entry = ui::Entry();
688 gtk_widget_show( GTK_WIDGET( entry ) );
689 gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 1, 2,
690 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
691 (GtkAttachOptions)( 0 ), 0, 0 );
692 AddDialogData( *entry, m_fY );
694 g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 );
697 GtkEntry* entry = ui::Entry();
698 gtk_widget_show( GTK_WIDGET( entry ) );
699 gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 2, 3,
700 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
701 (GtkAttachOptions)( 0 ), 0, 0 );
702 AddDialogData( *entry, m_fZ );
704 g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 );
707 GtkEntry* entry = ui::Entry();
708 gtk_widget_show( GTK_WIDGET( entry ) );
709 gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 3, 4,
710 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
711 (GtkAttachOptions)( 0 ), 0, 0 );
712 AddDialogData( *entry, m_fS );
714 g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 );
717 GtkEntry* entry = ui::Entry();
718 gtk_widget_show( GTK_WIDGET( entry ) );
719 gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 4, 5,
720 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
721 (GtkAttachOptions)( 0 ), 0, 0 );
722 AddDialogData( *entry, m_fT );
724 g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 );
728 if ( g_pGameDescription->mGameType == "doom3" ) {
729 GtkFrame* frame = ui::Frame( "Tesselation" );
730 gtk_widget_show( GTK_WIDGET( frame ) );
731 gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( frame ), TRUE, TRUE, 0 );
733 GtkVBox* vbox3 = ui::VBox( FALSE, 5 );
734 gtk_container_set_border_width( GTK_CONTAINER( vbox3 ), 5 );
735 gtk_widget_show( GTK_WIDGET( vbox3 ) );
736 gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) );
738 GtkTable* table = ui::Table( 3, 2, FALSE );
739 gtk_widget_show( GTK_WIDGET( table ) );
740 gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
741 gtk_table_set_row_spacings( table, 5 );
742 gtk_table_set_col_spacings( table, 5 );
744 GtkLabel* label = GTK_LABEL( ui::Label( "Fixed" ) );
745 gtk_widget_show( GTK_WIDGET( label ) );
746 gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1,
747 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
748 (GtkAttachOptions)( 0 ), 0, 0 );
751 auto check = ui::CheckButton(GTK_CHECK_BUTTON( gtk_check_button_new() ));
752 gtk_widget_show( GTK_WIDGET( check ) );
753 gtk_table_attach( table, GTK_WIDGET( check ), 1, 2, 0, 1,
754 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
755 (GtkAttachOptions)( 0 ), 0, 0 );
756 m_subdivisions.m_enabled = check;
757 guint handler_id = g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( &Subdivisions::applyGtk ), &m_subdivisions );
758 g_object_set_data( G_OBJECT( check ), "handler", gint_to_pointer( handler_id ) );
761 GtkLabel* label = GTK_LABEL( ui::Label( "Horizontal" ) );
762 gtk_widget_show( GTK_WIDGET( label ) );
763 gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2,
764 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
765 (GtkAttachOptions)( 0 ), 0, 0 );
768 auto entry = ui::Entry();
769 gtk_widget_show( GTK_WIDGET( entry ) );
770 gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 1, 2,
771 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
772 (GtkAttachOptions)( 0 ), 0, 0 );
773 m_subdivisions.m_horizontal = entry;
774 m_horizontalSubdivisionsEntry.connect( entry );
777 auto label = GTK_LABEL( ui::Label( "Vertical" ) );
778 gtk_widget_show( GTK_WIDGET( label ) );
779 gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 2, 3,
780 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
781 (GtkAttachOptions)( 0 ), 0, 0 );
784 auto entry = ui::Entry();
785 gtk_widget_show( GTK_WIDGET( entry ) );
786 gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 2, 3,
787 (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
788 (GtkAttachOptions)( 0 ), 0, 0 );
789 m_subdivisions.m_vertical = entry;
790 m_verticalSubdivisionsEntry.connect( entry );
797 GtkFrame* frame = ui::Frame( "Texturing" );
798 gtk_widget_show( GTK_WIDGET( frame ) );
799 gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( frame ), TRUE, TRUE, 0 );
801 GtkVBox* vbox2 = ui::VBox( FALSE, 5 );
802 gtk_widget_show( GTK_WIDGET( vbox2 ) );
803 gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox2 ) );
804 gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 );
806 GtkLabel* label = GTK_LABEL( ui::Label( "Name:" ) );
807 gtk_widget_show( GTK_WIDGET( label ) );
808 gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( label ), TRUE, TRUE, 0 );
809 gtk_label_set_justify( label, GTK_JUSTIFY_LEFT );
810 gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
813 GtkEntry* entry = ui::Entry();
814 // gtk_editable_set_editable (GTK_ENTRY (entry), false);
815 gtk_widget_show( GTK_WIDGET( entry ) );
816 gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( entry ), TRUE, TRUE, 0 );
817 AddDialogData( *entry, m_strName );
819 g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 );
822 GtkTable* table = ui::Table( 5, 4, FALSE );
823 gtk_widget_show( GTK_WIDGET( table ) );
824 gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
825 gtk_table_set_row_spacings( table, 5 );
826 gtk_table_set_col_spacings( table, 5 );
828 GtkLabel* label = GTK_LABEL( ui::Label( "Horizontal Shift Step" ) );
829 gtk_widget_show( GTK_WIDGET( label ) );
830 gtk_table_attach( table, GTK_WIDGET( label ), 2, 4, 0, 1,
831 (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ),
832 (GtkAttachOptions)( 0 ), 0, 0 );
833 gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
836 GtkLabel* label = GTK_LABEL( ui::Label( "Vertical Shift Step" ) );
837 gtk_widget_show( GTK_WIDGET( label ) );
838 gtk_table_attach( table, GTK_WIDGET( label ), 2, 4, 1, 2,
839 (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ),
840 (GtkAttachOptions)( 0 ), 0, 0 );
841 gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
844 GtkLabel* label = GTK_LABEL( ui::Label( "Horizontal Stretch Step" ) );
845 gtk_widget_show( GTK_WIDGET( label ) );
846 gtk_table_attach( table, GTK_WIDGET( label ), 2, 3, 2, 3,
847 (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ),
848 (GtkAttachOptions)( 0 ), 0, 0 );
849 gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
852 GtkButton* button = ui::Button( "Flip" );
853 gtk_widget_show( GTK_WIDGET( button ) );
854 gtk_table_attach( table, GTK_WIDGET( button ), 3, 4, 2, 3,
855 (GtkAttachOptions)( GTK_FILL ),
856 (GtkAttachOptions)( 0 ), 0, 0 );
857 g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchFlipX ), 0 );
858 gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 );
861 GtkLabel* label = GTK_LABEL( ui::Label( "Vertical Stretch Step" ) );
862 gtk_widget_show( GTK_WIDGET( label ) );
863 gtk_table_attach( table, GTK_WIDGET( label ), 2, 3, 3, 4,
864 (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ),
865 (GtkAttachOptions)( 0 ), 0, 0 );
866 gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
869 GtkButton* button = ui::Button( "Flip" );
870 gtk_widget_show( GTK_WIDGET( button ) );
871 gtk_table_attach( table, GTK_WIDGET( button ), 3, 4, 3, 4,
872 (GtkAttachOptions)( GTK_FILL ),
873 (GtkAttachOptions)( 0 ), 0, 0 );
874 g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchFlipY ), 0 );
875 gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 );
878 GtkLabel* label = GTK_LABEL( ui::Label( "Rotate Step" ) );
879 gtk_widget_show( GTK_WIDGET( label ) );
880 gtk_table_attach( table, GTK_WIDGET( label ), 2, 4, 4, 5,
881 (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ),
882 (GtkAttachOptions)( 0 ), 0, 0 );
883 gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
886 auto entry = ui::Entry();
887 gtk_widget_show( GTK_WIDGET( entry ) );
888 gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 0, 1,
889 (GtkAttachOptions)( GTK_FILL ),
890 (GtkAttachOptions)( 0 ), 0, 0 );
891 gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 );
892 g_object_set_data( G_OBJECT( window ), "hshift_entry", entry );
893 // we fill in this data, if no patch is selected the widgets are unmodified when the inspector is raised
894 // so we need to have at least one initialisation somewhere
895 entry_set_float( entry, g_pi_globals.shift[0] );
897 auto adj = ui::Adjustment( 0, -8192, 8192, 1, 1, 0 );
898 g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), (gpointer) entry );
899 g_object_set_data( G_OBJECT( window ), "hshift_adj", (gpointer) adj );
901 auto spin = ui::SpinButton( adj, 1, 0 );
902 gtk_widget_show( GTK_WIDGET( spin ) );
903 gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 0, 1,
904 (GtkAttachOptions)( 0 ),
905 (GtkAttachOptions)( 0 ), 0, 0 );
906 gtk_widget_set_size_request( GTK_WIDGET( spin ), 10, -1 );
907 gtk_widget_set_can_focus( spin, false );
910 auto entry = ui::Entry();
911 gtk_widget_show( GTK_WIDGET( entry ) );
912 gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 1, 2,
913 (GtkAttachOptions)( GTK_FILL ),
914 (GtkAttachOptions)( 0 ), 0, 0 );
915 gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 );
916 entry_set_float( entry, g_pi_globals.shift[1] );
918 auto adj = ui::Adjustment( 0, -8192, 8192, 1, 1, 0 );
919 g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry );
920 g_object_set_data( G_OBJECT( window ), "vshift_adj", (gpointer) adj );
922 auto spin = ui::SpinButton( adj, 1, 0 );
923 gtk_widget_show( GTK_WIDGET( spin ) );
924 gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 1, 2,
925 (GtkAttachOptions)( 0 ),
926 (GtkAttachOptions)( 0 ), 0, 0 );
927 gtk_widget_set_size_request( GTK_WIDGET( spin ), 10, -1 );
928 gtk_widget_set_can_focus( spin, false );
931 auto entry = ui::Entry();
932 gtk_widget_show( GTK_WIDGET( entry ) );
933 gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 2, 3,
934 (GtkAttachOptions)( GTK_FILL ),
935 (GtkAttachOptions)( 0 ), 0, 0 );
936 gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 );
937 entry_set_float( entry, g_pi_globals.scale[0] );
939 auto adj = ui::Adjustment( 0, -1000, 1000, 1, 1, 0 );
940 g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry );
941 g_object_set_data( G_OBJECT( window ), "hscale_adj", (gpointer) adj );
943 auto spin = ui::SpinButton( adj, 1, 0 );
944 gtk_widget_show( GTK_WIDGET( spin ) );
945 gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 2, 3,
946 (GtkAttachOptions)( 0 ),
947 (GtkAttachOptions)( 0 ), 0, 0 );
948 gtk_widget_set_size_request( GTK_WIDGET( spin ), 10, -1 );
949 gtk_widget_set_can_focus( spin, false );
952 auto entry = ui::Entry();
953 gtk_widget_show( GTK_WIDGET( entry ) );
954 gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 3, 4,
955 (GtkAttachOptions)( GTK_FILL ),
956 (GtkAttachOptions)( 0 ), 0, 0 );
957 gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 );
958 entry_set_float( entry, g_pi_globals.scale[1] );
960 auto adj = ui::Adjustment( 0, -1000, 1000, 1, 1, 0 );
961 g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry );
962 g_object_set_data( G_OBJECT( window ), "vscale_adj", (gpointer) adj );
964 auto spin = ui::SpinButton( adj, 1, 0 );
965 gtk_widget_show( GTK_WIDGET( spin ) );
966 gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 3, 4,
967 (GtkAttachOptions)( 0 ),
968 (GtkAttachOptions)( 0 ), 0, 0 );
969 gtk_widget_set_size_request( GTK_WIDGET( spin ), 10, -1 );
970 gtk_widget_set_can_focus( spin, false );
973 auto entry = ui::Entry();
974 gtk_widget_show( GTK_WIDGET( entry ) );
975 gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 4, 5,
976 (GtkAttachOptions)( GTK_FILL ),
977 (GtkAttachOptions)( 0 ), 0, 0 );
978 gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 );
979 entry_set_float( entry, g_pi_globals.rotate );
981 auto adj = ui::Adjustment( 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
982 g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry );
983 g_object_set_data( G_OBJECT( window ), "rotate_adj", (gpointer) adj );
985 auto spin = ui::SpinButton( adj, 1, 0 );
986 gtk_widget_show( GTK_WIDGET( spin ) );
987 gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 4, 5,
988 (GtkAttachOptions)( 0 ),
989 (GtkAttachOptions)( 0 ), 0, 0 );
990 gtk_widget_set_size_request( GTK_WIDGET( spin ), 10, -1 );
991 gtk_widget_set_can_focus( spin, false );
994 GtkHBox* hbox2 = ui::HBox( TRUE, 5 );
995 gtk_widget_show( GTK_WIDGET( hbox2 ) );
996 gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( hbox2 ), TRUE, FALSE, 0 );
998 GtkButton* button = ui::Button( "Auto Cap" );
999 gtk_widget_show( GTK_WIDGET( button ) );
1000 gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 );
1001 g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchAutoCap ), 0 );
1002 gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 );
1005 GtkButton* button = ui::Button( "CAP" );
1006 gtk_widget_show( GTK_WIDGET( button ) );
1007 gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 );
1008 g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchdetails ), 0 );
1009 gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 );
1012 GtkButton* button = ui::Button( "Set..." );
1013 gtk_widget_show( GTK_WIDGET( button ) );
1014 gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 );
1015 g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchreset ), 0 );
1016 gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 );
1019 GtkButton* button = ui::Button( "Natural" );
1020 gtk_widget_show( GTK_WIDGET( button ) );
1021 gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 );
1022 g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchnatural ), 0 );
1023 gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 );
1026 GtkButton* button = ui::Button( "Fit" );
1027 gtk_widget_show( GTK_WIDGET( button ) );
1028 gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 );
1029 g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchfit ), 0 );
1030 gtk_widget_set_size_request( GTK_WIDGET( button ), 60, -1 );
1040 // sync the dialog our internal data structures
1041 void PatchInspector::exportData(){
1042 m_bListenChanged = false;
1043 Dialog::exportData();
1044 m_bListenChanged = true;
1046 void PatchInspector::importData(){
1047 m_bListenChanged = false;
1048 Dialog::importData();
1049 m_bListenChanged = true;
1052 // read the map and feed in the stuff to the dialog box
1053 void PatchInspector::GetPatchInfo(){
1054 if ( g_pGameDescription->mGameType == "doom3" ) {
1055 m_subdivisions.update();
1058 if ( GlobalSelectionSystem().countSelected() == 0 ) {
1063 m_Patch = Node_getPatch( GlobalSelectionSystem().ultimateSelected().path().top() );
1066 if ( m_Patch != 0 ) {
1067 m_strName = m_Patch->GetShader();
1069 // fill in the numbers for Row / Col selection
1070 m_bListenChanged = false;
1073 gtk_combo_box_set_active( m_pRowCombo, 0 );
1075 for ( std::size_t i = 0; i < m_countRows; ++i )
1077 gtk_combo_box_text_remove( m_pRowCombo, gint( m_countRows - i - 1 ) );
1080 m_countRows = m_Patch->getHeight();
1081 for ( std::size_t i = 0; i < m_countRows; ++i )
1084 sprintf( buffer, "%u", Unsigned( i ) );
1085 gtk_combo_box_text_append_text( m_pRowCombo, buffer );
1088 gtk_combo_box_set_active( m_pRowCombo, 0 );
1092 gtk_combo_box_set_active( m_pColCombo, 0 );
1094 for ( std::size_t i = 0; i < m_countCols; ++i )
1096 gtk_combo_box_text_remove( m_pColCombo, gint( m_countCols - i - 1 ) );
1099 m_countCols = m_Patch->getWidth();
1100 for ( std::size_t i = 0; i < m_countCols; ++i )
1103 sprintf( buffer, "%u", Unsigned( i ) );
1104 gtk_combo_box_text_append_text( m_pColCombo, buffer );
1107 gtk_combo_box_set_active( m_pColCombo, 0 );
1110 m_bListenChanged = true;
1115 //globalOutputStream() << "WARNING: no patch\n";
1117 // fill in our internal structs
1118 m_nRow = 0; m_nCol = 0;
1120 // now update the dialog box
1124 // read the current patch on map and initialize m_fX m_fY accordingly
1125 // NOTE: don't call UpdateData in there, it's not meant for
1126 void PatchInspector::UpdateRowColInfo(){
1127 m_fX = m_fY = m_fZ = m_fS = m_fT = 0.0;
1129 if ( m_Patch != 0 ) {
1130 // we rely on whatever active row/column has been set before we get called
1131 std::size_t r = m_nRow;
1132 std::size_t c = m_nCol;
1133 if ( r < m_Patch->getHeight()
1134 && c < m_Patch->getWidth() ) {
1135 const PatchControl& p = m_Patch->ctrlAt( r,c );
1136 m_fX = p.m_vertex[0];
1137 m_fY = p.m_vertex[1];
1138 m_fZ = p.m_vertex[2];
1139 m_fS = p.m_texcoord[0];
1140 m_fT = p.m_texcoord[1];
1146 void PatchInspector_SelectionChanged( const Selectable& selectable ){
1147 PatchInspector_queueDraw();
1151 #include "preferencesystem.h"
1154 void PatchInspector_Construct(){
1155 GlobalCommands_insert( "PatchInspector", FreeCaller<PatchInspector_toggleShown>(), Accelerator( 'S', (GdkModifierType)GDK_SHIFT_MASK ) );
1157 GlobalPreferenceSystem().registerPreference( "PatchWnd", WindowPositionTrackerImportStringCaller( g_PatchInspector.m_position_tracker ), WindowPositionTrackerExportStringCaller( g_PatchInspector.m_position_tracker ) );
1158 GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Scale1", FloatImportStringCaller( g_pi_globals.scale[0] ), FloatExportStringCaller( g_pi_globals.scale[0] ) );
1159 GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Scale2", FloatImportStringCaller( g_pi_globals.scale[1] ), FloatExportStringCaller( g_pi_globals.scale[1] ) );
1160 GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Shift1", FloatImportStringCaller( g_pi_globals.shift[0] ), FloatExportStringCaller( g_pi_globals.shift[0] ) );
1161 GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Shift2", FloatImportStringCaller( g_pi_globals.shift[1] ), FloatExportStringCaller( g_pi_globals.shift[1] ) );
1162 GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Rotate", FloatImportStringCaller( g_pi_globals.rotate ), FloatExportStringCaller( g_pi_globals.rotate ) );
1164 typedef FreeCaller1<const Selectable&, PatchInspector_SelectionChanged> PatchInspectorSelectionChangedCaller;
1165 GlobalSelectionSystem().addSelectionChangeCallback( PatchInspectorSelectionChangedCaller() );
1166 typedef FreeCaller<PatchInspector_queueDraw> PatchInspectorQueueDrawCaller;
1167 Patch_addTextureChangedCallback( PatchInspectorQueueDrawCaller() );
1169 void PatchInspector_Destroy(){