Logo Search packages:      
Sourcecode: inkscape version File versions

Inkscape::UI::Dialog::TileDialog::TileDialog (  ) 

Constructor

Definition at line 610 of file tile.cpp.

References Inkscape::Preferences::get(), Inkscape::Preferences::getDouble(), Inkscape::Preferences::getInt(), HorizAlign_changed(), Inkscape::Selection::isEmpty(), Inkscape::Selection::itemList(), on_col_spinbutton_changed(), on_ColSize_checkbutton_changed(), on_row_spinbutton_changed(), on_RowSize_checkbutton_changed(), on_xpad_spinbutton_changed(), on_ypad_spinbutton_changed(), Spacing_button_changed(), and VertAlign_changed().

    : UI::Widget::Panel("", "/dialogs/gridtiler", SP_VERB_SELECTION_GRIDTILE)
{
     // bool used by spin button callbacks to stop loops where they change each other.
    updating = false;
    Inkscape::Preferences *prefs = Inkscape::Preferences::get();

    // could not do this in gtkmm - there's no Gtk::SizeGroup public constructor (!)
    GtkSizeGroup *_col1 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
    GtkSizeGroup *_col2 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
    GtkSizeGroup *_col3 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);

    {
        // Selection Change signal
        g_signal_connect ( G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (updateSelectionCallback), this);
    }

    Gtk::Box *contents = _getContents();

#define MARGIN 2

    //##Set up the panel

    SPDesktop *desktop = getDesktop();

    Inkscape::Selection *selection = sp_desktop_selection (desktop);
    int selcount = 1;
    if (!selection->isEmpty()) {
        GSList const *items = selection->itemList();
        selcount = g_slist_length((GSList *)items);
    }


    /*#### Number of Rows ####*/

    double PerRow = ceil(sqrt(selcount));
    double PerCol = ceil(sqrt(selcount));

    #ifdef DEBUG_GRID_ARRANGE
        g_print("/n PerRox = %f PerCol = %f selcount = %d",PerRow,PerCol,selcount);
    #endif

    NoOfRowsLabel.set_label(_("Rows:"));
    NoOfRowsBox.pack_start(NoOfRowsLabel, false, false, MARGIN);

    NoOfRowsSpinner.set_digits(0);
    NoOfRowsSpinner.set_increments(1, 0);
    NoOfRowsSpinner.set_range(1.0, 100.0);
    NoOfRowsSpinner.set_value(PerCol);
    NoOfRowsSpinner.signal_changed().connect(sigc::mem_fun(*this, &TileDialog::on_col_spinbutton_changed));
    tips.set_tip(NoOfRowsSpinner, _("Number of rows"));
    NoOfRowsBox.pack_start(NoOfRowsSpinner, false, false, MARGIN);
    gtk_size_group_add_widget(_col1, (GtkWidget *) NoOfRowsBox.gobj());

    RowHeightButton.set_label(_("Equal height"));
    double AutoRow = prefs->getDouble("/dialogs/gridtiler/AutoRowSize", 15);
    if (AutoRow>0)
         AutoRowSize=true;
    else
         AutoRowSize=false;
    RowHeightButton.set_active(AutoRowSize);

    NoOfRowsBox.pack_start(RowHeightButton, false, false, MARGIN);

    tips.set_tip(RowHeightButton, _("If not set, each row has the height of the tallest object in it"));
    RowHeightButton.signal_toggled().connect(sigc::mem_fun(*this, &TileDialog::on_RowSize_checkbutton_changed));

 {
        /*#### Radio buttons to control vertical alignment ####*/

        VertAlignLabel.set_label(_("Align:"));
        VertAlignHBox.pack_start(VertAlignLabel, false, false, MARGIN);

        VertTopRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &TileDialog::VertAlign_changed));
        VertAlignGroup = VertTopRadioButton.get_group();
        VertAlignVBox.pack_start(VertTopRadioButton, false, false, 0);

        VertCentreRadioButton.set_group(VertAlignGroup);
        VertCentreRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &TileDialog::VertAlign_changed));
        VertAlignVBox.pack_start(VertCentreRadioButton, false, false, 0);

        VertBotRadioButton.set_group(VertAlignGroup);
        VertBotRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &TileDialog::VertAlign_changed));
        VertAlignVBox.pack_start(VertBotRadioButton, false, false, 0);

        VertAlign = prefs->getInt("/dialogs/gridtiler/VertAlign", 1);
        if (VertAlign == 0) {
            VertTopRadioButton.set_active(TRUE);
        }
        else if (VertAlign == 1) {
            VertCentreRadioButton.set_active(TRUE);
        }
        else if (VertAlign == 2){
            VertBotRadioButton.set_active(TRUE);
        }
        VertAlignHBox.pack_start(VertAlignVBox, false, false, MARGIN);
        NoOfRowsBox.pack_start(VertAlignHBox, false, false, MARGIN);
    }

    SpinsHBox.pack_start(NoOfRowsBox, false, false, MARGIN);


    /*#### Label for X ####*/
    padXByYLabel.set_label(" ");
    XByYLabelVBox.pack_start(padXByYLabel, false, false, MARGIN);
    XByYLabel.set_markup(" × ");
    XByYLabelVBox.pack_start(XByYLabel, false, false, MARGIN);
    SpinsHBox.pack_start(XByYLabelVBox, false, false, MARGIN);
    gtk_size_group_add_widget(_col2, (GtkWidget *) XByYLabelVBox.gobj());

    /*#### Number of columns ####*/

    NoOfColsLabel.set_label(_("Columns:"));
    NoOfColsBox.pack_start(NoOfColsLabel, false, false, MARGIN);

    NoOfColsSpinner.set_digits(0);
    NoOfColsSpinner.set_increments(1, 0);
    NoOfColsSpinner.set_range(1.0, 100.0);
    NoOfColsSpinner.set_value(PerRow);
    NoOfColsSpinner.signal_changed().connect(sigc::mem_fun(*this, &TileDialog::on_row_spinbutton_changed));
    tips.set_tip(NoOfColsSpinner, _("Number of columns"));
    NoOfColsBox.pack_start(NoOfColsSpinner, false, false, MARGIN);
    gtk_size_group_add_widget(_col3, (GtkWidget *) NoOfColsBox.gobj());

    ColumnWidthButton.set_label(_("Equal width"));
    double AutoCol = prefs->getDouble("/dialogs/gridtiler/AutoColSize", 15);
    if (AutoCol>0)
         AutoColSize=true;
    else
         AutoColSize=false;
    ColumnWidthButton.set_active(AutoColSize);
    NoOfColsBox.pack_start(ColumnWidthButton, false, false, MARGIN);

    tips.set_tip(ColumnWidthButton, _("If not set, each column has the width of the widest object in it"));
    ColumnWidthButton.signal_toggled().connect(sigc::mem_fun(*this, &TileDialog::on_ColSize_checkbutton_changed));


    {
        /*#### Radio buttons to control horizontal alignment ####*/

        HorizAlignLabel.set_label(_("Align:"));
        HorizAlignVBox.pack_start(HorizAlignLabel, false, false, MARGIN);

        HorizAlignHBox.pack_start(*(new Gtk::HBox()), true, true, 0); // centering strut

        HorizLeftRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &TileDialog::HorizAlign_changed));
        HorizAlignGroup = HorizLeftRadioButton.get_group();
        HorizAlignHBox.pack_start(HorizLeftRadioButton, false, false, 0);

        HorizCentreRadioButton.set_group(HorizAlignGroup);
        HorizCentreRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &TileDialog::HorizAlign_changed));
        HorizAlignHBox.pack_start(HorizCentreRadioButton, false, false, 0);

        HorizRightRadioButton.set_group(HorizAlignGroup);
        HorizRightRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &TileDialog::HorizAlign_changed));
        HorizAlignHBox.pack_start(HorizRightRadioButton, false, false, 0);

        HorizAlignHBox.pack_start(*(new Gtk::HBox()), true, true, 0); // centering strut

        HorizAlign = prefs->getInt("/dialogs/gridtiler/HorizAlign", 1);
        if (HorizAlign == 0) {
            HorizLeftRadioButton.set_active(TRUE);
        }
        else if (HorizAlign == 1) {
            HorizCentreRadioButton.set_active(TRUE);
        }
        else if (HorizAlign == 2) {
            HorizRightRadioButton.set_active(TRUE);
        }
        HorizAlignVBox.pack_start(HorizAlignHBox, false, false, MARGIN);
        NoOfColsBox.pack_start(HorizAlignVBox, false, false, MARGIN);
    }

    SpinsHBox.pack_start(NoOfColsBox, false, false, MARGIN);

    TileBox.pack_start(SpinsHBox, false, false, MARGIN);

    {
        /*#### Radio buttons to control spacing manually or to fit selection bbox ####*/
        SpaceByBBoxRadioButton.set_label(_("Fit into selection box"));
        SpaceByBBoxRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &TileDialog::Spacing_button_changed));
        SpacingGroup = SpaceByBBoxRadioButton.get_group();

        SpacingVBox.pack_start(SpaceByBBoxRadioButton, false, false, MARGIN);

        SpaceManualRadioButton.set_label(_("Set spacing:"));
        SpaceManualRadioButton.set_group(SpacingGroup);
        SpaceManualRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &TileDialog::Spacing_button_changed));
        SpacingVBox.pack_start(SpaceManualRadioButton, false, false, MARGIN);

        TileBox.pack_start(SpacingVBox, false, false, MARGIN);
    }

    {
        /*#### Y Padding ####*/

        GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_MENU, "object-rows");
        YPadBox.pack_start (*(Glib::wrap(i)), false, false, MARGIN);

        YPadSpinner.set_digits(1);
        YPadSpinner.set_increments(0.2, 0);
        YPadSpinner.set_range(-10000, 10000);
        double YPad = prefs->getDouble("/dialogs/gridtiler/YPad", 15);
        YPadSpinner.set_value(YPad);
        YPadBox.pack_start(YPadSpinner, true, true, MARGIN);
        tips.set_tip(YPadSpinner, _("Vertical spacing between rows (px units)"));
        YPadSpinner.signal_changed().connect(sigc::mem_fun(*this, &TileDialog::on_ypad_spinbutton_changed));
        gtk_size_group_add_widget(_col1, (GtkWidget *) YPadBox.gobj());

        SizesHBox.pack_start(YPadBox, false, false, MARGIN);
    }

    {
    Gtk::HBox *spacer = new Gtk::HBox;
    SizesHBox.pack_start(*spacer, false, false, 0);
    gtk_size_group_add_widget(_col2, (GtkWidget *) spacer->gobj());
    }

    {
        /*#### X padding ####*/

        GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_MENU, "object-columns");
        XPadBox.pack_start (*(Glib::wrap(i)), false, false, MARGIN);

        XPadSpinner.set_digits(1);
        XPadSpinner.set_increments(0.2, 0);
        XPadSpinner.set_range(-10000, 10000);
        double XPad = prefs->getDouble("/dialogs/gridtiler/XPad", 15);
        XPadSpinner.set_value(XPad);
        XPadBox.pack_start(XPadSpinner, true, true, MARGIN);
        tips.set_tip(XPadSpinner, _("Horizontal spacing between columns (px units)"));
        XPadSpinner.signal_changed().connect(sigc::mem_fun(*this, &TileDialog::on_xpad_spinbutton_changed));
        gtk_size_group_add_widget(_col3, (GtkWidget *) XPadBox.gobj());

        SizesHBox.pack_start(XPadBox, false, false, MARGIN);
    }


    TileBox.pack_start(SizesHBox, false, false, MARGIN);

    contents->pack_start(TileBox);

    double SpacingType = prefs->getDouble("/dialogs/gridtiler/SpacingType", 15);
    if (SpacingType>0) {
        ManualSpacing=true;
    } else {
        ManualSpacing=false;
    }
    SpaceManualRadioButton.set_active(ManualSpacing);
    SpaceByBBoxRadioButton.set_active(!ManualSpacing);
    SizesHBox.set_sensitive (ManualSpacing);

    //## The OK button
    TileOkButton = addResponseButton(Q_("tileClonesDialog|Arrange"), GTK_RESPONSE_APPLY);
    tips.set_tip((*TileOkButton), _("Arrange selected objects"));

    show_all_children();
}


Generated by  Doxygen 1.6.0   Back to index