summaryrefslogtreecommitdiffstats
path: root/src/dialogs/stroke-style.cpp
diff options
context:
space:
mode:
authorMenTaLguY <mental@rydia.net>2007-03-04 19:06:11 +0000
committermental <mental@users.sourceforge.net>2007-03-04 19:06:11 +0000
commit99fe98445f78d07574fcf3a4a0243bff9097fdf5 (patch)
treec5d9561625928907ca56505e6fa672108f2ffeef /src/dialogs/stroke-style.cpp
parentimplement new API via wrapper for now (diff)
downloadinkscape-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/stroke-style.cpp')
-rw-r--r--src/dialogs/stroke-style.cpp97
1 files changed, 39 insertions, 58 deletions
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);