#include "select.h"
+#include <gtk/gtk.h>
+
#include "debugging/debugging.h"
#include "ientity.h"
#include "gtkutil/widget.h"
#include "brushmanip.h"
#include "brush.h"
+#include "patch.h"
#include "patchmanip.h"
#include "patchdialog.h"
#include "selection.h"
class InvertSelectionWalker : public scene::Graph::Walker
{
SelectionSystem::EMode m_mode;
+SelectionSystem::EComponentMode m_compmode;
mutable Selectable* m_selectable;
public:
-InvertSelectionWalker( SelectionSystem::EMode mode )
- : m_mode( mode ), m_selectable( 0 ){
+InvertSelectionWalker( SelectionSystem::EMode mode, SelectionSystem::EComponentMode compmode )
+ : m_mode( mode ), m_compmode( compmode ), m_selectable( 0 ){
}
bool pre( const scene::Path& path, scene::Instance& instance ) const {
if( !path.top().get().visible() ){
m_selectable = path.top().get().visible() ? selectable : 0;
break;
case SelectionSystem::eComponent:
+ BrushInstance* brushinstance = Instance_getBrush( instance );
+ if( brushinstance != 0 ){
+ if( brushinstance->isSelected() )
+ brushinstance->invertComponentSelection( m_compmode );
+ }
+ else{
+ PatchInstance* patchinstance = Instance_getPatch( instance );
+ if( patchinstance != 0 && m_compmode == SelectionSystem::eVertex ){
+ if( patchinstance->isSelected() )
+ patchinstance->invertComponentSelection();
+ }
+ }
break;
}
}
};
void Scene_Invert_Selection( scene::Graph& graph ){
- graph.traverse( InvertSelectionWalker( GlobalSelectionSystem().Mode() ) );
+ graph.traverse( InvertSelectionWalker( GlobalSelectionSystem().Mode(), GlobalSelectionSystem().ComponentMode() ) );
}
void Select_Invert(){
Scene_Invert_Selection( GlobalSceneGraph() );
}
+//interesting printings
+class ExpandSelectionToEntitiesWalker_dbg : public scene::Graph::Walker
+{
+mutable std::size_t m_depth;
+NodeSmartReference worldspawn;
+public:
+ExpandSelectionToEntitiesWalker_dbg() : m_depth( 0 ), worldspawn( Map_FindOrInsertWorldspawn( g_map ) ){
+}
+bool pre( const scene::Path& path, scene::Instance& instance ) const {
+ ++m_depth;
+ globalOutputStream() << "pre depth_" << m_depth;
+ globalOutputStream() << " path.size()_" << path.size();
+ if ( path.top().get() == worldspawn )
+ globalOutputStream() << " worldspawn";
+ if( path.top().get().isRoot() )
+ globalOutputStream() << " path.top().get().isRoot()";
+ Entity* entity = Node_getEntity( path.top() );
+ if ( entity != 0 ){
+ globalOutputStream() << " entity!=0";
+ if( entity->isContainer() ){
+ globalOutputStream() << " entity->isContainer()";
+ }
+ globalOutputStream() << " classname_" << entity->getKeyValue( "classname" );
+ }
+ globalOutputStream() << "\n";
+// globalOutputStream() << "" << ;
+// globalOutputStream() << "" << ;
+// globalOutputStream() << "" << ;
+// globalOutputStream() << "" << ;
+ return true;
+}
+void post( const scene::Path& path, scene::Instance& instance ) const {
+ globalOutputStream() << "post depth_" << m_depth;
+ globalOutputStream() << " path.size()_" << path.size();
+ if ( path.top().get() == worldspawn )
+ globalOutputStream() << " worldspawn";
+ if( path.top().get().isRoot() )
+ globalOutputStream() << " path.top().get().isRoot()";
+ Entity* entity = Node_getEntity( path.top() );
+ if ( entity != 0 ){
+ globalOutputStream() << " entity!=0";
+ if( entity->isContainer() ){
+ globalOutputStream() << " entity->isContainer()";
+ }
+ globalOutputStream() << " classname_" << entity->getKeyValue( "classname" );
+ }
+ globalOutputStream() << "\n";
+ --m_depth;
+}
+};
+
class ExpandSelectionToEntitiesWalker : public scene::Graph::Walker
{
mutable std::size_t m_depth;
++m_depth;
// ignore worldspawn
- NodeSmartReference me( path.top().get() );
- if ( me == worldspawn ) {
- return false;
- }
+// NodeSmartReference me( path.top().get() );
+// if ( me == worldspawn ) {
+// return false;
+// }
if ( m_depth == 2 ) { // entity depth
// traverse and select children if any one is selected
+ bool beselected = false;
if ( instance.childSelected() ) {
- Instance_setSelected( instance, true );
+ beselected = true;
+ if( path.top().get() != worldspawn ){
+ Instance_setSelected( instance, true );
+ }
}
- return Node_getEntity( path.top() )->isContainer() && instance.isSelected();
+ return Node_getEntity( path.top() )->isContainer() && beselected;
}
else if ( m_depth == 3 ) { // primitive depth
Instance_setSelected( instance, true );
Select_GetBounds( g_select_workzone.d_work_min, g_select_workzone.d_work_max );
}
}
-typedef FreeCaller<Selection_UpdateWorkzone> SelectionUpdateWorkzoneCaller;
+typedef FreeCaller<void(), Selection_UpdateWorkzone> SelectionUpdateWorkzoneCaller;
IdleDraw g_idleWorkzone = IdleDraw( SelectionUpdateWorkzoneCaller() );
}
void Select_RotateAxis( int axis, float deg ){
if ( fabs( deg ) == 90.f ) {
- GlobalSelectionSystem().rotateSelected( quaternion_for_axis90( (axis_t)axis, ( deg > 0 ) ? eSignPositive : eSignNegative ) );
+ GlobalSelectionSystem().rotateSelected( quaternion_for_axis90( (axis_t)axis, ( deg > 0 ) ? eSignPositive : eSignNegative ), true );
}
else
{
switch ( axis )
{
case 0:
- GlobalSelectionSystem().rotateSelected( quaternion_for_matrix4_rotation( matrix4_rotation_for_x_degrees( deg ) ) );
+ GlobalSelectionSystem().rotateSelected( quaternion_for_matrix4_rotation( matrix4_rotation_for_x_degrees( deg ) ), false );
break;
case 1:
- GlobalSelectionSystem().rotateSelected( quaternion_for_matrix4_rotation( matrix4_rotation_for_y_degrees( deg ) ) );
+ GlobalSelectionSystem().rotateSelected( quaternion_for_matrix4_rotation( matrix4_rotation_for_y_degrees( deg ) ), false );
break;
case 2:
- GlobalSelectionSystem().rotateSelected( quaternion_for_matrix4_rotation( matrix4_rotation_for_z_degrees( deg ) ) );
+ GlobalSelectionSystem().rotateSelected( quaternion_for_matrix4_rotation( matrix4_rotation_for_z_degrees( deg ) ), false );
break;
}
}
{
const PropertyValues& m_propertyvalues;
const char *m_prop;
+const NodeSmartReference worldspawn;
public:
EntityFindByPropertyValueWalker( const char *prop, const PropertyValues& propertyvalues )
- : m_propertyvalues( propertyvalues ), m_prop( prop ){
+ : m_propertyvalues( propertyvalues ), m_prop( prop ), worldspawn( Map_FindOrInsertWorldspawn( g_map ) ){
}
bool pre( const scene::Path& path, scene::Instance& instance ) const {
if( !path.top().get().visible() ){
return false;
}
+ // ignore worldspawn
+ if ( path.top().get() == worldspawn ) {
+ return false;
+ }
+
Entity* entity = Node_getEntity( path.top() );
- if ( entity != 0
- && propertyvalues_contain( m_propertyvalues, entity->getKeyValue( m_prop ) ) ) {
- Instance_getSelectable( instance )->setSelected( true );
+ if ( entity != 0 ){
+ if( propertyvalues_contain( m_propertyvalues, entity->getKeyValue( m_prop ) ) ) {
+ Instance_getSelectable( instance )->setSelected( true );
+ return true;
+ }
+ return false;
+ }
+ else if( path.size() > 2 && !path.top().get().isRoot() ){
+ Selectable* selectable = Instance_getSelectable( instance );
+ if( selectable != 0 )
+ selectable->setSelected( true );
}
return true;
}
{
PropertyValues& m_propertyvalues;
const char *m_prop;
+const NodeSmartReference worldspawn;
public:
EntityGetSelectedPropertyValuesWalker( const char *prop, PropertyValues& propertyvalues )
- : m_propertyvalues( propertyvalues ), m_prop( prop ){
+ : m_propertyvalues( propertyvalues ), m_prop( prop ), worldspawn( Map_FindOrInsertWorldspawn( g_map ) ){
+}
+bool pre( const scene::Path& path, scene::Instance& instance ) const {
+ Entity* entity = Node_getEntity( path.top() );
+ if ( entity != 0 ){
+ if( path.top().get() != worldspawn ){
+ Selectable* selectable = Instance_getSelectable( instance );
+ if ( ( selectable != 0 && selectable->isSelected() ) || instance.childSelected() ) {
+ if ( !propertyvalues_contain( m_propertyvalues, entity->getKeyValue( m_prop ) ) ) {
+ m_propertyvalues.push_back( entity->getKeyValue( m_prop ) );
+ }
+ }
+ }
+ return false;
+ }
+ return true;
+}
+};
+/*
+class EntityGetSelectedPropertyValuesWalker : public scene::Graph::Walker
+{
+PropertyValues& m_propertyvalues;
+const char *m_prop;
+mutable bool m_selected_children;
+const NodeSmartReference worldspawn;
+public:
+EntityGetSelectedPropertyValuesWalker( const char *prop, PropertyValues& propertyvalues )
+ : m_propertyvalues( propertyvalues ), m_prop( prop ), m_selected_children( false ), worldspawn( Map_FindOrInsertWorldspawn( g_map ) ){
}
bool pre( const scene::Path& path, scene::Instance& instance ) const {
Selectable* selectable = Instance_getSelectable( instance );
if ( !propertyvalues_contain( m_propertyvalues, entity->getKeyValue( m_prop ) ) ) {
m_propertyvalues.push_back( entity->getKeyValue( m_prop ) );
}
+ return false;
+ }
+ else{
+ m_selected_children = true;
}
}
return true;
}
+void post( const scene::Path& path, scene::Instance& instance ) const {
+ Entity* entity = Node_getEntity( path.top() );
+ if( entity != 0 && m_selected_children ){
+ m_selected_children = false;
+ if( path.top().get() == worldspawn )
+ return;
+ if ( !propertyvalues_contain( m_propertyvalues, entity->getKeyValue( m_prop ) ) ) {
+ m_propertyvalues.push_back( entity->getKeyValue( m_prop ) );
+ }
+ }
+}
};
-
+*/
void Scene_EntityGetPropertyValues( scene::Graph& graph, const char *prop, PropertyValues& propertyvalues ){
graph.traverse( EntityGetSelectedPropertyValuesWalker( prop, propertyvalues ) );
}
bool g_nodes_be_hidden = false;
-BoolExportCaller g_hidden_caller( g_nodes_be_hidden );
+ConstReferenceCaller<bool, void(const Callback<void(bool)> &), PropertyImpl<bool>::Export> g_hidden_caller( g_nodes_be_hidden );
+
ToggleItem g_hidden_item( g_hidden_caller );
class HideSelectedWalker : public scene::Graph::Walker
g_hidden_item.update();
}
-void Hide_registerCommands(){
- GlobalCommands_insert( "ShowHidden", FreeCaller<Select_ShowAllHidden>(), Accelerator( 'H', (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalToggles_insert( "HideSelected", FreeCaller<HideSelected>(), ToggleItem::AddCallbackCaller( g_hidden_item ), Accelerator( 'H' ) );
-}
-
-
void Selection_Flipx(){
UndoableCommand undo( "mirrorSelected -axis x" );
UndoableCommand undo( "rotateSelected -axis z -angle -90" );
Select_RotateAxis( 2,-90 );
}
+#include "xywindow.h"
+void Selection_FlipHorizontally(){
+ VIEWTYPE viewtype = GlobalXYWnd_getCurrentViewType();
+ switch ( viewtype )
+ {
+ case XY:
+ case XZ:
+ Selection_Flipx();
+ break;
+ default:
+ Selection_Flipy();
+ break;
+ }
+}
+
+void Selection_FlipVertically(){
+ VIEWTYPE viewtype = GlobalXYWnd_getCurrentViewType();
+ switch ( viewtype )
+ {
+ case XZ:
+ case YZ:
+ Selection_Flipz();
+ break;
+ default:
+ Selection_Flipy();
+ break;
+ }
+}
+
+void Selection_RotateClockwise(){
+ UndoableCommand undo( "rotateSelected Clockwise 90" );
+ VIEWTYPE viewtype = GlobalXYWnd_getCurrentViewType();
+ switch ( viewtype )
+ {
+ case XY:
+ Select_RotateAxis( 2, -90 );
+ break;
+ case XZ:
+ Select_RotateAxis( 1, 90 );
+ break;
+ default:
+ Select_RotateAxis( 0, -90 );
+ break;
+ }
+}
+void Selection_RotateAnticlockwise(){
+ UndoableCommand undo( "rotateSelected Anticlockwise 90" );
+ VIEWTYPE viewtype = GlobalXYWnd_getCurrentViewType();
+ switch ( viewtype )
+ {
+ case XY:
+ Select_RotateAxis( 2, 90 );
+ break;
+ case XZ:
+ Select_RotateAxis( 1, -90 );
+ break;
+ default:
+ Select_RotateAxis( 0, 90 );
+ break;
+ }
+
+}
+
+
+
+void Select_registerCommands(){
+ GlobalCommands_insert( "ShowHidden", makeCallbackF( Select_ShowAllHidden ), Accelerator( 'H', (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalToggles_insert( "HideSelected", makeCallbackF( HideSelected ), ToggleItem::AddCallbackCaller( g_hidden_item ), Accelerator( 'H' ) );
+
+ GlobalCommands_insert( "MirrorSelectionX", makeCallbackF( Selection_Flipx ) );
+ GlobalCommands_insert( "RotateSelectionX", makeCallbackF( Selection_Rotatex ) );
+ GlobalCommands_insert( "MirrorSelectionY", makeCallbackF( Selection_Flipy ) );
+ GlobalCommands_insert( "RotateSelectionY", makeCallbackF( Selection_Rotatey ) );
+ GlobalCommands_insert( "MirrorSelectionZ", makeCallbackF( Selection_Flipz ) );
+ GlobalCommands_insert( "RotateSelectionZ", makeCallbackF( Selection_Rotatez ) );
+
+ GlobalCommands_insert( "MirrorSelectionHorizontally", makeCallbackF( Selection_FlipHorizontally ) );
+ GlobalCommands_insert( "MirrorSelectionVertically", makeCallbackF( Selection_FlipVertically ) );
+
+ GlobalCommands_insert( "RotateSelectionClockwise", makeCallbackF( Selection_RotateClockwise ) );
+ GlobalCommands_insert( "RotateSelectionAnticlockwise", makeCallbackF( Selection_RotateAnticlockwise ) );
+}
void Nudge( int nDim, float fNudge ){
SignalHandlerId Selection_boundsChanged;
void Selection_construct(){
- typedef FreeCaller1<const Selectable&, SceneSelectionChange> SceneSelectionChangeCaller;
+ typedef FreeCaller<void(const Selectable&), SceneSelectionChange> SceneSelectionChangeCaller;
GlobalSelectionSystem().addSelectionChangeCallback( SceneSelectionChangeCaller() );
- typedef FreeCaller1<const Selectable&, UpdateWorkzone_ForSelectionChanged> UpdateWorkzoneForSelectionChangedCaller;
+ typedef FreeCaller<void(const Selectable&), UpdateWorkzone_ForSelectionChanged> UpdateWorkzoneForSelectionChangedCaller;
GlobalSelectionSystem().addSelectionChangeCallback( UpdateWorkzoneForSelectionChangedCaller() );
- typedef FreeCaller<UpdateWorkzone_ForSelection> UpdateWorkzoneForSelectionCaller;
+ typedef FreeCaller<void(), UpdateWorkzone_ForSelection> UpdateWorkzoneForSelectionCaller;
Selection_boundsChanged = GlobalSceneGraph().addBoundsChangedCallback( UpdateWorkzoneForSelectionCaller() );
}
#include "gtkdlgs.h"
-#include <gtk/gtkbox.h>
-#include <gtk/gtkspinbutton.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtklabel.h>
#include <gdk/gdkkeysyms.h>
struct RotateDialog
{
- GtkSpinButton* x;
- GtkSpinButton* y;
- GtkSpinButton* z;
- GtkWindow *window;
+ ui::SpinButton x{ui::null};
+ ui::SpinButton y{ui::null};
+ ui::SpinButton z{ui::null};
+ ui::Window window{ui::null};
};
-static gboolean rotatedlg_apply( GtkWidget *widget, RotateDialog* rotateDialog ){
+static gboolean rotatedlg_apply( ui::Widget widget, RotateDialog* rotateDialog ){
Vector3 eulerXYZ;
gtk_spin_button_update ( rotateDialog->x );
command << "rotateSelectedEulerXYZ -x " << eulerXYZ[0] << " -y " << eulerXYZ[1] << " -z " << eulerXYZ[2];
UndoableCommand undo( command.c_str() );
- GlobalSelectionSystem().rotateSelected( quaternion_for_euler_xyz_degrees( eulerXYZ ) );
+ GlobalSelectionSystem().rotateSelected( quaternion_for_euler_xyz_degrees( eulerXYZ ), false );
return TRUE;
}
-static gboolean rotatedlg_cancel( GtkWidget *widget, RotateDialog* rotateDialog ){
- gtk_widget_hide( GTK_WIDGET( rotateDialog->window ) );
+static gboolean rotatedlg_cancel( ui::Widget widget, RotateDialog* rotateDialog ){
+ rotateDialog->window.hide();
gtk_spin_button_set_value( rotateDialog->x, 0.0f ); // reset to 0 on close
gtk_spin_button_set_value( rotateDialog->y, 0.0f );
return TRUE;
}
-static gboolean rotatedlg_ok( GtkWidget *widget, RotateDialog* rotateDialog ){
+static gboolean rotatedlg_ok( ui::Widget widget, RotateDialog* rotateDialog ){
rotatedlg_apply( widget, rotateDialog );
// rotatedlg_cancel( widget, rotateDialog );
- gtk_widget_hide( GTK_WIDGET( rotateDialog->window ) );
+ rotateDialog->window.hide();
return TRUE;
}
-static gboolean rotatedlg_delete( GtkWidget *widget, GdkEventAny *event, RotateDialog* rotateDialog ){
+static gboolean rotatedlg_delete( ui::Widget widget, GdkEventAny *event, RotateDialog* rotateDialog ){
rotatedlg_cancel( widget, rotateDialog );
return TRUE;
}
RotateDialog g_rotate_dialog;
void DoRotateDlg(){
- if ( g_rotate_dialog.window == NULL ) {
- g_rotate_dialog.window = create_dialog_window( MainFrame_getWindow(), "Arbitrary rotation", G_CALLBACK( rotatedlg_delete ), &g_rotate_dialog );
+ if ( !g_rotate_dialog.window ) {
+ g_rotate_dialog.window = MainFrame_getWindow().create_dialog_window("Arbitrary rotation", G_CALLBACK(rotatedlg_delete ), &g_rotate_dialog );
- GtkAccelGroup* accel = gtk_accel_group_new();
- gtk_window_add_accel_group( g_rotate_dialog.window, accel );
+ auto accel = ui::AccelGroup(ui::New);
+ g_rotate_dialog.window.add_accel_group( accel );
{
- GtkHBox* hbox = create_dialog_hbox( 4, 4 );
- gtk_container_add( GTK_CONTAINER( g_rotate_dialog.window ), GTK_WIDGET( hbox ) );
+ auto hbox = create_dialog_hbox( 4, 4 );
+ g_rotate_dialog.window.add(hbox);
{
- GtkTable* table = create_dialog_table( 3, 2, 4, 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
+ auto table = create_dialog_table( 3, 2, 4, 4 );
+ hbox.pack_start( table, TRUE, TRUE, 0 );
{
- GtkWidget* label = gtk_label_new( " X " );
- gtk_widget_show( label );
- gtk_table_attach( table, label, 0, 1, 0, 1,
- (GtkAttachOptions) ( 0 ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ ui::Widget label = ui::Label( " X " );
+ label.show();
+ table.attach(label, {0, 1, 0, 1}, {0, 0});
}
{
- GtkWidget* label = gtk_label_new( " Y " );
- gtk_widget_show( label );
- gtk_table_attach( table, label, 0, 1, 1, 2,
- (GtkAttachOptions) ( 0 ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ ui::Widget label = ui::Label( " Y " );
+ label.show();
+ table.attach(label, {0, 1, 1, 2}, {0, 0});
}
{
- GtkWidget* label = gtk_label_new( " Z " );
- gtk_widget_show( label );
- gtk_table_attach( table, label, 0, 1, 2, 3,
- (GtkAttachOptions) ( 0 ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ ui::Widget label = ui::Label( " Z " );
+ label.show();
+ table.attach(label, {0, 1, 2, 3}, {0, 0});
}
{
- GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -359, 359, 1, 10, 0 ) );
- GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) );
- gtk_widget_show( GTK_WIDGET( spin ) );
- gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_set_size_request( GTK_WIDGET( spin ), 64, -1 );
+ auto adj = ui::Adjustment( 0, -359, 359, 1, 10, 0 );
+ auto spin = ui::SpinButton( adj, 1, 1 );
+ spin.show();
+ table.attach(spin, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
+ spin.dimensions(64, -1);
gtk_spin_button_set_wrap( spin, TRUE );
- gtk_widget_grab_focus( GTK_WIDGET( spin ) );
+ gtk_widget_grab_focus( spin );
g_rotate_dialog.x = spin;
}
{
- GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -359, 359, 1, 10, 0 ) );
- GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) );
- gtk_widget_show( GTK_WIDGET( spin ) );
- gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_set_size_request( GTK_WIDGET( spin ), 64, -1 );
+ auto adj = ui::Adjustment( 0, -359, 359, 1, 10, 0 );
+ auto spin = ui::SpinButton( adj, 1, 1 );
+ spin.show();
+ table.attach(spin, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
+ spin.dimensions(64, -1);
gtk_spin_button_set_wrap( spin, TRUE );
g_rotate_dialog.y = spin;
}
{
- GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -359, 359, 1, 10, 0 ) );
- GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) );
- gtk_widget_show( GTK_WIDGET( spin ) );
- gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 2, 3,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_set_size_request( GTK_WIDGET( spin ), 64, -1 );
+ auto adj = ui::Adjustment( 0, -359, 359, 1, 10, 0 );
+ auto spin = ui::SpinButton( adj, 1, 1 );
+ spin.show();
+ table.attach(spin, {1, 2, 2, 3}, {GTK_EXPAND | GTK_FILL, 0});
+ spin.dimensions(64, -1);
gtk_spin_button_set_wrap( spin, TRUE );
g_rotate_dialog.z = spin;
}
}
{
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox, TRUE, TRUE, 0 );
{
- GtkButton* button = create_dialog_button( "OK", G_CALLBACK( rotatedlg_ok ), &g_rotate_dialog );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- widget_make_default( GTK_WIDGET( button ) );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
+ auto button = create_dialog_button( "OK", G_CALLBACK( rotatedlg_ok ), &g_rotate_dialog );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ widget_make_default( button );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
}
{
- GtkButton* button = create_dialog_button( "Cancel", G_CALLBACK( rotatedlg_cancel ), &g_rotate_dialog );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
+ auto button = create_dialog_button( "Cancel", G_CALLBACK( rotatedlg_cancel ), &g_rotate_dialog );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
}
{
- GtkButton* button = create_dialog_button( "Apply", G_CALLBACK( rotatedlg_apply ), &g_rotate_dialog );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ auto button = create_dialog_button( "Apply", G_CALLBACK( rotatedlg_apply ), &g_rotate_dialog );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
}
}
}
}
- gtk_widget_show( GTK_WIDGET( g_rotate_dialog.window ) );
+ g_rotate_dialog.window.show();
}
struct ScaleDialog
{
- GtkWidget* x;
- GtkWidget* y;
- GtkWidget* z;
- GtkWindow *window;
+ ui::Entry x{ui::null};
+ ui::Entry y{ui::null};
+ ui::Entry z{ui::null};
+ ui::Window window{ui::null};
};
-static gboolean scaledlg_apply( GtkWidget *widget, ScaleDialog* scaleDialog ){
+static gboolean scaledlg_apply( ui::Widget widget, ScaleDialog* scaleDialog ){
float sx, sy, sz;
sx = static_cast<float>( atof( gtk_entry_get_text( GTK_ENTRY( scaleDialog->x ) ) ) );
return TRUE;
}
-static gboolean scaledlg_cancel( GtkWidget *widget, ScaleDialog* scaleDialog ){
- gtk_widget_hide( GTK_WIDGET( scaleDialog->window ) );
+static gboolean scaledlg_cancel( ui::Widget widget, ScaleDialog* scaleDialog ){
+ scaleDialog->window.hide();
- gtk_entry_set_text( GTK_ENTRY( scaleDialog->x ), "1.0" );
- gtk_entry_set_text( GTK_ENTRY( scaleDialog->y ), "1.0" );
- gtk_entry_set_text( GTK_ENTRY( scaleDialog->z ), "1.0" );
+ scaleDialog->x.text("1.0");
+ scaleDialog->y.text("1.0");
+ scaleDialog->z.text("1.0");
return TRUE;
}
-static gboolean scaledlg_ok( GtkWidget *widget, ScaleDialog* scaleDialog ){
+static gboolean scaledlg_ok( ui::Widget widget, ScaleDialog* scaleDialog ){
scaledlg_apply( widget, scaleDialog );
//scaledlg_cancel( widget, scaleDialog );
- gtk_widget_hide( GTK_WIDGET( scaleDialog->window ) );
+ scaleDialog->window.hide();
return TRUE;
}
-static gboolean scaledlg_delete( GtkWidget *widget, GdkEventAny *event, ScaleDialog* scaleDialog ){
+static gboolean scaledlg_delete( ui::Widget widget, GdkEventAny *event, ScaleDialog* scaleDialog ){
scaledlg_cancel( widget, scaleDialog );
return TRUE;
}
ScaleDialog g_scale_dialog;
void DoScaleDlg(){
- if ( g_scale_dialog.window == NULL ) {
- g_scale_dialog.window = create_dialog_window( MainFrame_getWindow(), "Arbitrary scale", G_CALLBACK( scaledlg_delete ), &g_scale_dialog );
+ if ( !g_scale_dialog.window ) {
+ g_scale_dialog.window = MainFrame_getWindow().create_dialog_window("Arbitrary scale", G_CALLBACK(scaledlg_delete ), &g_scale_dialog );
- GtkAccelGroup* accel = gtk_accel_group_new();
- gtk_window_add_accel_group( g_scale_dialog.window, accel );
+ auto accel = ui::AccelGroup(ui::New);
+ g_scale_dialog.window.add_accel_group( accel );
{
- GtkHBox* hbox = create_dialog_hbox( 4, 4 );
- gtk_container_add( GTK_CONTAINER( g_scale_dialog.window ), GTK_WIDGET( hbox ) );
+ auto hbox = create_dialog_hbox( 4, 4 );
+ g_scale_dialog.window.add(hbox);
{
- GtkTable* table = create_dialog_table( 3, 2, 4, 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
+ auto table = create_dialog_table( 3, 2, 4, 4 );
+ hbox.pack_start( table, TRUE, TRUE, 0 );
{
- GtkWidget* label = gtk_label_new( " X " );
- gtk_widget_show( label );
- gtk_table_attach( table, label, 0, 1, 0, 1,
- (GtkAttachOptions) ( 0 ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ ui::Widget label = ui::Label( " X " );
+ label.show();
+ table.attach(label, {0, 1, 0, 1}, {0, 0});
}
{
- GtkWidget* label = gtk_label_new( " Y " );
- gtk_widget_show( label );
- gtk_table_attach( table, label, 0, 1, 1, 2,
- (GtkAttachOptions) ( 0 ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ ui::Widget label = ui::Label( " Y " );
+ label.show();
+ table.attach(label, {0, 1, 1, 2}, {0, 0});
}
{
- GtkWidget* label = gtk_label_new( " Z " );
- gtk_widget_show( label );
- gtk_table_attach( table, label, 0, 1, 2, 3,
- (GtkAttachOptions) ( 0 ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ ui::Widget label = ui::Label( " Z " );
+ label.show();
+ table.attach(label, {0, 1, 2, 3}, {0, 0});
}
{
- GtkWidget* entry = gtk_entry_new();
- gtk_entry_set_text( GTK_ENTRY( entry ), "1.0" );
- gtk_widget_show( entry );
- gtk_table_attach( table, entry, 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto entry = ui::Entry(ui::New);
+ entry.text("1.0");
+ entry.show();
+ table.attach(entry, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
g_scale_dialog.x = entry;
}
{
- GtkWidget* entry = gtk_entry_new();
- gtk_entry_set_text( GTK_ENTRY( entry ), "1.0" );
- gtk_widget_show( entry );
- gtk_table_attach( table, entry, 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto entry = ui::Entry(ui::New);
+ entry.text("1.0");
+ entry.show();
+ table.attach(entry, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
g_scale_dialog.y = entry;
}
{
- GtkWidget* entry = gtk_entry_new();
- gtk_entry_set_text( GTK_ENTRY( entry ), "1.0" );
- gtk_widget_show( entry );
- gtk_table_attach( table, entry, 1, 2, 2, 3,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto entry = ui::Entry(ui::New);
+ entry.text("1.0");
+ entry.show();
+ table.attach(entry, {1, 2, 2, 3}, {GTK_EXPAND | GTK_FILL, 0});
g_scale_dialog.z = entry;
}
}
{
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox, TRUE, TRUE, 0 );
{
- GtkButton* button = create_dialog_button( "OK", G_CALLBACK( scaledlg_ok ), &g_scale_dialog );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- widget_make_default( GTK_WIDGET( button ) );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
+ auto button = create_dialog_button( "OK", G_CALLBACK( scaledlg_ok ), &g_scale_dialog );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ widget_make_default( button );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
}
{
- GtkButton* button = create_dialog_button( "Cancel", G_CALLBACK( scaledlg_cancel ), &g_scale_dialog );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
+ auto button = create_dialog_button( "Cancel", G_CALLBACK( scaledlg_cancel ), &g_scale_dialog );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
}
{
- GtkButton* button = create_dialog_button( "Apply", G_CALLBACK( scaledlg_apply ), &g_scale_dialog );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ auto button = create_dialog_button( "Apply", G_CALLBACK( scaledlg_apply ), &g_scale_dialog );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
}
}
}
}
- gtk_widget_show( GTK_WIDGET( g_scale_dialog.window ) );
+ g_scale_dialog.window.show();
}