X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fdialogs%2Ftiledialog.cpp;h=f9bde3c0b18bf5cabd4aa5f9fe6e26ee489f0a75;hb=8b9a820756fdf348239872236be2257f854e094a;hp=b10f952da5848d9a9dc3e578c274eb14fd7a41fe;hpb=090b64622aefb974887ffe27031360a5022acc99;p=inkscape.git diff --git a/src/dialogs/tiledialog.cpp b/src/dialogs/tiledialog.cpp index b10f952da..f9bde3c0b 100644 --- a/src/dialogs/tiledialog.cpp +++ b/src/dialogs/tiledialog.cpp @@ -49,8 +49,8 @@ sp_compare_x_position(SPItem *first, SPItem *second) using NR::X; using NR::Y; - NR::Maybe a = first->getBounds(sp_item_i2doc_affine(first)); - NR::Maybe b = second->getBounds(sp_item_i2doc_affine(second)); + boost::optional a = first->getBounds(from_2geom(sp_item_i2doc_affine(first))); + boost::optional b = second->getBounds(from_2geom(sp_item_i2doc_affine(second))); if ( !a || !b ) { // FIXME? @@ -89,8 +89,8 @@ sp_compare_x_position(SPItem *first, SPItem *second) int sp_compare_y_position(SPItem *first, SPItem *second) { - NR::Maybe a = first->getBounds(sp_item_i2doc_affine(first)); - NR::Maybe b = second->getBounds(sp_item_i2doc_affine(second)); + boost::optional a = first->getBounds(from_2geom(sp_item_i2doc_affine(first))); + boost::optional b = second->getBounds(from_2geom(sp_item_i2doc_affine(second))); if ( !a || !b ) { // FIXME? @@ -161,7 +161,7 @@ void TileDialog::Grid_Arrange () grid_left = 99999; grid_top = 99999; - SPDesktop *desktop = SP_ACTIVE_DESKTOP; + SPDesktop *desktop = getDesktop(); sp_document_ensure_up_to_date(sp_desktop_document(desktop)); Inkscape::Selection *selection = sp_desktop_selection (desktop); @@ -169,7 +169,7 @@ void TileDialog::Grid_Arrange () cnt=0; for (; items != NULL; items = items->next) { SPItem *item = SP_ITEM(items->data); - NR::Maybe b = item->getBounds(sp_item_i2doc_affine(item)); + boost::optional b = item->getBounds(from_2geom(sp_item_i2doc_affine(item))); if (!b) { continue; } @@ -211,7 +211,7 @@ void TileDialog::Grid_Arrange () const GSList *sizes = sorted; for (; sizes != NULL; sizes = sizes->next) { SPItem *item = SP_ITEM(sizes->data); - NR::Maybe b = item->getBounds(sp_item_i2doc_affine(item)); + boost::optional b = item->getBounds(from_2geom(sp_item_i2doc_affine(item))); if (b) { width = b->dimensions()[NR::X]; height = b->dimensions()[NR::Y]; @@ -268,14 +268,14 @@ void TileDialog::Grid_Arrange () } + boost::optional sel_bbox = selection->bounds(); // Fit to bbox, calculate padding between rows accordingly. - if (!SpaceManualRadioButton.get_active()){ - NR::Rect b = selection->bounds(); + if ( sel_bbox && !SpaceManualRadioButton.get_active() ){ #ifdef DEBUG_GRID_ARRANGE g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_height,total_col_width, b.extent(NR::X), b.extent(NR::Y)); #endif - paddingx = (b.extent(NR::X) - total_col_width) / (NoOfCols -1); - paddingy = (b.extent(NR::Y) - total_row_height) / (NoOfRows -1); + paddingx = (sel_bbox->extent(NR::X) - total_col_width) / (NoOfCols -1); + paddingy = (sel_bbox->extent(NR::Y) - total_row_height) / (NoOfRows -1); } /* @@ -318,7 +318,7 @@ g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_h for (; current_row != NULL; current_row = current_row->next) { SPItem *item=SP_ITEM(current_row->data); Inkscape::XML::Node *repr = SP_OBJECT_REPR(item); - NR::Maybe b = item->getBounds(sp_item_i2doc_affine(item)); + boost::optional b = item->getBounds(from_2geom(sp_item_i2doc_affine(item))); NR::Point min; if (b) { width = b->dimensions()[NR::X]; @@ -338,9 +338,9 @@ g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_h // signs are inverted between x and y due to y inversion NR::Point move = NR::Point(new_x - min[NR::X], min[NR::Y] - new_y); NR::Matrix const &affine = NR::Matrix(NR::translate(move)); - sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * affine); + sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * to_2geom(affine)); sp_item_write_transform(item, repr, item->transform, NULL); - SP_OBJECT (current_row->data)->updateRepr(repr, SP_OBJECT_WRITE_EXT); + SP_OBJECT (current_row->data)->updateRepr(); cnt +=1; } g_slist_free (current_row); @@ -378,7 +378,7 @@ void TileDialog::on_row_spinbutton_changed() // in turn, prevent listener from responding updating = true; - SPDesktop *desktop = SP_ACTIVE_DESKTOP; + SPDesktop *desktop = getDesktop(); Inkscape::Selection *selection = sp_desktop_selection (desktop); @@ -403,7 +403,7 @@ void TileDialog::on_col_spinbutton_changed() // in turn, prevent listener from responding updating = true; - SPDesktop *desktop = SP_ACTIVE_DESKTOP; + SPDesktop *desktop = getDesktop(); Inkscape::Selection *selection = sp_desktop_selection (desktop); GSList const *items = selection->itemList(); @@ -565,7 +565,7 @@ void TileDialog::updateSelection() row_height=0; // in turn, prevent listener from responding updating = true; - SPDesktop *desktop = SP_ACTIVE_DESKTOP; + SPDesktop *desktop = getDesktop(); Inkscape::Selection *selection = sp_desktop_selection (desktop); const GSList *items = selection->itemList(); int selcount = g_slist_length((GSList *)items); @@ -593,13 +593,11 @@ void TileDialog::updateSelection() - - /*########################## ## Experimental ##########################*/ -static void updateSelectionCallback(Inkscape::Application *inkscape, Inkscape::Selection *selection, TileDialog *dlg) +static void updateSelectionCallback(Inkscape::Application */*inkscape*/, Inkscape::Selection */*selection*/, TileDialog *dlg) { TileDialog *tledlg = (TileDialog *) dlg; tledlg->updateSelection(); @@ -613,7 +611,7 @@ static void updateSelectionCallback(Inkscape::Application *inkscape, Inkscape::S * Constructor */ TileDialog::TileDialog() - : Dialog ("dialogs.gridtiler", SP_VERB_SELECTION_GRIDTILE) + : 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; @@ -628,13 +626,13 @@ TileDialog::TileDialog() g_signal_connect ( G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (updateSelectionCallback), this); } - Gtk::VBox *mainVBox = get_vbox(); + Gtk::Box *contents = _getContents(); #define MARGIN 2 //##Set up the panel - SPDesktop *desktop = SP_ACTIVE_DESKTOP; + SPDesktop *desktop = getDesktop(); Inkscape::Selection *selection = sp_desktop_selection (desktop); int selcount = 1; @@ -851,7 +849,7 @@ TileDialog::TileDialog() TileBox.pack_start(SizesHBox, false, false, MARGIN); - mainVBox->pack_start(TileBox); + contents->pack_start(TileBox); double SpacingType = prefs_get_double_attribute ("dialogs.gridtiler", "SpacingType", 15); if (SpacingType>0) { @@ -864,7 +862,7 @@ TileDialog::TileDialog() SizesHBox.set_sensitive (ManualSpacing); //## The OK button - TileOkButton = add_button(Gtk::Stock::APPLY, GTK_RESPONSE_APPLY); + TileOkButton = addResponseButton(_("Arrange"), GTK_RESPONSE_APPLY); tips.set_tip((*TileOkButton), _("Arrange selected objects")); show_all_children();