This commit is contained in:
Garux
2022-10-27 09:10:31 +03:00
parent b1e5581c60
commit 9d3d204018
289 changed files with 13557 additions and 33481 deletions

View File

@@ -23,8 +23,6 @@
* along with MeshTex. If not, see <http://www.gnu.org/licenses/>.
*/
#include <gtk/gtk.h>
#include "GenericPluginUI.h"
#include "SetScaleDialog.h"
#include "PluginUIMessages.h"
@@ -88,465 +86,185 @@ SetScaleDialog::SetScaleDialog(const std::string& key) :
GenericDialog(key),
_nullVisitor(new MeshVisitor())
{
// Enable the usual handling of the close event.
CreateWindowCloseCallback();
// Configure the dialog window.
gtk_window_set_resizable(GTK_WINDOW(_dialog), FALSE);
gtk_window_set_title(GTK_WINDOW(_dialog), DIALOG_SET_SCALE_TITLE);
gtk_container_set_border_width(GTK_CONTAINER(_dialog), 10);
_dialog->setWindowTitle(DIALOG_SET_SCALE_TITLE);
// Create the contained widgets.
GtkWidget *table;
GtkWidget *entry;
GtkWidget *applybutton, *refbutton, *button;
GtkWidget *label;
GtkWidget *mainvbox, *vbox, *hbox;
GtkWidget *frame;
table = gtk_table_new(2, 2, FALSE);
gtk_table_set_row_spacing(GTK_TABLE(table), 0, 15);
gtk_table_set_col_spacing(GTK_TABLE(table), 0, 10);
gtk_container_add(GTK_CONTAINER(_dialog), table);
gtk_widget_show(table);
// Checkbox for the "S" grouping of widgets. All the widgets in that
// grouping will have a dependence registered on this checkbox; i.e. they
// will only be active when it is checked.
applybutton = gtk_check_button_new_with_label(DIALOG_SET_SCALE_S_ACTIVE_OPT_LABEL);
g_object_set_data(G_OBJECT(_dialog), "s_apply", applybutton);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(applybutton), TRUE);
gtk_widget_show(applybutton);
frame = gtk_frame_new(NULL);
gtk_frame_set_label_widget(GTK_FRAME(frame), applybutton);
gtk_table_attach_defaults(GTK_TABLE(table), frame, 0, 1, 0, 1);
gtk_widget_show(frame);
mainvbox = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(frame), mainvbox);
gtk_widget_show(mainvbox);
hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(mainvbox), hbox, TRUE, TRUE, 5);
gtk_widget_show(hbox);
// Widgets for specifying S scaling.
label = gtk_label_new(DIALOG_SET_SCALE_METHOD_FRAME_TITLE);
gtk_widget_show(label);
UIInstance().RegisterWidgetDependence(applybutton, label);
frame = gtk_frame_new(NULL);
gtk_frame_set_label_widget(GTK_FRAME(frame), label);
gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 5);
gtk_widget_show(frame);
vbox = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(frame), vbox);
gtk_widget_show(vbox);
hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_end(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
gtk_widget_show(hbox);
button = gtk_radio_button_new_with_label_from_widget(NULL, DIALOG_SET_SCALE_TILES_OPT_LABEL);
g_object_set_data(G_OBJECT(_dialog), "s_tiling", button);
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
gtk_widget_show(button);
UIInstance().RegisterWidgetDependence(applybutton, button);
entry = gtk_entry_new();
g_object_set_data(G_OBJECT(_dialog), "s_tiles", entry);
gtk_entry_set_text(GTK_ENTRY(entry), "1");
gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
gtk_widget_set_size_request(entry, 50, -1);
gtk_widget_set_sensitive(entry, FALSE);
gtk_widget_show(entry);
UIInstance().RegisterWidgetDependence(applybutton, entry);
UIInstance().RegisterWidgetDependence(button, entry);
hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_end(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
gtk_widget_show(hbox);
button = gtk_radio_button_new_with_label_from_widget(
GTK_RADIO_BUTTON(button),
DIALOG_SET_SCALE_NATURAL_OPT_LABEL);
g_object_set_data(G_OBJECT(_dialog), "s_natural", button);
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
gtk_widget_show(button);
UIInstance().RegisterWidgetDependence(applybutton, button);
entry = gtk_entry_new();
g_object_set_data(G_OBJECT(_dialog), "s_scale", entry);
gtk_entry_set_text(GTK_ENTRY(entry), "1");
gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
gtk_widget_set_size_request(entry, 50, -1);
gtk_widget_set_sensitive(entry, TRUE);
gtk_widget_show(entry);
UIInstance().RegisterWidgetDependence(applybutton, entry);
UIInstance().RegisterWidgetDependence(button, entry);
hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(mainvbox), hbox, TRUE, TRUE, 5);
gtk_widget_show(hbox);
// Widgets for specifying the alignment column.
label = gtk_label_new(DIALOG_SET_SCALE_S_ALIGN_FRAME_TITLE);
gtk_widget_show(label);
UIInstance().RegisterWidgetDependence(applybutton, label);
frame = gtk_frame_new(NULL);
gtk_frame_set_label_widget(GTK_FRAME(frame), label);
gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 5);
gtk_widget_show(frame);
vbox = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(frame), vbox);
gtk_widget_show(vbox);
hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
gtk_widget_show(hbox);
button = gtk_radio_button_new(NULL);
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
gtk_widget_show(button);
UIInstance().RegisterWidgetDependence(applybutton, button);
entry = gtk_entry_new();
g_object_set_data(G_OBJECT(_dialog), "col_num_align", entry);
gtk_entry_set_text(GTK_ENTRY(entry), "0");
gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
gtk_widget_set_size_request(entry, 25, -1);
gtk_widget_show(entry);
UIInstance().RegisterWidgetDependence(applybutton, entry);
UIInstance().RegisterWidgetDependence(button, entry);
button = gtk_radio_button_new_with_label_from_widget(
GTK_RADIO_BUTTON(button),
DIALOG_SET_SCALE_MAX_OPT_LABEL);
g_object_set_data(G_OBJECT(_dialog), "col_max_align", button);
gtk_box_pack_end(GTK_BOX(hbox), button, TRUE, FALSE, 5);
gtk_widget_show(button);
UIInstance().RegisterWidgetDependence(applybutton, button);
hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(mainvbox), hbox, TRUE, TRUE, 5);
gtk_widget_show(hbox);
// Widgets for specifying the reference row & usage.
refbutton = gtk_check_button_new_with_label(DIALOG_SET_SCALE_S_REF_ROW_OPT_LABEL);
g_object_set_data(G_OBJECT(_dialog), "row_ref", refbutton);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(refbutton), TRUE);
gtk_widget_show(refbutton);
UIInstance().RegisterWidgetDependence(applybutton, refbutton);
frame = gtk_frame_new(NULL);
gtk_frame_set_label_widget(GTK_FRAME(frame), refbutton);
gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 5);
gtk_widget_show(frame);
vbox = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(frame), vbox);
gtk_widget_show(vbox);
hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
gtk_widget_show(hbox);
button = gtk_radio_button_new(NULL);
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
gtk_widget_show(button);
UIInstance().RegisterWidgetDependence(applybutton, button);
UIInstance().RegisterWidgetDependence(refbutton, button);
entry = gtk_entry_new();
g_object_set_data(G_OBJECT(_dialog), "row_num_ref", entry);
gtk_entry_set_text(GTK_ENTRY(entry), "0");
gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
gtk_widget_set_size_request(entry, 25, -1);
gtk_widget_show(entry);
UIInstance().RegisterWidgetDependence(applybutton, entry);
UIInstance().RegisterWidgetDependence(refbutton, entry);
UIInstance().RegisterWidgetDependence(button, entry);
button = gtk_radio_button_new_with_label_from_widget(
GTK_RADIO_BUTTON(button),
DIALOG_SET_SCALE_MAX_OPT_LABEL);
g_object_set_data(G_OBJECT(_dialog), "row_max_ref", button);
gtk_box_pack_end(GTK_BOX(hbox), button, TRUE, FALSE, 5);
gtk_widget_show(button);
UIInstance().RegisterWidgetDependence(applybutton, button);
UIInstance().RegisterWidgetDependence(refbutton, button);
hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_end(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
gtk_widget_show(hbox);
button = gtk_check_button_new_with_label(DIALOG_SET_SCALE_REF_TOTAL_OPT_LABEL);
g_object_set_data(G_OBJECT(_dialog), "row_ref_total", button);
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
gtk_widget_show(button);
UIInstance().RegisterWidgetDependence(applybutton, button);
UIInstance().RegisterWidgetDependence(refbutton, button);
// Checkbox for the "T" grouping of widgets. All the widgets in that
// grouping will have a dependence registered on this checkbox; i.e. they
// will only be active when it is checked.
applybutton = gtk_check_button_new_with_label(DIALOG_SET_SCALE_T_ACTIVE_OPT_LABEL);
g_object_set_data(G_OBJECT(_dialog), "t_apply", applybutton);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(applybutton), TRUE);
gtk_widget_show(applybutton);
frame = gtk_frame_new(NULL);
gtk_frame_set_label_widget(GTK_FRAME(frame), applybutton);
gtk_table_attach_defaults(GTK_TABLE(table), frame, 1, 2, 0, 1);
gtk_widget_show(frame);
mainvbox = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(frame), mainvbox);
gtk_widget_show(mainvbox);
hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(mainvbox), hbox, TRUE, TRUE, 5);
gtk_widget_show(hbox);
// Widgets for specifying T scaling.
label = gtk_label_new(DIALOG_SET_SCALE_METHOD_FRAME_TITLE);
gtk_widget_show(label);
UIInstance().RegisterWidgetDependence(applybutton, label);
frame = gtk_frame_new(NULL);
gtk_frame_set_label_widget(GTK_FRAME(frame), label);
gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 5);
gtk_widget_show(frame);
vbox = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(frame), vbox);
gtk_widget_show(vbox);
hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_end(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
gtk_widget_show(hbox);
button = gtk_radio_button_new_with_label_from_widget(NULL, DIALOG_SET_SCALE_TILES_OPT_LABEL);
g_object_set_data(G_OBJECT(_dialog), "t_tiling", button);
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
gtk_widget_show(button);
UIInstance().RegisterWidgetDependence(applybutton, button);
entry = gtk_entry_new();
g_object_set_data(G_OBJECT(_dialog), "t_tiles", entry);
gtk_entry_set_text(GTK_ENTRY(entry), "1");
gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
gtk_widget_set_size_request(entry, 50, -1);
gtk_widget_set_sensitive(entry, FALSE);
gtk_widget_show(entry);
UIInstance().RegisterWidgetDependence(applybutton, entry);
UIInstance().RegisterWidgetDependence(button, entry);
hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_end(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
gtk_widget_show(hbox);
button = gtk_radio_button_new_with_label_from_widget(
GTK_RADIO_BUTTON(button),
DIALOG_SET_SCALE_NATURAL_OPT_LABEL);
g_object_set_data(G_OBJECT(_dialog), "t_natural", button);
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
gtk_widget_show(button);
UIInstance().RegisterWidgetDependence(applybutton, button);
entry = gtk_entry_new();
g_object_set_data(G_OBJECT(_dialog), "t_scale", entry);
gtk_entry_set_text(GTK_ENTRY(entry), "1");
gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
gtk_widget_set_size_request(entry, 50, -1);
gtk_widget_set_sensitive(entry, TRUE);
gtk_widget_show(entry);
UIInstance().RegisterWidgetDependence(applybutton, entry);
UIInstance().RegisterWidgetDependence(button, entry);
hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(mainvbox), hbox, TRUE, TRUE, 5);
gtk_widget_show(hbox);
// Widgets for specifying the alignment row.
label = gtk_label_new(DIALOG_SET_SCALE_T_ALIGN_FRAME_TITLE);
gtk_widget_show(label);
UIInstance().RegisterWidgetDependence(applybutton, label);
frame = gtk_frame_new(NULL);
gtk_frame_set_label_widget(GTK_FRAME(frame), label);
gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 5);
gtk_widget_show(frame);
vbox = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(frame), vbox);
gtk_widget_show(vbox);
hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
gtk_widget_show(hbox);
button = gtk_radio_button_new(NULL);
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
gtk_widget_show(button);
UIInstance().RegisterWidgetDependence(applybutton, button);
entry = gtk_entry_new();
g_object_set_data(G_OBJECT(_dialog), "row_num_align", entry);
gtk_entry_set_text(GTK_ENTRY(entry), "0");
gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
gtk_widget_set_size_request(entry, 25, -1);
gtk_widget_show(entry);
UIInstance().RegisterWidgetDependence(applybutton, entry);
UIInstance().RegisterWidgetDependence(button, entry);
button = gtk_radio_button_new_with_label_from_widget(
GTK_RADIO_BUTTON(button),
DIALOG_SET_SCALE_MAX_OPT_LABEL);
g_object_set_data(G_OBJECT(_dialog), "row_max_align", button);
gtk_box_pack_end(GTK_BOX(hbox), button, TRUE, FALSE, 5);
gtk_widget_show(button);
UIInstance().RegisterWidgetDependence(applybutton, button);
hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(mainvbox), hbox, TRUE, TRUE, 5);
gtk_widget_show(hbox);
// Widgets for specifying the reference column & usage.
refbutton = gtk_check_button_new_with_label(DIALOG_SET_SCALE_T_REF_COL_OPT_LABEL);
g_object_set_data(G_OBJECT(_dialog), "col_ref", refbutton);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(refbutton), TRUE);
gtk_widget_show(refbutton);
UIInstance().RegisterWidgetDependence(applybutton, refbutton);
frame = gtk_frame_new(NULL);
gtk_frame_set_label_widget(GTK_FRAME(frame), refbutton);
gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 5);
gtk_widget_show(frame);
vbox = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(frame), vbox);
gtk_widget_show(vbox);
hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
gtk_widget_show(hbox);
button = gtk_radio_button_new(NULL);
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
gtk_widget_show(button);
UIInstance().RegisterWidgetDependence(applybutton, button);
UIInstance().RegisterWidgetDependence(refbutton, button);
entry = gtk_entry_new();
g_object_set_data(G_OBJECT(_dialog), "col_num_ref", entry);
gtk_entry_set_text(GTK_ENTRY(entry), "0");
gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
gtk_widget_set_size_request(entry, 25, -1);
gtk_widget_show(entry);
UIInstance().RegisterWidgetDependence(applybutton, entry);
UIInstance().RegisterWidgetDependence(refbutton, entry);
UIInstance().RegisterWidgetDependence(button, entry);
button = gtk_radio_button_new_with_label_from_widget(
GTK_RADIO_BUTTON(button),
DIALOG_SET_SCALE_MAX_OPT_LABEL);
g_object_set_data(G_OBJECT(_dialog), "col_max_ref", button);
gtk_box_pack_end(GTK_BOX(hbox), button, TRUE, FALSE, 5);
gtk_widget_show(button);
UIInstance().RegisterWidgetDependence(applybutton, button);
UIInstance().RegisterWidgetDependence(refbutton, button);
hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_end(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
gtk_widget_show(hbox);
button = gtk_check_button_new_with_label(DIALOG_SET_SCALE_REF_TOTAL_OPT_LABEL);
g_object_set_data(G_OBJECT(_dialog), "col_ref_total", button);
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
gtk_widget_show(button);
UIInstance().RegisterWidgetDependence(applybutton, button);
UIInstance().RegisterWidgetDependence(refbutton, button);
hbox = gtk_hbox_new(FALSE, 0);
gtk_table_attach_defaults(GTK_TABLE(table), hbox, 0, 2, 1, 2);
gtk_widget_show(hbox);
// Create Cancel button and hook it to callback.
button = gtk_button_new_with_label(DIALOG_CANCEL_BUTTON);
gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
gtk_widget_set_size_request(button, 60, -1);
gtk_widget_show(button);
CreateCancelButtonCallback(button);
// Create Apply button and hook it to callback.
button = gtk_button_new_with_label(DIALOG_APPLY_BUTTON);
gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 10);
gtk_widget_set_size_request (button, 60, -1);
gtk_widget_show(button);
CreateApplyButtonCallback(button);
// Create OK button and hook it to callback.
button = gtk_button_new_with_label(DIALOG_OK_BUTTON);
gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
gtk_widget_set_size_request (button, 60, -1);
gtk_widget_show(button);
CreateOkButtonCallback(button);
{
auto dialog_grid = new QGridLayout( _dialog );
dialog_grid->setSizeConstraint( QLayout::SizeConstraint::SetFixedSize );
{
// Checkbox for the "S" grouping of widgets. All the widgets in that
// grouping will have a dependence registered on this checkbox; i.e. they
// will only be active when it is checked.
auto group = s_apply = new QGroupBox( DIALOG_SET_SCALE_S_ACTIVE_OPT_LABEL );
dialog_grid->addWidget( group, 0, 0 );
group->setCheckable( true );
group->setChecked( true );
{
auto vbox = new QVBoxLayout( group );
{
// Widgets for specifying S scaling.
auto group = new QGroupBox( DIALOG_SET_SCALE_METHOD_FRAME_TITLE );
vbox->addWidget( group );
auto grid = new QGridLayout( group );
{
auto radio = new QRadioButton( DIALOG_SET_SCALE_NATURAL_OPT_LABEL );
grid->addWidget( radio, 0, 0 );
auto spin = s_scale = new DoubleSpinBox( -999, 999, 1, 3 );
grid->addWidget( spin, 0, 1 );
UIInstance().RegisterWidgetDependence( radio, spin );
radio->setChecked( true );
}
{
auto radio = new QRadioButton( DIALOG_SET_SCALE_TILES_OPT_LABEL );
grid->addWidget( radio, 1, 0 );
auto spin = s_tiles = new DoubleSpinBox( -999, 999, 1, 3 );
grid->addWidget( spin, 1, 1 );
UIInstance().RegisterWidgetDependence( radio, spin );
spin->setEnabled( false );
}
}
{
// Widgets for specifying the alignment column.
auto group = new QGroupBox( DIALOG_SET_SCALE_S_ALIGN_FRAME_TITLE );
vbox->addWidget( group );
auto grid = new QGridLayout( group );
grid->setColumnStretch( 2, 1 );
{
auto radio = new QRadioButton;
grid->addWidget( radio, 0, 0 );
auto spin = col_num_align = new SpinBox( 0, 30 );
grid->addWidget( spin, 0, 1 );
UIInstance().RegisterWidgetDependence( radio, spin );
radio->setChecked( true );
}
{
auto radio = new QRadioButton( DIALOG_SET_SCALE_MAX_OPT_LABEL );
grid->addWidget( radio, 0, 2, Qt::AlignmentFlag::AlignRight );
}
}
{
// Widgets for specifying the reference row & usage.
auto group = row_ref = new QGroupBox( DIALOG_SET_SCALE_S_REF_ROW_OPT_LABEL );
group->setCheckable( true );
group->setChecked( true );
vbox->addWidget( group );
auto grid = new QGridLayout( group );
grid->setColumnStretch( 2, 1 );
{
auto radio = new QRadioButton;
grid->addWidget( radio, 0, 0 );
auto spin = row_num_ref = new SpinBox( 0, 30 );
grid->addWidget( spin, 0, 1 );
UIInstance().RegisterWidgetDependence( radio, spin );
radio->setChecked( true );
}
{
auto radio = new QRadioButton( DIALOG_SET_SCALE_MAX_OPT_LABEL );
grid->addWidget( radio, 0, 2, Qt::AlignmentFlag::AlignRight );
}
{
auto check = row_ref_total = new QCheckBox( DIALOG_SET_SCALE_REF_TOTAL_OPT_LABEL );
grid->addWidget( check, 1, 0, 1, 3 );
check->setChecked( true );
}
}
}
}
{
// Checkbox for the "T" grouping of widgets. All the widgets in that
// grouping will have a dependence registered on this checkbox; i.e. they
// will only be active when it is checked.
auto group = t_apply = new QGroupBox( DIALOG_SET_SCALE_T_ACTIVE_OPT_LABEL );
dialog_grid->addWidget( group, 0, 1 );
group->setCheckable( true );
group->setChecked( true );
{
auto vbox = new QVBoxLayout( group );
{
// Widgets for specifying T scaling.
auto group = new QGroupBox( DIALOG_SET_SCALE_METHOD_FRAME_TITLE );
vbox->addWidget( group );
auto grid = new QGridLayout( group );
{
auto radio = new QRadioButton( DIALOG_SET_SCALE_NATURAL_OPT_LABEL );
grid->addWidget( radio, 0, 0 );
auto spin = t_scale = new DoubleSpinBox( -999, 999, 1, 3 );
grid->addWidget( spin, 0, 1 );
UIInstance().RegisterWidgetDependence( radio, spin );
radio->setChecked( true );
}
{
auto radio = new QRadioButton( DIALOG_SET_SCALE_TILES_OPT_LABEL );
grid->addWidget( radio, 1, 0 );
auto spin = t_tiles = new DoubleSpinBox( -999, 999, 1, 3 );
grid->addWidget( spin, 1, 1 );
UIInstance().RegisterWidgetDependence( radio, spin );
spin->setEnabled( false );
}
}
{
// Widgets for specifying the alignment row.
auto group = new QGroupBox( DIALOG_SET_SCALE_T_ALIGN_FRAME_TITLE );
vbox->addWidget( group );
auto grid = new QGridLayout( group );
grid->setColumnStretch( 2, 1 );
{
auto radio = new QRadioButton;
grid->addWidget( radio, 0, 0 );
auto spin = row_num_align = new SpinBox( 0, 30 );
grid->addWidget( spin, 0, 1 );
UIInstance().RegisterWidgetDependence( radio, spin );
radio->setChecked( true );
}
{
auto radio = new QRadioButton( DIALOG_SET_SCALE_MAX_OPT_LABEL );
grid->addWidget( radio, 0, 2, Qt::AlignmentFlag::AlignRight );
}
}
{
// Widgets for specifying the reference column & usage.
auto group = col_ref = new QGroupBox( DIALOG_SET_SCALE_T_REF_COL_OPT_LABEL );
group->setCheckable( true );
group->setChecked( true );
vbox->addWidget( group );
auto grid = new QGridLayout( group );
grid->setColumnStretch( 2, 1 );
{
auto radio = new QRadioButton;
grid->addWidget( radio, 0, 0 );
auto spin = col_num_ref = new SpinBox( 0, 30 );
grid->addWidget( spin, 0, 1 );
UIInstance().RegisterWidgetDependence( radio, spin );
radio->setChecked( true );
}
{
auto radio = new QRadioButton( DIALOG_SET_SCALE_MAX_OPT_LABEL );
grid->addWidget( radio, 0, 2, Qt::AlignmentFlag::AlignRight );
}
{
auto check = col_ref_total = new QCheckBox( DIALOG_SET_SCALE_REF_TOTAL_OPT_LABEL );
grid->addWidget( check, 1, 0, 1, 3 );
check->setChecked( true );
}
}
}
}
{
auto buttons = new QDialogButtonBox;
dialog_grid->addWidget( buttons, 1, 0, 1, 2 );
CreateOkButtonCallback( buttons->addButton( QDialogButtonBox::StandardButton::Ok ) );
CreateApplyButtonCallback( buttons->addButton( QDialogButtonBox::StandardButton::Apply ) );
CreateCancelButtonCallback( buttons->addButton( QDialogButtonBox::StandardButton::Cancel ) );
}
}
}
/**
@@ -577,8 +295,8 @@ SetScaleDialog::Apply()
}
// See if we're going to be affecting the S and/or T texture axis.
bool sApply = NamedToggleWidgetActive("s_apply");
bool tApply = NamedToggleWidgetActive("t_apply");
const bool sApply = s_apply->isChecked();
const bool tApply = t_apply->isChecked();
if (!sApply && !tApply)
{
@@ -596,25 +314,25 @@ SetScaleDialog::Apply()
if (sApply)
{
// S axis is affected, so read the S info.
row.naturalScale = NamedToggleWidgetActive("s_natural");
row.naturalScale = s_scale->isEnabled();
if (row.naturalScale)
{
row.scaleOrTiles = (float)atof(NamedEntryWidgetText("s_scale"));
row.scaleOrTiles = s_scale->value();
}
else
{
row.scaleOrTiles = (float)atof(NamedEntryWidgetText("s_tiles"));
row.scaleOrTiles = s_tiles->value();
}
alignCol.maxSlice = NamedToggleWidgetActive("col_max_align");
alignCol.index = atoi(NamedEntryWidgetText("col_num_align"));
alignCol.maxSlice = !col_num_align->isEnabled();
alignCol.index = col_num_align->value();
row.alignSlice = &alignCol;
row.refSlice = NULL;
if (NamedToggleWidgetActive("row_ref"))
if ( row_ref->isChecked() )
{
// Reference row is specified, so get that info.
refRow.designation.maxSlice = NamedToggleWidgetActive("row_max_ref");
refRow.designation.index = atoi(NamedEntryWidgetText("row_num_ref"));
refRow.totalLengthOnly = NamedToggleWidgetActive("row_ref_total");
refRow.designation.maxSlice = !row_num_ref->isEnabled();
refRow.designation.index = row_num_ref->value();
refRow.totalLengthOnly = row_ref_total->isChecked();
row.refSlice = &refRow;
}
rowArgs = &row;
@@ -622,25 +340,25 @@ SetScaleDialog::Apply()
if (tApply)
{
// T axis is affected, so read the T info.
col.naturalScale = NamedToggleWidgetActive("t_natural");
col.naturalScale = t_scale->isEnabled();
if (col.naturalScale)
{
col.scaleOrTiles = (float)atof(NamedEntryWidgetText("t_scale"));
col.scaleOrTiles = t_scale->value();
}
else
{
col.scaleOrTiles = (float)atof(NamedEntryWidgetText("t_tiles"));
col.scaleOrTiles = t_tiles->value();
}
alignRow.maxSlice = NamedToggleWidgetActive("row_max_align");
alignRow.index = atoi(NamedEntryWidgetText("row_num_align"));
alignRow.maxSlice = !row_num_align->isEnabled();
alignRow.index = row_num_align->value();
col.alignSlice = &alignRow;
col.refSlice = NULL;
if (NamedToggleWidgetActive("col_ref"))
if ( col_ref->isChecked() )
{
// Reference column is specified, so get that info.
refCol.designation.maxSlice = NamedToggleWidgetActive("col_max_ref");
refCol.designation.index = atoi(NamedEntryWidgetText("col_num_ref"));
refCol.totalLengthOnly = NamedToggleWidgetActive("col_ref_total");
refCol.designation.maxSlice = !col_num_ref->isEnabled();
refCol.designation.index = col_num_ref->value();
refCol.totalLengthOnly = col_ref_total->isChecked();
col.refSlice = &refCol;
}
colArgs = &col;
@@ -669,8 +387,8 @@ SetScaleDialog::PopulateSWidgets(float scale,
float tiles)
{
// Use the texture info to populate some of our widgets.
PopulateEntry("s_scale", scale);
PopulateEntry("s_tiles", tiles);
s_scale->setValue( scale);
s_tiles->setValue( tiles);
}
/**
@@ -684,21 +402,6 @@ SetScaleDialog::PopulateTWidgets(float scale,
float tiles)
{
// Use the texture info to populate some of our widgets.
PopulateEntry("t_scale", scale);
PopulateEntry("t_tiles", tiles);
}
/**
* Populate a text widget with a floating point number.
*
* @param widgetName Name of the widget.
* @param value The number to write to the widget.
*/
void
SetScaleDialog::PopulateEntry(const char *widgetName,
float value)
{
static char entryBuffer[ENTRY_BUFFER_SIZE + 1] = { 0 };
snprintf(entryBuffer, ENTRY_BUFFER_SIZE, "%f", value);
gtk_entry_set_text(GTK_ENTRY(NamedWidget(widgetName)), entryBuffer);
t_scale->setValue( scale);
t_tiles->setValue( tiles);
}