diff options
| author | MenTaLguY <mental@rydia.net> | 2007-03-04 19:06:11 +0000 |
|---|---|---|
| committer | mental <mental@users.sourceforge.net> | 2007-03-04 19:06:11 +0000 |
| commit | 99fe98445f78d07574fcf3a4a0243bff9097fdf5 (patch) | |
| tree | c5d9561625928907ca56505e6fa672108f2ffeef /src/dialogs | |
| parent | implement new API via wrapper for now (diff) | |
| download | inkscape-99fe98445f78d07574fcf3a4a0243bff9097fdf5.tar.gz inkscape-99fe98445f78d07574fcf3a4a0243bff9097fdf5.zip | |
switch from invokeBbox to getBounds (need to fix problems with empty
rect handling, though)
(bzr r2536)
Diffstat (limited to 'src/dialogs')
| -rw-r--r-- | src/dialogs/clonetiler.cpp | 18 | ||||
| -rw-r--r-- | src/dialogs/stroke-style.cpp | 97 | ||||
| -rw-r--r-- | src/dialogs/tiledialog.cpp | 14 | ||||
| -rw-r--r-- | src/dialogs/unclump.cpp | 4 |
4 files changed, 56 insertions, 77 deletions
diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 5cd5df143..00fcac48e 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -786,11 +786,6 @@ clonetiler_trace_pick (NR::Rect box) /* Set up pixblock */ guchar *px = g_new(guchar, 4 * width * height); - - if (px == NULL) { - return 0; // buffer is too big or too small, cannot pick, so return 0 - } - memset(px, 0x00, 4 * width * height); /* Render */ @@ -798,7 +793,7 @@ clonetiler_trace_pick (NR::Rect box) nr_pixblock_setup_extern( &pb, NR_PIXBLOCK_MODE_R8G8B8A8N, ibox.x0, ibox.y0, ibox.x1, ibox.y1, px, 4 * width, FALSE, FALSE ); - nr_arena_item_invoke_render(NULL, trace_root, &ibox, &pb, + nr_arena_item_invoke_render( trace_root, &ibox, &pb, NR_ARENA_ITEM_RENDER_NO_CACHE ); double R = 0, G = 0, B = 0, A = 0; @@ -1085,7 +1080,7 @@ clonetiler_apply (GtkWidget *widget, void *) w = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-w", 0); h = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-h", 0); } else { - NR::Rect const r = SP_ITEM(obj)->invokeBbox(sp_item_i2doc_affine(SP_ITEM(obj))); + NR::Rect const r = SP_ITEM(obj)->getBounds(sp_item_i2doc_affine(SP_ITEM(obj))); c = r.midpoint(); w = r.dimensions()[NR::X]; h = r.dimensions()[NR::Y]; @@ -1286,9 +1281,12 @@ clonetiler_apply (GtkWidget *widget, void *) center_set = true; } - gchar *affinestr=sp_svg_transform_write(t); - clone->setAttribute("transform", affinestr); - g_free(affinestr); + gchar affinestr[80]; + if (sp_svg_transform_write(affinestr, 79, t)) { + clone->setAttribute("transform", affinestr); + } else { + clone->setAttribute("transform", NULL); + } if (opacity < 1.0) { sp_repr_set_css_double(clone, "opacity", opacity); diff --git a/src/dialogs/stroke-style.cpp b/src/dialogs/stroke-style.cpp index 58505df97..53c5c722f 100644 --- a/src/dialogs/stroke-style.cpp +++ b/src/dialogs/stroke-style.cpp @@ -83,7 +83,7 @@ static GtkWidget * marker_mid_menu = NULL; static GtkWidget * marker_end_menu = NULL; static SPObject *ink_extract_marker_name(gchar const *n); -static void ink_markers_menu_update(SPWidget* spw); +static void ink_markers_menu_update(); static Inkscape::UI::Cache::SvgPreview svg_preview_cache; @@ -184,6 +184,14 @@ sp_stroke_style_widget_change_subselection ( Inkscape::Application *inkscape, sp_stroke_style_paint_update (spw); } +static void +sp_stroke_style_widget_transientize_callback(Inkscape::Application *inkscape, + SPDesktop *desktop, + SPWidget *spw ) +{ + ink_markers_menu_update(); +} + /** * Gets the active stroke style property, then sets the appropriate color, alpha, gradient, * pattern, etc. for the paint-selector. @@ -559,16 +567,6 @@ sp_stroke_radio_button(GtkWidget *tb, char const *icon, } -static void -sp_stroke_style_widget_transientize_callback(Inkscape::Application *inkscape, - SPDesktop *desktop, - SPWidget *spw ) -{ -// TODO: Either of these will cause crashes sometimes -// sp_stroke_style_line_update( SP_WIDGET(spw), desktop ? sp_desktop_selection(desktop) : NULL); -// ink_markers_menu_update(spw); -} - /** * Creates a copy of the marker named mname, determines its visible and renderable * area in menu_id's bounding box, and then renders it. This allows us to fill in @@ -611,7 +609,7 @@ sp_marker_prev_new(unsigned psize, gchar const *mname, // Find object's bbox in document NR::Matrix const i2doc(sp_item_i2doc_affine(SP_ITEM(object))); - NR::Rect const dbox = SP_ITEM(object)->invokeBbox(i2doc); + NR::Rect const dbox = SP_ITEM(object)->getBounds(i2doc); if (dbox.isEmpty()) { return NULL; @@ -721,6 +719,15 @@ sp_marker_list_from_doc (GtkWidget *m, SPDocument *current_doc, SPDocument *sour GSList *ml = ink_marker_list_get(source); GSList *clean_ml = NULL; + // Do this here, outside of loop, to speed up preview generation: + /* Create new arena */ + NRArena const *arena = NRArena::create(); + /* Create ArenaItem and set transform */ + unsigned const visionkey = sp_item_display_key_new(1); +/* + NRArenaItem *root = sp_item_invoke_show( SP_ITEM(SP_DOCUMENT_ROOT (sandbox)), (NRArena *) arena, visionkey, SP_ITEM_SHOW_DISPLAY ); +*/ + for (; ml != NULL; ml = ml->next) { if (!SP_IS_MARKER(ml->data)) continue; @@ -779,7 +786,7 @@ ink_marker_menu_create_menu(GtkWidget *m, gchar *menu_id, SPDocument *doc, SPDoc GtkWidget *i = gtk_menu_item_new(); gtk_widget_show(i); - g_object_set_data(G_OBJECT(i), "marker", (void *) "none"); +// g_object_set_data(G_OBJECT(i), "marker", (void *) "none"); GtkWidget *hb = gtk_hbox_new(FALSE, MARKER_ITEM_MARGIN); gtk_widget_show(hb); @@ -818,7 +825,6 @@ ink_marker_menu_create_menu(GtkWidget *m, gchar *menu_id, SPDocument *doc, SPDoc sp_document_ensure_up_to_date(doc); sp_marker_list_from_doc ( m, doc, markers_doc, NULL, sandbox, menu_id ); } - } @@ -906,14 +912,9 @@ sp_marker_select(GtkOptionMenu *mnu, GtkWidget *spw) gchar *menu_id = (gchar *) g_object_get_data(G_OBJECT(mnu), "menu_id"); sp_repr_css_set_property(css, menu_id, marker); - // Also update the marker dropdown menus, so the document's markers - // show up at the top of the menu -// sp_stroke_style_line_update( SP_WIDGET(spw), desktop ? sp_desktop_selection(desktop) : NULL); - ink_markers_menu_update(SP_WIDGET(spw)); - - Inkscape::Selection *selection = sp_desktop_selection(desktop); - GSList const *items = selection->itemList(); - for (; items != NULL; items = items->next) { + Inkscape::Selection *selection = sp_desktop_selection(desktop); + GSList const *items = selection->itemList(); + for (; items != NULL; items = items->next) { SPItem *item = (SPItem *) items->data; if (!SP_IS_SHAPE(item) || SP_IS_RECT(item)) // can't set marker to rect, until it's converted to using <path> continue; @@ -930,66 +931,35 @@ sp_marker_select(GtkOptionMenu *mnu, GtkWidget *spw) sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE, _("Set markers")); + // Lastly, also update the marker dropdown menus, so the document's markers + // show up at the top of the menu + ink_markers_menu_update(); }; -static int -ink_marker_menu_get_pos(GtkMenu* mnu, gchar* markname) { - - if (markname == NULL) - markname = (gchar *) g_object_get_data(G_OBJECT(gtk_menu_get_active(mnu)), "marker"); - - if (markname == NULL) - return 0; - - GList *kids = GTK_MENU_SHELL(mnu)->children; - int i = 0; - for (; kids != NULL; kids = kids->next) { - gchar *mark = (gchar *) g_object_get_data(G_OBJECT(kids->data), "marker"); - if ( mark && strcmp(mark, markname) == 0 ) { - break; - } - i++; - } - return i; -} - static void -ink_markers_menu_update(SPWidget* spw) { +ink_markers_menu_update() { SPDesktop *desktop = inkscape_active_desktop(); SPDocument *document = sp_desktop_document(desktop); SPDocument *sandbox = ink_markers_preview_doc (); GtkWidget *m; - int pos; - gtk_signal_handler_block_by_func( GTK_OBJECT(marker_start_menu), GTK_SIGNAL_FUNC(sp_marker_select), spw); - pos = ink_marker_menu_get_pos(GTK_MENU(gtk_option_menu_get_menu(GTK_OPTION_MENU(marker_start_menu))), NULL); m = gtk_menu_new(); gtk_widget_show(m); ink_marker_menu_create_menu(m, "marker-start", document, sandbox); gtk_option_menu_remove_menu(GTK_OPTION_MENU(marker_start_menu)); gtk_option_menu_set_menu(GTK_OPTION_MENU(marker_start_menu), m); - gtk_option_menu_set_history(GTK_OPTION_MENU(marker_start_menu), pos); - gtk_signal_handler_unblock_by_func( GTK_OBJECT(marker_start_menu), GTK_SIGNAL_FUNC(sp_marker_select), spw); - gtk_signal_handler_block_by_func( GTK_OBJECT(marker_mid_menu), GTK_SIGNAL_FUNC(sp_marker_select), spw); - pos = ink_marker_menu_get_pos(GTK_MENU(gtk_option_menu_get_menu(GTK_OPTION_MENU(marker_mid_menu))), NULL); m = gtk_menu_new(); gtk_widget_show(m); ink_marker_menu_create_menu(m, "marker-mid", document, sandbox); gtk_option_menu_remove_menu(GTK_OPTION_MENU(marker_mid_menu)); gtk_option_menu_set_menu(GTK_OPTION_MENU(marker_mid_menu), m); - gtk_option_menu_set_history(GTK_OPTION_MENU(marker_mid_menu), pos); - gtk_signal_handler_unblock_by_func( GTK_OBJECT(marker_mid_menu), GTK_SIGNAL_FUNC(sp_marker_select), spw); - gtk_signal_handler_block_by_func( GTK_OBJECT(marker_end_menu), GTK_SIGNAL_FUNC(sp_marker_select), spw); - pos = ink_marker_menu_get_pos(GTK_MENU(gtk_option_menu_get_menu(GTK_OPTION_MENU(marker_end_menu))), NULL); m = gtk_menu_new(); gtk_widget_show(m); ink_marker_menu_create_menu(m, "marker-end", document, sandbox); gtk_option_menu_remove_menu(GTK_OPTION_MENU(marker_end_menu)); gtk_option_menu_set_menu(GTK_OPTION_MENU(marker_end_menu), m); - gtk_option_menu_set_history(GTK_OPTION_MENU(marker_end_menu), pos); - gtk_signal_handler_unblock_by_func( GTK_OBJECT(marker_end_menu), GTK_SIGNAL_FUNC(sp_marker_select), spw); } /** @@ -1764,7 +1734,17 @@ ink_marker_menu_set_current(SPObject *marker, GtkOptionMenu *mnu) else markname = g_strdup(SP_OBJECT_REPR(marker)->attribute("id")); - int markpos = ink_marker_menu_get_pos(m, markname); + int markpos = 0; + GList *kids = GTK_MENU_SHELL(m)->children; + int i = 0; + for (; kids != NULL; kids = kids->next) { + gchar *mark = (gchar *) g_object_get_data(G_OBJECT(kids->data), "marker"); + if ( mark && strcmp(mark, markname) == 0 ) { + markpos = i; + break; + } + i++; + } gtk_option_menu_set_history(GTK_OPTION_MENU(mnu), markpos); g_free (markname); @@ -1867,6 +1847,7 @@ ink_extract_marker_name(gchar const *n) gchar* b = g_strdup(p); b[c] = '\0'; + SPDesktop *desktop = inkscape_active_desktop(); SPDocument *doc = sp_desktop_document(desktop); SPObject *marker = doc->getObjectById(b); diff --git a/src/dialogs/tiledialog.cpp b/src/dialogs/tiledialog.cpp index 693426d2d..d56d083ba 100644 --- a/src/dialogs/tiledialog.cpp +++ b/src/dialogs/tiledialog.cpp @@ -49,10 +49,10 @@ sp_compare_x_position(SPItem *first, SPItem *second) using NR::X; using NR::Y; - NR::Rect const a = first->invokeBbox(sp_item_i2doc_affine(first)); + NR::Rect const a = first->getBounds(sp_item_i2doc_affine(first)); double const a_height = a.dimensions()[Y]; - NR::Rect const b = second->invokeBbox(sp_item_i2doc_affine(second)); + NR::Rect const b = second->getBounds(sp_item_i2doc_affine(second)); double const b_height = b.dimensions()[Y]; bool a_in_b_vert = false; @@ -84,8 +84,8 @@ sp_compare_x_position(SPItem *first, SPItem *second) int sp_compare_y_position(SPItem *first, SPItem *second) { - NR::Rect const a = first->invokeBbox(sp_item_i2doc_affine(first)); - NR::Rect const b = second->invokeBbox(sp_item_i2doc_affine(second)); + NR::Rect const a = first->getBounds(sp_item_i2doc_affine(first)); + NR::Rect const b = second->getBounds(sp_item_i2doc_affine(second)); if (a.min()[NR::Y] > b.min()[NR::Y]) { return 1; @@ -159,7 +159,7 @@ void TileDialog::Grid_Arrange () cnt=0; for (; items != NULL; items = items->next) { SPItem *item = SP_ITEM(items->data); - NR::Rect const b = item->invokeBbox(sp_item_i2doc_affine(item)); + NR::Rect const b = item->getBounds(sp_item_i2doc_affine(item)); width = b.dimensions()[NR::X]; height = b.dimensions()[NR::Y]; cx = b.midpoint()[NR::X]; @@ -196,7 +196,7 @@ void TileDialog::Grid_Arrange () const GSList *sizes = sorted; for (; sizes != NULL; sizes = sizes->next) { SPItem *item = SP_ITEM(sizes->data); - NR::Rect const b = item->invokeBbox(sp_item_i2doc_affine(item)); + NR::Rect const b = item->getBounds(sp_item_i2doc_affine(item)); width = b.dimensions()[NR::X]; height = b.dimensions()[NR::Y]; if (width > col_widths[(cnt % NoOfCols)]) { @@ -300,7 +300,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::Rect const b = item->invokeBbox(sp_item_i2doc_affine(item)); + NR::Rect const b = item->getBounds(sp_item_i2doc_affine(item)); width = b.dimensions()[NR::X]; height = b.dimensions()[NR::Y]; row = cnt / NoOfCols; diff --git a/src/dialogs/unclump.cpp b/src/dialogs/unclump.cpp index 64c348be5..f067aef5f 100644 --- a/src/dialogs/unclump.cpp +++ b/src/dialogs/unclump.cpp @@ -34,7 +34,7 @@ unclump_center (SPItem *item) return i->second; } - NR::Rect const r = item->invokeBbox(sp_item_i2d_affine(item)); + NR::Rect const r = item->getBounds(sp_item_i2d_affine(item)); NR::Point const c = r.midpoint(); c_cache[SP_OBJECT_ID(item)] = c; return c; @@ -48,7 +48,7 @@ unclump_wh (SPItem *item) if ( i != wh_cache.end() ) { wh = i->second; } else { - NR::Rect const r = item->invokeBbox(sp_item_i2d_affine(item)); + NR::Rect const r = item->getBounds(sp_item_i2d_affine(item)); wh = r.dimensions(); wh_cache[SP_OBJECT_ID(item)] = wh; } |
