-void DoRotateDlg()
-{
- ModalDialog dialog;
- RotateDialog rotateDialog;
-
- GtkWindow* window = create_dialog_window(MainFrame_getWindow(), "Arbitrary rotation", G_CALLBACK(dialog_delete_callback), &dialog);
-
- GtkAccelGroup* accel = gtk_accel_group_new();
- gtk_window_add_accel_group(window, accel);
-
- {
- GtkHBox* hbox = create_dialog_hbox(4, 4);
- gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(hbox));
- {
- GtkTable* table = create_dialog_table(3, 2, 4, 4);
- gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(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);
- }
- {
- 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);
- }
- {
- 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);
- }
- {
- GtkAdjustment* adj = GTK_ADJUSTMENT(gtk_adjustment_new(0, -359, 359, 1, 10, 10));
- 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);
- gtk_spin_button_set_wrap(spin, TRUE);
-
- gtk_widget_grab_focus(GTK_WIDGET(spin));
-
- rotateDialog.x = spin;
- }
- {
- GtkAdjustment* adj = GTK_ADJUSTMENT(gtk_adjustment_new(0, -359, 359, 1, 10, 10));
- 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);
- gtk_spin_button_set_wrap(spin, TRUE);
-
- rotateDialog.y = spin;
- }
- {
- GtkAdjustment* adj = GTK_ADJUSTMENT(gtk_adjustment_new(0, -359, 359, 1, 10, 10));
- 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);
- gtk_spin_button_set_wrap(spin, TRUE);
-
- rotateDialog.z = spin;
- }
- }
- {
- GtkVBox* vbox = create_dialog_vbox(4);
- gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(vbox), TRUE, TRUE, 0);
- {
- GtkButton* button = create_dialog_button("OK", G_CALLBACK(dialog_button_ok), &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);
- }
- {
- GtkButton* button = create_dialog_button("Cancel", G_CALLBACK(dialog_button_cancel), &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);
- }
- {
- GtkButton* button = create_dialog_button("Apply", G_CALLBACK(rotatedlg_apply), &rotateDialog);
- gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(button), FALSE, FALSE, 0);
- }
- }
- }
-
- if(modal_dialog_show(window, dialog) == eIDOK)
- {
- rotatedlg_apply(0, &rotateDialog);
- }
-
- gtk_widget_destroy(GTK_WIDGET(window));
-}
-
-void DoScaleDlg()
+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 );
+ gtk_spin_button_set_value( rotateDialog->z, 0.0f );
+
+ return TRUE;
+}
+
+static gboolean rotatedlg_ok( ui::Widget widget, RotateDialog* rotateDialog ){
+ rotatedlg_apply( widget, rotateDialog );
+ rotateDialog->window.hide();
+ return TRUE;
+}
+
+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 ) {
+ g_rotate_dialog.window = MainFrame_getWindow().create_dialog_window("Arbitrary rotation", G_CALLBACK(rotatedlg_delete ), &g_rotate_dialog );
+
+ auto accel = ui::AccelGroup(ui::New);
+ g_rotate_dialog.window.add_accel_group( accel );
+
+ {
+ auto hbox = create_dialog_hbox( 4, 4 );
+ g_rotate_dialog.window.add(hbox);
+ {
+ auto table = create_dialog_table( 3, 2, 4, 4 );
+ hbox.pack_start( table, TRUE, TRUE, 0 );
+ {
+ ui::Widget label = ui::Label( " X " );
+ label.show();
+ table.attach(label, {0, 1, 0, 1}, {0, 0});
+ }
+ {
+ ui::Widget label = ui::Label( " Y " );
+ label.show();
+ table.attach(label, {0, 1, 1, 2}, {0, 0});
+ }
+ {
+ ui::Widget label = ui::Label( " Z " );
+ label.show();
+ table.attach(label, {0, 1, 2, 3}, {0, 0});
+ }
+ {
+ auto adj = ui::Adjustment( 0, -359, 359, 1, 10, 0 );
+ auto spin = ui::SpinButton( adj, 1, 0 );
+ 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( spin );
+
+ g_rotate_dialog.x = spin;
+ }
+ {
+ auto adj = ui::Adjustment( 0, -359, 359, 1, 10, 0 );
+ auto spin = ui::SpinButton( adj, 1, 0 );
+ 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;
+ }
+ {
+ auto adj = ui::Adjustment( 0, -359, 359, 1, 10, 0 );
+ auto spin = ui::SpinButton( adj, 1, 0 );
+ 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;
+ }
+ }
+ {
+ auto vbox = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox, TRUE, TRUE, 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 );
+ }
+ {
+ 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 );
+ }
+ {
+ auto button = create_dialog_button( "Apply", G_CALLBACK( rotatedlg_apply ), &g_rotate_dialog );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ }
+ }
+ }
+ }
+
+ g_rotate_dialog.window.show();
+}
+
+
+
+
+
+
+
+
+
+struct ScaleDialog