summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard White <rwhite8282@gmail.com>2016-05-19 01:17:29 +0000
committerRichard White <rwhite8282@gmail.com>2016-05-19 01:17:29 +0000
commit1fe9c2603c33fddcd9f2688b30e843f91e1a86fa (patch)
tree13289cbe033a46a40eb829437e115b5393e2ca84 /src
parentCorrected frame extension stroke and fill values on 64 bit machine. (diff)
parentGTK3: Another widget named. (diff)
downloadinkscape-1fe9c2603c33fddcd9f2688b30e843f91e1a86fa.tar.gz
inkscape-1fe9c2603c33fddcd9f2688b30e843f91e1a86fa.zip
Merge from Inkscape trunk.
(bzr r14668.1.3)
Diffstat (limited to 'src')
-rw-r--r--src/2geom/Makefile_insert1
-rw-r--r--src/2geom/path-sink.h6
-rw-r--r--src/2geom/sbasis-to-bezier.cpp2
-rw-r--r--src/CMakeLists.txt47
-rw-r--r--src/desktop-events.cpp49
-rw-r--r--src/desktop-style.cpp184
-rw-r--r--src/desktop-style.h1
-rw-r--r--src/desktop.cpp26
-rw-r--r--src/desktop.h1
-rw-r--r--src/display/canvas-arena.cpp6
-rw-r--r--src/display/drawing-image.cpp6
-rw-r--r--src/display/drawing-text.cpp16
-rw-r--r--src/display/nr-filter-tile.cpp19
-rw-r--r--src/display/sp-canvas-item.h1
-rw-r--r--src/display/sp-canvas.cpp1119
-rw-r--r--src/display/sp-canvas.h194
-rw-r--r--src/document.cpp13
-rw-r--r--src/extension/CMakeLists.txt19
-rw-r--r--src/extension/Makefile_insert2
-rw-r--r--src/extension/dbus/CMakeLists.txt29
-rw-r--r--src/extension/dbus/document-interface.cpp6
-rw-r--r--src/extension/dependency.cpp12
-rw-r--r--src/extension/dependency.h1
-rw-r--r--src/extension/execution-env.cpp2
-rw-r--r--src/extension/implementation/implementation.h24
-rw-r--r--src/extension/implementation/script.cpp62
-rw-r--r--src/extension/implementation/script.h45
-rw-r--r--src/extension/init.cpp2
-rw-r--r--src/extension/internal/cairo-render-context.cpp90
-rw-r--r--src/extension/internal/cairo-render-context.h9
-rw-r--r--src/extension/internal/cairo-renderer.cpp30
-rw-r--r--src/extension/internal/cdr-input.cpp179
-rw-r--r--src/extension/internal/emf-print.cpp2
-rw-r--r--src/extension/internal/image-resolution.cpp78
-rw-r--r--src/extension/internal/text_reassemble.c82
-rw-r--r--src/extension/internal/vsd-input.cpp183
-rw-r--r--src/extension/loader.cpp137
-rw-r--r--src/extension/loader.h73
-rw-r--r--src/extension/output.cpp3
-rw-r--r--src/extension/plugins/CMakeLists.txt1
-rw-r--r--src/extension/plugins/grid2/CMakeLists.txt8
-rw-r--r--src/extension/plugins/grid2/grid.cpp220
-rw-r--r--src/extension/plugins/grid2/grid.h58
-rw-r--r--src/extension/plugins/grid2/libgrid2.inx20
-rw-r--r--src/extension/system.cpp26
-rw-r--r--src/helper/geom-pathstroke.cpp8
-rw-r--r--src/inkscape-version.cpp.in7
-rw-r--r--src/inkview.cpp333
-rw-r--r--src/io/inkjar.h8
-rw-r--r--src/libgdl/gdl-dock-bar.c2
-rw-r--r--src/libnrtype/Layout-TNG-Compute.cpp5
-rw-r--r--src/libnrtype/Layout-TNG-Scanline-Makers.cpp3
-rw-r--r--src/livarot/LivarotDefs.h12
-rw-r--r--src/livarot/PathOutline.cpp9
-rw-r--r--src/live_effects/effect.cpp28
-rw-r--r--src/live_effects/effect.h2
-rw-r--r--src/live_effects/lpe-bendpath.cpp5
-rw-r--r--src/live_effects/lpe-copy_rotate.cpp324
-rw-r--r--src/live_effects/lpe-copy_rotate.h20
-rw-r--r--src/live_effects/lpe-envelope.cpp4
-rw-r--r--src/live_effects/lpe-jointype.cpp2
-rw-r--r--src/live_effects/lpe-jointype.h2
-rw-r--r--src/live_effects/lpe-lattice.cpp5
-rw-r--r--src/live_effects/lpe-lattice2.cpp4
-rw-r--r--src/live_effects/lpe-mirror_symmetry.cpp330
-rw-r--r--src/live_effects/lpe-mirror_symmetry.h37
-rw-r--r--src/live_effects/lpe-offset.cpp10
-rw-r--r--src/live_effects/lpe-offset.h2
-rw-r--r--src/live_effects/lpe-patternalongpath.cpp7
-rw-r--r--src/live_effects/lpe-patternalongpath.h2
-rw-r--r--src/live_effects/lpe-perspective-envelope.cpp4
-rw-r--r--src/live_effects/lpe-perspective_path.cpp3
-rw-r--r--src/live_effects/lpe-roughen.cpp4
-rw-r--r--src/live_effects/lpe-simplify.cpp4
-rw-r--r--src/live_effects/lpe-transform_2pts.cpp3
-rw-r--r--src/live_effects/lpe-vonkoch.cpp5
-rw-r--r--src/live_effects/parameter/filletchamferpointarray.cpp2
-rw-r--r--src/live_effects/parameter/originalpatharray.cpp8
-rw-r--r--src/live_effects/parameter/path.cpp7
-rw-r--r--src/main-cmdlineact.cpp2
-rw-r--r--src/main-cmdlineact.h2
-rw-r--r--src/main.cpp85
-rw-r--r--src/menus-skeleton.h3
-rw-r--r--src/path-chemistry.cpp32
-rw-r--r--src/path-chemistry.h4
-rw-r--r--src/preferences-skeleton.h1
-rw-r--r--src/selection-chemistry.cpp36
-rw-r--r--src/selection-chemistry.h1
-rw-r--r--src/sp-flowtext.h5
-rw-r--r--src/sp-item.cpp1
-rw-r--r--src/sp-lpe-item.cpp199
-rw-r--r--src/sp-lpe-item.h4
-rw-r--r--src/sp-offset.cpp4
-rw-r--r--src/sp-pattern.cpp9
-rw-r--r--src/sp-text.cpp11
-rw-r--r--src/splivarot.cpp20
-rw-r--r--src/splivarot.h1
-rw-r--r--src/style.cpp6
-rw-r--r--src/svg-view-widget.cpp16
-rw-r--r--src/svg-view.cpp3
-rw-r--r--src/svg/svg-length-test.h5
-rw-r--r--src/svg/svg-length.cpp20
-rw-r--r--src/svg/svg-length.h2
-rw-r--r--src/trace/trace.cpp1
-rw-r--r--src/ui/cache/svg_preview_cache.cpp2
-rw-r--r--src/ui/clipboard.cpp45
-rw-r--r--src/ui/control-manager.cpp56
-rw-r--r--src/ui/control-manager.h2
-rw-r--r--src/ui/dialog/aboutbox.cpp918
-rw-r--r--src/ui/dialog/align-and-distribute.cpp125
-rw-r--r--src/ui/dialog/align-and-distribute.h13
-rw-r--r--src/ui/dialog/clonetiler.cpp24
-rw-r--r--src/ui/dialog/color-item.cpp2
-rw-r--r--src/ui/dialog/filter-effects-dialog.cpp78
-rw-r--r--src/ui/dialog/filter-effects-dialog.h11
-rw-r--r--src/ui/dialog/glyphs.h2
-rw-r--r--src/ui/dialog/inkscape-preferences.cpp15
-rw-r--r--src/ui/dialog/inkscape-preferences.h1
-rw-r--r--src/ui/dialog/new-from-template.cpp18
-rw-r--r--src/ui/dialog/new-from-template.h6
-rw-r--r--src/ui/dialog/object-properties.cpp2
-rw-r--r--src/ui/dialog/object-properties.h2
-rw-r--r--src/ui/dialog/objects.cpp4
-rw-r--r--src/ui/dialog/ocaldialogs.cpp4
-rw-r--r--src/ui/dialog/ocaldialogs.h6
-rw-r--r--src/ui/dialog/swatches.cpp12
-rw-r--r--src/ui/dialog/tags.cpp12
-rw-r--r--src/ui/dialog/template-load-tab.cpp38
-rw-r--r--src/ui/dialog/template-load-tab.h4
-rw-r--r--src/ui/dialog/template-widget.cpp26
-rw-r--r--src/ui/dialog/template-widget.h1
-rw-r--r--src/ui/draw-anchor.cpp3
-rw-r--r--src/ui/interface.cpp30
-rw-r--r--src/ui/interface.h1
-rw-r--r--src/ui/previewholder.cpp10
-rw-r--r--src/ui/previewholder.h1
-rw-r--r--src/ui/selected-color.cpp1
-rw-r--r--src/ui/tool/control-point-selection.cpp29
-rw-r--r--src/ui/tool/control-point-selection.h3
-rw-r--r--src/ui/tool/event-utils.cpp8
-rw-r--r--src/ui/tool/path-manipulator.cpp2
-rw-r--r--src/ui/tools/connector-tool.cpp4
-rw-r--r--src/ui/tools/eraser-tool.cpp208
-rw-r--r--src/ui/tools/eraser-tool.h1
-rw-r--r--src/ui/tools/freehand-base.cpp5
-rw-r--r--src/ui/tools/measure-tool.cpp7
-rw-r--r--src/ui/tools/pen-tool.cpp21
-rw-r--r--src/ui/tools/pencil-tool.cpp16
-rw-r--r--src/ui/tools/zoom-tool.cpp2
-rw-r--r--src/ui/widget/addtoicon.cpp1
-rw-r--r--src/ui/widget/color-icc-selector.cpp13
-rw-r--r--src/ui/widget/color-notebook.cpp4
-rw-r--r--src/ui/widget/color-preview.cpp1
-rw-r--r--src/ui/widget/color-scales.cpp6
-rw-r--r--src/ui/widget/color-wheel-selector.cpp8
-rw-r--r--src/ui/widget/dock.cpp1
-rw-r--r--src/ui/widget/gimpcolorwheel.c8
-rw-r--r--src/ui/widget/layer-selector.cpp5
-rw-r--r--src/ui/widget/panel.cpp10
-rw-r--r--src/ui/widget/panel.h4
-rw-r--r--src/ui/widget/preferences-widget.cpp4
-rw-r--r--src/ui/widget/selected-style.cpp25
-rw-r--r--src/ui/widget/style-swatch.cpp2
-rw-r--r--src/ui/widget/unit-tracker.cpp10
-rw-r--r--src/ui/widget/unit-tracker.h1
-rw-r--r--src/unclump.cpp8
-rw-r--r--src/util/units.cpp37
-rw-r--r--src/util/units.h5
-rw-r--r--src/verbs.cpp13
-rw-r--r--src/verbs.h1
-rw-r--r--src/widgets/CMakeLists.txt10
-rw-r--r--src/widgets/Makefile_insert8
-rw-r--r--src/widgets/button.cpp24
-rw-r--r--src/widgets/desktop-widget.cpp186
-rw-r--r--src/widgets/eek-preview.cpp34
-rw-r--r--src/widgets/ege-adjustment-action.cpp6
-rw-r--r--src/widgets/ege-select-one-action.cpp13
-rw-r--r--src/widgets/eraser-toolbar.cpp82
-rw-r--r--src/widgets/font-selector.cpp17
-rw-r--r--src/widgets/gradient-vector.cpp6
-rw-r--r--src/widgets/icon.cpp46
-rw-r--r--src/widgets/image-menu-item.c1071
-rw-r--r--src/widgets/image-menu-item.h81
-rw-r--r--src/widgets/ink-action.cpp42
-rw-r--r--src/widgets/ink-comboboxentry-action.cpp18
-rw-r--r--src/widgets/ruler.cpp376
-rw-r--r--src/widgets/select-toolbar.cpp160
-rw-r--r--src/widgets/shrink-wrap-button.cpp65
-rw-r--r--src/widgets/shrink-wrap-button.h35
-rw-r--r--src/widgets/spw-utilities.cpp43
-rw-r--r--src/widgets/stroke-style.cpp219
-rw-r--r--src/widgets/stroke-style.h11
-rw-r--r--src/widgets/swatch-selector.cpp48
-rw-r--r--src/widgets/text-toolbar.cpp293
-rw-r--r--src/widgets/toolbox.cpp21
195 files changed, 6699 insertions, 2942 deletions
diff --git a/src/2geom/Makefile_insert b/src/2geom/Makefile_insert
index b56942caa..4d41de297 100644
--- a/src/2geom/Makefile_insert
+++ b/src/2geom/Makefile_insert
@@ -45,7 +45,6 @@
2geom/curves.h \
2geom/d2.h \
2geom/d2-sbasis.cpp \
- 2geom/d2-sbasis.h \
2geom/ellipse.cpp \
2geom/ellipse.h \
2geom/elliptical-arc.cpp \
diff --git a/src/2geom/path-sink.h b/src/2geom/path-sink.h
index 17ede18a4..3bdb00783 100644
--- a/src/2geom/path-sink.h
+++ b/src/2geom/path-sink.h
@@ -179,8 +179,10 @@ public:
}
void closePath() {
- _path.close();
- flush();
+ if (_in_path) {
+ _path.close();
+ flush();
+ }
}
void flush() {
diff --git a/src/2geom/sbasis-to-bezier.cpp b/src/2geom/sbasis-to-bezier.cpp
index 8a18cfd4a..64c07f35e 100644
--- a/src/2geom/sbasis-to-bezier.cpp
+++ b/src/2geom/sbasis-to-bezier.cpp
@@ -197,6 +197,8 @@ void sbasis_to_cubic_bezier (std::vector<Point> & bz, D2<SBasis> const& sb)
}
sbasis_to_bezier(bz, sb, 4); // zeroth-order estimate
+ if ((sb[X].size() < 3) && (sb[Y].size() < 3))
+ return; // cubic bezier estimate is exact
Geom::ConvexHull bezhull(bz);
// calculate first derivatives of x and y wrt t
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 30af55925..df25728f4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -443,11 +443,6 @@ endif()
# a custom target that is always built
add_custom_target(
inkscape_version ALL
- DEPENDS ${CMAKE_BINARY_DIR}/src/inkscape-version.cpp)
-
-# creates inkscape-version.cpp using cmake script
-add_custom_command(
- OUTPUT ${CMAKE_BINARY_DIR}/src/inkscape-version.cpp
COMMAND ${CMAKE_COMMAND}
-DINKSCAPE_SOURCE_DIR=${CMAKE_SOURCE_DIR}
-DINKSCAPE_BINARY_DIR=${CMAKE_BINARY_DIR}
@@ -511,14 +506,14 @@ set(inkscape_SRC
#add_inkscape_lib(sp_LIB "${sp_SRC}")
#add_inkscape_lib(inkscape_LIB "${inkscape_SRC}")
-# Build everything except main and inkview.c in a CMake "object" library.
-# An object library is just a bunch of .o files. Linking them with main.c or inkview.c
-# we get the inkscape and inkview executables respectively.
-add_library(inkscape_base OBJECT ${inkscape_SRC} ${sp_SRC})
+# Build everything except main and inkview.c in a shared library.
+add_library(inkscape_base SHARED ${inkscape_SRC} ${sp_SRC})
# make executables for inkscape and inkview
-add_executable(inkscape ${main_SRC} $<TARGET_OBJECTS:inkscape_base>)
-add_executable(inkview inkview.cpp $<TARGET_OBJECTS:inkscape_base>)
+add_executable(inkscape ${main_SRC} )
+add_executable(inkview inkview.cpp )
+
+
if(UNIX)
# message after building.
@@ -531,8 +526,8 @@ endif()
add_dependencies(inkscape inkscape_version)
-if (NOT "${WITH_EXT_GDL}")
- list (APPEND INKSCAPE_LIBS "gdl_LIB")
+if(WITH_DBUS)
+ add_dependencies(inkscape inkscape_dbus)
endif()
set(INKSCAPE_TARGET_LIBS
@@ -557,5 +552,27 @@ set(INKSCAPE_TARGET_LIBS
${INKSCAPE_LIBS}
)
-target_link_libraries(inkscape ${INKSCAPE_TARGET_LIBS})
-target_link_libraries(inkview ${INKSCAPE_TARGET_LIBS})
+if (NOT "${WITH_EXT_GDL}")
+ # Insert it at the beginning of the list as the windows build fails otherwise
+ list (INSERT INKSCAPE_TARGET_LIBS 0 "gdl_LIB")
+endif()
+
+
+
+
+# Link the inkscape_base library against all external dependencies
+target_link_libraries(inkscape_base ${INKSCAPE_TARGET_LIBS})
+
+# Link inkscape and inkview against inkscape_base
+target_link_libraries(inkscape inkscape_base )
+target_link_libraries(inkview inkscape_base)
+
+#Define the installation
+install(
+ TARGETS inkscape_base inkscape inkview
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib/inkscape
+ ARCHIVE DESTINATION lib/inkscape
+ )
+
+
diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp
index 99bc4f7ae..b9bd949ff 100644
--- a/src/desktop-events.cpp
+++ b/src/desktop-events.cpp
@@ -519,34 +519,29 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data)
if (!guide->getLocked()) {
sp_guideline_set_color(SP_GUIDELINE(item), guide->getHiColor());
}
+
// set move or rotate cursor
Geom::Point const event_w(event->crossing.x, event->crossing.y);
+ GdkDisplay *display = gdk_display_get_default();
+ GdkCursorType cursor_type;
+
if ((event->crossing.state & GDK_SHIFT_MASK) && (drag_type != SP_DRAG_MOVE_ORIGIN)) {
- GdkCursor *guide_cursor;
- guide_cursor = gdk_cursor_new (GDK_EXCHANGE);
- if(guide->getLocked()){
- guide_cursor = sp_cursor_new_from_xpm(cursor_select_xpm , 1, 1);
- }
- gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(desktop->getCanvas())), guide_cursor);
-#if GTK_CHECK_VERSION(3,0,0)
- g_object_unref(guide_cursor);
-#else
- gdk_cursor_unref(guide_cursor);
-#endif
+ cursor_type = GDK_EXCHANGE;
} else {
- GdkCursor *guide_cursor;
- guide_cursor = gdk_cursor_new (GDK_HAND1);
- if(guide->getLocked()){
- guide_cursor = sp_cursor_new_from_xpm(cursor_select_xpm , 1, 1);
- }
- gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(desktop->getCanvas())), guide_cursor);
+ cursor_type = GDK_HAND1;
+ }
+
+ GdkCursor *guide_cursor = gdk_cursor_new_for_display(display, cursor_type);
+ if(guide->getLocked()){
+ guide_cursor = sp_cursor_new_from_xpm(cursor_select_xpm , 1, 1);
+ }
+ gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(desktop->getCanvas())), guide_cursor);
#if GTK_CHECK_VERSION(3,0,0)
- g_object_unref(guide_cursor);
+ g_object_unref(guide_cursor);
#else
- gdk_cursor_unref(guide_cursor);
+ gdk_cursor_unref(guide_cursor);
#endif
- }
char *guide_description = guide->description();
desktop->guidesMessageContext()->setF(Inkscape::NORMAL_MESSAGE, _("<b>Guideline</b>: %s"), guide_description);
@@ -577,11 +572,11 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data)
case GDK_KEY_Shift_L:
case GDK_KEY_Shift_R:
if (drag_type != SP_DRAG_MOVE_ORIGIN) {
- GdkCursor *guide_cursor;
- guide_cursor = gdk_cursor_new (GDK_EXCHANGE);
+ GdkDisplay *display = gdk_display_get_default();
+ GdkCursor *guide_cursor = gdk_cursor_new_for_display(display, GDK_EXCHANGE);
gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(desktop->getCanvas())), guide_cursor);
#if GTK_CHECK_VERSION(3,0,0)
- g_object_unref(guide_cursor);
+ g_object_unref(guide_cursor);
#else
gdk_cursor_unref(guide_cursor);
#endif
@@ -598,15 +593,17 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data)
switch (Inkscape::UI::Tools::get_group0_keyval (&event->key)) {
case GDK_KEY_Shift_L:
case GDK_KEY_Shift_R:
- GdkCursor *guide_cursor;
- guide_cursor = gdk_cursor_new (GDK_EXCHANGE);
+ {
+ GdkDisplay *display = gdk_display_get_default();
+ GdkCursor *guide_cursor = gdk_cursor_new_for_display(display, GDK_EXCHANGE);
gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(desktop->getCanvas())), guide_cursor);
#if GTK_CHECK_VERSION(3,0,0)
- g_object_unref(guide_cursor);
+ g_object_unref(guide_cursor);
#else
gdk_cursor_unref(guide_cursor);
#endif
break;
+ }
default:
// do nothing;
break;
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp
index a81cbdd1f..7f9b46c7d 100644
--- a/src/desktop-style.cpp
+++ b/src/desktop-style.cpp
@@ -881,8 +881,7 @@ objects_query_strokecap (const std::vector<SPItem*> &objects, SPStyle *style_res
return QUERY_STYLE_NOTHING;
}
- int cap = -1;
- gdouble prev_cap = -1;
+ int prev_cap = -1;
bool same_cap = true;
int n_stroked = 0;
@@ -905,11 +904,9 @@ objects_query_strokecap (const std::vector<SPItem*> &objects, SPStyle *style_res
if (prev_cap != -1 && style->stroke_linecap.value != prev_cap)
same_cap = false;
prev_cap = style->stroke_linecap.value;
-
- cap = style->stroke_linecap.value;
}
- style_res->stroke_linecap.value = cap;
+ style_res->stroke_linecap.value = prev_cap;
style_res->stroke_linecap.set = true;
if (n_stroked == 0) {
@@ -935,8 +932,7 @@ objects_query_strokejoin (const std::vector<SPItem*> &objects, SPStyle *style_re
return QUERY_STYLE_NOTHING;
}
- int join = -1;
- gdouble prev_join = -1;
+ int prev_join = -1;
bool same_join = true;
int n_stroked = 0;
@@ -960,11 +956,9 @@ objects_query_strokejoin (const std::vector<SPItem*> &objects, SPStyle *style_re
same_join = false;
}
prev_join = style->stroke_linejoin.value;
-
- join = style->stroke_linejoin.value;
}
- style_res->stroke_linejoin.value = join;
+ style_res->stroke_linejoin.value = prev_join;
style_res->stroke_linejoin.set = true;
if (n_stroked == 0) {
@@ -980,25 +974,86 @@ objects_query_strokejoin (const std::vector<SPItem*> &objects, SPStyle *style_re
}
/**
+ * Write to style_res the paint order of a list of objects.
+ */
+int
+objects_query_paintorder (const std::vector<SPItem*> &objects, SPStyle *style_res)
+{
+ if (objects.empty()) {
+ /* No objects, set empty */
+ return QUERY_STYLE_NOTHING;
+ }
+
+ std::string prev_order;
+ bool same_order = true;
+ int n_order = 0;
+
+ for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); ++i) {
+ SPObject *obj = *i;
+ if (!dynamic_cast<SPItem *>(obj)) {
+ continue;
+ }
+ SPStyle *style = obj->style;
+ if (!style) {
+ continue;
+ }
+
+ if ( style->stroke.isNone() ) {
+ continue;
+ }
+
+ n_order ++;
+
+ if (style->paint_order.set) {
+ if (!prev_order.empty() && prev_order.compare( style->paint_order.value ) != 0) {
+ same_order = false;
+ }
+ prev_order = style->paint_order.value;
+ }
+ }
+
+
+ g_free( style_res->paint_order.value );
+ style_res->paint_order.value= g_strdup( prev_order.c_str() );
+ style_res->paint_order.set = true;
+
+ if (n_order == 0) {
+ return QUERY_STYLE_NOTHING;
+ } else if (n_order == 1) {
+ return QUERY_STYLE_SINGLE;
+ } else {
+ if (same_order)
+ return QUERY_STYLE_MULTIPLE_SAME;
+ else
+ return QUERY_STYLE_MULTIPLE_DIFFERENT;
+ }
+}
+
+/**
* Write to style_res the average font size and spacing of objects.
*/
int
objects_query_fontnumbers (const std::vector<SPItem*> &objects, SPStyle *style_res)
{
bool different = false;
+ bool different_lineheight = false;
+ bool different_lineheight_unit = false;
double size = 0;
double letterspacing = 0;
double wordspacing = 0;
- double linespacing = 0;
+ double lineheight = 0;
bool letterspacing_normal = false;
bool wordspacing_normal = false;
- bool linespacing_normal = false;
+ bool lineheight_normal = false;
+ bool lineheight_unit_proportional = false;
+ bool lineheight_unit_absolute = false;
double size_prev = 0;
double letterspacing_prev = 0;
double wordspacing_prev = 0;
- double linespacing_prev = 0;
+ double lineheight_prev = 0;
+ int lineheight_unit_prev = -1;
int texts = 0;
int no_size = 0;
@@ -1018,7 +1073,12 @@ objects_query_fontnumbers (const std::vector<SPItem*> &objects, SPStyle *style_r
texts ++;
SPItem *item = dynamic_cast<SPItem *>(obj);
g_assert(item != NULL);
- double dummy = style->font_size.computed * Geom::Affine(item->i2dt_affine()).descrim();
+
+ // Quick way of getting document scale. Should be same as:
+ // item->document->getDocumentScale().Affine().descrim()
+ double doc_scale = Geom::Affine(item->i2dt_affine()).descrim();
+
+ double dummy = style->font_size.computed * doc_scale;
if (!IS_NAN(dummy)) {
size += dummy; /// \todo FIXME: we assume non-% units here
} else {
@@ -1030,7 +1090,7 @@ objects_query_fontnumbers (const std::vector<SPItem*> &objects, SPStyle *style_r
letterspacing_normal = true;
}
} else {
- letterspacing += style->letter_spacing.computed * Geom::Affine(item->i2dt_affine()).descrim(); /// \todo FIXME: we assume non-% units here
+ letterspacing += style->letter_spacing.computed * doc_scale;; /// \todo FIXME: we assume non-% units here
letterspacing_normal = false;
}
@@ -1039,35 +1099,60 @@ objects_query_fontnumbers (const std::vector<SPItem*> &objects, SPStyle *style_r
wordspacing_normal = true;
}
} else {
- wordspacing += style->word_spacing.computed * Geom::Affine(item->i2dt_affine()).descrim(); /// \todo FIXME: we assume non-% units here
+ wordspacing += style->word_spacing.computed * doc_scale; /// \todo FIXME: we assume non-% units here
wordspacing_normal = false;
}
- double linespacing_current;
+ // If all line spacing units the same, use that (average line spacing).
+ // Else if all line spacings absolute, use 'px' (average line spacing).
+ // Else if all line spacings proportional, use % (average line spacing).
+ // Else use default.
+ double lineheight_current;
+ int lineheight_unit_current;
if (style->line_height.normal) {
- linespacing_current = Inkscape::Text::Layout::LINE_HEIGHT_NORMAL;
- if (!different && (linespacing_prev == 0 || linespacing_prev == linespacing_current))
- linespacing_normal = true;
- } else if (style->line_height.unit == SP_CSS_UNIT_PERCENT || style->font_size.computed == 0) {
- linespacing_current = style->line_height.value;
- linespacing_normal = false;
+ lineheight_current = Inkscape::Text::Layout::LINE_HEIGHT_NORMAL;
+ lineheight_unit_current = SP_CSS_UNIT_NONE;
+ if (!different_lineheight &&
+ (lineheight_prev == 0 || lineheight_prev == lineheight_current))
+ lineheight_normal = true;
+ } else if (style->line_height.unit == SP_CSS_UNIT_NONE ||
+ style->line_height.unit == SP_CSS_UNIT_PERCENT ||
+ style->line_height.unit == SP_CSS_UNIT_EM ||
+ style->line_height.unit == SP_CSS_UNIT_EX ||
+ style->font_size.computed == 0) {
+ lineheight_current = style->line_height.value;
+ lineheight_unit_current = style->line_height.unit;
+ lineheight_unit_proportional = true;
+ lineheight_normal = false;
+ lineheight += lineheight_current;
} else {
- linespacing_current = style->line_height.computed;
- linespacing_normal = false;
+ // Always 'px' internally
+ lineheight_current = style->line_height.computed;
+ lineheight_unit_current = style->line_height.unit;
+ lineheight_unit_absolute = true;
+ lineheight_normal = false;
+ lineheight += lineheight_current * doc_scale;
}
- linespacing += linespacing_current;
if ((size_prev != 0 && style->font_size.computed != size_prev) ||
(letterspacing_prev != 0 && style->letter_spacing.computed != letterspacing_prev) ||
- (wordspacing_prev != 0 && style->word_spacing.computed != wordspacing_prev) ||
- (linespacing_prev != 0 && linespacing_current != linespacing_prev)) {
+ (wordspacing_prev != 0 && style->word_spacing.computed != wordspacing_prev)) {
different = true;
}
+ if (lineheight_prev != 0 && lineheight_current != lineheight_prev) {
+ different_lineheight = true;
+ }
+
+ if (lineheight_unit_prev != -1 && lineheight_unit_current != lineheight_unit_prev) {
+ different_lineheight_unit = true;
+ }
+
size_prev = style->font_size.computed;
letterspacing_prev = style->letter_spacing.computed;
wordspacing_prev = style->word_spacing.computed;
- linespacing_prev = linespacing_current;
+ lineheight_prev = lineheight_current;
+ lineheight_unit_prev = lineheight_unit_current;
// FIXME: we must detect MULTIPLE_DIFFERENT for these too
style_res->text_anchor.computed = style->text_anchor.computed;
@@ -1083,7 +1168,7 @@ objects_query_fontnumbers (const std::vector<SPItem*> &objects, SPStyle *style_r
}
letterspacing /= texts;
wordspacing /= texts;
- linespacing /= texts;
+ lineheight /= texts;
}
style_res->font_size.computed = size;
@@ -1095,13 +1180,36 @@ objects_query_fontnumbers (const std::vector<SPItem*> &objects, SPStyle *style_r
style_res->word_spacing.normal = wordspacing_normal;
style_res->word_spacing.computed = wordspacing;
- style_res->line_height.normal = linespacing_normal;
- style_res->line_height.computed = linespacing;
- style_res->line_height.value = linespacing;
- style_res->line_height.unit = SP_CSS_UNIT_PERCENT;
+ style_res->line_height.normal = lineheight_normal;
+ style_res->line_height.computed = lineheight;
+ style_res->line_height.value = lineheight;
+ if (different_lineheight_unit) {
+ if (lineheight_unit_absolute && !lineheight_unit_proportional) {
+ // Mixture of absolute units
+ style_res->line_height.unit = SP_CSS_UNIT_PX;
+ } else {
+ // Mixture of relative units
+ style_res->line_height.unit = SP_CSS_UNIT_PERCENT;
+ }
+ if (lineheight_unit_absolute && lineheight_unit_proportional) {
+ // Mixed types of units, fallback to default
+ style_res->line_height.computed = Inkscape::Text::Layout::LINE_HEIGHT_NORMAL * 100.0;
+ style_res->line_height.value = Inkscape::Text::Layout::LINE_HEIGHT_NORMAL * 100.0;
+ }
+ } else {
+ // Same units.
+ if (lineheight_unit_prev != -1) {
+ style_res->line_height.unit = lineheight_unit_prev;
+ } else {
+ // No text object... use default.
+ style_res->line_height.unit = SP_CSS_UNIT_NONE;
+ style_res->line_height.computed = Inkscape::Text::Layout::LINE_HEIGHT_NORMAL;
+ style_res->line_height.value = Inkscape::Text::Layout::LINE_HEIGHT_NORMAL;
+ }
+ }
if (texts > 1) {
- if (different) {
+ if (different || different_lineheight) {
return QUERY_STYLE_MULTIPLE_AVERAGED;
} else {
return QUERY_STYLE_MULTIPLE_SAME;
@@ -1763,6 +1871,8 @@ sp_desktop_query_style_from_list (const std::vector<SPItem*> &list, SPStyle *sty
} else if (property == QUERY_STYLE_PROPERTY_STROKEJOIN) {
return objects_query_strokejoin (list, style);
+ } else if (property == QUERY_STYLE_PROPERTY_PAINTORDER) {
+ return objects_query_paintorder (list, style);
} else if (property == QUERY_STYLE_PROPERTY_MASTEROPACITY) {
return objects_query_opacity (list, style);
@@ -1829,6 +1939,9 @@ sp_desktop_query_style_all (SPDesktop *desktop, SPStyle *query)
int result_strokemiterlimit = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKEMITERLIMIT);
int result_strokecap = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKECAP);
int result_strokejoin = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKEJOIN);
+
+ int result_paintorder = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_PAINTORDER);
+
int result_opacity = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_MASTEROPACITY);
int result_blur = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_BLUR);
@@ -1842,6 +1955,7 @@ sp_desktop_query_style_all (SPDesktop *desktop, SPStyle *query)
result_strokemiterlimit != QUERY_STYLE_NOTHING ||
result_strokecap != QUERY_STYLE_NOTHING ||
result_strokejoin != QUERY_STYLE_NOTHING ||
+ result_paintorder != QUERY_STYLE_NOTHING ||
result_blur != QUERY_STYLE_NOTHING);
}
diff --git a/src/desktop-style.h b/src/desktop-style.h
index bf05adadf..f3d6775a4 100644
--- a/src/desktop-style.h
+++ b/src/desktop-style.h
@@ -43,6 +43,7 @@ enum { // which property was queried (add when you need more)
QUERY_STYLE_PROPERTY_STROKEJOIN, // stroke join
QUERY_STYLE_PROPERTY_STROKECAP, // stroke cap
QUERY_STYLE_PROPERTY_STROKESTYLE, // markers, dasharray, miterlimit, stroke-width, stroke-cap, stroke-join
+ QUERY_STYLE_PROPERTY_PAINTORDER, // paint-order
QUERY_STYLE_PROPERTY_FONT_SPECIFICATION, //-inkscape-font-specification
QUERY_STYLE_PROPERTY_FONTFAMILY, // font-family
QUERY_STYLE_PROPERTY_FONTSTYLE, // font style
diff --git a/src/desktop.cpp b/src/desktop.cpp
index f099ba39f..d482d0d7f 100644
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
@@ -111,7 +111,6 @@ SPDesktop::SPDesktop() :
sketch( NULL ),
controls( NULL ),
tempgroup ( NULL ),
- table( NULL ),
page( NULL ),
page_border( NULL ),
current( NULL ),
@@ -211,11 +210,7 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid
g_signal_connect (G_OBJECT (main), "event", G_CALLBACK (sp_desktop_root_handler), this);
/* This is the background the page sits on. */
- table = sp_canvas_item_new (main, SP_TYPE_CTRLRECT, NULL);
- SP_CTRLRECT(table)->setRectangle(Geom::Rect(Geom::Point(-80000, -80000), Geom::Point(80000, 80000)));
- SP_CTRLRECT(table)->setColor(0x00000000, true, 0x00000000);
- SP_CTRLRECT(table)->setCheckerboard( false );
- sp_canvas_item_move_to_z (table, 0);
+ canvas->setBackgroundColor(0xffffff00);
page = sp_canvas_item_new (main, SP_TYPE_CTRLRECT, NULL);
((CtrlRect *) page)->setColor(0x00000000, FALSE, 0x00000000);
@@ -501,7 +496,7 @@ void SPDesktop::redrawDesktop() {
void SPDesktop::_setDisplayMode(Inkscape::RenderMode mode) {
SP_CANVAS_ARENA (drawing)->drawing.setRenderMode(mode);
- canvas->rendermode = mode;
+ canvas->_rendermode = mode;
_display_mode = mode;
redrawDesktop();
_widget->setTitle( this->getDocument()->getName() );
@@ -522,7 +517,7 @@ void SPDesktop::_setDisplayColorMode(Inkscape::ColorMode mode) {
}
SP_CANVAS_ARENA (drawing)->drawing.setColorMode(mode);
- canvas->colorrendermode = mode;
+ canvas->_colorrendermode = mode;
_display_color_mode = mode;
redrawDesktop();
_widget->setTitle( this->getDocument()->getName() );
@@ -1446,7 +1441,8 @@ void SPDesktop::disableInteraction()
void SPDesktop::setWaitingCursor()
{
- GdkCursor *waiting = gdk_cursor_new(GDK_WATCH);
+ GdkDisplay *display = gdk_display_get_default();
+ GdkCursor *waiting = gdk_cursor_new_for_display(display, GDK_WATCH);
gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(getCanvas())), waiting);
#if GTK_CHECK_VERSION(3,0,0)
g_object_unref(waiting);
@@ -1732,17 +1728,11 @@ static void _namedview_modified (SPObject *obj, guint flags, SPDesktop *desktop)
SPNamedView *nv=SP_NAMEDVIEW(obj);
if (flags & SP_OBJECT_MODIFIED_FLAG) {
-
- /* Set page background */
- sp_canvas_item_show (desktop->table);
if (nv->pagecheckerboard) {
- ((CtrlRect *) desktop->table)->setCheckerboard( true );
- ((CtrlRect *) desktop->table)->setColor(0x00000000, true, nv->pagecolor ); // | 0xff);
+ desktop->canvas->setBackgroundCheckerboard();
} else {
- ((CtrlRect *) desktop->table)->setCheckerboard( false );
- ((CtrlRect *) desktop->table)->setColor(0x00000000, true, nv->pagecolor | 0xff);
+ desktop->canvas->setBackgroundColor(nv->pagecolor);
}
- sp_canvas_item_move_to_z (desktop->table, 0);
/* Show/hide page border */
if (nv->showborder) {
@@ -1755,7 +1745,7 @@ static void _namedview_modified (SPObject *obj, guint flags, SPDesktop *desktop)
}
// place in the z-order stack
if (nv->borderlayer == SP_BORDER_LAYER_BOTTOM) {
- sp_canvas_item_move_to_z (desktop->page_border, 2);
+ sp_canvas_item_move_to_z (desktop->page_border, 1);
} else {
int order = sp_canvas_item_order (desktop->page_border);
int morder = sp_canvas_item_order (desktop->drawing);
diff --git a/src/desktop.h b/src/desktop.h
index f1444ba7b..3652d4a97 100644
--- a/src/desktop.h
+++ b/src/desktop.h
@@ -174,7 +174,6 @@ public:
SPCanvasGroup *sketch;
SPCanvasGroup *controls;
SPCanvasGroup *tempgroup; ///< contains temporary canvas items
- SPCanvasItem *table; ///< outside-of-page background
SPCanvasItem *page; ///< page background
SPCanvasItem *page_border; ///< page border
SPCSSAttr *current; ///< current style
diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp
index ec99eca9a..366b3c7d1 100644
--- a/src/display/canvas-arena.cpp
+++ b/src/display/canvas-arena.cpp
@@ -250,7 +250,8 @@ sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event)
arena->c = Geom::Point(event->crossing.x, event->crossing.y);
/* fixme: Not sure abut this, but seems the right thing (Lauris) */
- arena->drawing.update(Geom::IntRect::infinite(), arena->ctx, DrawingItem::STATE_PICK, 0);
+ arena->drawing.update(Geom::IntRect::infinite(), arena->ctx,
+ DrawingItem::STATE_PICK | DrawingItem::STATE_BBOX, 0);
arena->active = arena->drawing.pick(arena->c, arena->drawing.delta, arena->sticky);
ret = sp_canvas_arena_send_event (arena, event);
}
@@ -269,7 +270,8 @@ sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event)
arena->c = Geom::Point(event->motion.x, event->motion.y);
/* fixme: Not sure abut this, but seems the right thing (Lauris) */
- arena->drawing.update(Geom::IntRect::infinite(), arena->ctx, DrawingItem::STATE_PICK);
+ arena->drawing.update(Geom::IntRect::infinite(), arena->ctx,
+ DrawingItem::STATE_PICK | DrawingItem::STATE_BBOX);
new_arena = arena->drawing.pick(arena->c, arena->drawing.delta, arena->sticky);
if (new_arena != arena->active) {
GdkEventCrossing ec;
diff --git a/src/display/drawing-image.cpp b/src/display/drawing-image.cpp
index 2a943d16c..e23c89c59 100644
--- a/src/display/drawing-image.cpp
+++ b/src/display/drawing-image.cpp
@@ -118,14 +118,14 @@ unsigned DrawingImage::_renderItem(DrawingContext &dc, Geom::IntRect const &/*ar
// http://www.w3.org/TR/css4-images/#the-image-rendering
// style.h/style.cpp
switch (_style->image_rendering.computed) {
- case SP_CSS_COLOR_RENDERING_AUTO:
+ case SP_CSS_IMAGE_RENDERING_AUTO:
// Do nothing
break;
- case SP_CSS_COLOR_RENDERING_OPTIMIZEQUALITY:
+ case SP_CSS_IMAGE_RENDERING_OPTIMIZEQUALITY:
// In recent Cairo, BEST used Lanczos3, which is prohibitively slow
dc.patternSetFilter( CAIRO_FILTER_GOOD );
break;
- case SP_CSS_COLOR_RENDERING_OPTIMIZESPEED:
+ case SP_CSS_IMAGE_RENDERING_OPTIMIZESPEED:
default:
dc.patternSetFilter( CAIRO_FILTER_NEAREST );
break;
diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp
index a3ca7173a..f0d83abfd 100644
--- a/src/display/drawing-text.cpp
+++ b/src/display/drawing-text.cpp
@@ -100,14 +100,16 @@ unsigned DrawingGlyphs::_updateItem(Geom::IntRect const &/*area*/, UpdateContext
above and below the max/min y positions of the letters to place the text decorations.*/
Geom::Rect b;
- if(_drawable){
- Geom::OptRect tiltb = bounds_exact(*_font->PathVector(_glyph));
- Geom::Rect bigbox(Geom::Point(tiltb->left(),-_dsc*scale_bigbox*1.1),Geom::Point(tiltb->right(),_asc*scale_bigbox*1.1));
- b = bigbox * ctx.ctm;
+ if (_drawable) {
+ Geom::OptRect tiltb = bounds_exact(*_font->PathVector(_glyph));
+ if (tiltb) {
+ Geom::Rect bigbox(Geom::Point(tiltb->left(),-_dsc*scale_bigbox*1.1),Geom::Point(tiltb->right(),_asc*scale_bigbox*1.1));
+ b = bigbox * ctx.ctm;
+ }
}
- else { // Fallback, spaces mostly
- Geom::Rect bigbox(Geom::Point(0.0, -_dsc*scale_bigbox*1.1),Geom::Point(_width*scale_bigbox, _asc*scale_bigbox*1.1));
- b = bigbox * ctx.ctm;
+ if (b.hasZeroArea()) { // Fallback, spaces mostly
+ Geom::Rect bigbox(Geom::Point(0.0, -_dsc*scale_bigbox*1.1),Geom::Point(_width*scale_bigbox, _asc*scale_bigbox*1.1));
+ b = bigbox * ctx.ctm;
}
/*
diff --git a/src/display/nr-filter-tile.cpp b/src/display/nr-filter-tile.cpp
index 913812828..c151c8537 100644
--- a/src/display/nr-filter-tile.cpp
+++ b/src/display/nr-filter-tile.cpp
@@ -32,18 +32,6 @@ FilterTile::~FilterTile()
void FilterTile::render_cairo(FilterSlot &slot)
{
- // FIX ME!
- static bool tile_warning = false;
- if (!tile_warning) {
- g_warning("Renderer for feTile has non-optimal implementation, expect slowness and bugs.");
- tile_warning = true;
- }
-
- // Fixing isn't so easy as the Inkscape renderer breaks the canvas into "rendering" tiles for
- // faster rendering. (The "rendering" tiles are not the same as the tiles in this primitive.)
- // Only if the the feTile tile source falls inside the current "rendering" tile will the tile
- // image be available.
-
// This input source contains only the "rendering" tile.
cairo_surface_t *in = slot.getcairo(_input);
@@ -126,11 +114,8 @@ void FilterTile::render_cairo(FilterSlot &slot)
void FilterTile::area_enlarge(Geom::IntRect &area, Geom::Affine const &trans)
{
- // We need to enlarge enough to get tile source... we don't the area of the source tile in this
- // function so we guess. This is VERY inefficient.
- Geom::Point enlarge(200, 200);
- enlarge *= trans;
- area.expandBy( enlarge[Geom::X] < 100 ? 100: enlarge[Geom::X] );
+ // Set to infinite rectangle so we get tile source. It will be clipped later.
+ area = Geom::IntRect::infinite();
}
double FilterTile::complexity(Geom::Affine const &)
diff --git a/src/display/sp-canvas-item.h b/src/display/sp-canvas-item.h
index 66cd03dd9..00edb4dee 100644
--- a/src/display/sp-canvas-item.h
+++ b/src/display/sp-canvas-item.h
@@ -62,6 +62,7 @@ struct SPCanvasItem {
Geom::Rect bounds;
Geom::Affine xform;
+ int ctrlResize;
Inkscape::ControlType ctrlType;
Inkscape::ControlFlags ctrlFlags;
diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp
index ef47613e4..7d76fa043 100644
--- a/src/display/sp-canvas.cpp
+++ b/src/display/sp-canvas.cpp
@@ -8,9 +8,11 @@
* fred
* bbyak
* Jon A. Cruz <jon@joncruz.org>
+ * Krzysztof Kosiński <tweenk.pl@gmail.com>
*
* Copyright (C) 1998 The Free Software Foundation
* Copyright (C) 2002-2006 authors
+ * Copyright (C) 2016 Google Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -25,6 +27,7 @@
#include "helper/sp-marshal.h"
#include <2geom/rect.h>
#include <2geom/affine.h>
+#include "display/cairo-utils.h"
#include "display/sp-canvas.h"
#include "display/sp-canvas-group.h"
#include "preferences.h"
@@ -35,6 +38,7 @@
#include "display/cairo-utils.h"
#include "debug/gdk-event-latency-tracker.h"
#include "desktop.h"
+#include "color.h"
using Inkscape::Debug::GdkEventLatencyTracker;
@@ -122,7 +126,7 @@ struct SPCanvasClass {
namespace {
-gint const UPDATE_PRIORITY = G_PRIORITY_HIGH_IDLE;
+gint const UPDATE_PRIORITY = G_PRIORITY_DEFAULT_IDLE;
GdkWindow *getWindow(SPCanvas *canvas)
{
@@ -173,159 +177,8 @@ bool is_descendant(SPCanvasItem const *item, SPCanvasItem const *parent);
guint item_signals[ITEM_LAST_SIGNAL] = { 0 };
-struct PaintRectSetup;
-
} // namespace
-class SPCanvasImpl
-{
-public:
-
- /**
- * Helper that emits an event for an item in the canvas, be it the current
- * item, grabbed item, or focused item, as appropriate.
- */
- static int emitEvent(SPCanvas *canvas, GdkEvent *event);
-
- /**
- * Helper that re-picks the current item in the canvas, based on the event's
- * coordinates and emits enter/leave events for items as appropriate.
- */
- static int pickCurrentItem(SPCanvas *canvas, GdkEvent *event);
-
- /**
- * The canvas widget's realize callback.
- */
- static void realize(GtkWidget *widget);
-
- /**
- * The canvas widget's unrealize callback.
- */
- static void unrealize(GtkWidget *widget);
-
- /**
- * The canvas widget's size request callback.
- */
-#if GTK_CHECK_VERSION(3,0,0)
- static void getPreferredWidth(GtkWidget *widget, gint *min_w, gint *nat_w);
- static void getPreferredHeight(GtkWidget *widget, gint *min_h, gint *nat_h);
-#else
- static void sizeRequest(GtkWidget *widget, GtkRequisition *req);
-#endif
-
- /**
- * The canvas widget's size allocate callback.
- */
- static void sizeAllocate(GtkWidget *widget, GtkAllocation *allocation);
-
- /**
- * Button event handler for the canvas.
- */
- static gint button(GtkWidget *widget, GdkEventButton *event);
-
- /**
- * Scroll event handler for the canvas.
- *
- * @todo FIXME: generate motion events to re-select items.
- */
- static gint handleScroll(GtkWidget *widget, GdkEventScroll *event);
-
- /**
- * Motion event handler for the canvas.
- */
- static gint handleMotion(GtkWidget *widget, GdkEventMotion *event);
-
- /**
- * The canvas widget's expose callback.
- *
- * @todo FIXME: function allways retruns false.
- */
-#if GTK_CHECK_VERSION(3,0,0)
- static gboolean handleDraw(GtkWidget *widget, cairo_t *cr);
-#else
- static gboolean handleExpose(GtkWidget *widget, GdkEventExpose *event);
-#endif
-
- /**
- * The canvas widget's keypress callback.
- */
- static gint handleKeyEvent(GtkWidget *widget, GdkEventKey *event);
-
- /**
- * Crossing event handler for the canvas.
- */
- static gint handleCrossing(GtkWidget *widget, GdkEventCrossing *event);
-
- /**
- * Focus in handler for the canvas.
- */
- static gint handleFocusIn(GtkWidget *widget, GdkEventFocus *event);
-
- /**
- * Focus out handler for the canvas.
- */
- static gint handleFocusOut(GtkWidget *widget, GdkEventFocus *event);
-
- /**
- * Helper that allocates a new tile array for the canvas, copying overlapping tiles from the old array
- */
- static void sp_canvas_resize_tiles(SPCanvas* canvas, int nl, int nt, int nr, int nb);
-
- /**
- * Helper that queues a canvas rectangle for redraw
- */
- static void sp_canvas_dirty_rect(SPCanvas* canvas, Geom::IntRect const &area);
-
- /**
- * Helper that marks specific canvas rectangle as clean (val == 0) or dirty (otherwise)
- */
- static void sp_canvas_mark_rect(SPCanvas* canvas, Geom::IntRect const &area, uint8_t val);
-
- /**
- * Helper that invokes update, paint, and repick on canvas.
- */
- static int do_update(SPCanvas *canvas);
-
- static void sp_canvas_paint_single_buffer(SPCanvas *canvas, Geom::IntRect const &paint_rect, Geom::IntRect const &canvas_rect, int sw);
-
- /**
- * Paint the given rect, recursively subdividing the region until it is the size of a single
- * buffer.
- *
- * @return true if the drawing completes
- */
- static int sp_canvas_paint_rect_internal(PaintRectSetup const *setup, Geom::IntRect const &this_rect);
-
- /**
- * Helper that draws a specific rectangular part of the canvas.
- *
- * @return true if the rectangle painting succeeds.
- */
- static bool sp_canvas_paint_rect(SPCanvas *canvas, int xx0, int yy0, int xx1, int yy1);
-
- /**
- * Helper that repaints the areas in the canvas that need it.
- *
- * @return true if all the dirty parts have been redrawn
- */
- static int paint(SPCanvas *canvas);
-
- /**
- * Idle handler for the canvas that deals with pending updates and redraws.
- */
- static gint idle_handler(gpointer data);
-
- /**
- * Convenience function to add an idle handler to a canvas.
- */
- static void add_idle(SPCanvas *canvas);
-
- /**
- * Update callback for canvas widget.
- */
- static void requestCanvasUpdate(SPCanvas *canvas);
-};
-
G_DEFINE_TYPE(SPCanvasItem, sp_canvas_item, G_TYPE_INITIALLY_UNOWNED);
static void
@@ -360,6 +213,7 @@ static void
sp_canvas_item_init(SPCanvasItem *item)
{
item->xform = Geom::Affine(Geom::identity());
+ item->ctrlResize = 0;
item->ctrlType = Inkscape::CTRL_TYPE_UNKNOWN;
item->ctrlFlags = Inkscape::CTRL_FLAG_NORMAL;
@@ -455,18 +309,18 @@ void sp_canvas_item_dispose(GObject *object)
}
item->visible = FALSE;
- if (item == item->canvas->current_item) {
- item->canvas->current_item = NULL;
- item->canvas->need_repick = TRUE;
+ if (item == item->canvas->_current_item) {
+ item->canvas->_current_item = NULL;
+ item->canvas->_need_repick = TRUE;
}
- if (item == item->canvas->new_current_item) {
- item->canvas->new_current_item = NULL;
- item->canvas->need_repick = TRUE;
+ if (item == item->canvas->_new_current_item) {
+ item->canvas->_new_current_item = NULL;
+ item->canvas->_need_repick = TRUE;
}
- if (item == item->canvas->grabbed_item) {
- item->canvas->grabbed_item = NULL;
+ if (item == item->canvas->_grabbed_item) {
+ item->canvas->_grabbed_item = NULL;
#if GTK_CHECK_VERSION(3,0,0)
GdkDeviceManager *dm = gdk_display_get_device_manager(gdk_display_get_default());
@@ -477,8 +331,8 @@ void sp_canvas_item_dispose(GObject *object)
#endif
}
- if (item == item->canvas->focused_item) {
- item->canvas->focused_item = NULL;
+ if (item == item->canvas->_focused_item) {
+ item->canvas->_focused_item = NULL;
}
if (item->parent) {
@@ -576,11 +430,11 @@ void sp_canvas_item_affine_absolute(SPCanvasItem *item, Geom::Affine const &affi
if (item->parent != NULL) {
sp_canvas_item_request_update (item->parent);
} else {
- SPCanvasImpl::requestCanvasUpdate(item->canvas);
+ item->canvas->requestUpdate();
}
}
- item->canvas->need_repick = TRUE;
+ item->canvas->_need_repick = TRUE;
}
/**
@@ -613,7 +467,7 @@ void sp_canvas_item_raise(SPCanvasItem *item, int positions)
parent->items.insert(l, item);
redraw_if_visible (item);
- item->canvas->need_repick = TRUE;
+ item->canvas->_need_repick = TRUE;
}
void sp_canvas_item_raise_to_top(SPCanvasItem *item)
@@ -626,7 +480,7 @@ void sp_canvas_item_raise_to_top(SPCanvasItem *item)
parent->items.remove(item);
parent->items.push_back(item);
redraw_if_visible (item);
- item->canvas->need_repick = TRUE;
+ item->canvas->_need_repick = TRUE;
}
@@ -656,13 +510,13 @@ void sp_canvas_item_lower(SPCanvasItem *item, int positions)
g_assert (l != parent->items.end());
for (int i=0; i<positions && l != parent->items.begin(); ++i)
- ++l;
+ --l;
parent->items.remove(item);
parent->items.insert(l, item);
redraw_if_visible (item);
- item->canvas->need_repick = TRUE;
+ item->canvas->_need_repick = TRUE;
}
void sp_canvas_item_lower_to_bottom(SPCanvasItem *item)
@@ -675,7 +529,7 @@ void sp_canvas_item_lower_to_bottom(SPCanvasItem *item)
parent->items.remove(item);
parent->items.push_front(item);
redraw_if_visible (item);
- item->canvas->need_repick = TRUE;
+ item->canvas->_need_repick = TRUE;
}
bool sp_canvas_item_is_visible(SPCanvasItem *item)
@@ -704,7 +558,7 @@ void sp_canvas_item_show(SPCanvasItem *item)
if (x0 !=0 || x1 !=0 || y0 !=0 || y1 !=0) {
item->canvas->requestRedraw((int)(item->x1), (int)(item->y1), (int)(item->x2 + 1), (int)(item->y2 + 1));
- item->canvas->need_repick = TRUE;
+ item->canvas->_need_repick = TRUE;
}
}
@@ -729,7 +583,7 @@ void sp_canvas_item_hide(SPCanvasItem *item)
if (x0 !=0 || x1 !=0 || y0 !=0 || y1 !=0) {
item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)(item->x2 + 1), (int)(item->y2 + 1));
- item->canvas->need_repick = TRUE;
+ item->canvas->_need_repick = TRUE;
}
}
@@ -744,7 +598,7 @@ int sp_canvas_item_grab(SPCanvasItem *item, guint event_mask, GdkCursor *cursor,
g_return_val_if_fail (SP_IS_CANVAS_ITEM (item), -1);
g_return_val_if_fail (gtk_widget_get_mapped (GTK_WIDGET (item->canvas)), -1);
- if (item->canvas->grabbed_item) {
+ if (item->canvas->_grabbed_item) {
return -1;
}
@@ -779,9 +633,9 @@ int sp_canvas_item_grab(SPCanvasItem *item, guint event_mask, GdkCursor *cursor,
NULL, cursor, etime);
#endif
- item->canvas->grabbed_item = item;
- item->canvas->grabbed_event_mask = event_mask;
- item->canvas->current_item = item; // So that events go to the grabbed item
+ item->canvas->_grabbed_item = item;
+ item->canvas->_grabbed_event_mask = event_mask;
+ item->canvas->_current_item = item; // So that events go to the grabbed item
return 0;
}
@@ -798,11 +652,11 @@ void sp_canvas_item_ungrab(SPCanvasItem *item, guint32 etime)
g_return_if_fail (item != NULL);
g_return_if_fail (SP_IS_CANVAS_ITEM (item));
- if (item->canvas->grabbed_item != item) {
+ if (item->canvas->_grabbed_item != item) {
return;
}
- item->canvas->grabbed_item = NULL;
+ item->canvas->_grabbed_item = NULL;
#if GTK_CHECK_VERSION(3,0,0)
GdkDeviceManager *dm = gdk_display_get_device_manager(gdk_display_get_default());
@@ -864,7 +718,7 @@ void sp_canvas_item_request_update(SPCanvasItem *item)
sp_canvas_item_request_update (item->parent);
} else {
// Have reached the top of the tree, make sure the update call gets scheduled.
- SPCanvasImpl::requestCanvasUpdate(item->canvas);
+ item->canvas->requestUpdate();
}
}
@@ -954,10 +808,10 @@ double SPCanvasGroup::point(SPCanvasItem *item, Geom::Point p, SPCanvasItem **ac
SPCanvasGroup const *group = SP_CANVAS_GROUP(item);
double const x = p[Geom::X];
double const y = p[Geom::Y];
- int x1 = (int)(x - item->canvas->close_enough);
- int y1 = (int)(y - item->canvas->close_enough);
- int x2 = (int)(x + item->canvas->close_enough);
- int y2 = (int)(y + item->canvas->close_enough);
+ int x1 = (int)(x - item->canvas->_close_enough);
+ int y1 = (int)(y - item->canvas->_close_enough);
+ int x2 = (int)(x + item->canvas->_close_enough);
+ int y2 = (int)(y + item->canvas->_close_enough);
double best = 0.0;
*actual_item = NULL;
@@ -983,7 +837,7 @@ double SPCanvasGroup::point(SPCanvasItem *item, Geom::Point p, SPCanvasItem **ac
// of the item to be focused, and have that one selected. Of course this will only work if the
// centers are not coincident, but at least it's better than what we have now.
// See the extensive comment in Inkscape::SelTrans::_updateHandles()
- if (pickable && point_item && ((int) (dist + 0.5) <= item->canvas->close_enough)) {
+ if (pickable && point_item && ((int) (dist + 0.5) <= item->canvas->_close_enough)) {
best = dist;
*actual_item = point_item;
}
@@ -1048,135 +902,119 @@ void SPCanvasGroup::remove(SPCanvasItem *item)
}
-static void sp_canvas_dispose (GObject *object);
-static void sp_canvas_shutdown_transients(SPCanvas *canvas);
-
G_DEFINE_TYPE(SPCanvas, sp_canvas, GTK_TYPE_WIDGET);
-static void
-sp_canvas_class_init(SPCanvasClass *klass)
+void sp_canvas_class_init(SPCanvasClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
- object_class->dispose = sp_canvas_dispose;
+ object_class->dispose = SPCanvas::dispose;
- widget_class->realize = SPCanvasImpl::realize;
- widget_class->unrealize = SPCanvasImpl::unrealize;
+ widget_class->realize = SPCanvas::handle_realize;
+ widget_class->unrealize = SPCanvas::handle_unrealize;
#if GTK_CHECK_VERSION(3,0,0)
- widget_class->get_preferred_width = SPCanvasImpl::getPreferredWidth;
- widget_class->get_preferred_height = SPCanvasImpl::getPreferredHeight;
- widget_class->draw = SPCanvasImpl::handleDraw;
+ widget_class->get_preferred_width = SPCanvas::handle_get_preferred_width;
+ widget_class->get_preferred_height = SPCanvas::handle_get_preferred_height;
+ widget_class->draw = SPCanvas::handle_draw;
#else
- widget_class->size_request = SPCanvasImpl::sizeRequest;
- widget_class->expose_event = SPCanvasImpl::handleExpose;
+ widget_class->size_request = SPCanvas::handle_size_request;
+ widget_class->expose_event = SPCanvas::handle_expose;
#endif
- widget_class->size_allocate = SPCanvasImpl::sizeAllocate;
- widget_class->button_press_event = SPCanvasImpl::button;
- widget_class->button_release_event = SPCanvasImpl::button;
- widget_class->motion_notify_event = SPCanvasImpl::handleMotion;
- widget_class->scroll_event = SPCanvasImpl::handleScroll;
- widget_class->key_press_event = SPCanvasImpl::handleKeyEvent;
- widget_class->key_release_event = SPCanvasImpl::handleKeyEvent;
- widget_class->enter_notify_event = SPCanvasImpl::handleCrossing;
- widget_class->leave_notify_event = SPCanvasImpl::handleCrossing;
- widget_class->focus_in_event = SPCanvasImpl::handleFocusIn;
- widget_class->focus_out_event = SPCanvasImpl::handleFocusOut;
+ widget_class->size_allocate = SPCanvas::handle_size_allocate;
+ widget_class->button_press_event = SPCanvas::handle_button;
+ widget_class->button_release_event = SPCanvas::handle_button;
+ widget_class->motion_notify_event = SPCanvas::handle_motion;
+ widget_class->scroll_event = SPCanvas::handle_scroll;
+ widget_class->key_press_event = SPCanvas::handle_key_event;
+ widget_class->key_release_event = SPCanvas::handle_key_event;
+ widget_class->enter_notify_event = SPCanvas::handle_crossing;
+ widget_class->leave_notify_event = SPCanvas::handle_crossing;
+ widget_class->focus_in_event = SPCanvas::handle_focus_in;
+ widget_class->focus_out_event = SPCanvas::handle_focus_out;
}
-static void
-sp_canvas_init(SPCanvas *canvas)
+static void sp_canvas_init(SPCanvas *canvas)
{
gtk_widget_set_has_window (GTK_WIDGET (canvas), TRUE);
- gtk_widget_set_double_buffered (GTK_WIDGET (canvas), FALSE);
gtk_widget_set_can_focus (GTK_WIDGET (canvas), TRUE);
- canvas->pick_event.type = GDK_LEAVE_NOTIFY;
- canvas->pick_event.crossing.x = 0;
- canvas->pick_event.crossing.y = 0;
+ canvas->_pick_event.type = GDK_LEAVE_NOTIFY;
+ canvas->_pick_event.crossing.x = 0;
+ canvas->_pick_event.crossing.y = 0;
// Create the root item as a special case
- canvas->root = SP_CANVAS_ITEM(g_object_new(SP_TYPE_CANVAS_GROUP, NULL));
- canvas->root->canvas = canvas;
+ canvas->_root = SP_CANVAS_ITEM(g_object_new(SP_TYPE_CANVAS_GROUP, NULL));
+ canvas->_root->canvas = canvas;
- g_object_ref (canvas->root);
- g_object_ref_sink (canvas->root);
+ g_object_ref (canvas->_root);
+ g_object_ref_sink (canvas->_root);
- canvas->need_repick = TRUE;
+ canvas->_need_repick = TRUE;
// See comment at in sp-canvas.h.
- canvas->gen_all_enter_events = false;
+ canvas->_gen_all_enter_events = false;
- canvas->drawing_disabled = false;
+ canvas->_drawing_disabled = false;
- canvas->tiles=NULL;
- canvas->tLeft=canvas->tTop=canvas->tRight=canvas->tBottom=0;
- canvas->tileH=canvas->tileV=0;
+ canvas->_backing_store = NULL;
+ canvas->_clean_region = cairo_region_create();
+ canvas->_background = cairo_pattern_create_rgb(1, 1, 1);
+ canvas->_background_is_checkerboard = false;
- canvas->forced_redraw_count = 0;
- canvas->forced_redraw_limit = -1;
+ canvas->_forced_redraw_count = 0;
+ canvas->_forced_redraw_limit = -1;
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
- canvas->enable_cms_display_adj = false;
- new (&canvas->cms_key) Glib::ustring("");
+ canvas->_enable_cms_display_adj = false;
+ new (&canvas->_cms_key) Glib::ustring("");
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
-
- canvas->is_scrolling = false;
}
-static void sp_canvas_remove_idle(SPCanvas *canvas)
+void SPCanvas::shutdownTransients()
{
- if (canvas->idle_id) {
- g_source_remove (canvas->idle_id);
- canvas->idle_id = 0;
- }
-}
+ // Reset the clean region
+ dirtyAll();
-static void
-sp_canvas_shutdown_transients(SPCanvas *canvas)
-{
- // We turn off the need_redraw flag, since if the canvas is mapped again
- // it will request a redraw anyways. We do not turn off the need_update
- // flag, though, because updates are not queued when the canvas remaps
- // itself.
- //
- if (canvas->need_redraw) {
- canvas->need_redraw = FALSE;
- }
- if ( canvas->tiles ) g_free(canvas->tiles);
- canvas->tiles=NULL;
- canvas->tLeft=canvas->tTop=canvas->tRight=canvas->tBottom=0;
- canvas->tileH=canvas->tileV=0;
-
- if (canvas->grabbed_item) {
- canvas->grabbed_item = NULL;
+ if (_grabbed_item) {
+ _grabbed_item = NULL;
#if GTK_CHECK_VERSION(3,0,0)
GdkDeviceManager *dm = gdk_display_get_device_manager(gdk_display_get_default());
GdkDevice *device = gdk_device_manager_get_client_pointer(dm);
gdk_device_ungrab(device, GDK_CURRENT_TIME);
#else
- gdk_pointer_ungrab (GDK_CURRENT_TIME);
+ gdk_pointer_ungrab(GDK_CURRENT_TIME);
#endif
}
-
- sp_canvas_remove_idle(canvas);
+ removeIdle();
}
-static void
-sp_canvas_dispose(GObject *object)
+void SPCanvas::dispose(GObject *object)
{
SPCanvas *canvas = SP_CANVAS(object);
- if (canvas->root) {
- g_object_unref (canvas->root);
- canvas->root = NULL;
+ if (canvas->_root) {
+ g_object_unref (canvas->_root);
+ canvas->_root = NULL;
+ }
+ if (canvas->_backing_store) {
+ cairo_surface_destroy(canvas->_backing_store);
+ canvas->_backing_store = NULL;
+ }
+ if (canvas->_clean_region) {
+ cairo_region_destroy(canvas->_clean_region);
+ canvas->_clean_region = NULL;
+ }
+ if (canvas->_background) {
+ cairo_pattern_destroy(canvas->_background);
+ canvas->_background = NULL;
}
- sp_canvas_shutdown_transients(canvas);
+ canvas->shutdownTransients();
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
- canvas->cms_key.~ustring();
+ canvas->_cms_key.~ustring();
#endif
if (G_OBJECT_CLASS(sp_canvas_parent_class)->dispose) {
(* G_OBJECT_CLASS(sp_canvas_parent_class)->dispose)(object);
@@ -1202,7 +1040,7 @@ GtkWidget *SPCanvas::createAA()
return GTK_WIDGET(canvas);
}
-void SPCanvasImpl::realize(GtkWidget *widget)
+void SPCanvas::handle_realize(GtkWidget *widget)
{
GdkWindowAttr attributes;
GtkAllocation allocation;
@@ -1263,15 +1101,15 @@ void SPCanvasImpl::realize(GtkWidget *widget)
gtk_widget_set_realized (widget, TRUE);
}
-void SPCanvasImpl::unrealize(GtkWidget *widget)
+void SPCanvas::handle_unrealize(GtkWidget *widget)
{
SPCanvas *canvas = SP_CANVAS (widget);
- canvas->current_item = NULL;
- canvas->grabbed_item = NULL;
- canvas->focused_item = NULL;
+ canvas->_current_item = NULL;
+ canvas->_grabbed_item = NULL;
+ canvas->_focused_item = NULL;
- sp_canvas_shutdown_transients(canvas);
+ canvas->shutdownTransients();
if (GTK_WIDGET_CLASS(sp_canvas_parent_class)->unrealize)
(* GTK_WIDGET_CLASS(sp_canvas_parent_class)->unrealize)(widget);
@@ -1279,21 +1117,21 @@ void SPCanvasImpl::unrealize(GtkWidget *widget)
#if GTK_CHECK_VERSION(3,0,0)
-void SPCanvasImpl::getPreferredWidth(GtkWidget *widget, gint *minimum_width, gint *natural_width)
+void SPCanvas::handle_get_preferred_width(GtkWidget *widget, gint *minimum_width, gint *natural_width)
{
static_cast<void>(SP_CANVAS (widget));
*minimum_width = 256;
*natural_width = 256;
}
-void SPCanvasImpl::getPreferredHeight(GtkWidget *widget, gint *minimum_height, gint *natural_height)
+void SPCanvas::handle_get_preferred_height(GtkWidget *widget, gint *minimum_height, gint *natural_height)
{
static_cast<void>(SP_CANVAS (widget));
*minimum_height = 256;
*natural_height = 256;
}
#else
-void SPCanvasImpl::sizeRequest(GtkWidget *widget, GtkRequisition *req)
+void SPCanvas::handle_size_request(GtkWidget *widget, GtkRequisition *req)
{
static_cast<void>(SP_CANVAS (widget));
@@ -1303,51 +1141,58 @@ void SPCanvasImpl::sizeRequest(GtkWidget *widget, GtkRequisition *req)
#endif
-void SPCanvasImpl::sizeAllocate(GtkWidget *widget, GtkAllocation *allocation)
+void SPCanvas::handle_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
{
SPCanvas *canvas = SP_CANVAS (widget);
- GtkAllocation widg_allocation;
+ GtkAllocation old_allocation;
- gtk_widget_get_allocation (widget, &widg_allocation);
+ gtk_widget_get_allocation(widget, &old_allocation);
-// Geom::IntRect old_area = Geom::IntRect::from_xywh(canvas->x0, canvas->y0,
-// widg_allocation.width, widg_allocation.height);
+// Geom::IntRect old_area = Geom::IntRect::from_xywh(canvas->_x0, canvas->_y0,
+// old_allocation.width, old_allocation.height);
- Geom::IntRect new_area = Geom::IntRect::from_xywh(canvas->x0, canvas->y0,
+ Geom::IntRect new_area = Geom::IntRect::from_xywh(canvas->_x0, canvas->_y0,
allocation->width, allocation->height);
- // Schedule redraw of new region
- sp_canvas_resize_tiles(canvas,canvas->x0,canvas->y0,canvas->x0+allocation->width,canvas->y0+allocation->height);
- if (SP_CANVAS_ITEM_GET_CLASS (canvas->root)->viewbox_changed)
- SP_CANVAS_ITEM_GET_CLASS (canvas->root)->viewbox_changed (canvas->root, new_area);
-
- if (allocation->width > widg_allocation.width) {
- canvas->requestRedraw(canvas->x0 + widg_allocation.width,
- 0,
- canvas->x0 + allocation->width,
- canvas->y0 + allocation->height);
- }
- if (allocation->height > widg_allocation.height) {
- canvas->requestRedraw(0,
- canvas->y0 + widg_allocation.height,
- canvas->x0 + allocation->width,
- canvas->y0 + allocation->height);
- }
+ // resize backing store
+ cairo_surface_t *new_backing_store = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
+ allocation->width, allocation->height);
+ if (canvas->_backing_store) {
+ cairo_t *cr = cairo_create(new_backing_store);
+ cairo_translate(cr, -canvas->_x0, -canvas->_y0);
+ cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
+ cairo_set_source(cr, canvas->_background);
+ cairo_paint(cr);
+ cairo_set_source_surface(cr, canvas->_backing_store, canvas->_x0, canvas->_y0);
+ cairo_paint(cr);
+ cairo_destroy(cr);
+ cairo_surface_destroy(canvas->_backing_store);
+ }
+ canvas->_backing_store = new_backing_store;
+
+ // Clip the clean region to the new allocation
+ cairo_rectangle_int_t crect = { canvas->_x0, canvas->_y0, allocation->width, allocation->height };
+ cairo_region_intersect_rectangle(canvas->_clean_region, &crect);
gtk_widget_set_allocation (widget, allocation);
+ if (SP_CANVAS_ITEM_GET_CLASS (canvas->_root)->viewbox_changed)
+ SP_CANVAS_ITEM_GET_CLASS (canvas->_root)->viewbox_changed (canvas->_root, new_area);
+
if (gtk_widget_get_realized (widget)) {
gdk_window_move_resize (gtk_widget_get_window (widget),
allocation->x, allocation->y,
allocation->width, allocation->height);
}
+ // Schedule redraw of any newly exposed regions
+ canvas->addIdle();
}
-int SPCanvasImpl::emitEvent(SPCanvas *canvas, GdkEvent *event)
+int SPCanvas::emitEvent(GdkEvent *event)
{
guint mask;
- if (canvas->grabbed_item) {
+ if (_grabbed_item) {
switch (event->type) {
case GDK_ENTER_NOTIFY:
mask = GDK_ENTER_NOTIFY_MASK;
@@ -1383,7 +1228,7 @@ int SPCanvasImpl::emitEvent(SPCanvas *canvas, GdkEvent *event)
break;
}
- if (!(mask & canvas->grabbed_event_mask)) return FALSE;
+ if (!(mask & _grabbed_event_mask)) return FALSE;
}
// Convert to world coordinates -- we have two cases because of different
@@ -1394,25 +1239,25 @@ int SPCanvasImpl::emitEvent(SPCanvas *canvas, GdkEvent *event)
switch (ev->type) {
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
- ev->crossing.x += canvas->x0;
- ev->crossing.y += canvas->y0;
+ ev->crossing.x += _x0;
+ ev->crossing.y += _y0;
break;
case GDK_MOTION_NOTIFY:
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
- ev->motion.x += canvas->x0;
- ev->motion.y += canvas->y0;
+ ev->motion.x += _x0;
+ ev->motion.y += _y0;
break;
default:
break;
}
// Block Undo and Redo while we drag /anything/
if(event->type == GDK_BUTTON_PRESS && event->button.button == 1)
- canvas->is_dragging = true;
+ _is_dragging = true;
else if(event->type == GDK_BUTTON_RELEASE)
- canvas->is_dragging = false;
+ _is_dragging = false;
// Choose where we send the event
@@ -1421,17 +1266,17 @@ int SPCanvasImpl::emitEvent(SPCanvas *canvas, GdkEvent *event)
// Lauris applied to SP to get around the problem.
//
SPCanvasItem* item = NULL;
- if (canvas->grabbed_item && !is_descendant (canvas->current_item, canvas->grabbed_item)) {
- item = canvas->grabbed_item;
+ if (_grabbed_item && !is_descendant(_current_item, _grabbed_item)) {
+ item = _grabbed_item;
} else {
- item = canvas->current_item;
+ item = _current_item;
}
- if (canvas->focused_item &&
+ if (_focused_item &&
((event->type == GDK_KEY_PRESS) ||
(event->type == GDK_KEY_RELEASE) ||
(event->type == GDK_FOCUS_CHANGE))) {
- item = canvas->focused_item;
+ item = _focused_item;
}
// The event is propagated up the hierarchy (for if someone connected to
@@ -1453,24 +1298,24 @@ int SPCanvasImpl::emitEvent(SPCanvas *canvas, GdkEvent *event)
return finished;
}
-int SPCanvasImpl::pickCurrentItem(SPCanvas *canvas, GdkEvent *event)
+int SPCanvas::pickCurrentItem(GdkEvent *event)
{
int button_down = 0;
- if (!canvas->root) // canvas may have already be destroyed by closing desktop during interrupted display!
+ if (!_root) // canvas may have already be destroyed by closing desktop during interrupted display!
return FALSE;
int retval = FALSE;
- if (canvas->gen_all_enter_events == false) {
+ if (_gen_all_enter_events == false) {
// If a button is down, we'll perform enter and leave events on the
// current item, but not enter on any other item. This is more or
// less like X pointer grabbing for canvas items.
//
- button_down = canvas->state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK |
+ button_down = _state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK |
GDK_BUTTON3_MASK | GDK_BUTTON4_MASK | GDK_BUTTON5_MASK);
- if (!button_down) canvas->left_grabbed_item = FALSE;
+ if (!button_down) _left_grabbed_item = FALSE;
}
// Save the event in the canvas. This is used to synthesize enter and
@@ -1478,116 +1323,115 @@ int SPCanvasImpl::pickCurrentItem(SPCanvas *canvas, GdkEvent *event)
// re-pick the current item if the current one gets deleted. Also,
// synthesize an enter event.
- if (event != &canvas->pick_event) {
+ if (event != &_pick_event) {
if ((event->type == GDK_MOTION_NOTIFY) || (event->type == GDK_BUTTON_RELEASE)) {
// these fields have the same offsets in both types of events
- canvas->pick_event.crossing.type = GDK_ENTER_NOTIFY;
- canvas->pick_event.crossing.window = event->motion.window;
- canvas->pick_event.crossing.send_event = event->motion.send_event;
- canvas->pick_event.crossing.subwindow = NULL;
- canvas->pick_event.crossing.x = event->motion.x;
- canvas->pick_event.crossing.y = event->motion.y;
- canvas->pick_event.crossing.mode = GDK_CROSSING_NORMAL;
- canvas->pick_event.crossing.detail = GDK_NOTIFY_NONLINEAR;
- canvas->pick_event.crossing.focus = FALSE;
- canvas->pick_event.crossing.state = event->motion.state;
+ _pick_event.crossing.type = GDK_ENTER_NOTIFY;
+ _pick_event.crossing.window = event->motion.window;
+ _pick_event.crossing.send_event = event->motion.send_event;
+ _pick_event.crossing.subwindow = NULL;
+ _pick_event.crossing.x = event->motion.x;
+ _pick_event.crossing.y = event->motion.y;
+ _pick_event.crossing.mode = GDK_CROSSING_NORMAL;
+ _pick_event.crossing.detail = GDK_NOTIFY_NONLINEAR;
+ _pick_event.crossing.focus = FALSE;
+ _pick_event.crossing.state = event->motion.state;
// these fields don't have the same offsets in both types of events
if (event->type == GDK_MOTION_NOTIFY) {
- canvas->pick_event.crossing.x_root = event->motion.x_root;
- canvas->pick_event.crossing.y_root = event->motion.y_root;
+ _pick_event.crossing.x_root = event->motion.x_root;
+ _pick_event.crossing.y_root = event->motion.y_root;
} else {
- canvas->pick_event.crossing.x_root = event->button.x_root;
- canvas->pick_event.crossing.y_root = event->button.y_root;
+ _pick_event.crossing.x_root = event->button.x_root;
+ _pick_event.crossing.y_root = event->button.y_root;
}
} else {
- canvas->pick_event = *event;
+ _pick_event = *event;
}
}
// Don't do anything else if this is a recursive call
- if (canvas->in_repick) {
+ if (_in_repick) {
return retval;
}
// LeaveNotify means that there is no current item, so we don't look for one
- if (canvas->pick_event.type != GDK_LEAVE_NOTIFY) {
+ if (_pick_event.type != GDK_LEAVE_NOTIFY) {
// these fields don't have the same offsets in both types of events
double x, y;
- if (canvas->pick_event.type == GDK_ENTER_NOTIFY) {
- x = canvas->pick_event.crossing.x;
- y = canvas->pick_event.crossing.y;
+ if (_pick_event.type == GDK_ENTER_NOTIFY) {
+ x = _pick_event.crossing.x;
+ y = _pick_event.crossing.y;
} else {
- x = canvas->pick_event.motion.x;
- y = canvas->pick_event.motion.y;
+ x = _pick_event.motion.x;
+ y = _pick_event.motion.y;
}
// world coords
- x += canvas->x0;
- y += canvas->y0;
+ x += _x0;
+ y += _y0;
// find the closest item
- if (canvas->root->visible) {
- sp_canvas_item_invoke_point (canvas->root, Geom::Point(x, y), &canvas->new_current_item);
+ if (_root->visible) {
+ sp_canvas_item_invoke_point (_root, Geom::Point(x, y), &_new_current_item);
} else {
- canvas->new_current_item = NULL;
+ _new_current_item = NULL;
}
} else {
- canvas->new_current_item = NULL;
+ _new_current_item = NULL;
}
- if ((canvas->new_current_item == canvas->current_item) && !canvas->left_grabbed_item) {
+ if ((_new_current_item == _current_item) && !_left_grabbed_item) {
return retval; // current item did not change
}
// Synthesize events for old and new current items
- if ((canvas->new_current_item != canvas->current_item)
- && (canvas->current_item != NULL)
- && !canvas->left_grabbed_item) {
+ if ((_new_current_item != _current_item) &&
+ _current_item != NULL && !_left_grabbed_item)
+ {
GdkEvent new_event;
- new_event = canvas->pick_event;
+ new_event = _pick_event;
new_event.type = GDK_LEAVE_NOTIFY;
new_event.crossing.detail = GDK_NOTIFY_ANCESTOR;
new_event.crossing.subwindow = NULL;
- canvas->in_repick = TRUE;
- retval = emitEvent(canvas, &new_event);
- canvas->in_repick = FALSE;
+ _in_repick = TRUE;
+ retval = emitEvent(&new_event);
+ _in_repick = FALSE;
}
- if (canvas->gen_all_enter_events == false) {
+ if (_gen_all_enter_events == false) {
// new_current_item may have been set to NULL during the call to
// emitEvent() above
- if ((canvas->new_current_item != canvas->current_item) && button_down) {
- canvas->left_grabbed_item = TRUE;
+ if ((_new_current_item != _current_item) && button_down) {
+ _left_grabbed_item = TRUE;
return retval;
}
}
// Handle the rest of cases
+ _left_grabbed_item = FALSE;
+ _current_item = _new_current_item;
- canvas->left_grabbed_item = FALSE;
- canvas->current_item = canvas->new_current_item;
-
- if (canvas->current_item != NULL) {
+ if (_current_item != NULL) {
GdkEvent new_event;
- new_event = canvas->pick_event;
+ new_event = _pick_event;
new_event.type = GDK_ENTER_NOTIFY;
new_event.crossing.detail = GDK_NOTIFY_ANCESTOR;
new_event.crossing.subwindow = NULL;
- retval = emitEvent(canvas, &new_event);
+ retval = emitEvent(&new_event);
}
return retval;
}
-gint SPCanvasImpl::button(GtkWidget *widget, GdkEventButton *event)
+gint SPCanvas::handle_button(GtkWidget *widget, GdkEventButton *event)
{
SPCanvas *canvas = SP_CANVAS (widget);
@@ -1595,7 +1439,7 @@ gint SPCanvasImpl::button(GtkWidget *widget, GdkEventButton *event)
// dispatch normally regardless of the event's window if an item
// has a pointer grab in effect
- if (!canvas->grabbed_item &&
+ if (!canvas->_grabbed_item &&
event->window != getWindow(canvas))
return retval;
@@ -1627,21 +1471,21 @@ gint SPCanvasImpl::button(GtkWidget *widget, GdkEventButton *event)
// Pick the current item as if the button were not pressed, and
// then process the event.
//
- canvas->state = event->state;
- pickCurrentItem(canvas, reinterpret_cast<GdkEvent *>(event));
- canvas->state ^= mask;
- retval = emitEvent(canvas, (GdkEvent *) event);
+ canvas->_state = event->state;
+ canvas->pickCurrentItem(reinterpret_cast<GdkEvent *>(event));
+ canvas->_state ^= mask;
+ retval = canvas->emitEvent((GdkEvent *) event);
break;
case GDK_BUTTON_RELEASE:
// Process the event as if the button were pressed, then repick
// after the button has been released
//
- canvas->state = event->state;
- retval = emitEvent(canvas, (GdkEvent *) event);
+ canvas->_state = event->state;
+ retval = canvas->emitEvent((GdkEvent *) event);
event->state ^= mask;
- canvas->state = event->state;
- pickCurrentItem(canvas, reinterpret_cast<GdkEvent *>(event));
+ canvas->_state = event->state;
+ canvas->pickCurrentItem(reinterpret_cast<GdkEvent *>(event));
event->state ^= mask;
break;
@@ -1653,9 +1497,9 @@ gint SPCanvasImpl::button(GtkWidget *widget, GdkEventButton *event)
return retval;
}
-gint SPCanvasImpl::handleScroll(GtkWidget *widget, GdkEventScroll *event)
+gint SPCanvas::handle_scroll(GtkWidget *widget, GdkEventScroll *event)
{
- return emitEvent(SP_CANVAS(widget), reinterpret_cast<GdkEvent *>(event));
+ return SP_CANVAS(widget)->emitEvent(reinterpret_cast<GdkEvent *>(event));
}
static inline void request_motions(GdkWindow *w, GdkEventMotion *event) {
@@ -1669,7 +1513,7 @@ static inline void request_motions(GdkWindow *w, GdkEventMotion *event) {
gdk_event_request_motions(event);
}
-int SPCanvasImpl::handleMotion(GtkWidget *widget, GdkEventMotion *event)
+int SPCanvas::handle_motion(GtkWidget *widget, GdkEventMotion *event)
{
int status;
SPCanvas *canvas = SP_CANVAS (widget);
@@ -1680,12 +1524,12 @@ int SPCanvasImpl::handleMotion(GtkWidget *widget, GdkEventMotion *event)
return FALSE;
}
- if (canvas->root == NULL) // canvas being deleted
+ if (canvas->_root == NULL) // canvas being deleted
return FALSE;
- canvas->state = event->state;
- pickCurrentItem(canvas, reinterpret_cast<GdkEvent *>(event));
- status = emitEvent(canvas, reinterpret_cast<GdkEvent *>(event));
+ canvas->_state = event->state;
+ canvas->pickCurrentItem(reinterpret_cast<GdkEvent *>(event));
+ status = canvas->emitEvent(reinterpret_cast<GdkEvent *>(event));
if (event->is_hint) {
request_motions(gtk_widget_get_window (widget), event);
}
@@ -1693,75 +1537,40 @@ int SPCanvasImpl::handleMotion(GtkWidget *widget, GdkEventMotion *event)
return status;
}
-void SPCanvasImpl::sp_canvas_paint_single_buffer(SPCanvas *canvas, Geom::IntRect const &paint_rect, Geom::IntRect const &canvas_rect, int /*sw*/)
+void SPCanvas::paintSingleBuffer(Geom::IntRect const &paint_rect, Geom::IntRect const &canvas_rect, int /*sw*/)
{
- GtkWidget *widget = GTK_WIDGET (canvas);
-
- // Mark the region clean
- sp_canvas_mark_rect(canvas, paint_rect, 0);
-
SPCanvasBuf buf;
buf.buf = NULL;
buf.buf_rowstride = 0;
buf.rect = paint_rect;
buf.visible_rect = canvas_rect;
buf.is_empty = true;
- //buf.ct = gdk_cairo_create(widget->window);
-
- /*
- cairo_t *xctt = gdk_cairo_create(widget->window);
- cairo_translate(xctt, paint_rect.left() - canvas->x0, paint_rect.top() - canvas->y0);
- cairo_set_source_rgb(xctt, 1,0,0);
- cairo_rectangle(xctt, 0, 0, paint_rect.width(), paint_rect.height());
- cairo_fill(xctt);
- cairo_destroy(xctt);
- //
- */
// create temporary surface
cairo_surface_t *imgs = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, paint_rect.width(), paint_rect.height());
buf.ct = cairo_create(imgs);
- //cairo_translate(buf.ct, -x0, -y0);
-
- // fix coordinates, clip all drawing to the tile and clear the background
- //cairo_translate(buf.ct, paint_rect.left() - canvas->x0, paint_rect.top() - canvas->y0);
- //cairo_rectangle(buf.ct, 0, 0, paint_rect.width(), paint_rect.height());
- //cairo_set_line_width(buf.ct, 3);
- //cairo_set_source_rgba(buf.ct, 1.0, 0.0, 0.0, 0.1);
- //cairo_stroke_preserve(buf.ct);
- //cairo_clip(buf.ct);
-
-#if GTK_CHECK_VERSION(3,0,0)
- GtkStyleContext *context = gtk_widget_get_style_context(widget);
- GdkRGBA color;
- gtk_style_context_get_background_color(context,
- gtk_widget_get_state_flags(widget),
- &color);
- gdk_cairo_set_source_rgba(buf.ct, &color);
-#else
- GtkStyle *style = gtk_widget_get_style (widget);
- gdk_cairo_set_source_color(buf.ct, &style->bg[GTK_STATE_NORMAL]);
-#endif
+ cairo_save(buf.ct);
+ cairo_translate(buf.ct, -paint_rect.left(), -paint_rect.top());
+ cairo_set_source(buf.ct, _background);
cairo_set_operator(buf.ct, CAIRO_OPERATOR_SOURCE);
- //cairo_rectangle(buf.ct, 0, 0, paint_rect.width(), paint_rec.height());
cairo_paint(buf.ct);
- cairo_set_operator(buf.ct, CAIRO_OPERATOR_OVER);
+ cairo_restore(buf.ct);
- if (canvas->root->visible) {
- SP_CANVAS_ITEM_GET_CLASS (canvas->root)->render (canvas->root, &buf);
+ if (_root->visible) {
+ SP_CANVAS_ITEM_GET_CLASS(_root)->render(_root, &buf);
}
// output to X
cairo_destroy(buf.ct);
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
- if (canvas->enable_cms_display_adj) {
+ if (_enable_cms_display_adj) {
cmsHTRANSFORM transf = 0;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
bool fromDisplay = prefs->getBool( "/options/displayprofile/from_display");
if ( fromDisplay ) {
- transf = Inkscape::CMSSystem::getDisplayPer( canvas->cms_key );
+ transf = Inkscape::CMSSystem::getDisplayPer(_cms_key);
} else {
transf = Inkscape::CMSSystem::getDisplayTransform();
}
@@ -1779,8 +1588,9 @@ void SPCanvasImpl::sp_canvas_paint_single_buffer(SPCanvas *canvas, Geom::IntRect
}
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
- cairo_t *xct = gdk_cairo_create(gtk_widget_get_window (widget));
- cairo_translate(xct, paint_rect.left() - canvas->x0, paint_rect.top() - canvas->y0);
+ //cairo_t *xct = gdk_cairo_create(gtk_widget_get_window (widget));
+ cairo_t *xct = cairo_create(_backing_store);
+ cairo_translate(xct, paint_rect.left() - _x0, paint_rect.top() - _y0);
cairo_rectangle(xct, 0, 0, paint_rect.width(), paint_rect.height());
cairo_clip(xct);
cairo_set_source_surface(xct, imgs, 0, 0);
@@ -1789,25 +1599,21 @@ void SPCanvasImpl::sp_canvas_paint_single_buffer(SPCanvas *canvas, Geom::IntRect
cairo_destroy(xct);
cairo_surface_destroy(imgs);
- //cairo_surface_t *cst = cairo_get_target(buf.ct);
- //cairo_destroy (buf.ct);
- //cairo_surface_finish (cst);
- //cairo_surface_destroy (cst);
-}
+ // Mark the painted rectangle clean
+ markRect(paint_rect, 0);
-namespace {
+ gtk_widget_queue_draw_area(GTK_WIDGET(this), paint_rect.left() -_x0, paint_rect.top() - _y0,
+ paint_rect.width(), paint_rect.height());
+}
struct PaintRectSetup {
- SPCanvas* canvas;
Geom::IntRect big_rect;
GTimeVal start_time;
int max_pixels;
Geom::Point mouse_loc;
};
-}// namespace
-
-int SPCanvasImpl::sp_canvas_paint_rect_internal(PaintRectSetup const *setup, Geom::IntRect const &this_rect)
+int SPCanvas::paintRectInternal(PaintRectSetup const *setup, Geom::IntRect const &this_rect)
{
GTimeVal now;
g_get_current_time (&now);
@@ -1830,11 +1636,11 @@ int SPCanvasImpl::sp_canvas_paint_rect_internal(PaintRectSetup const *setup, Geo
// If this limit is set, and if we have aborted redraw more times than is allowed,
// interrupting is blocked and we're forced to redraw full screen once
// (after which we can again interrupt forced_redraw_limit times).
- if (setup->canvas->forced_redraw_limit < 0 ||
- setup->canvas->forced_redraw_count < setup->canvas->forced_redraw_limit) {
+ if (_forced_redraw_limit < 0 ||
+ _forced_redraw_count < _forced_redraw_limit) {
- if (setup->canvas->forced_redraw_limit != -1) {
- setup->canvas->forced_redraw_count++;
+ if (_forced_redraw_limit != -1) {
+ _forced_redraw_count++;
}
return false;
@@ -1860,8 +1666,7 @@ int SPCanvasImpl::sp_canvas_paint_rect_internal(PaintRectSetup const *setup, Geo
gdk_window_begin_paint_rect(window, &r);
*/
- sp_canvas_paint_single_buffer (setup->canvas,
- this_rect, setup->big_rect, bw);
+ paintSingleBuffer(this_rect, setup->big_rect, bw);
//gdk_window_end_paint(window);
return 1;
}
@@ -1893,11 +1698,11 @@ The default for now is the strips mode.
if (setup->mouse_loc[Geom::X] < mid) {
// Always paint towards the mouse first
- return sp_canvas_paint_rect_internal(setup, lo)
- && sp_canvas_paint_rect_internal(setup, hi);
+ return paintRectInternal(setup, lo)
+ && paintRectInternal(setup, hi);
} else {
- return sp_canvas_paint_rect_internal(setup, hi)
- && sp_canvas_paint_rect_internal(setup, lo);
+ return paintRectInternal(setup, hi)
+ && paintRectInternal(setup, lo);
}
} else {
int mid = this_rect[Geom::Y].middle();
@@ -1909,24 +1714,24 @@ The default for now is the strips mode.
if (setup->mouse_loc[Geom::Y] < mid) {
// Always paint towards the mouse first
- return sp_canvas_paint_rect_internal(setup, lo)
- && sp_canvas_paint_rect_internal(setup, hi);
+ return paintRectInternal(setup, lo)
+ && paintRectInternal(setup, hi);
} else {
- return sp_canvas_paint_rect_internal(setup, hi)
- && sp_canvas_paint_rect_internal(setup, lo);
+ return paintRectInternal(setup, hi)
+ && paintRectInternal(setup, lo);
}
}
}
-bool SPCanvasImpl::sp_canvas_paint_rect(SPCanvas *canvas, int xx0, int yy0, int xx1, int yy1)
+bool SPCanvas::paintRect(int xx0, int yy0, int xx1, int yy1)
{
GtkAllocation allocation;
- g_return_val_if_fail (!canvas->need_update, false);
+ g_return_val_if_fail (!_need_update, false);
- gtk_widget_get_allocation (GTK_WIDGET (canvas), &allocation);
+ gtk_widget_get_allocation(GTK_WIDGET(this), &allocation);
- Geom::IntRect canvas_rect = Geom::IntRect::from_xywh(canvas->x0, canvas->y0,
+ Geom::IntRect canvas_rect = Geom::IntRect::from_xywh(_x0, _y0,
allocation.width, allocation.height);
Geom::IntRect paint_rect(xx0, yy0, xx1, yy1);
@@ -1936,8 +1741,6 @@ bool SPCanvasImpl::sp_canvas_paint_rect(SPCanvas *canvas, int xx0, int yy0, int
paint_rect = *area;
PaintRectSetup setup;
-
- setup.canvas = canvas;
setup.big_rect = paint_rect;
// Save the mouse location
@@ -1947,16 +1750,16 @@ bool SPCanvasImpl::sp_canvas_paint_rect(SPCanvas *canvas, int xx0, int yy0, int
GdkDeviceManager *dm = gdk_display_get_device_manager(gdk_display_get_default());
GdkDevice *device = gdk_device_manager_get_client_pointer(dm);
- gdk_window_get_device_position(gtk_widget_get_window(GTK_WIDGET(canvas)),
+ gdk_window_get_device_position(gtk_widget_get_window(GTK_WIDGET(this)),
device,
&x, &y, NULL);
#else
- gdk_window_get_pointer (gtk_widget_get_window (GTK_WIDGET(canvas)), &x, &y, NULL);
+ gdk_window_get_pointer(gtk_widget_get_window(GTK_WIDGET(this)), &x, &y, NULL);
#endif
- setup.mouse_loc = sp_canvas_window_to_world (canvas, Geom::Point(x,y));
+ setup.mouse_loc = sp_canvas_window_to_world(this, Geom::Point(x,y));
- if (canvas->rendermode != Inkscape::RENDERMODE_OUTLINE) {
+ if (_rendermode != Inkscape::RENDERMODE_OUTLINE) {
// use 256K as a compromise to not slow down gradients
// 256K is the cached buffer and we need 4 channels
setup.max_pixels = 65536; // 256K/4
@@ -1970,76 +1773,73 @@ bool SPCanvasImpl::sp_canvas_paint_rect(SPCanvas *canvas, int xx0, int yy0, int
g_get_current_time(&(setup.start_time));
// Go
- return sp_canvas_paint_rect_internal(&setup, paint_rect);
+ return paintRectInternal(&setup, paint_rect);
}
void SPCanvas::forceFullRedrawAfterInterruptions(unsigned int count)
{
- forced_redraw_limit = count;
- forced_redraw_count = 0;
+ _forced_redraw_limit = count;
+ _forced_redraw_count = 0;
}
void SPCanvas::endForcedFullRedraws()
{
- forced_redraw_limit = -1;
+ _forced_redraw_limit = -1;
}
-#if GTK_CHECK_VERSION(3,0,0)
-gboolean SPCanvasImpl::handleDraw(GtkWidget *widget, cairo_t *cr) {
- SPCanvas *canvas = SP_CANVAS(widget);
-
- cairo_rectangle_list_t *rects = cairo_copy_clip_rectangle_list(cr);
+gboolean SPCanvas::handle_draw(GtkWidget *widget, cairo_t *cr) {
+ SPCanvas *canvas = SP_CANVAS(widget);
- for (int i = 0; i < rects->num_rectangles; i++) {
- cairo_rectangle_t rectangle = rects->rectangles[i];
+ // Blit from the backing store, without regard for the clean region.
+ // This is necessary because GTK clears the widget for us, which causes
+ // severe flicker while drawing if we don't blit the old contents.
+ cairo_set_source_surface(cr, canvas->_backing_store, 0, 0);
+ cairo_paint(cr);
- Geom::IntRect r = Geom::IntRect::from_xywh(rectangle.x + canvas->x0, rectangle.y + canvas->y0,
- rectangle.width, rectangle.height);
+ cairo_rectangle_list_t *rects = cairo_copy_clip_rectangle_list(cr);
+ cairo_region_t *dirty_region = cairo_region_create();
- canvas->requestRedraw(r.left(), r.top(), r.right(), r.bottom());
- }
+ for (int i = 0; i < rects->num_rectangles; i++) {
+ cairo_rectangle_t rectangle = rects->rectangles[i];
+ Geom::Rect dr = Geom::Rect::from_xywh(rectangle.x + canvas->_x0, rectangle.y + canvas->_y0,
+ rectangle.width, rectangle.height);
+ Geom::IntRect ir = dr.roundOutwards();
+ cairo_rectangle_int_t irect = { ir.left(), ir.top(), ir.width(), ir.height() };
+ cairo_region_union_rectangle(dirty_region, &irect);
+ }
+ cairo_rectangle_list_destroy(rects);
+ cairo_region_subtract(dirty_region, canvas->_clean_region);
- cairo_rectangle_list_destroy(rects);
+ // Render the dirty portion in the background
+ if (!cairo_region_is_empty(dirty_region)) {
+ canvas->addIdle();
+ }
+ cairo_region_destroy(dirty_region);
- return FALSE;
+ return TRUE;
}
-#else
-gboolean SPCanvasImpl::handleExpose(GtkWidget *widget, GdkEventExpose *event)
+#if !GTK_CHECK_VERSION(3,0,0)
+gboolean SPCanvas::handle_expose(GtkWidget *widget, GdkEventExpose *event)
{
- SPCanvas *canvas = SP_CANVAS(widget);
+ cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(widget));
- if (!gtk_widget_is_drawable (widget) ||
- (event->window != getWindow(canvas))) {
- return FALSE;
- }
+ gdk_cairo_region (cr, event->region);
+ cairo_clip (cr);
+ gboolean result = SPCanvas::handle_draw(widget, cr);
- int n_rects = 0;
- GdkRectangle *rects = NULL;
- gdk_region_get_rectangles(event->region, &rects, &n_rects);
+ cairo_destroy (cr);
- if(rects == NULL)
- return FALSE;
-
- for (int i = 0; i < n_rects; i++) {
- GdkRectangle rectangle = rects[i];
-
- Geom::IntRect r = Geom::IntRect::from_xywh(rectangle.x + canvas->x0, rectangle.y + canvas->y0,
- rectangle.width, rectangle.height);
-
- canvas->requestRedraw(r.left(), r.top(), r.right(), r.bottom());
- }
-
- return FALSE;
+ return result;
}
#endif
-gint SPCanvasImpl::handleKeyEvent(GtkWidget *widget, GdkEventKey *event)
+gint SPCanvas::handle_key_event(GtkWidget *widget, GdkEventKey *event)
{
- return emitEvent(SP_CANVAS(widget), reinterpret_cast<GdkEvent *>(event));
+ return SP_CANVAS(widget)->emitEvent(reinterpret_cast<GdkEvent *>(event));
}
-gint SPCanvasImpl::handleCrossing(GtkWidget *widget, GdkEventCrossing *event)
+gint SPCanvas::handle_crossing(GtkWidget *widget, GdkEventCrossing *event)
{
SPCanvas *canvas = SP_CANVAS (widget);
@@ -2047,140 +1847,122 @@ gint SPCanvasImpl::handleCrossing(GtkWidget *widget, GdkEventCrossing *event)
return FALSE;
}
- canvas->state = event->state;
- return pickCurrentItem(canvas, reinterpret_cast<GdkEvent *>(event));
+ canvas->_state = event->state;
+ return canvas->pickCurrentItem(reinterpret_cast<GdkEvent *>(event));
}
-gint SPCanvasImpl::handleFocusIn(GtkWidget *widget, GdkEventFocus *event)
+gint SPCanvas::handle_focus_in(GtkWidget *widget, GdkEventFocus *event)
{
gtk_widget_grab_focus (widget);
SPCanvas *canvas = SP_CANVAS (widget);
- if (canvas->focused_item) {
- return emitEvent(canvas, reinterpret_cast<GdkEvent *>(event));
+ if (canvas->_focused_item) {
+ return canvas->emitEvent(reinterpret_cast<GdkEvent *>(event));
} else {
return FALSE;
}
}
-gint SPCanvasImpl::handleFocusOut(GtkWidget *widget, GdkEventFocus *event)
+gint SPCanvas::handle_focus_out(GtkWidget *widget, GdkEventFocus *event)
{
SPCanvas *canvas = SP_CANVAS(widget);
- if (canvas->focused_item) {
- return emitEvent(canvas, reinterpret_cast<GdkEvent *>(event));
+ if (canvas->_focused_item) {
+ return canvas->emitEvent(reinterpret_cast<GdkEvent *>(event));
} else {
return FALSE;
}
}
-int SPCanvasImpl::paint(SPCanvas *canvas)
+int SPCanvas::paint()
{
- if (canvas->need_update) {
- sp_canvas_item_invoke_update (canvas->root, Geom::identity(), 0);
- canvas->need_update = FALSE;
+ if (_need_update) {
+ sp_canvas_item_invoke_update(_root, Geom::identity(), 0);
+ _need_update = FALSE;
}
- if (!canvas->need_redraw) {
- return TRUE;
- }
-
- Cairo::RefPtr<Cairo::Region> to_paint = Cairo::Region::create();
-
- for (int j=canvas->tTop; j<canvas->tBottom; j++) {
- for (int i=canvas->tLeft; i<canvas->tRight; i++) {
- int tile_index = (i - canvas->tLeft) + (j - canvas->tTop)*canvas->tileH;
-
- if ( canvas->tiles[tile_index] ) { // if this tile is dirtied (nonzero)
- Cairo::RectangleInt rect = {i*TILE_SIZE, j*TILE_SIZE,
- TILE_SIZE, TILE_SIZE};
- to_paint->do_union(rect);
- }
-
- }
- }
-
- int n_rect = to_paint->get_num_rectangles();
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(GTK_WIDGET(this), &allocation);
+ cairo_rectangle_int_t crect = { _x0, _y0, allocation.width, allocation.height };
+ cairo_region_t *to_draw = cairo_region_create_rectangle(&crect);
+ cairo_region_subtract(to_draw, _clean_region);
- if (n_rect > 0) {
- for (int i=0; i < n_rect; i++) {
- Cairo::RectangleInt rect = to_paint->get_rectangle(i);
- int x0 = rect.x;
- int y0 = rect.y;
- int x1 = x0 + rect.width;
- int y1 = y0 + rect.height;
- if (!sp_canvas_paint_rect(canvas, x0, y0, x1, y1)) {
- // Aborted
- return FALSE;
- };
- }
+ int n_rects = cairo_region_num_rectangles(to_draw);
+ for (int i = 0; i < n_rects; ++i) {
+ cairo_rectangle_int_t crect;
+ cairo_region_get_rectangle(to_draw, i, &crect);
+ if (!paintRect(crect.x, crect.y, crect.x + crect.width, crect.y + crect.height)) {
+ // Aborted
+ return FALSE;
+ };
}
- canvas->need_redraw = FALSE;
-
// we've had a full unaborted redraw, reset the full redraw counter
- if (canvas->forced_redraw_limit != -1) {
- canvas->forced_redraw_count = 0;
+ if (_forced_redraw_limit != -1) {
+ _forced_redraw_count = 0;
}
return TRUE;
}
-int SPCanvasImpl::do_update(SPCanvas *canvas)
+int SPCanvas::doUpdate()
{
- if (!canvas->root) { // canvas may have already be destroyed by closing desktop during interrupted display!
+ if (!_root) { // canvas may have already be destroyed by closing desktop during interrupted display!
return TRUE;
}
-
- if (canvas->drawing_disabled) {
+ if (_drawing_disabled) {
return TRUE;
}
// Cause the update if necessary
- if (canvas->need_update) {
- sp_canvas_item_invoke_update(canvas->root, Geom::identity(), 0);
- canvas->need_update = FALSE;
+ if (_need_update) {
+ sp_canvas_item_invoke_update(_root, Geom::identity(), 0);
+ _need_update = FALSE;
}
// Paint if able to
- if (gtk_widget_is_drawable( GTK_WIDGET(canvas) )) {
- return paint(canvas);
+ if (gtk_widget_is_drawable(GTK_WIDGET(this))) {
+ return paint();
}
// Pick new current item
- while (canvas->need_repick) {
- canvas->need_repick = FALSE;
- pickCurrentItem(canvas, &canvas->pick_event);
+ while (_need_repick) {
+ _need_repick = FALSE;
+ pickCurrentItem(&_pick_event);
}
return TRUE;
}
-gint SPCanvasImpl::idle_handler(gpointer data)
+gint SPCanvas::idle_handler(gpointer data)
{
SPCanvas *canvas = SP_CANVAS (data);
-
- int const ret = do_update (canvas);
-
+ int const ret = canvas->doUpdate();
if (ret) {
// Reset idle id
- canvas->idle_id = 0;
+ canvas->_idle_id = 0;
}
-
return !ret;
}
-void SPCanvasImpl::add_idle(SPCanvas *canvas)
+void SPCanvas::addIdle()
{
- if (canvas->idle_id == 0) {
- canvas->idle_id = gdk_threads_add_idle_full(UPDATE_PRIORITY, idle_handler, canvas, NULL);
+ if (_idle_id == 0) {
+ _idle_id = gdk_threads_add_idle_full(UPDATE_PRIORITY, idle_handler, this, NULL);
+ }
+}
+void SPCanvas::removeIdle()
+{
+ if (_idle_id) {
+ g_source_remove(_idle_id);
+ _idle_id = 0;
}
}
SPCanvasGroup *SPCanvas::getRoot()
{
- return SP_CANVAS_GROUP(root);
+ return SP_CANVAS_GROUP(_root);
}
void SPCanvas::scrollTo(double cx, double cy, unsigned int clear, bool is_scrolling)
@@ -2189,72 +1971,115 @@ void SPCanvas::scrollTo(double cx, double cy, unsigned int clear, bool is_scroll
int ix = (int) round(cx); // ix and iy are the new canvas coordinates (integer screen pixels)
int iy = (int) round(cy); // cx might be negative, so (int)(cx + 0.5) will not do!
- int dx = ix - x0; // dx and dy specify the displacement (scroll) of the
- int dy = iy - y0; // canvas w.r.t its previous position
+ int dx = ix - _x0; // dx and dy specify the displacement (scroll) of the
+ int dy = iy - _y0; // canvas w.r.t its previous position
Geom::IntRect old_area = getViewboxIntegers();
Geom::IntRect new_area = old_area + Geom::IntPoint(dx, dy);
-
- dx0 = cx; // here the 'd' stands for double, not delta!
- dy0 = cy;
- x0 = ix;
- y0 = iy;
- gtk_widget_get_allocation(&widget, &allocation);
+ gtk_widget_get_allocation(&_widget, &allocation);
+
+ // adjust backing store contents
+ assert(_backing_store);
+ cairo_surface_t *new_backing_store = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
+ allocation.width, allocation.height);
+ cairo_t *cr = cairo_create(new_backing_store);
+ cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
+ // Paint the background
+ cairo_translate(cr, -ix, -iy);
+ cairo_set_source(cr, _background);
+ cairo_paint(cr);
+ // Copy the old backing store contents
+ cairo_set_source_surface(cr, _backing_store, _x0, _y0);
+ cairo_rectangle(cr, _x0, _y0, allocation.width, allocation.height);
+ cairo_clip(cr);
+ cairo_paint(cr);
+ cairo_destroy(cr);
+ cairo_surface_destroy(_backing_store);
+ _backing_store = new_backing_store;
+
+ _dx0 = cx; // here the 'd' stands for double, not delta!
+ _dy0 = cy;
+ _x0 = ix;
+ _y0 = iy;
+
+ // Adjust the clean region
+ if (clear) {
+ dirtyAll();
+ } else {
+ cairo_rectangle_int_t crect = { _x0, _y0, allocation.width, allocation.height };
+ cairo_region_intersect_rectangle(_clean_region, &crect);
+ }
- SPCanvasImpl::sp_canvas_resize_tiles(this, x0, y0, x0 + allocation.width, y0 + allocation.height);
- if (SP_CANVAS_ITEM_GET_CLASS(root)->viewbox_changed) {
- SP_CANVAS_ITEM_GET_CLASS(root)->viewbox_changed(root, new_area);
+ if (SP_CANVAS_ITEM_GET_CLASS(_root)->viewbox_changed) {
+ SP_CANVAS_ITEM_GET_CLASS(_root)->viewbox_changed(_root, new_area);
}
if (!clear) {
// scrolling without zoom; redraw only the newly exposed areas
if ((dx != 0) || (dy != 0)) {
- this->is_scrolling = is_scrolling;
if (gtk_widget_get_realized(GTK_WIDGET(this))) {
gdk_window_scroll(getWindow(this), -dx, -dy);
}
}
- } else {
- // scrolling as part of zoom; do nothing here - the next do_update will perform full redraw
}
+ addIdle();
}
void SPCanvas::updateNow()
{
- if (need_update || need_redraw) {
- SPCanvasImpl::do_update(this);
+ if (_need_update) {
+ doUpdate();
}
}
-void SPCanvasImpl::requestCanvasUpdate(SPCanvas *canvas)
+void SPCanvas::requestUpdate()
{
- canvas->need_update = TRUE;
- add_idle(canvas);
+ _need_update = TRUE;
+ addIdle();
}
void SPCanvas::requestRedraw(int x0, int y0, int x1, int y1)
{
- GtkAllocation allocation;
-
if (!gtk_widget_is_drawable( GTK_WIDGET(this) )) {
return;
}
- if ((x0 >= x1) || (y0 >= y1)) {
+ if (x0 >= x1 || y0 >= y1) {
return;
}
Geom::IntRect bbox(x0, y0, x1, y1);
- gtk_widget_get_allocation(GTK_WIDGET(this), &allocation);
+ dirtyRect(bbox);
+ addIdle();
+}
- Geom::IntRect canvas_rect = Geom::IntRect::from_xywh(this->x0, this->y0,
- allocation.width, allocation.height);
-
- Geom::OptIntRect clip = bbox & canvas_rect;
- if (clip) {
- SPCanvasImpl::sp_canvas_dirty_rect(this, *clip);
- SPCanvasImpl::add_idle(this);
+void SPCanvas::setBackgroundColor(guint32 rgba) {
+ double new_r = SP_RGBA32_R_F(rgba);
+ double new_g = SP_RGBA32_G_F(rgba);
+ double new_b = SP_RGBA32_B_F(rgba);
+ if (!_background_is_checkerboard) {
+ double old_r, old_g, old_b;
+ cairo_pattern_get_rgba(_background, &old_r, &old_g, &old_b, NULL);
+ if (new_r == old_r && new_g == old_g && new_b == old_b) return;
+ }
+ if (_background) {
+ cairo_pattern_destroy(_background);
+ }
+ _background = cairo_pattern_create_rgb(new_r, new_g, new_b);
+ _background_is_checkerboard = false;
+ dirtyAll();
+ addIdle();
+}
+
+void SPCanvas::setBackgroundCheckerboard() {
+ if (_background_is_checkerboard) return;
+ if (_background) {
+ cairo_pattern_destroy(_background);
}
+ _background = ink_cairo_pattern_create_checkerboard();
+ _background_is_checkerboard = true;
+ dirtyAll();
+ addIdle();
}
/**
@@ -2265,8 +2090,8 @@ void sp_canvas_window_to_world(SPCanvas const *canvas, double winx, double winy,
g_return_if_fail (canvas != NULL);
g_return_if_fail (SP_IS_CANVAS (canvas));
- if (worldx) *worldx = canvas->x0 + winx;
- if (worldy) *worldy = canvas->y0 + winy;
+ if (worldx) *worldx = canvas->_x0 + winx;
+ if (worldy) *worldy = canvas->_y0 + winy;
}
/**
@@ -2277,8 +2102,8 @@ void sp_canvas_world_to_window(SPCanvas const *canvas, double worldx, double wor
g_return_if_fail (canvas != NULL);
g_return_if_fail (SP_IS_CANVAS (canvas));
- if (winx) *winx = worldx - canvas->x0;
- if (winy) *winy = worldy - canvas->y0;
+ if (winx) *winx = worldx - canvas->_x0;
+ if (winy) *winy = worldy - canvas->_y0;
}
/**
@@ -2289,7 +2114,7 @@ Geom::Point sp_canvas_window_to_world(SPCanvas const *canvas, Geom::Point const
g_assert (canvas != NULL);
g_assert (SP_IS_CANVAS (canvas));
- return Geom::Point(canvas->x0 + win[0], canvas->y0 + win[1]);
+ return Geom::Point(canvas->_x0 + win[0], canvas->_y0 + win[1]);
}
/**
@@ -2300,7 +2125,7 @@ Geom::Point sp_canvas_world_to_window(SPCanvas const *canvas, Geom::Point const
g_assert (canvas != NULL);
g_assert (SP_IS_CANVAS (canvas));
- return Geom::Point(world[0] - canvas->x0, world[1] - canvas->y0);
+ return Geom::Point(world[0] - canvas->_x0, world[1] - canvas->_y0);
}
/**
@@ -2316,10 +2141,10 @@ bool sp_canvas_world_pt_inside_window(SPCanvas const *canvas, Geom::Point const
GtkWidget *w = GTK_WIDGET(canvas);
gtk_widget_get_allocation (w, &allocation);
- return ( ( canvas->x0 <= world[Geom::X] ) &&
- ( canvas->y0 <= world[Geom::Y] ) &&
- ( world[Geom::X] < canvas->x0 + allocation.width ) &&
- ( world[Geom::Y] < canvas->y0 + allocation.height ) );
+ return ( ( canvas->_x0 <= world[Geom::X] ) &&
+ ( canvas->_y0 <= world[Geom::Y] ) &&
+ ( world[Geom::X] < canvas->_x0 + allocation.width ) &&
+ ( world[Geom::Y] < canvas->_y0 + allocation.height ) );
}
/**
@@ -2330,8 +2155,8 @@ Geom::Rect SPCanvas::getViewbox() const
GtkAllocation allocation;
gtk_widget_get_allocation (GTK_WIDGET (this), &allocation);
- return Geom::Rect(Geom::Point(dx0, dy0),
- Geom::Point(dx0 + allocation.width, dy0 + allocation.height));
+ return Geom::Rect(Geom::Point(_dx0, _dy0),
+ Geom::Point(_dx0 + allocation.width, _dy0 + allocation.height));
}
/**
@@ -2343,8 +2168,8 @@ Geom::IntRect SPCanvas::getViewboxIntegers() const
gtk_widget_get_allocation (GTK_WIDGET(this), &allocation);
Geom::IntRect ret;
- ret.setMin(Geom::IntPoint(x0, y0));
- ret.setMax(Geom::IntPoint(x0 + allocation.width, y0 + allocation.height));
+ ret.setMin(Geom::IntPoint(_x0, _y0));
+ ret.setMax(Geom::IntPoint(_x0 + allocation.width, _y0 + allocation.height));
return ret;
}
@@ -2358,64 +2183,24 @@ inline int sp_canvas_tile_ceil(int x)
return ((x + (TILE_SIZE - 1)) & (~(TILE_SIZE - 1))) / TILE_SIZE;
}
-void SPCanvasImpl::sp_canvas_resize_tiles(SPCanvas* canvas, int nl, int nt, int nr, int nb)
-{
- if ( nl >= nr || nt >= nb ) {
- if ( canvas->tiles ) g_free(canvas->tiles);
- canvas->tLeft=canvas->tTop=canvas->tRight=canvas->tBottom=0;
- canvas->tileH=canvas->tileV=0;
- canvas->tiles=NULL;
- return;
- }
- int tl=sp_canvas_tile_floor(nl);
- int tt=sp_canvas_tile_floor(nt);
- int tr=sp_canvas_tile_ceil(nr);
- int tb=sp_canvas_tile_ceil(nb);
-
- int nh = tr-tl, nv = tb-tt;
- uint8_t* ntiles = (uint8_t*)g_malloc(nh*nv*sizeof(uint8_t));
- for (int i=tl; i<tr; i++) {
- for (int j=tt; j<tb; j++) {
- int ind = (i-tl) + (j-tt)*nh;
- if ( i >= canvas->tLeft && i < canvas->tRight && j >= canvas->tTop && j < canvas->tBottom ) {
- ntiles[ind]=canvas->tiles[(i-canvas->tLeft)+(j-canvas->tTop)*canvas->tileH]; // copy from the old tile
- } else {
- ntiles[ind]=0; // newly exposed areas get 0
- }
- }
- }
- if ( canvas->tiles ) g_free(canvas->tiles);
- canvas->tiles=ntiles;
- canvas->tLeft=tl;
- canvas->tTop=tt;
- canvas->tRight=tr;
- canvas->tBottom=tb;
- canvas->tileH=nh;
- canvas->tileV=nv;
+void SPCanvas::dirtyRect(Geom::IntRect const &area) {
+ markRect(area, 1);
}
-void SPCanvasImpl::sp_canvas_dirty_rect(SPCanvas* canvas, Geom::IntRect const &area) {
- canvas->need_redraw = TRUE;
-
- sp_canvas_mark_rect(canvas, area, 1);
+void SPCanvas::dirtyAll() {
+ if (_clean_region && !cairo_region_is_empty(_clean_region)) {
+ cairo_region_destroy(_clean_region);
+ _clean_region = cairo_region_create();
+ }
}
-void SPCanvasImpl::sp_canvas_mark_rect(SPCanvas* canvas, Geom::IntRect const &area, uint8_t val)
+void SPCanvas::markRect(Geom::IntRect const &area, uint8_t val)
{
- int tl=sp_canvas_tile_floor(area.left());
- int tt=sp_canvas_tile_floor(area.top());
- int tr=sp_canvas_tile_ceil(area.right());
- int tb=sp_canvas_tile_ceil(area.bottom());
- if ( tl >= canvas->tRight || tr <= canvas->tLeft || tt >= canvas->tBottom || tb <= canvas->tTop ) return;
- if ( tl < canvas->tLeft ) tl=canvas->tLeft;
- if ( tr > canvas->tRight ) tr=canvas->tRight;
- if ( tt < canvas->tTop ) tt=canvas->tTop;
- if ( tb > canvas->tBottom ) tb=canvas->tBottom;
-
- for (int i=tl; i<tr; i++) {
- for (int j=tt; j<tb; j++) {
- canvas->tiles[(i-canvas->tLeft)+(j-canvas->tTop)*canvas->tileH] = val;
- }
+ cairo_rectangle_int_t crect = { area.left(), area.top(), area.width(), area.height() };
+ if (val) {
+ cairo_region_subtract_rectangle(_clean_region, &crect);
+ } else {
+ cairo_region_union_rectangle(_clean_region, &crect);
}
}
diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h
index 65b06ade8..171fdaf67 100644
--- a/src/display/sp-canvas.h
+++ b/src/display/sp-canvas.h
@@ -11,9 +11,11 @@
* Raph Levien <raph@gimp.org>
* Lauris Kaplinski <lauris@kaplinski.com>
* Jon A. Cruz <jon@joncruz.org>
+ * Krzysztof Kosiński <tweenk.pl@gmail.com>
*
* Copyright (C) 1998 The Free Software Foundation
* Copyright (C) 2002 Lauris Kaplinski
+ * Copyright (C) 2016 Google Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -60,7 +62,7 @@ G_END_DECLS
// SPCanvas -------------------------------------------------
-class SPCanvasImpl;
+struct PaintRectSetup;
GType sp_canvas_get_type() G_GNUC_CONST;
@@ -68,123 +70,183 @@ GType sp_canvas_get_type() G_GNUC_CONST;
* Port of GnomeCanvas for inkscape needs.
*/
struct SPCanvas {
- friend class SPCanvasImpl;
+ /// Scrolls canvas to specific position (cx and cy are measured in screen pixels).
+ void scrollTo(double cx, double cy, unsigned int clear, bool is_scrolling = false);
- /**
- * Returns new canvas as widget.
- */
- static GtkWidget *createAA();
+ /// Synchronously updates the canvas if necessary.
+ void updateNow();
- /**
- * Returns the root group of the specified canvas.
- */
+ /// Queues a redraw of rectangular canvas area.
+ void requestRedraw(int x1, int y1, int x2, int y2);
+ void requestUpdate();
+
+ void forceFullRedrawAfterInterruptions(unsigned int count);
+ void endForcedFullRedraws();
+
+ Geom::Rect getViewbox() const;
+ Geom::IntRect getViewboxIntegers() const;
SPCanvasGroup *getRoot();
- /**
- * Scrolls canvas to specific position (cx and cy are measured in screen pixels).
- */
- void scrollTo(double cx, double cy, unsigned int clear, bool is_scrolling = false);
+ void setBackgroundColor(guint32 rgba);
+ void setBackgroundCheckerboard();
+ /// Returns new canvas as widget.
+ static GtkWidget *createAA();
- /**
- * Updates canvas if necessary.
- */
- void updateNow();
+private:
+ /// Emits an event for an item in the canvas, be it the current
+ /// item, grabbed item, or focused item, as appropriate.
+ int emitEvent(GdkEvent *event);
- /**
- * Forces redraw of rectangular canvas area.
- */
- void requestRedraw(int x1, int y1, int x2, int y2);
+ /// Re-picks the current item in the canvas, based on the event's
+ /// coordinates and emits enter/leave events for items as appropriate.
+ int pickCurrentItem(GdkEvent *event);
+ void shutdownTransients();
+
+ /// Allocates a new tile array for the canvas, copying overlapping tiles from the old array
+ void resizeTiles(int nl, int nt, int nr, int nb);
+
+ /// Marks the specified area as dirty (requiring redraw)
+ void dirtyRect(Geom::IntRect const &area);
+ /// Marks the whole widget for redraw
+ void dirtyAll();
+ void markRect(Geom::IntRect const &area, uint8_t val);
+
+ /// Invokes update, paint, and repick on canvas.
+ int doUpdate();
+
+ void paintSingleBuffer(Geom::IntRect const &paint_rect, Geom::IntRect const &canvas_rect, int sw);
/**
- * Force a full redraw after a specified number of interrupted redraws.
+ * Paint the given rect, recursively subdividing the region until it is the size of a single
+ * buffer.
+ *
+ * @return true if the drawing completes
*/
- void forceFullRedrawAfterInterruptions(unsigned int count);
+ int paintRectInternal(PaintRectSetup const *setup, Geom::IntRect const &this_rect);
+
+ /// Draws a specific rectangular part of the canvas.
+ /// @return true if the rectangle painting succeeds.
+ bool paintRect(int xx0, int yy0, int xx1, int yy1);
+
+ /// Repaints the areas in the canvas that need it.
+ /// @return true if all the dirty parts have been redrawn
+ int paint();
+
+ /// Idle handler for the canvas that deals with pending updates and redraws.
+ static gint idle_handler(gpointer data);
+
+ /// Convenience function to add an idle handler to a canvas.
+ void addIdle();
+ void removeIdle();
+
+public:
+ // GTK virtual functions.
+ static void dispose(GObject *object);
+ static void handle_realize(GtkWidget *widget);
+ static void handle_unrealize(GtkWidget *widget);
+#if GTK_CHECK_VERSION(3,0,0)
+ static void handle_get_preferred_width(GtkWidget *widget, gint *min_w, gint *nat_w);
+ static void handle_get_preferred_height(GtkWidget *widget, gint *min_h, gint *nat_h);
+#else
+ static void handle_size_request(GtkWidget *widget, GtkRequisition *req);
+#endif
+ static void handle_size_allocate(GtkWidget *widget, GtkAllocation *allocation);
+ static gint handle_button(GtkWidget *widget, GdkEventButton *event);
/**
- * End forced full redraw requests.
+ * Scroll event handler for the canvas.
+ *
+ * @todo FIXME: generate motion events to re-select items.
*/
- void endForcedFullRedraws();
-
+ static gint handle_scroll(GtkWidget *widget, GdkEventScroll *event);
+ static gint handle_motion(GtkWidget *widget, GdkEventMotion *event);
+ static gboolean handle_draw(GtkWidget *widget, cairo_t *cr);
+#if !GTK_CHECK_VERSION(3,0,0)
+ static gboolean handle_expose(GtkWidget *widget, GdkEventExpose *event);
+#endif
+ static gint handle_key_event(GtkWidget *widget, GdkEventKey *event);
+ static gint handle_crossing(GtkWidget *widget, GdkEventCrossing *event);
+ static gint handle_focus_in(GtkWidget *widget, GdkEventFocus *event);
+ static gint handle_focus_out(GtkWidget *widget, GdkEventFocus *event);
+public:
// Data members: ----------------------------------------------------------
+ GtkWidget _widget;
- GtkWidget widget;
+ guint _idle_id;
- guint idle_id;
+ SPCanvasItem *_root;
- SPCanvasItem *root;
+ bool _is_dragging;
+ double _dx0;
+ double _dy0;
+ int _x0; ///< World coordinate of the leftmost pixels
+ int _y0; ///< World coordinate of the topmost pixels
- bool is_dragging;
- double dx0;
- double dy0;
- int x0;
- int y0;
+ /// Image surface storing the contents of the widget
+ cairo_surface_t *_backing_store;
+ /// Area of the widget that has up-to-date content
+ cairo_region_t *_clean_region;
+ /// Widget background, defaults to white
+ cairo_pattern_t *_background;
+ bool _background_is_checkerboard;
- /* Area that needs redrawing, stored as a microtile array */
- int tLeft, tTop, tRight, tBottom;
- int tileH, tileV;
- uint8_t *tiles;
-
- /** Last known modifier state, for deferred repick when a button is down. */
- int state;
+ /// Last known modifier state, for deferred repick when a button is down.
+ int _state;
/** The item containing the mouse pointer, or NULL if none. */
- SPCanvasItem *current_item;
+ SPCanvasItem *_current_item;
/** Item that is about to become current (used to track deletions and such). */
- SPCanvasItem *new_current_item;
+ SPCanvasItem *_new_current_item;
/** Item that holds a pointer grab, or NULL if none. */
- SPCanvasItem *grabbed_item;
+ SPCanvasItem *_grabbed_item;
/** Event mask specified when grabbing an item. */
- guint grabbed_event_mask;
+ guint _grabbed_event_mask;
/** If non-NULL, the currently focused item. */
- SPCanvasItem *focused_item;
+ SPCanvasItem *_focused_item;
/** Event on which selection of current item is based. */
- GdkEvent pick_event;
+ GdkEvent _pick_event;
- int close_enough;
+ int _close_enough;
- unsigned int need_update : 1;
- unsigned int need_redraw : 1;
- unsigned int need_repick : 1;
+ unsigned int _need_update : 1;
+ unsigned int _need_repick : 1;
- int forced_redraw_count;
- int forced_redraw_limit;
+ int _forced_redraw_count;
+ int _forced_redraw_limit;
/** For use by internal pick_current_item() function. */
- unsigned int left_grabbed_item : 1;
+ unsigned int _left_grabbed_item : 1;
/** For use by internal pick_current_item() function. */
- unsigned int in_repick : 1;
+ unsigned int _in_repick : 1;
// In most tools Inkscape only generates enter and leave events
// on the current item, but no other enter events if a mouse button
- // is depressed -- see function pick_current_item(). Some tools
+ // is depressed -- see function pickCurrentItem(). Some tools
// may wish the canvas to generate to all enter events, (e.g., the
// connector tool). If so, they may temporarily set this flag to
// 'true'.
- bool gen_all_enter_events;
+ bool _gen_all_enter_events;
/** For scripting, sometimes we want to delay drawing. */
- bool drawing_disabled;
+ bool _drawing_disabled;
- int rendermode;
- int colorrendermode;
+ int _rendermode;
+ int _colorrendermode;
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
- bool enable_cms_display_adj;
- Glib::ustring cms_key;
+ bool _enable_cms_display_adj;
+ Glib::ustring _cms_key;
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
- bool is_scrolling;
-
- Geom::Rect getViewbox() const;
- Geom::IntRect getViewboxIntegers() const;
+ bool _is_scrolling;
};
bool sp_canvas_world_pt_inside_window(SPCanvas const *canvas, Geom::Point const &world);
diff --git a/src/document.cpp b/src/document.cpp
index ae03b1ba1..7086fc0be 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -46,6 +46,7 @@
#include "widgets/desktop-widget.h"
#include "desktop.h"
#include "dir-util.h"
+#include "display/drawing.h"
#include "display/drawing-item.h"
#include "document-private.h"
#include "document-undo.h"
@@ -1316,6 +1317,7 @@ SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *gro
if ( SP_IS_ITEM(o) ) {
SPItem *item = SP_ITEM(o);
Inkscape::DrawingItem *arenaitem = item->get_arenaitem(dkey);
+ arenaitem->drawing().update();
if (arenaitem && arenaitem->pick(p, delta, 1) != NULL
&& (take_insensitive || item->isVisibleAndUnlocked(dkey))) {
if (find(list.begin(),list.end(),item)!=list.end() ) {
@@ -1380,10 +1382,12 @@ static SPItem *find_item_at_point(std::deque<SPItem*> *nodes, unsigned int dkey,
continue;
}
Inkscape::DrawingItem *arenaitem = child->get_arenaitem(dkey);
-
- if (arenaitem && arenaitem->pick(p, delta, 1) != NULL) {
- seen = child;
- break;
+ if (arenaitem) {
+ arenaitem->drawing().update();
+ if (arenaitem->pick(p, delta, 1) != NULL) {
+ seen = child;
+ break;
+ }
}
}
@@ -1413,6 +1417,7 @@ static SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Poin
if (SP_IS_GROUP(o) && SP_GROUP(o)->effectiveLayerMode(dkey) != SPGroup::LAYER ) {
SPItem *child = SP_ITEM(o);
Inkscape::DrawingItem *arenaitem = child->get_arenaitem(dkey);
+ arenaitem->drawing().update();
// seen remembers the last (topmost) of groups pickable at this point
if (arenaitem && arenaitem->pick(p, delta, 1) != NULL) {
diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt
index 21e652563..a5352d0ba 100644
--- a/src/extension/CMakeLists.txt
+++ b/src/extension/CMakeLists.txt
@@ -14,6 +14,7 @@ set(extension_SRC
print.cpp
system.cpp
timer.cpp
+ loader.cpp
implementation/implementation.cpp
implementation/xslt.cpp
@@ -90,6 +91,7 @@ set(extension_SRC
print.h
system.h
timer.h
+ loader.h
implementation/implementation.h
implementation/script.h
@@ -244,21 +246,10 @@ if(WITH_IMAGE_MAGICK)
endif()
if(WITH_DBUS)
- list(APPEND extension_SRC
- dbus/application-interface.cpp
- dbus/dbus-init.cpp
- dbus/document-interface.cpp
-
- # ------
- # Header
- dbus/application-interface.h
- dbus/dbus-init.h
- dbus/document-interface.h
- dbus/wrapper/inkscape-dbus-wrapper.h
- )
-
- include_directories(dbus)
+ add_subdirectory(dbus)
endif()
# add_inkscape_lib(extension_LIB "${extension_SRC}")
add_inkscape_source("${extension_SRC}")
+
+add_subdirectory( plugins )
diff --git a/src/extension/Makefile_insert b/src/extension/Makefile_insert
index 4e75de13a..fb9713904 100644
--- a/src/extension/Makefile_insert
+++ b/src/extension/Makefile_insert
@@ -13,6 +13,8 @@ ink_common_sources += \
extension/execution-env.h \
extension/init.cpp \
extension/init.h \
+ extension/loader.h \
+ extension/loader.cpp \
extension/param/parameter.h \
extension/param/parameter.cpp \
extension/param/notebook.h \
diff --git a/src/extension/dbus/CMakeLists.txt b/src/extension/dbus/CMakeLists.txt
new file mode 100644
index 000000000..ad9e1fd7d
--- /dev/null
+++ b/src/extension/dbus/CMakeLists.txt
@@ -0,0 +1,29 @@
+if(WITH_DBUS)
+include_directories(${CMAKE_BINARY_DIR}/src/extension/dbus)
+set(dbus_SRC "")
+ list(APPEND dbus_SRC
+ application-interface.cpp
+ dbus-init.cpp
+ document-interface.cpp
+ )
+ add_custom_target(inkscape_dbus
+ DEPENDS ${CMAKE_BINARY_DIR}/src/extension/dbus/application-server-glue.h ${CMAKE_BINARY_DIR}/src/extension/dbus/document-server-glue.h ${CMAKE_BINARY_DIR}/src/extension/dbus/document-client-glue.h
+ )
+ add_custom_command(
+ OUTPUT ${CMAKE_BINARY_DIR}/src/extension/dbus/application-server-glue.h ${CMAKE_BINARY_DIR}/src/extension/dbus/document-server-glue.h ${CMAKE_BINARY_DIR}/src/extension/dbus/document-client-glue.h
+ DEPENDS ${CMAKE_SOURCE_DIR}/src/extension/dbus/application-interface.xml ${CMAKE_SOURCE_DIR}/src/extension/dbus/document-interface.xml
+ COMMAND dbus-binding-tool --mode=glib-server --output=${CMAKE_BINARY_DIR}/src/extension/dbus/application-server-glue.h --prefix=application_interface ${CMAKE_SOURCE_DIR}/src/extension/dbus/application-interface.xml
+ COMMAND dbus-binding-tool --mode=glib-server --output=${CMAKE_BINARY_DIR}/src/extension/dbus/document-server-glue.h --prefix=document_interface ${CMAKE_SOURCE_DIR}/src/extension/dbus/document-interface.xml
+ COMMAND dbus-binding-tool --mode=glib-client --output=${CMAKE_BINARY_DIR}/src/extension/dbus/document-client-glue.h --prefix=document_interface ${CMAKE_SOURCE_DIR}/src/extension/dbus/document-interface.xml
+ )
+ set_source_files_properties(
+ ${CMAKE_BINARY_DIR}/src/extension/dbus/application-server-glue.h
+ PROPERTIES GENERATED TRUE)
+ set_source_files_properties(
+ ${CMAKE_BINARY_DIR}/src/extension/dbus/document-server-glue.h
+ PROPERTIES GENERATED TRUE)
+ set_source_files_properties(
+ ${CMAKE_BINARY_DIR}/src/extension/dbus/document-client-glue.h
+ PROPERTIES GENERATED TRUE)
+add_inkscape_source("${dbus_SRC}")
+endif()
diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp
index d64bdbc5c..d0a2e81aa 100644
--- a/src/extension/dbus/document-interface.cpp
+++ b/src/extension/dbus/document-interface.cpp
@@ -1,7 +1,7 @@
/*
* This is where the implementation of the DBus based document API lives.
* All the methods in here (except in the helper section) are
- * designed to be called remotly via DBus. application-interface.cpp
+ * designed to be called remotely via DBus. application-interface.cpp
* has the methods used to connect to the bus and get a document instance.
*
* Documentation for these methods is in document-interface.xml
@@ -1052,7 +1052,7 @@ void document_interface_pause_updates(DocumentInterface *doc_interface, GError *
SPDesktop *desk = doc_interface->target.getDesktop();
g_return_if_fail(ensure_desktop_valid(desk, error));
doc_interface->updates = FALSE;
- desk->canvas->drawing_disabled = 1;
+ desk->canvas->_drawing_disabled = 1;
}
void document_interface_resume_updates(DocumentInterface *doc_interface, GError ** error)
@@ -1060,7 +1060,7 @@ void document_interface_resume_updates(DocumentInterface *doc_interface, GError
SPDesktop *desk = doc_interface->target.getDesktop();
g_return_if_fail(ensure_desktop_valid(desk, error));
doc_interface->updates = TRUE;
- desk->canvas->drawing_disabled = 0;
+ desk->canvas->_drawing_disabled = 0;
//FIXME: use better verb than rect.
Inkscape::DocumentUndo::done(doc_interface->target.getDocument(), SP_VERB_CONTEXT_RECT, "Multiple actions");
}
diff --git a/src/extension/dependency.cpp b/src/extension/dependency.cpp
index e46b6fbd2..624be12f9 100644
--- a/src/extension/dependency.cpp
+++ b/src/extension/dependency.cpp
@@ -235,6 +235,18 @@ bool Dependency::check (void) const
}
/**
+ \brief Accessor to the name attribute.
+ \return A string containing the name of the dependency.
+
+ Returns the name of the dependency as found in the configuration file.
+
+*/
+const gchar* Dependency::get_name()
+{
+ return _string;
+}
+
+/**
\brief Print out a dependency to a string.
*/
std::ostream &
diff --git a/src/extension/dependency.h b/src/extension/dependency.h
index 829912dc3..8f5dcc0c8 100644
--- a/src/extension/dependency.h
+++ b/src/extension/dependency.h
@@ -58,6 +58,7 @@ public:
Dependency (Inkscape::XML::Node * in_repr);
virtual ~Dependency (void);
bool check (void) const;
+ const gchar* get_name();
Glib::ustring &get_help (void) const;
Glib::ustring &get_link (void) const;
diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp
index 31491605b..d5c80f26e 100644
--- a/src/extension/execution-env.cpp
+++ b/src/extension/execution-env.cpp
@@ -128,7 +128,7 @@ ExecutionEnv::createWorkingDialog (void) {
}
SPDesktop *desktop = (SPDesktop *)_doc;
- GtkWidget *toplevel = gtk_widget_get_toplevel(&(desktop->canvas->widget));
+ GtkWidget *toplevel = gtk_widget_get_toplevel(GTK_WIDGET(desktop->canvas));
if (!toplevel || !gtk_widget_is_toplevel (toplevel))
return;
Gtk::Window *window = Glib::wrap(GTK_WINDOW(toplevel), false);
diff --git a/src/extension/implementation/implementation.h b/src/extension/implementation/implementation.h
index f6f933aaf..1232ae0c8 100644
--- a/src/extension/implementation/implementation.h
+++ b/src/extension/implementation/implementation.h
@@ -18,7 +18,7 @@
#include <2geom/forward.h>
namespace Gtk {
- class Widget;
+ class Widget;
}
class SPDocument;
@@ -33,7 +33,7 @@ class View;
} // namespace UI
namespace XML {
- class Node;
+ class Node;
} // namespace XML
namespace Extension {
@@ -51,18 +51,18 @@ namespace Implementation {
*/
class ImplementationDocumentCache {
- /**
+ /**
* The document that this instance is working on.
*/
- Inkscape::UI::View::View * _view;
+ Inkscape::UI::View::View * _view;
public:
- ImplementationDocumentCache (Inkscape::UI::View::View * view) :
- _view(view)
- {
- return;
- };
- virtual ~ImplementationDocumentCache ( ) { return; };
- Inkscape::UI::View::View const * view ( ) { return _view; };
+ ImplementationDocumentCache (Inkscape::UI::View::View * view) :
+ _view(view)
+ {
+ return;
+ };
+ virtual ~ImplementationDocumentCache ( ) { return; };
+ Inkscape::UI::View::View const * view ( ) { return _view; };
};
/**
@@ -116,7 +116,7 @@ public:
// ----- Effect functions -----
/** Find out information about the file. */
virtual Gtk::Widget * prefs_effect(Inkscape::Extension::Effect *module,
- Inkscape::UI::View::View *view,
+ Inkscape::UI::View::View *view,
sigc::signal<void> *changeSignal,
ImplementationDocumentCache *docCache);
virtual void effect(Inkscape::Extension::Effect * /*module*/,
diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp
index 4cb0c9b73..9aaf4b952 100644
--- a/src/extension/implementation/script.cpp
+++ b/src/extension/implementation/script.cpp
@@ -152,7 +152,7 @@ Script::Script() :
}
/**
- * brief Destructor
+ * \brief Destructor
*/
Script::~Script()
{
@@ -232,11 +232,7 @@ bool Script::check_existence(const std::string &command)
//Don't search when it is an absolute path. */
if (Glib::path_is_absolute(command)) {
- if (Glib::file_test(command, Glib::FILE_TEST_EXISTS)) {
- return true;
- } else {
- return false;
- }
+ return Glib::file_test(command, Glib::FILE_TEST_EXISTS);
}
// First search in the current directory
@@ -280,9 +276,9 @@ bool Script::check_existence(const std::string &command)
/**
\return none
- \brief This function 'loads' an extention, basically it determines
- the full command for the extention and stores that.
- \param module The extention to be loaded.
+ \brief This function 'loads' an extension, basically it determines
+ the full command for the extension and stores that.
+ \param module The extension to be loaded.
The most difficult part about this function is finding the actual
command through all of the Reprs. Basically it is hidden down a
@@ -292,7 +288,7 @@ bool Script::check_existence(const std::string &command)
At that point all of the loops are exited, and there is an
if statement to make sure they didn't exit because of not finding
- the command. If that's the case, the extention doesn't get loaded
+ the command. If that's the case, the extension doesn't get loaded
and should error out at a higher level.
*/
@@ -545,17 +541,17 @@ SPDocument *Script::open(Inkscape::Extension::Input *module,
/**
\return none
- \brief This function uses an extention to save a document. It first
+ \brief This function uses an extension to save a document. It first
creates an SVG file of the document, and then runs it through
the script.
- \param module Extention to be used
+ \param module Extension to be used
\param doc Document to be saved
\param filename The name to save the final file as
\return false in case of any failure writing the file, otherwise true
Well, at some point people need to save - it is really what makes
the entire application useful. And, it is possible that someone
- would want to use an extetion for this, so we need a function to
+ would want to use an extension for this, so we need a function to
do that eh?
First things first, the document is saved to a temporary file that
@@ -563,7 +559,7 @@ SPDocument *Script::open(Inkscape::Extension::Input *module,
ink_ext_ as a prefix. Don't worry, this file gets deleted at the
end of the function.
- After we have the SVG file, then extention_execute is called with
+ After we have the SVG file, then Script::execute is called with
the temporary file name and the final output filename. This should
put the output of the script into the final output file. We then
delete the temporary file.
@@ -1123,7 +1119,45 @@ int Script::execute (const std::list<std::string> &in_command,
}
+void Script::file_listener::init(int fd, Glib::RefPtr<Glib::MainLoop> main) {
+ _channel = Glib::IOChannel::create_from_fd(fd);
+ _channel->set_encoding();
+ _conn = main->get_context()->signal_io().connect(sigc::mem_fun(*this, &file_listener::read), _channel, Glib::IO_IN | Glib::IO_HUP | Glib::IO_ERR);
+ _main_loop = main;
+
+ return;
+}
+bool Script::file_listener::read(Glib::IOCondition condition) {
+ if (condition != Glib::IO_IN) {
+ _main_loop->quit();
+ return false;
+ }
+
+ Glib::IOStatus status;
+ Glib::ustring out;
+ status = _channel->read_line(out);
+ _string += out;
+
+ if (status != Glib::IO_STATUS_NORMAL) {
+ _main_loop->quit();
+ _dead = true;
+ return false;
+ }
+
+ return true;
+}
+
+bool Script::file_listener::toFile(const Glib::ustring &name) {
+ try {
+ Glib::RefPtr<Glib::IOChannel> stdout_file = Glib::IOChannel::create_from_file(name, "w");
+ stdout_file->set_encoding();
+ stdout_file->write(_string);
+ } catch (Glib::FileError &e) {
+ return false;
+ }
+ return true;
+}
} // namespace Implementation
} // namespace Extension
diff --git a/src/extension/implementation/script.h b/src/extension/implementation/script.h
index 4cf33c989..684719895 100644
--- a/src/extension/implementation/script.h
+++ b/src/extension/implementation/script.h
@@ -85,49 +85,10 @@ private:
};
bool isDead () { return _dead; }
-
- // TODO move these definitions into script.cpp
- void init (int fd, Glib::RefPtr<Glib::MainLoop> main) {
- _channel = Glib::IOChannel::create_from_fd(fd);
- _channel->set_encoding();
- _conn = main->get_context()->signal_io().connect(sigc::mem_fun(*this, &file_listener::read), _channel, Glib::IO_IN | Glib::IO_HUP | Glib::IO_ERR);
- _main_loop = main;
-
- return;
- };
-
- bool read (Glib::IOCondition condition) {
- if (condition != Glib::IO_IN) {
- _main_loop->quit();
- return false;
- }
-
- Glib::IOStatus status;
- Glib::ustring out;
- status = _channel->read_line(out);
- _string += out;
-
- if (status != Glib::IO_STATUS_NORMAL) {
- _main_loop->quit();
- _dead = true;
- return false;
- }
-
- return true;
- };
-
+ void init(int fd, Glib::RefPtr<Glib::MainLoop> main);
+ bool read(Glib::IOCondition condition);
Glib::ustring string (void) { return _string; };
-
- bool toFile (const Glib::ustring &name) {
- try {
- Glib::RefPtr<Glib::IOChannel> stdout_file = Glib::IOChannel::create_from_file(name, "w");
- stdout_file->set_encoding();
- stdout_file->write(_string);
- } catch (Glib::FileError &e) {
- return false;
- }
- return true;
- };
+ bool toFile(const Glib::ustring &name);
};
int execute (const std::list<std::string> &in_command,
diff --git a/src/extension/init.cpp b/src/extension/init.cpp
index c16a5a899..af7af2cb1 100644
--- a/src/extension/init.cpp
+++ b/src/extension/init.cpp
@@ -1,6 +1,6 @@
/*
* This is what gets executed to initialize all of the modules. For
- * the internal modules this invovles executing their initialization
+ * the internal modules this involves executing their initialization
* functions, for external ones it involves reading their .spmodule
* files and bringing them into Sodipodi.
*
diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp
index f811f00ad..5d8b0e076 100644
--- a/src/extension/internal/cairo-render-context.cpp
+++ b/src/extension/internal/cairo-render-context.cpp
@@ -1453,8 +1453,11 @@ CairoRenderContext::_prepareRenderText()
}
}
+/* We need CairoPaintOrder as markers are rendered in a separate step and may be rendered
+ * inbetween fill and stroke.
+ */
bool
-CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle const *style, Geom::OptRect const &pbox)
+CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle const *style, Geom::OptRect const &pbox, CairoPaintOrder order)
{
g_assert( _is_valid );
@@ -1476,9 +1479,10 @@ CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle con
return true;
}
- bool no_fill = style->fill.isNone() || style->fill_opacity.value == 0;
+ bool no_fill = style->fill.isNone() || style->fill_opacity.value == 0 ||
+ order == STROKE_ONLY;
bool no_stroke = style->stroke.isNone() || style->stroke_width.computed < 1e-9 ||
- style->stroke_opacity.value == 0;
+ style->stroke_opacity.value == 0 || order == FILL_ONLY;
if (no_fill && no_stroke)
return true;
@@ -1492,14 +1496,17 @@ CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle con
pushLayer();
if (!no_fill) {
- _setFillStyle(style, pbox);
- setPathVector(pathv);
-
if (style->fill_rule.computed == SP_WIND_RULE_EVENODD) {
cairo_set_fill_rule(_cr, CAIRO_FILL_RULE_EVEN_ODD);
} else {
cairo_set_fill_rule(_cr, CAIRO_FILL_RULE_WINDING);
}
+ }
+
+ setPathVector(pathv);
+
+ if (!no_fill && (order == STROKE_OVER_FILL || order == FILL_ONLY)) {
+ _setFillStyle(style, pbox);
if (no_stroke)
cairo_fill(_cr);
@@ -1509,10 +1516,17 @@ CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle con
if (!no_stroke) {
_setStrokeStyle(style, pbox);
- if (no_fill)
- setPathVector(pathv);
- cairo_stroke(_cr);
+ if (no_fill || order == STROKE_OVER_FILL)
+ cairo_stroke(_cr);
+ else
+ cairo_stroke_preserve(_cr);
+ }
+
+ if (!no_fill && order == FILL_OVER_STROKE) {
+ _setFillStyle(style, pbox);
+
+ cairo_fill(_cr);
}
if (need_layer)
@@ -1642,7 +1656,7 @@ CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const &font_ma
return true;
// create a cairo_font_face from PangoFont
- double size = style->font_size.computed; /// \fixme why is this variable never used?
+ // double size = style->font_size.computed; /// \fixme why is this variable never used?
gpointer fonthash = (gpointer)font;
cairo_font_face_t *font_face = NULL;
if(font_table.find(fonthash)!=font_table.end())
@@ -1699,30 +1713,72 @@ CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const &font_ma
_showGlyphs(_cr, font, glyphtext, TRUE);
}
} else {
- bool fill = false, stroke = false, have_path = false;
+
+ bool fill = false;
if (style->fill.isColor() || style->fill.isPaintserver()) {
fill = true;
}
+ bool stroke = false;
if (style->stroke.isColor() || style->stroke.isPaintserver()) {
stroke = true;
}
- if (fill) {
+
+ // Text never has markers
+ bool stroke_over_fill = true;
+ if ( (style->paint_order.layer[0] == SP_CSS_PAINT_ORDER_STROKE &&
+ style->paint_order.layer[1] == SP_CSS_PAINT_ORDER_FILL) ||
+
+ (style->paint_order.layer[0] == SP_CSS_PAINT_ORDER_STROKE &&
+ style->paint_order.layer[2] == SP_CSS_PAINT_ORDER_FILL) ||
+
+ (style->paint_order.layer[1] == SP_CSS_PAINT_ORDER_STROKE &&
+ style->paint_order.layer[2] == SP_CSS_PAINT_ORDER_FILL) ) {
+ stroke_over_fill = false;
+ }
+
+ bool have_path = false;
+ if (fill && stroke_over_fill) {
_setFillStyle(style, Geom::OptRect());
if (_is_texttopath) {
_showGlyphs(_cr, font, glyphtext, true);
- have_path = true;
- if (stroke) cairo_fill_preserve(_cr);
- else cairo_fill(_cr);
+ if (stroke) {
+ cairo_fill_preserve(_cr);
+ have_path = true;
+ } else {
+ cairo_fill(_cr);
+ }
} else {
_showGlyphs(_cr, font, glyphtext, false);
}
}
+
if (stroke) {
_setStrokeStyle(style, Geom::OptRect());
- if (!have_path) _showGlyphs(_cr, font, glyphtext, true);
- cairo_stroke(_cr);
+ if (!have_path) {
+ _showGlyphs(_cr, font, glyphtext, true);
+ }
+ if (fill && _is_texttopath && !stroke_over_fill) {
+ cairo_stroke_preserve(_cr);
+ have_path = true;
+ } else {
+ cairo_stroke(_cr);
+ }
+ }
+
+ if (fill && !stroke_over_fill) {
+ _setFillStyle(style, Geom::OptRect());
+ if (_is_texttopath) {
+ if (!have_path) {
+ // Could happen if both 'stroke' and 'stroke_over_fill' are false
+ _showGlyphs(_cr, font, glyphtext, true);
+ }
+ cairo_fill(_cr);
+ } else {
+ _showGlyphs(_cr, font, glyphtext, false);
+ }
}
+
}
cairo_restore(_cr);
diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h
index b3ab3655a..dfa6084d1 100644
--- a/src/extension/internal/cairo-render-context.h
+++ b/src/extension/internal/cairo-render-context.h
@@ -148,7 +148,14 @@ public:
void addClippingRect(double x, double y, double width, double height);
/* Rendering methods */
- bool renderPathVector(Geom::PathVector const &pathv, SPStyle const *style, Geom::OptRect const &pbox);
+ enum CairoPaintOrder {
+ STROKE_OVER_FILL,
+ FILL_OVER_STROKE,
+ FILL_ONLY,
+ STROKE_ONLY
+ };
+
+ bool renderPathVector(Geom::PathVector const &pathv, SPStyle const *style, Geom::OptRect const &pbox, CairoPaintOrder order = STROKE_OVER_FILL);
bool renderImage(Inkscape::Pixbuf *pb,
Geom::Affine const &image_transform, SPStyle const *style);
bool renderGlyphtext(PangoFont *font, Geom::Affine const &font_matrix,
diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp
index a4561fd11..5dc20ab06 100644
--- a/src/extension/internal/cairo-renderer.cpp
+++ b/src/extension/internal/cairo-renderer.cpp
@@ -194,7 +194,20 @@ static void sp_shape_render(SPShape *shape, CairoRenderContext *ctx)
return;
}
- ctx->renderPathVector(pathv, style, pbox);
+ if (style->paint_order.layer[0] == SP_CSS_PAINT_ORDER_NORMAL ||
+ (style->paint_order.layer[0] == SP_CSS_PAINT_ORDER_FILL &&
+ style->paint_order.layer[1] == SP_CSS_PAINT_ORDER_STROKE)) {
+ ctx->renderPathVector(pathv, style, pbox, CairoRenderContext::STROKE_OVER_FILL);
+ } else if (style->paint_order.layer[0] == SP_CSS_PAINT_ORDER_STROKE &&
+ style->paint_order.layer[1] == SP_CSS_PAINT_ORDER_FILL ) {
+ ctx->renderPathVector(pathv, style, pbox, CairoRenderContext::FILL_OVER_STROKE);
+ } else if (style->paint_order.layer[0] == SP_CSS_PAINT_ORDER_STROKE &&
+ style->paint_order.layer[1] == SP_CSS_PAINT_ORDER_MARKER ) {
+ ctx->renderPathVector(pathv, style, pbox, CairoRenderContext::STROKE_ONLY);
+ } else if (style->paint_order.layer[0] == SP_CSS_PAINT_ORDER_FILL &&
+ style->paint_order.layer[1] == SP_CSS_PAINT_ORDER_MARKER ) {
+ ctx->renderPathVector(pathv, style, pbox, CairoRenderContext::FILL_ONLY);
+ }
// START marker
for (int i = 0; i < 2; i++) { // SP_MARKER_LOC and SP_MARKER_LOC_START
@@ -287,6 +300,21 @@ static void sp_shape_render(SPShape *shape, CairoRenderContext *ctx)
sp_shape_render_invoke_marker_rendering(marker, tr, style, ctx);
}
}
+
+ if (style->paint_order.layer[1] == SP_CSS_PAINT_ORDER_FILL &&
+ style->paint_order.layer[2] == SP_CSS_PAINT_ORDER_STROKE) {
+ ctx->renderPathVector(pathv, style, pbox, CairoRenderContext::STROKE_OVER_FILL);
+ } else if (style->paint_order.layer[1] == SP_CSS_PAINT_ORDER_STROKE &&
+ style->paint_order.layer[2] == SP_CSS_PAINT_ORDER_FILL ) {
+ ctx->renderPathVector(pathv, style, pbox, CairoRenderContext::FILL_OVER_STROKE);
+ } else if (style->paint_order.layer[2] == SP_CSS_PAINT_ORDER_STROKE &&
+ style->paint_order.layer[1] == SP_CSS_PAINT_ORDER_MARKER ) {
+ ctx->renderPathVector(pathv, style, pbox, CairoRenderContext::STROKE_ONLY);
+ } else if (style->paint_order.layer[2] == SP_CSS_PAINT_ORDER_FILL &&
+ style->paint_order.layer[1] == SP_CSS_PAINT_ORDER_MARKER ) {
+ ctx->renderPathVector(pathv, style, pbox, CairoRenderContext::FILL_ONLY);
+ }
+
}
static void sp_group_render(SPGroup *group, CairoRenderContext *ctx)
diff --git a/src/extension/internal/cdr-input.cpp b/src/extension/internal/cdr-input.cpp
index a4e26e224..a26af2078 100644
--- a/src/extension/internal/cdr-input.cpp
+++ b/src/extension/internal/cdr-input.cpp
@@ -22,7 +22,6 @@
#include <string>
#include <cstring>
-#include <glibmm/regex.h>
#include <libcdr/libcdr.h>
@@ -42,28 +41,18 @@
#endif
#include <gtkmm/alignment.h>
-#include <gtkmm/comboboxtext.h>
-#include <gtkmm/drawingarea.h>
-#include <gtkmm/frame.h>
-#include <gtkmm/scale.h>
+#include <gtkmm/spinbutton.h>
#include "extension/system.h"
#include "extension/input.h"
-#include "document.h"
+#include "document.h"
#include "document-private.h"
-#include "document-undo.h"
#include "inkscape.h"
#include "ui/dialog-events.h"
-#include <gtk/gtk.h>
-#include "ui/widget/spinbutton.h"
-#include "ui/widget/frame.h"
#include <glibmm/i18n.h>
-#include <gdkmm/general.h>
-
-#include "svg-view.h"
#include "svg-view-widget.h"
#include "util/units.h"
@@ -83,108 +72,99 @@ public:
void getImportSettings(Inkscape::XML::Node *prefs);
private:
- void _setPreviewPage(unsigned page);
+ void _setPreviewPage();
// Signal handlers
-#if !WITH_GTKMM_3_0
- bool _onExposePreview(GdkEventExpose *event);
-#endif
-
void _onPageNumberChanged();
+ void _onSpinButtonPress(GdkEventButton* button_event);
+ void _onSpinButtonRelease(GdkEventButton* button_event);
+ class Gtk::VBox * vbox1;
+ class Gtk::Widget * _previewArea;
class Gtk::Button * cancelbutton;
class Gtk::Button * okbutton;
class Gtk::Label * _labelSelect;
- class Inkscape::UI::Widget::SpinButton * _pageNumberSpin;
class Gtk::Label * _labelTotalPages;
- class Gtk::VBox * vbox1;
- class Gtk::VBox * vbox2;
- class Gtk::Widget * _previewArea;
+ class Gtk::SpinButton * _pageNumberSpin;
- const std::vector<RVNGString> &_vec; // Document to be imported
- unsigned _current_page; // Current selected page
- int _preview_width, _preview_height; // Size of the preview area
+ const std::vector<RVNGString> &_vec; // Document to be imported
+ unsigned _current_page; // Current selected page
+ bool _spinning; // whether SpinButton is pressed (i.e. we're "spinning")
};
CdrImportDialog::CdrImportDialog(const std::vector<RVNGString> &vec)
- : _vec(vec), _current_page(1)
+ : _vec(vec), _current_page(1), _spinning(false)
{
int num_pages = _vec.size();
if ( num_pages <= 1 )
return;
- cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
- okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok")));
- _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:")));
- // Page number
+ // Dialog settings
+ this->set_title(_("Page Selector"));
+ this->set_modal(true);
+ sp_transientize(GTK_WIDGET(this->gobj())); //Make transient
+ this->property_window_position().set_value(Gtk::WIN_POS_NONE);
+ this->set_resizable(true);
+ this->property_destroy_with_parent().set_value(false);
+
+ // Preview area
+ _previewArea = Gtk::manage(new class Gtk::VBox());
+ vbox1 = Gtk::manage(new class Gtk::VBox());
+ vbox1->pack_start(*_previewArea, Gtk::PACK_EXPAND_WIDGET, 0);
#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0);
- _pageNumberSpin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(_pageNumberSpin_adj, 1, 1));
+ this->get_content_area()->pack_start(*vbox1);
#else
- Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(
- new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0));
- _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1));
+ this->get_vbox()->pack_start(*vbox1);
#endif
- _labelTotalPages = Gtk::manage(new class Gtk::Label());
- gchar *label_text = g_strdup_printf(_("out of %i"), num_pages);
- _labelTotalPages->set_label(label_text);
- g_free(label_text);
- vbox1 = Gtk::manage(new class Gtk::VBox(false, 4));
- SPDocument *doc = SPDocument::createNewDocFromMem(_vec[0].cstr(), strlen(_vec[0].cstr()), 0);
- _previewArea = Glib::wrap(sp_svg_view_widget_new(doc));
-
- vbox2 = Gtk::manage(new class Gtk::VBox(false, 4));
- cancelbutton->set_can_focus();
- cancelbutton->set_can_default();
- cancelbutton->set_relief(Gtk::RELIEF_NORMAL);
- okbutton->set_can_focus();
- okbutton->set_can_default();
- okbutton->set_relief(Gtk::RELIEF_NORMAL);
- this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END);
+ // CONTROLS
+
+ // Buttons
+ cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
+ okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok")));
+
+ // Labels
+ _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:")));
+ _labelTotalPages = Gtk::manage(new class Gtk::Label());
_labelSelect->set_line_wrap(false);
_labelSelect->set_use_markup(false);
_labelSelect->set_selectable(false);
- _pageNumberSpin->set_can_focus();
- _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS);
- _pageNumberSpin->set_numeric(true);
- _pageNumberSpin->set_digits(0);
- _pageNumberSpin->set_wrap(false);
_labelTotalPages->set_line_wrap(false);
_labelTotalPages->set_use_markup(false);
_labelTotalPages->set_selectable(false);
- vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
+ gchar *label_text = g_strdup_printf(_("out of %i"), num_pages);
+ _labelTotalPages->set_label(label_text);
+ g_free(label_text);
+
+ // Adjustment + spinner
#if WITH_GTKMM_3_0
- this->get_content_area()->set_homogeneous(false);
- this->get_content_area()->set_spacing(0);
- this->get_content_area()->pack_start(*vbox2);
+ Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0);
+ _pageNumberSpin = Gtk::manage(new Gtk::SpinButton(_pageNumberSpin_adj, 1, 0));
#else
- this->get_vbox()->set_homogeneous(false);
- this->get_vbox()->set_spacing(0);
- this->get_vbox()->pack_start(*vbox2);
+ Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0));
+ _pageNumberSpin = Gtk::manage(new Gtk::SpinButton(*_pageNumberSpin_adj, 1, 0));
#endif
- this->set_title(_("Page Selector"));
- this->set_modal(true);
- sp_transientize(GTK_WIDGET(this->gobj())); //Make transient
- this->property_window_position().set_value(Gtk::WIN_POS_NONE);
- this->set_resizable(true);
- this->property_destroy_with_parent().set_value(false);
+ _pageNumberSpin->set_can_focus();
+ _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS);
+ _pageNumberSpin->set_numeric(true);
+ _pageNumberSpin->set_wrap(false);
+
+ this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END);
this->get_action_area()->add(*_labelSelect);
- this->add_action_widget(*_pageNumberSpin, -7);
+ this->add_action_widget(*_pageNumberSpin, Gtk::RESPONSE_ACCEPT);
this->get_action_area()->add(*_labelTotalPages);
- this->add_action_widget(*cancelbutton, -6);
- this->add_action_widget(*okbutton, -5);
- cancelbutton->show();
- okbutton->show();
- _labelSelect->show();
- _pageNumberSpin->show();
- _labelTotalPages->show();
- vbox1->show();
- _previewArea->show();
- vbox2->show();
+ this->add_action_widget(*cancelbutton, Gtk::RESPONSE_CANCEL);
+ this->add_action_widget(*okbutton, Gtk::RESPONSE_OK);
+
+ // Show all widgets in dialog
+ this->show_all();
// Connect signals
- _pageNumberSpin_adj->signal_value_changed().connect(sigc::mem_fun(*this, &CdrImportDialog::_onPageNumberChanged));
+ _pageNumberSpin->signal_value_changed().connect(sigc::mem_fun(*this, &CdrImportDialog::_onPageNumberChanged));
+ _pageNumberSpin->signal_button_press_event().connect_notify(sigc::mem_fun(*this, &CdrImportDialog::_onSpinButtonPress));
+ _pageNumberSpin->signal_button_release_event().connect_notify(sigc::mem_fun(*this, &CdrImportDialog::_onSpinButtonRelease));
+
+ _setPreviewPage();
}
CdrImportDialog::~CdrImportDialog() {}
@@ -194,7 +174,7 @@ bool CdrImportDialog::showDialog()
show();
gint b = run();
hide();
- if ( b == Gtk::RESPONSE_OK ) {
+ if (b == Gtk::RESPONSE_OK || b == Gtk::RESPONSE_ACCEPT) {
return TRUE;
} else {
return FALSE;
@@ -210,22 +190,34 @@ void CdrImportDialog::_onPageNumberChanged()
{
unsigned page = static_cast<unsigned>(_pageNumberSpin->get_value_as_int());
_current_page = CLAMP(page, 1U, _vec.size());
- _setPreviewPage(_current_page);
+ _setPreviewPage();
+}
+
+void CdrImportDialog::_onSpinButtonPress(GdkEventButton* /*button_event*/)
+{
+ _spinning = true;
+}
+
+void CdrImportDialog::_onSpinButtonRelease(GdkEventButton* /*button_event*/)
+{
+ _spinning = false;
+ _setPreviewPage();
}
/**
* \brief Renders the given page's thumbnail
*/
-void CdrImportDialog::_setPreviewPage(unsigned page)
+void CdrImportDialog::_setPreviewPage()
{
- SPDocument *doc = SPDocument::createNewDocFromMem(_vec[page-1].cstr(), strlen(_vec[page-1].cstr()), 0);
+ if (_spinning) {
+ return;
+ }
+
+ SPDocument *doc = SPDocument::createNewDocFromMem(_vec[_current_page-1].cstr(), strlen(_vec[_current_page-1].cstr()), 0);
Gtk::Widget * tmpPreviewArea = Glib::wrap(sp_svg_view_widget_new(doc));
std::swap(_previewArea, tmpPreviewArea);
- if (tmpPreviewArea) {
- _previewArea->set_size_request( tmpPreviewArea->get_width(), tmpPreviewArea->get_height() );
- delete tmpPreviewArea;
- }
- vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
+ delete tmpPreviewArea;
+ vbox1->pack_start(*_previewArea, Gtk::PACK_EXPAND_WIDGET, 0);
_previewArea->show_now();
}
@@ -282,12 +274,7 @@ SPDocument *CdrInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u
}
}
- // remove consecutive closepath commands (see bug 1492153)
- Glib::RefPtr<Glib::Regex> regex = Glib::Regex::create("(Z(?:\\s+Z)+)(?=[^<]+\")");
- Glib::ustring outString1 = Glib::ustring(tmpSVGOutput[page_num-1].cstr());
- Glib::ustring outString2 = regex->replace(outString1, 0, "Z", Glib::REGEX_MATCH_NEWLINE_ANY);
-
- SPDocument * doc = SPDocument::createNewDocFromMem(outString2.c_str(), outString2.bytes(), TRUE);
+ SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE);
// Set viewBox if it doesn't exist
if (doc && !doc->getRoot()->viewBox_set) {
diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp
index 3dfa5cb23..1c85182ae 100644
--- a/src/extension/internal/emf-print.cpp
+++ b/src/extension/internal/emf-print.cpp
@@ -253,7 +253,7 @@ unsigned int PrintEmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc)
char *oldlocale = g_strdup(setlocale(LC_NUMERIC, NULL));
setlocale(LC_NUMERIC, "C");
- snprintf(buff, sizeof(buff) - 1, "Drawing=%.1lfx%.1lfpx, %.1lfx%.1lfmm", _width, _height, Inkscape::Util::Quantity::convert(dwInchesX, "in", "mm"), Inkscape::Util::Quantity::convert(dwInchesY, "in", "mm"));
+ snprintf(buff, sizeof(buff) - 1, "Drawing=%.1fx%.1fpx, %.1fx%.1fmm", _width, _height, Inkscape::Util::Quantity::convert(dwInchesX, "in", "mm"), Inkscape::Util::Quantity::convert(dwInchesY, "in", "mm"));
setlocale(LC_NUMERIC, oldlocale);
g_free(oldlocale);
rec = textcomment_set(buff);
diff --git a/src/extension/internal/image-resolution.cpp b/src/extension/internal/image-resolution.cpp
index e96fd6437..57142bbdd 100644
--- a/src/extension/internal/image-resolution.cpp
+++ b/src/extension/internal/image-resolution.cpp
@@ -34,6 +34,18 @@
#include <Magick++.h>
#endif
+#define noIMAGE_RESOLUTION_DEBUG
+
+#ifdef IMAGE_RESOLUTION_DEBUG
+# define debug(f, a...) { g_print("%s(%d) %s:", \
+ __FILE__,__LINE__,__FUNCTION__); \
+ g_print(f, ## a); \
+ g_print("\n"); \
+ }
+#else
+# define debug(f, a...) /* */
+#endif
+
namespace Inkscape {
namespace Extension {
namespace Internal {
@@ -118,17 +130,38 @@ void ImageResolution::readpng(char const *fn) {
png_read_info(png_ptr, info_ptr);
png_uint_32 res_x, res_y;
+#ifdef PNG_INCH_CONVERSIONS_SUPPORTED
+ debug("PNG_INCH_CONVERSIONS_SUPPORTED");
+ res_x = png_get_x_pixels_per_inch(png_ptr, info_ptr);
+ res_y = png_get_y_pixels_per_inch(png_ptr, info_ptr);
+ if (res_x != 0 && res_y != 0) {
+ ok_ = true;
+ x_ = res_x * 1.0; // FIXME: implicit conversion of png_uint_32 to double ok?
+ y_ = res_y * 1.0; // FIXME: implicit conversion of png_uint_32 to double ok?
+ }
+#else
+ debug("PNG_RESOLUTION_METER");
int unit_type;
+ // FIXME: png_get_pHYs() fails to return expected values
+ // with clang (based on LLVM 3.2svn) from Xcode 4.6.3 (OS X 10.7.5)
png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, &unit_type);
- png_destroy_read_struct(&png_ptr, &info_ptr, 0);
- fclose(fp);
-
if (unit_type == PNG_RESOLUTION_METER) {
ok_ = true;
x_ = res_x * 2.54 / 100;
y_ = res_y * 2.54 / 100;
}
+#endif
+
+ png_destroy_read_struct(&png_ptr, &info_ptr, 0);
+ fclose(fp);
+
+ if (ok_) {
+ debug("xdpi: %f", x_);
+ debug("ydpi: %f", y_);
+ } else {
+ debug("FAILED");
+ }
}
#else
@@ -206,6 +239,13 @@ void ImageResolution::readexif(char const *fn) {
ok_ = true;
}
exif_data_free(ed);
+
+ if (ok_) {
+ debug("xdpi: %f", x_);
+ debug("ydpi: %f", y_);
+ } else {
+ debug("FAILED");
+ }
}
#else
@@ -256,6 +296,13 @@ void ImageResolution::readexiv(char const *fn) {
}
}
ok_ = havex && havey;
+
+ if (ok_) {
+ debug("xdpi: %f", x_);
+ debug("ydpi: %f", y_);
+ } else {
+ debug("FAILED");
+ }
}
#else
@@ -312,6 +359,7 @@ void ImageResolution::readjfif(char const *fn) {
jpeg_stdio_src(&cinfo, ifd);
jpeg_read_header(&cinfo, TRUE);
+ debug("cinfo.[XY]_density");
if (cinfo.saw_JFIF_marker) { // JFIF APP0 marker was seen
if ( cinfo.density_unit == 1 ) { // dots/inch
x_ = cinfo.X_density;
@@ -331,6 +379,13 @@ void ImageResolution::readjfif(char const *fn) {
}
jpeg_destroy_decompress(&cinfo);
fclose(ifd);
+
+ if (ok_) {
+ debug("xdpi: %f", x_);
+ debug("ydpi: %f", y_);
+ } else {
+ debug("FAILED");
+ }
}
#else
@@ -344,16 +399,17 @@ void ImageResolution::readjfif(char const *) {
#ifdef WITH_IMAGE_MAGICK
void ImageResolution::readmagick(char const *fn) {
Magick::Image image;
+ debug("Trying image.read");
try {
image.read(fn);
} catch (Magick::Error & err) {
- g_warning("ImageMagick error: %s", err.what());
+ debug("ImageMagick error: %s", err.what());
return;
- } catch (...) {
- g_warning("ImageResolution::readmagick: Unknown error");
+ } catch (std::exception & err) {
+ debug("ImageResolution::readmagick: %s", err.what());
return;
}
-
+ debug("image.[xy]Resolution");
std::string const type = image.magick();
x_ = image.xResolution();
y_ = image.yResolution();
@@ -367,6 +423,14 @@ void ImageResolution::readmagick(char const *fn) {
if (x_ != 0 && y_ != 0) {
ok_ = true;
}
+
+ if (ok_) {
+ debug("xdpi: %f", x_);
+ debug("ydpi: %f", y_);
+ } else {
+ debug("FAILED");
+ debug("Using default Inkscape import resolution");
+ }
}
#else
diff --git a/src/extension/internal/text_reassemble.c b/src/extension/internal/text_reassemble.c
index fa983b83d..b23176ed5 100644
--- a/src/extension/internal/text_reassemble.c
+++ b/src/extension/internal/text_reassemble.c
@@ -67,11 +67,11 @@ Optional compiler switches for development:
File: text_reassemble.c
-Version: 0.0.17
-Date: 21-MAY-2015
+Version: 0.0.18
+Date: 11-MAR-2016
Author: David Mathog, Biology Division, Caltech
email: mathog@caltech.edu
-Copyright: 2015 David Mathog and California Institute of Technology (Caltech)
+Copyright: 2016 David Mathog and California Institute of Technology (Caltech)
*/
#ifdef __cplusplus
@@ -223,7 +223,7 @@ char *TR_construct_fontspec(const TCHUNK_SPECS *tsp, const char *fontname){
int newlen = 128 + strlen(fontname); /* too big, but not by much */
char *newfs = NULL;
newfs = (char *) malloc(newlen);
- sprintf(newfs,"%s:slant=%d:weight=%d:size=%lf:width=%d",fontname,tsp->italics,tsp->weight,tsp->fs,(tsp->co ? 75 : tsp->condensed));
+ sprintf(newfs,"%s:slant=%d:weight=%d:size=%f:width=%d",fontname,tsp->italics,tsp->weight,tsp->fs,(tsp->co ? 75 : tsp->condensed));
return(newfs);
}
@@ -804,7 +804,7 @@ int ftinfo_load_fontname(FT_INFO *fti, const char *fontspec){
int fb;
if(FcPatternGetBool( fpat, FC_OUTLINE, 0, &fb)== FcResultMatch){ printf("outline: %d\n",fb);fflush(stdout); }
if(FcPatternGetBool( fpat, FC_SCALABLE, 0, &fb)== FcResultMatch){ printf("scalable: %d\n",fb);fflush(stdout); }
- if(FcPatternGetDouble( fpat, FC_DPI, 0, &fd)== FcResultMatch){ printf("DPI: %lf\n",fd);fflush(stdout); }
+ if(FcPatternGetDouble( fpat, FC_DPI, 0, &fd)== FcResultMatch){ printf("DPI: %f\n",fd);fflush(stdout); }
if(FcPatternGetInteger( fpat, FC_FONTVERSION, 0, &fb)== FcResultMatch){ printf("fontversion: %d\n",fb);fflush(stdout); }
if(FcPatternGetString( fpat, FC_FULLNAME , 0, (FcChar8 **)&fs)== FcResultMatch){ printf("FULLNAME : %s\n",fs);fflush(stdout); }
if(FcPatternGetString( fpat, FC_FAMILY , 0, (FcChar8 **)&fs)== FcResultMatch){ printf("FAMILY : %s\n",fs);fflush(stdout); }
@@ -831,7 +831,7 @@ void ftinfo_dump(const FT_INFO *fti){
printf("fti used: %d\n",fti->used);
for(i=0; i< fti->used; i++){
fsp = &(fti->fonts[i]);
- printf("fti font: %6d space: %6d used: %6d spcadv %8lf fsize %8lf \n",i,fsp->space,fsp->used,fsp->spcadv,fsp->fsize);
+ printf("fti font: %6d space: %6d used: %6d spcadv %8f fsize %8f \n",i,fsp->space,fsp->used,fsp->spcadv,fsp->fsize);
printf(" file: %s\n",fsp->file);
printf(" fspc: %s\n",fsp->fontspec);
for(j=0;j<fsp->used;j++){
@@ -1123,18 +1123,18 @@ void cxinfo_dump(const TR_INFO *tri){
printf("cxi phase1: %d\n",cxi->phase1);
printf("cxi lines: %d\n",cxi->lines);
printf("cxi paras: %d\n",cxi->paras);
- printf("cxi xy: %lf , %lf\n",tri->x,tri->y);
+ printf("cxi xy: %f , %f\n",tri->x,tri->y);
for(i=0;i<cxi->used;i++){
csp = &(cxi->cx[i]);
bsp = &(bri->rects[csp->rt_cidx]);
printf("cxi cx[%d] type:%d rt_tidx:%d kids_used:%d kids_space:%d\n",i, csp->type, csp->rt_cidx, csp->kids.used, csp->kids.space);
- printf("cxi cx[%d] br (LL,UR) (%lf,%lf),(%lf,%lf)\n",i,bsp->xll,bsp->yll,bsp->xur,bsp->yur);
+ printf("cxi cx[%d] br (LL,UR) (%f,%f),(%f,%f)\n",i,bsp->xll,bsp->yll,bsp->xur,bsp->yur);
for(j=0;j<csp->kids.used;j++){
k = csp->kids.members[j];
bsp = &(bri->rects[k]);
if(csp->type == TR_TEXT || csp->type == TR_LINE){
- printf("cxi cx[%d] member:%3d tp_idx:%3d ldir:%d rt_tidx:%3d br (LL,UR) (%8.3lf,%8.3lf),(%8.3lf,%8.3lf) xy (%8.3lf,%8.3lf) kern (%8.3lf,%8.3lf) text:<%s> decor:%5.5x\n",
+ printf("cxi cx[%d] member:%3d tp_idx:%3d ldir:%d rt_tidx:%3d br (LL,UR) (%8.3f,%8.3f),(%8.3f,%8.3f) xy (%8.3f,%8.3f) kern (%8.3f,%8.3f) text:<%s> decor:%5.5x\n",
i, j, k, tpi->chunks[k].ldir, tpi->chunks[k].rt_tidx,
bsp->xll,bsp->yll,bsp->xur,bsp->yur,
tpi->chunks[k].x, tpi->chunks[k].y,
@@ -1311,7 +1311,7 @@ int brinfo_merge(BR_INFO *bri, int dst, int src){
bri->rects[dst].xur = TEREMAX(bri->rects[dst].xur, bri->rects[src].xur);
bri->rects[dst].yur = TEREMIN(bri->rects[dst].yur, bri->rects[src].yur); /* MIN because Y is positive DOWN */
/*
-printf("bri_Merge into rect:%d (LL,UR) dst:(%lf,%lf),(%lf,%lf) src:(%lf,%lf),(%lf,%lf)\n",dst,
+printf("bri_Merge into rect:%d (LL,UR) dst:(%f,%f),(%f,%f) src:(%f,%f),(%f,%f)\n",dst,
(bri->rects[dst].xll),
(bri->rects[dst].yll),
(bri->rects[dst].xur),
@@ -1374,7 +1374,7 @@ int brinfo_overlap(const BR_INFO *bri, int dst, int src, RT_PAD *rp_dst, RT_PAD
}
}
/*
-printf("Overlap status:%d\nOverlap trects (LL,UR) dst:(%lf,%lf),(%lf,%lf) src:(%lf,%lf),(%lf,%lf)\n",
+printf("Overlap status:%d\nOverlap trects (LL,UR) dst:(%f,%f),(%f,%f) src:(%f,%f),(%f,%f)\n",
status,
(br_dst->xll - rp_dst->left ),
(br_dst->yll - rp_dst->down ),
@@ -1384,7 +1384,7 @@ status,
(br_src->yll - rp_src->down ),
(br_src->xur + rp_src->right),
(br_src->yur + rp_src->up ));
-printf("Overlap brects (LL,UR) dst:(%lf,%lf),(%lf,%lf) src:(%lf,%lf),(%lf,%lf)\n",
+printf("Overlap brects (LL,UR) dst:(%f,%f),(%f,%f) src:(%f,%f),(%f,%f)\n",
(br_dst->xll),
(br_dst->yll),
(br_dst->xur),
@@ -1393,7 +1393,7 @@ printf("Overlap brects (LL,UR) dst:(%lf,%lf),(%lf,%lf) src:(%lf,%lf),(%lf,%lf)\n
(br_src->yll),
(br_src->xur),
(br_src->yur));
-printf("Overlap rprect (LL,UR) dst:(%lf,%lf),(%lf,%lf) src:(%lf,%lf),(%lf,%lf)\n",
+printf("Overlap rprect (LL,UR) dst:(%f,%f),(%f,%f) src:(%f,%f),(%f,%f)\n",
(rp_dst->left),
(rp_dst->down),
(rp_dst->right),
@@ -1481,7 +1481,7 @@ enum tr_classes brinfo_pp_alignment(const BR_INFO *bri, int dst, int src, double
newtype = TR_PARA_UJ;
}
/*
-printf("pp_align newtype:%d brects (LL,UR) dst:(%lf,%lf),(%lf,%lf) src:(%lf,%lf),(%lf,%lf)\n",
+printf("pp_align newtype:%d brects (LL,UR) dst:(%f,%f),(%f,%f) src:(%f,%f),(%f,%f)\n",
newtype,
(br_dst->xll),
(br_dst->yll),
@@ -1779,7 +1779,7 @@ int trinfo_load_textrec(TR_INFO *tri, const TCHUNK_SPECS *tsp, double escapement
tpi->chunks[current].y = x * sin(escapement) + y * cos(escapement);
/* Careful! face bbox does NOT scale with FT_Set_Char_Size
-printf("Face idx:%d bbox: xMax/Min:%ld,%ld yMax/Min:%ld,%ld UpEM:%d asc/des:%d,%d height:%d size:%lf\n",
+printf("Face idx:%d bbox: xMax/Min:%ld,%ld yMax/Min:%ld,%ld UpEM:%d asc/des:%d,%d height:%d size:%f\n",
idx,
fsp->face->bbox.xMax,fsp->face->bbox.xMin,
fsp->face->bbox.yMax,fsp->face->bbox.yMin,
@@ -1955,7 +1955,7 @@ void TR_layout_2_svg(TR_INFO *tri){
/* put rectangles down for each text string - debugging!!! This will not work properly for any Narrow fonts */
esc = tri->esc;
esc *= 2.0 * M_PI / 360.0; /* degrees to radians and change direction of rotation */
- sprintf(stransform,"transform=\"matrix(%lf,%lf,%lf,%lf,%lf,%lf)\"\n",cos(esc),-sin(esc),sin(esc),cos(esc), 1.25*x,1.25*y);
+ sprintf(stransform,"transform=\"matrix(%f,%f,%f,%f,%f,%f)\"\n",cos(esc),-sin(esc),sin(esc),cos(esc), 1.25*x,1.25*y);
for(i=cxi->phase1; i<cxi->used;i++){ /* over all complex members from phase2 == TR_PARA_* complexes */
csp = &(cxi->cx[i]);
for(j=0; j<csp->kids.used; j++){ /* over all members of these complexes, which are phase1 complexes */
@@ -1968,11 +1968,11 @@ void TR_layout_2_svg(TR_INFO *tri){
#if DBG_TR_PARA
TRPRINT(tri, "<rect\n");
TRPRINT(tri, "style=\"color:#0000FF;color-interpolation:sRGB;color-interpolation-filters:linearRGB;fill:none;stroke:#000000;stroke-width:0.8;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;clip-rule:nonzero\"\n");
- sprintf(obuf,"width=\"%lf\"\n", 1.25*(bri->rects[csp->rt_cidx].xur - bri->rects[csp->rt_cidx].xll));
+ sprintf(obuf,"width=\"%f\"\n", 1.25*(bri->rects[csp->rt_cidx].xur - bri->rects[csp->rt_cidx].xll));
TRPRINT(tri, obuf);
- sprintf(obuf,"height=\"%lf\"\n",1.25*(bri->rects[csp->rt_cidx].yll - bri->rects[csp->rt_cidx].yur));
+ sprintf(obuf,"height=\"%f\"\n",1.25*(bri->rects[csp->rt_cidx].yll - bri->rects[csp->rt_cidx].yur));
TRPRINT(tri, obuf);
- sprintf(obuf,"x=\"%lf\" y=\"%lf\"\n",1.25*(bri->rects[csp->rt_cidx].xll),1.25*(bri->rects[csp->rt_cidx].yur));
+ sprintf(obuf,"x=\"%f\" y=\"%f\"\n",1.25*(bri->rects[csp->rt_cidx].xll),1.25*(bri->rects[csp->rt_cidx].yur));
TRPRINT(tri, obuf);
TRPRINT(tri, stransform);
TRPRINT(tri, "/>\n");
@@ -1983,23 +1983,23 @@ void TR_layout_2_svg(TR_INFO *tri){
newy = 1.25*(bri->rects[tsp->rt_tidx].yur);
TRPRINT(tri, "<rect\n");
TRPRINT(tri, "style=\"color:#000000;color-interpolation:sRGB;color-interpolation-filters:linearRGB;fill:none;stroke:#00FF00;stroke-width:0.3;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;clip-rule:nonzero\"\n");
- sprintf(obuf,"width=\"%lf\"\n", 1.25*(bri->rects[tsp->rt_tidx].xur - bri->rects[tsp->rt_tidx].xll));
+ sprintf(obuf,"width=\"%f\"\n", 1.25*(bri->rects[tsp->rt_tidx].xur - bri->rects[tsp->rt_tidx].xll));
TRPRINT(tri, obuf);
- sprintf(obuf,"height=\"%lf\"\n",1.25*(bri->rects[tsp->rt_tidx].yll - bri->rects[tsp->rt_tidx].yur));
+ sprintf(obuf,"height=\"%f\"\n",1.25*(bri->rects[tsp->rt_tidx].yll - bri->rects[tsp->rt_tidx].yur));
TRPRINT(tri, obuf);
- sprintf(obuf,"x=\"%lf\" y=\"%lf\"\n",1.25*(bri->rects[tsp->rt_tidx].xll),newy);
+ sprintf(obuf,"x=\"%f\" y=\"%f\"\n",1.25*(bri->rects[tsp->rt_tidx].xll),newy);
TRPRINT(tri, obuf);
TRPRINT(tri, stransform);
TRPRINT(tri, "/>\n");
newy = 1.25*(bri->rects[tsp->rt_tidx].yll - tsp->boff);
- sprintf(obuf,"<text x=\"%lf\" y=\"%lf\"\n",newx, newy );
+ sprintf(obuf,"<text x=\"%f\" y=\"%f\"\n",newx, newy );
TRPRINT(tri, obuf);
sprintf(obuf,"xml:space=\"preserve\"\n");
TRPRINT(tri, obuf);
TRPRINT(tri, stransform);
TRPRINT(tri, "style=\"fill:#FF0000;");
- sprintf(obuf,"font-size:%lfpx;",tsp->fs*1.25); /*IMPORTANT, if the FS is given in pt it looks like crap in browsers. As if px != 1.25 pt, maybe 96 dpi not 90?*/
+ sprintf(obuf,"font-size:%fpx;",tsp->fs*1.25); /*IMPORTANT, if the FS is given in pt it looks like crap in browsers. As if px != 1.25 pt, maybe 96 dpi not 90?*/
TRPRINT(tri, obuf);
sprintf(obuf,"font-style:%s;",(tsp->italics ? "italic" : "normal"));
TRPRINT(tri, obuf);
@@ -2025,7 +2025,7 @@ void TR_layout_2_svg(TR_INFO *tri){
if(tri->usebk){
esc = tri->esc;
esc *= 2.0 * M_PI / 360.0; /* degrees to radians and change direction of rotation */
- sprintf(stransform,"transform=\"matrix(%lf,%lf,%lf,%lf,%lf,%lf)\"\n",cos(esc),-sin(esc),sin(esc),cos(esc), 1.25*x,1.25*y);
+ sprintf(stransform,"transform=\"matrix(%f,%f,%f,%f,%f,%f)\"\n",cos(esc),-sin(esc),sin(esc),cos(esc), 1.25*x,1.25*y);
for(i=cxi->phase1; i<cxi->used;i++){ /* over all complex members from phase2 == TR_PARA_* complexes */
TRPRINT(tri, "<g>\n"); /* group backgrounds for each <text> object in the SVG */
@@ -2037,11 +2037,11 @@ void TR_layout_2_svg(TR_INFO *tri){
TRPRINT(tri, "<rect\n");
sprintf(obuf,"style=\"color-interpolation:sRGB;color-interpolation-filters:linearRGB;fill:#%2.2X%2.2X%2.2X;;stroke:none;;stroke-dasharray:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;clip-rule:nonzero\"\n",tri->bkcolor.Red,tri->bkcolor.Green,tri->bkcolor.Blue);
TRPRINT(tri, obuf);
- sprintf(obuf,"width=\"%lf\"\n", 1.25*(bri->rects[cline_sp->rt_cidx].xur - bri->rects[cline_sp->rt_cidx].xll));
+ sprintf(obuf,"width=\"%f\"\n", 1.25*(bri->rects[cline_sp->rt_cidx].xur - bri->rects[cline_sp->rt_cidx].xll));
TRPRINT(tri, obuf);
- sprintf(obuf,"height=\"%lf\"\n",1.25*(bri->rects[cline_sp->rt_cidx].yll - bri->rects[cline_sp->rt_cidx].yur));
+ sprintf(obuf,"height=\"%f\"\n",1.25*(bri->rects[cline_sp->rt_cidx].yll - bri->rects[cline_sp->rt_cidx].yur));
TRPRINT(tri, obuf);
- sprintf(obuf,"x=\"%lf\" y=\"%lf\"\n",1.25*(bri->rects[cline_sp->rt_cidx].xll),1.25*(bri->rects[cline_sp->rt_cidx].yur));
+ sprintf(obuf,"x=\"%f\" y=\"%f\"\n",1.25*(bri->rects[cline_sp->rt_cidx].xll),1.25*(bri->rects[cline_sp->rt_cidx].yur));
TRPRINT(tri, obuf);
TRPRINT(tri, stransform);
TRPRINT(tri, "/>\n");
@@ -2056,11 +2056,11 @@ void TR_layout_2_svg(TR_INFO *tri){
TRPRINT(tri, "<rect\n");
sprintf(obuf,"style=\"color-interpolation:sRGB;color-interpolation-filters:linearRGB;fill:#%2.2X%2.2X%2.2X;;stroke:none;;stroke-dasharray:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;clip-rule:nonzero\"\n",tri->bkcolor.Red,tri->bkcolor.Green,tri->bkcolor.Blue);
TRPRINT(tri, obuf);
- sprintf(obuf,"width=\"%lf\"\n", 1.25*(bri->rects[csp->rt_cidx].xur - bri->rects[csp->rt_cidx].xll));
+ sprintf(obuf,"width=\"%f\"\n", 1.25*(bri->rects[csp->rt_cidx].xur - bri->rects[csp->rt_cidx].xll));
TRPRINT(tri, obuf);
- sprintf(obuf,"height=\"%lf\"\n",1.25*(bri->rects[csp->rt_cidx].yll - bri->rects[csp->rt_cidx].yur));
+ sprintf(obuf,"height=\"%f\"\n",1.25*(bri->rects[csp->rt_cidx].yll - bri->rects[csp->rt_cidx].yur));
TRPRINT(tri, obuf);
- sprintf(obuf,"x=\"%lf\" y=\"%lf\"\n",1.25*(bri->rects[csp->rt_cidx].xll),1.25*(bri->rects[csp->rt_cidx].yur));
+ sprintf(obuf,"x=\"%f\" y=\"%f\"\n",1.25*(bri->rects[csp->rt_cidx].xll),1.25*(bri->rects[csp->rt_cidx].yur));
TRPRINT(tri, obuf);
TRPRINT(tri, stransform);
TRPRINT(tri, "/>\n");
@@ -2072,11 +2072,11 @@ void TR_layout_2_svg(TR_INFO *tri){
TRPRINT(tri, "<rect\n");
sprintf(obuf,"style=\"color-interpolation:sRGB;color-interpolation-filters:linearRGB;fill:#%2.2X%2.2X%2.2X;;stroke:none;;stroke-dasharray:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;clip-rule:nonzero\"\n",tri->bkcolor.Red,tri->bkcolor.Green,tri->bkcolor.Blue);
TRPRINT(tri, obuf);
- sprintf(obuf,"width=\"%lf\"\n", 1.25*(bri->rects[tsp->rt_tidx].xur - bri->rects[tsp->rt_tidx].xll));
+ sprintf(obuf,"width=\"%f\"\n", 1.25*(bri->rects[tsp->rt_tidx].xur - bri->rects[tsp->rt_tidx].xll));
TRPRINT(tri, obuf);
- sprintf(obuf,"height=\"%lf\"\n",1.25*(bri->rects[tsp->rt_tidx].yll - bri->rects[tsp->rt_tidx].yur));
+ sprintf(obuf,"height=\"%f\"\n",1.25*(bri->rects[tsp->rt_tidx].yll - bri->rects[tsp->rt_tidx].yur));
TRPRINT(tri, obuf);
- sprintf(obuf,"x=\"%lf\" y=\"%lf\"\n",newx,newy);
+ sprintf(obuf,"x=\"%f\" y=\"%f\"\n",newx,newy);
TRPRINT(tri, obuf);
TRPRINT(tri, stransform);
TRPRINT(tri, "/>\n");
@@ -2135,7 +2135,7 @@ void TR_layout_2_svg(TR_INFO *tri){
TRPRINT(tri, "<text\n");
TRPRINT(tri, "xml:space=\"preserve\"\n");
TRPRINT(tri, "style=\"");
- sprintf(obuf,"font-size:%lfpx;",tsp->fs*1.25); /*IMPORTANT, if the FS is given in pt it looks like crap in browsers. As if px != 1.25 pt, maybe 96 dpi not 90?*/
+ sprintf(obuf,"font-size:%fpx;",tsp->fs*1.25); /*IMPORTANT, if the FS is given in pt it looks like crap in browsers. As if px != 1.25 pt, maybe 96 dpi not 90?*/
TRPRINT(tri, obuf);
sprintf(obuf,"font-style:%s;",(tsp->italics ? "italic" : "normal"));
TRPRINT(tri, obuf);
@@ -2146,7 +2146,7 @@ void TR_layout_2_svg(TR_INFO *tri){
TRPRINT(tri, obuf);
if(tsp->vadvance){ lineheight = tsp->vadvance *100.0; }
else { lineheight = 125.0; }
- sprintf(obuf,"line-height:%lf%%;",lineheight);
+ sprintf(obuf,"line-height:%f%%;",lineheight);
TRPRINT(tri, obuf);
TRPRINT(tri, "letter-spacing:0px;");
TRPRINT(tri, "word-spacing:0px;");
@@ -2174,14 +2174,14 @@ void TR_layout_2_svg(TR_INFO *tri){
}
TRPRINT(tri, obuf);
TRPRINT(tri, "\"\n"); /* End of style specification */
- sprintf(obuf,"transform=\"matrix(%lf,%lf,%lf,%lf,%lf,%lf)\"\n",cos(esc),-sin(esc),sin(esc),cos(esc),1.25*x,1.25*y);
+ sprintf(obuf,"transform=\"matrix(%f,%f,%f,%f,%f,%f)\"\n",cos(esc),-sin(esc),sin(esc),cos(esc),1.25*x,1.25*y);
TRPRINT(tri, obuf);
tmpx = 1.25*((ldir == LDIR_RL ? bri->rects[kdx].xur : bri->rects[kdx].xll) + recenter);
- sprintf(obuf,"x=\"%lf\" y=\"%lf\"\n>",tmpx,1.25*(bri->rects[kdx].yll - tsp->boff));
+ sprintf(obuf,"x=\"%f\" y=\"%f\"\n>",tmpx,1.25*(bri->rects[kdx].yll - tsp->boff));
TRPRINT(tri, obuf);
}
tmpx = 1.25*((ldir == LDIR_RL ? bri->rects[kdx].xur : bri->rects[kdx].xll) + recenter);
- sprintf(obuf,"<tspan sodipodi:role=\"line\"\nx=\"%lf\" y=\"%lf\"\n>",tmpx,1.25*(bri->rects[kdx].yll - tsp->boff));
+ sprintf(obuf,"<tspan sodipodi:role=\"line\"\nx=\"%f\" y=\"%f\"\n>",tmpx,1.25*(bri->rects[kdx].yll - tsp->boff));
TRPRINT(tri, obuf);
}
TRPRINT(tri, "<tspan\n");
@@ -2192,11 +2192,11 @@ void TR_layout_2_svg(TR_INFO *tri){
dx = 1.25 * tsp->xkern;
dy = 1.25 * tsp->ykern;
- sprintf(obuf,"dx=\"%lf\" dy=\"%lf\" ",dx, dy);
+ sprintf(obuf,"dx=\"%f\" dy=\"%f\" ",dx, dy);
TRPRINT(tri, obuf);
sprintf(obuf,"style=\"fill:#%2.2X%2.2X%2.2X;",tsp->color.Red,tsp->color.Green,tsp->color.Blue);
TRPRINT(tri, obuf);
- sprintf(obuf,"font-size:%lfpx;",tsp->fs*1.25); /*IMPORTANT, if the FS is given in pt it looks like crap in browsers. As if px != 1.25 pt, maybe 96 dpi not 90?*/
+ sprintf(obuf,"font-size:%fpx;",tsp->fs*1.25); /*IMPORTANT, if the FS is given in pt it looks like crap in browsers. As if px != 1.25 pt, maybe 96 dpi not 90?*/
TRPRINT(tri, obuf);
sprintf(obuf,"font-style:%s;",(tsp->italics ? "italic" : "normal"));
TRPRINT(tri, obuf);
diff --git a/src/extension/internal/vsd-input.cpp b/src/extension/internal/vsd-input.cpp
index 7fd0d363b..a3d4aad37 100644
--- a/src/extension/internal/vsd-input.cpp
+++ b/src/extension/internal/vsd-input.cpp
@@ -40,33 +40,24 @@
typedef libvisio::VSDStringVector RVNGStringVector;
#endif
-
#include <gtkmm/alignment.h>
-#include <gtkmm/comboboxtext.h>
-#include <gtkmm/drawingarea.h>
-#include <gtkmm/frame.h>
-#include <gtkmm/scale.h>
+#include <gtkmm/spinbutton.h>
#include "extension/system.h"
#include "extension/input.h"
-#include "document.h"
+#include "document.h"
#include "document-private.h"
-#include "document-undo.h"
#include "inkscape.h"
-#include "util/units.h"
#include "ui/dialog-events.h"
-#include <gtk/gtk.h>
-#include "ui/widget/spinbutton.h"
-#include "ui/widget/frame.h"
#include <glibmm/i18n.h>
-#include <gdkmm/general.h>
-
-#include "svg-view.h"
#include "svg-view-widget.h"
+
+#include "util/units.h"
+
namespace Inkscape {
namespace Extension {
namespace Internal {
@@ -82,108 +73,101 @@ public:
void getImportSettings(Inkscape::XML::Node *prefs);
private:
- void _setPreviewPage(unsigned page);
+ void _setPreviewPage();
// Signal handlers
-#if !WITH_GTKMM_3_0
- bool _onExposePreview(GdkEventExpose *event);
-#endif
-
void _onPageNumberChanged();
+ void _onSpinButtonPress(GdkEventButton* button_event);
+ void _onSpinButtonRelease(GdkEventButton* button_event);
+ class Gtk::VBox * vbox1;
+ class Gtk::Widget * _previewArea;
class Gtk::Button * cancelbutton;
class Gtk::Button * okbutton;
class Gtk::Label * _labelSelect;
- class Inkscape::UI::Widget::SpinButton * _pageNumberSpin;
class Gtk::Label * _labelTotalPages;
- class Gtk::VBox * vbox1;
- class Gtk::VBox * vbox2;
- class Gtk::Widget * _previewArea;
+ class Gtk::SpinButton * _pageNumberSpin;
- const std::vector<RVNGString> &_vec; // Document to be imported
- unsigned _current_page; // Current selected page
- int _preview_width, _preview_height; // Size of the preview area
+ const std::vector<RVNGString> &_vec; // Document to be imported
+ unsigned _current_page; // Current selected page
+ bool _spinning; // whether SpinButton is pressed (i.e. we're "spinning")
};
VsdImportDialog::VsdImportDialog(const std::vector<RVNGString> &vec)
- : _vec(vec), _current_page(1)
+ : _vec(vec), _current_page(1), _spinning(false)
{
int num_pages = _vec.size();
if ( num_pages <= 1 )
return;
- cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
- okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok")));
- _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:")));
- // Page number
+
+ // Dialog settings
+ this->set_title(_("Page Selector"));
+ this->set_modal(true);
+ sp_transientize(GTK_WIDGET(this->gobj())); //Make transient
+ this->property_window_position().set_value(Gtk::WIN_POS_NONE);
+ this->set_resizable(true);
+ this->property_destroy_with_parent().set_value(false);
+
+ // Preview area
+ _previewArea = Gtk::manage(new class Gtk::VBox());
+ vbox1 = Gtk::manage(new class Gtk::VBox());
+ vbox1->pack_start(*_previewArea, Gtk::PACK_EXPAND_WIDGET, 0);
#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0);
- _pageNumberSpin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(_pageNumberSpin_adj, 1, 1));
+ this->get_content_area()->pack_start(*vbox1);
#else
- Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(
- new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0));
- _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1));
+ this->get_vbox()->pack_start(*vbox1);
#endif
- _labelTotalPages = Gtk::manage(new class Gtk::Label());
- gchar *label_text = g_strdup_printf(_("out of %i"), num_pages);
- _labelTotalPages->set_label(label_text);
- g_free(label_text);
- vbox1 = Gtk::manage(new class Gtk::VBox(false, 4));
- SPDocument *doc = SPDocument::createNewDocFromMem(_vec[0].cstr(), strlen(_vec[0].cstr()), 0);
- _previewArea = Glib::wrap(sp_svg_view_widget_new(doc));
-
- vbox2 = Gtk::manage(new class Gtk::VBox(false, 4));
- cancelbutton->set_can_focus();
- cancelbutton->set_can_default();
- cancelbutton->set_relief(Gtk::RELIEF_NORMAL);
- okbutton->set_can_focus();
- okbutton->set_can_default();
- okbutton->set_relief(Gtk::RELIEF_NORMAL);
- this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END);
+
+ // CONTROLS
+
+ // Buttons
+ cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
+ okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok")));
+
+ // Labels
+ _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:")));
+ _labelTotalPages = Gtk::manage(new class Gtk::Label());
_labelSelect->set_line_wrap(false);
_labelSelect->set_use_markup(false);
_labelSelect->set_selectable(false);
- _pageNumberSpin->set_can_focus();
- _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS);
- _pageNumberSpin->set_numeric(true);
- _pageNumberSpin->set_digits(0);
- _pageNumberSpin->set_wrap(false);
_labelTotalPages->set_line_wrap(false);
_labelTotalPages->set_use_markup(false);
_labelTotalPages->set_selectable(false);
- vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
+ gchar *label_text = g_strdup_printf(_("out of %i"), num_pages);
+ _labelTotalPages->set_label(label_text);
+ g_free(label_text);
+
+ // Adjustment + spinner
#if WITH_GTKMM_3_0
- this->get_content_area()->set_homogeneous(false);
- this->get_content_area()->set_spacing(0);
- this->get_content_area()->pack_start(*vbox2);
+ Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0);
+ _pageNumberSpin = Gtk::manage(new Gtk::SpinButton(_pageNumberSpin_adj, 1, 0));
#else
- this->get_vbox()->set_homogeneous(false);
- this->get_vbox()->set_spacing(0);
- this->get_vbox()->pack_start(*vbox2);
+ Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0));
+ _pageNumberSpin = Gtk::manage(new Gtk::SpinButton(*_pageNumberSpin_adj, 1, 0));
#endif
- this->set_title(_("Page Selector"));
- this->set_modal(true);
- sp_transientize(GTK_WIDGET(this->gobj())); //Make transient
- this->property_window_position().set_value(Gtk::WIN_POS_NONE);
- this->set_resizable(true);
- this->property_destroy_with_parent().set_value(false);
+ _pageNumberSpin->set_can_focus();
+ _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS);
+ _pageNumberSpin->set_numeric(true);
+ _pageNumberSpin->set_wrap(false);
+
+ this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END);
this->get_action_area()->add(*_labelSelect);
- this->add_action_widget(*_pageNumberSpin, -7);
+ this->add_action_widget(*_pageNumberSpin, Gtk::RESPONSE_ACCEPT);
this->get_action_area()->add(*_labelTotalPages);
- this->add_action_widget(*cancelbutton, -6);
- this->add_action_widget(*okbutton, -5);
- cancelbutton->show();
- okbutton->show();
- _labelSelect->show();
- _pageNumberSpin->show();
- _labelTotalPages->show();
- vbox1->show();
- _previewArea->show();
- vbox2->show();
+ this->add_action_widget(*cancelbutton, Gtk::RESPONSE_CANCEL);
+ this->add_action_widget(*okbutton, Gtk::RESPONSE_OK);
+
+ // Show all widgets in dialog
+ this->show_all();
// Connect signals
- _pageNumberSpin_adj->signal_value_changed().connect(sigc::mem_fun(*this, &VsdImportDialog::_onPageNumberChanged));
+ _pageNumberSpin->signal_value_changed().connect(sigc::mem_fun(*this, &VsdImportDialog::_onPageNumberChanged));
+ _pageNumberSpin->signal_button_press_event().connect_notify(sigc::mem_fun(*this, &VsdImportDialog::_onSpinButtonPress));
+ _pageNumberSpin->signal_button_release_event().connect_notify(sigc::mem_fun(*this, &VsdImportDialog::_onSpinButtonRelease));
+
+ _setPreviewPage();
}
VsdImportDialog::~VsdImportDialog() {}
@@ -193,7 +177,7 @@ bool VsdImportDialog::showDialog()
show();
gint b = run();
hide();
- if ( b == Gtk::RESPONSE_OK ) {
+ if (b == Gtk::RESPONSE_OK || b == Gtk::RESPONSE_ACCEPT) {
return TRUE;
} else {
return FALSE;
@@ -209,22 +193,34 @@ void VsdImportDialog::_onPageNumberChanged()
{
unsigned page = static_cast<unsigned>(_pageNumberSpin->get_value_as_int());
_current_page = CLAMP(page, 1U, _vec.size());
- _setPreviewPage(_current_page);
+ _setPreviewPage();
+}
+
+void VsdImportDialog::_onSpinButtonPress(GdkEventButton* /*button_event*/)
+{
+ _spinning = true;
+}
+
+void VsdImportDialog::_onSpinButtonRelease(GdkEventButton* /*button_event*/)
+{
+ _spinning = false;
+ _setPreviewPage();
}
/**
* \brief Renders the given page's thumbnail
*/
-void VsdImportDialog::_setPreviewPage(unsigned page)
+void VsdImportDialog::_setPreviewPage()
{
- SPDocument *doc = SPDocument::createNewDocFromMem(_vec[page-1].cstr(), strlen(_vec[page-1].cstr()), 0);
+ if (_spinning) {
+ return;
+ }
+
+ SPDocument *doc = SPDocument::createNewDocFromMem(_vec[_current_page-1].cstr(), strlen(_vec[_current_page-1].cstr()), 0);
Gtk::Widget * tmpPreviewArea = Glib::wrap(sp_svg_view_widget_new(doc));
std::swap(_previewArea, tmpPreviewArea);
- if (tmpPreviewArea) {
- _previewArea->set_size_request( tmpPreviewArea->get_width(), tmpPreviewArea->get_height() );
- delete tmpPreviewArea;
- }
- vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
+ delete tmpPreviewArea;
+ vbox1->pack_start(*_previewArea, Gtk::PACK_EXPAND_WIDGET, 0);
_previewArea->show_now();
}
@@ -282,12 +278,11 @@ SPDocument *VsdInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u
}
SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE);
-
+
// Set viewBox if it doesn't exist
- if (!doc->getRoot()->viewBox_set) {
+ if (doc && !doc->getRoot()->viewBox_set) {
doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDisplayUnit()), doc->getHeight().value(doc->getDisplayUnit())));
}
-
return doc;
}
diff --git a/src/extension/loader.cpp b/src/extension/loader.cpp
new file mode 100644
index 000000000..863a176ca
--- /dev/null
+++ b/src/extension/loader.cpp
@@ -0,0 +1,137 @@
+/*
+ * Loader for external plug-ins.
+ *
+ * Authors:
+ * Moritz Eberl <moritz@semiodesk.com>
+ *
+ * Copyright (C) 2016 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "loader.h"
+#include "system.h"
+#include <exception>
+#include <string.h>
+#include "dependency.h"
+#include "inkscape-version.h"
+
+namespace Inkscape {
+namespace Extension {
+
+typedef Implementation::Implementation *(*_getImplementation)(void);
+typedef const gchar *(*_getInkscapeVersion)(void);
+
+bool Loader::load_dependency(Dependency *dep)
+{
+ GModule *module = NULL;
+ module = g_module_open(dep->get_name(), (GModuleFlags)0);
+ if (module == NULL) {
+ return false;
+ }
+ return true;
+}
+
+/**
+ * @brief Load the actual implementation of a plugin supplied by the plugin.
+ * @param doc The xml representation of the INX extension configuration.
+ * @return The implementation of the extension loaded from the plugin.
+ */
+Implementation::Implementation *Loader::load_implementation(Inkscape::XML::Document *doc)
+{
+ try {
+
+ Inkscape::XML::Node *repr = doc->root();
+ Inkscape::XML::Node *child_repr = repr->firstChild();
+
+ // Iterate over the xml content
+ while (child_repr != NULL) {
+ char const *chname = child_repr->name();
+ if (!strncmp(chname, INKSCAPE_EXTENSION_NS_NC, strlen(INKSCAPE_EXTENSION_NS_NC))) {
+ chname += strlen(INKSCAPE_EXTENSION_NS);
+ }
+
+ // Deal with dependencies if we have them
+ if (!strcmp(chname, "dependency")) {
+ Dependency dep = Dependency(child_repr);
+ // try to load it
+ bool success = load_dependency(&dep);
+ if( !success ){
+ // Could not load dependency, we abort
+ const char *res = g_module_error();
+ g_warning("Unable to load dependency %s of plugin %s.\nDetails: %s\n", dep.get_name(), "<todo>", res);
+ return NULL;
+ }
+ }
+
+ // Found a plugin to load
+ if (!strcmp(chname, "plugin")) {
+
+ // The name of the plugin is actually the library file we want to load
+ if (const gchar *name = child_repr->attribute("name")) {
+ GModule *module = NULL;
+ _getImplementation GetImplementation = NULL;
+ _getInkscapeVersion GetInkscapeVersion = NULL;
+
+ // build the path where to look for the plugin
+ gchar *path = g_build_filename(_baseDirectory.c_str(), name, (char *) NULL);
+ module = g_module_open(path, G_MODULE_BIND_LOCAL);
+ g_free(path);
+
+ if (module == NULL) {
+ // we were not able to load the plugin, write warning and abort
+ const char *res = g_module_error();
+ g_warning("Unable to load extension %s.\nDetails: %s\n", name, res);
+ return NULL;
+ }
+
+ // Get a handle to the version function of the module
+ if (g_module_symbol(module, "GetInkscapeVersion", (gpointer *) &GetInkscapeVersion) == FALSE) {
+ // This didn't work, write warning and abort
+ const char *res = g_module_error();
+ g_warning("Unable to load extension %s.\nDetails: %s\n", name, res);
+ return NULL;
+ }
+
+ // Get a handle to the function that delivers the implementation
+ if (g_module_symbol(module, "GetImplementation", (gpointer *) &GetImplementation) == FALSE) {
+ // This didn't work, write warning and abort
+ const char *res = g_module_error();
+ g_warning("Unable to load extension %s.\nDetails: %s\n", name, res);
+ return NULL;
+ }
+
+ // Get version and test against this version
+ const gchar* version = GetInkscapeVersion();
+ if( strcmp(version, version_string) != 0) {
+ // The versions are different, display warning.
+ g_warning("Plugin was built against Inkscape version %s, this is %s. The plugin might not be compatible.", version, version_string);
+ }
+
+
+ Implementation::Implementation *i = GetImplementation();
+ return i;
+ }
+ }
+
+ child_repr = child_repr->next();
+ }
+ } catch (std::exception &e) {
+ g_warning("Unable to load extension.");
+ }
+ return NULL;
+}
+
+} // namespace Extension
+} // namespace Inkscape
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace .0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim:filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99:
diff --git a/src/extension/loader.h b/src/extension/loader.h
new file mode 100644
index 000000000..0d3a69061
--- /dev/null
+++ b/src/extension/loader.h
@@ -0,0 +1,73 @@
+/** @file
+ * Loader for external plug-ins.
+ *//*
+ *
+ * Authors:
+ * Moritz Eberl <moritz@semiodesk.com>
+ *
+ * Copyright (C) 2016 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifndef INKSCAPE_EXTENSION_LOADER_H_
+#define INKSCAPE_EXTENSION_LOADER_H_
+
+#include "extension.h"
+#include "implementation/implementation.h"
+#include <gmodule.h>
+
+
+namespace Inkscape {
+namespace Extension {
+
+/** This class contains the mechanism to load c++ plugins dynamically.
+*/
+class Loader {
+
+public:
+ /**
+ * Sets a base directory where to look for the actual plugin to load.
+ *
+ * @param dir is the path where the plugin should be loaded from.
+ */
+ void set_base_directory(std::string dir) {
+ _baseDirectory = dir;
+ }
+
+ /**
+ * Loads plugin dependencies which are needed for the plugin to load.
+ *
+ * @param dep
+ */
+ bool load_dependency(Dependency *dep);
+
+ /**
+ * Load the actual implementation of a plugin supplied by the plugin.
+ *
+ * @param doc The xml representation of the INX extension configuration.
+ * @return The implementation of the extension loaded from the plugin.
+ */
+ Implementation::Implementation *load_implementation(Inkscape::XML::Document *doc);
+
+private:
+ std::string _baseDirectory; /**< The base directory to load a plugin from */
+
+
+};
+
+} // namespace Extension
+} // namespace Inkscape */
+
+#endif // _LOADER_H_
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace .0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim:filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99:
diff --git a/src/extension/output.cpp b/src/extension/output.cpp
index 8de5583c7..83f0fed2f 100644
--- a/src/extension/output.cpp
+++ b/src/extension/output.cpp
@@ -192,8 +192,7 @@ Output::prefs (void)
delete dialog;
- if (response == Gtk::RESPONSE_OK) return true;
- return false;
+ return (response == Gtk::RESPONSE_OK);
}
/**
diff --git a/src/extension/plugins/CMakeLists.txt b/src/extension/plugins/CMakeLists.txt
new file mode 100644
index 000000000..78f268c6b
--- /dev/null
+++ b/src/extension/plugins/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory(grid2)
diff --git a/src/extension/plugins/grid2/CMakeLists.txt b/src/extension/plugins/grid2/CMakeLists.txt
new file mode 100644
index 000000000..f39e259de
--- /dev/null
+++ b/src/extension/plugins/grid2/CMakeLists.txt
@@ -0,0 +1,8 @@
+set(grid_PART_SRCS grid.cpp)
+
+include_directories( ${CMAKE_BINARY_DIR}/src )
+
+add_library(grid2 SHARED ${grid_PART_SRCS})
+
+target_link_libraries(grid2 inkscape_base)
+
diff --git a/src/extension/plugins/grid2/grid.cpp b/src/extension/plugins/grid2/grid.cpp
new file mode 100644
index 000000000..3a2ed7867
--- /dev/null
+++ b/src/extension/plugins/grid2/grid.cpp
@@ -0,0 +1,220 @@
+/**
+ \file grid.cpp
+
+ A plug-in to add a grid creation effect into Inkscape.
+*/
+/*
+ * Copyright (C) 2004-2005 Ted Gould <ted@gould.cx>
+ * Copyright (C) 2007 MenTaLguY <mental@rydia.net>
+ * Abhishek Sharma
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <gtkmm/box.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/spinbutton.h>
+
+#include "desktop.h"
+
+#include "document.h"
+#include "selection.h"
+#include "sp-object.h"
+#include "2geom/geom.h"
+
+#include "svg/path-string.h"
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "util/units.h"
+
+#include "grid.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+
+/**
+ \brief A function to allocated anything -- just an example here
+ \param module Unused
+ \return Whether the load was sucessful
+*/
+bool
+Grid::load (Inkscape::Extension::Extension */*module*/)
+{
+ // std::cout << "Hey, I'm Grid, I'm loading!" << std::endl;
+ return TRUE;
+}
+
+namespace {
+
+Glib::ustring build_lines(Geom::Rect bounding_area,
+ Geom::Point const &offset, Geom::Point const &spacing)
+{
+
+ std::cout << "Building lines" << std::endl;
+
+ Geom::Point point_offset(0.0, 0.0);
+
+ SVG::PathString path_data;
+
+ for ( int axis = Geom::X ; axis <= Geom::Y ; ++axis ) {
+ point_offset[axis] = offset[axis];
+
+ for (Geom::Point start_point = bounding_area.min();
+ start_point[axis] + offset[axis] <= (bounding_area.max())[axis];
+ start_point[axis] += spacing[axis]) {
+ Geom::Point end_point = start_point;
+ end_point[1-axis] = (bounding_area.max())[1-axis];
+
+ path_data.moveTo(start_point + point_offset)
+ .lineTo(end_point + point_offset);
+ }
+ }
+ std::cout << "Path data:" << path_data.c_str() << std::endl;
+ return path_data;
+}
+
+} // namespace
+
+/**
+ \brief This actually draws the grid.
+ \param module The effect that was called (unused)
+ \param document What should be edited.
+*/
+void
+Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document, Inkscape::Extension::Implementation::ImplementationDocumentCache * /*docCache*/)
+{
+
+ std::cout << "Executing effect" << std::endl;
+
+ Inkscape::Selection * selection = ((SPDesktop *)document)->selection;
+
+ Geom::Rect bounding_area = Geom::Rect(Geom::Point(0,0), Geom::Point(100,100));
+ if (selection->isEmpty()) {
+ /* get page size */
+ SPDocument * doc = document->doc();
+ bounding_area = Geom::Rect( Geom::Point(0,0),
+ Geom::Point(doc->getWidth().value("px"), doc->getHeight().value("px")) );
+ } else {
+ Geom::OptRect bounds = selection->visualBounds();
+ if (bounds) {
+ bounding_area = *bounds;
+ }
+
+ gdouble doc_height = (document->doc())->getHeight().value("px");
+ Geom::Rect temprec = Geom::Rect(Geom::Point(bounding_area.min()[Geom::X], doc_height - bounding_area.min()[Geom::Y]),
+ Geom::Point(bounding_area.max()[Geom::X], doc_height - bounding_area.max()[Geom::Y]));
+
+ bounding_area = temprec;
+ }
+
+ gdouble scale = Inkscape::Util::Quantity::convert(1, "px", &document->doc()->getSVGUnit());
+ bounding_area *= Geom::Scale(scale);
+ Geom::Point spacings( scale * module->get_param_float("xspacing"),
+ scale * module->get_param_float("yspacing") );
+ gdouble line_width = scale * module->get_param_float("lineWidth");
+ Geom::Point offsets( scale * module->get_param_float("xoffset"),
+ scale * module->get_param_float("yoffset") );
+
+ Glib::ustring path_data("");
+
+ path_data = build_lines(bounding_area, offsets, spacings);
+ Inkscape::XML::Document * xml_doc = document->doc()->getReprDoc();
+
+ //XML Tree being used directly here while it shouldn't be.
+ Inkscape::XML::Node * current_layer = static_cast<SPDesktop *>(document)->currentLayer()->getRepr();
+ Inkscape::XML::Node * path = xml_doc->createElement("svg:path");
+
+ path->setAttribute("d", path_data.c_str());
+
+ Glib::ustring style("fill:none;fill-opacity:0.75000000;fill-rule:evenodd;stroke:#000000;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000");
+ style += ";stroke-width:";
+ gchar floatstring[64];
+ std::ostringstream stringstream;
+ stringstream << line_width;
+ sprintf(floatstring, "%s", stringstream.str().c_str());
+ style += floatstring;
+ style += "pt";
+ path->setAttribute("style", style.c_str());
+
+ current_layer->appendChild(path);
+ Inkscape::GC::release(path);
+}
+
+/** \brief A class to make an adjustment that uses Extension params */
+class PrefAdjustment : public Gtk::Adjustment {
+ /** Extension that this relates to */
+ Inkscape::Extension::Extension * _ext;
+ /** The string which represents the parameter */
+ char * _pref;
+public:
+ /** \brief Make the adjustment using an extension and the string
+ describing the parameter. */
+ PrefAdjustment(Inkscape::Extension::Extension * ext, char * pref) :
+ Gtk::Adjustment(0.0, 0.0, 10.0, 0.1), _ext(ext), _pref(pref) {
+ this->set_value(_ext->get_param_float(_pref));
+ this->signal_value_changed().connect(sigc::mem_fun(this, &PrefAdjustment::val_changed));
+ return;
+ };
+
+ void val_changed (void);
+}; /* class PrefAdjustment */
+
+/** \brief A function to respond to the value_changed signal from the
+ adjustment.
+
+ This function just grabs the value from the adjustment and writes
+ it to the parameter. Very simple, but yet beautiful.
+*/
+void
+PrefAdjustment::val_changed (void)
+{
+ // std::cout << "Value Changed to: " << this->get_value() << std::endl;
+ _ext->set_param_float(_pref, this->get_value());
+ return;
+}
+
+/** \brief A function to get the prefences for the grid
+ \param moudule Module which holds the params
+ \param view Unused today - may get style information in the future.
+
+ Uses AutoGUI for creating the GUI.
+*/
+Gtk::Widget *
+Grid::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view, sigc::signal<void> * changeSignal, Inkscape::Extension::Implementation::ImplementationDocumentCache * /*docCache*/)
+{
+ SPDocument * current_document = view->doc();
+
+ std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList();
+ Inkscape::XML::Node * first_select = NULL;
+ if (!selected.empty()) {
+ first_select = selected[0]->getRepr();
+ }
+
+ return module->autogui(current_document, first_select, changeSignal);
+}
+
+
+
+
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
+
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/extension/plugins/grid2/grid.h b/src/extension/plugins/grid2/grid.h
new file mode 100644
index 000000000..b4997bb18
--- /dev/null
+++ b/src/extension/plugins/grid2/grid.h
@@ -0,0 +1,58 @@
+/*
+ * Authors:
+ * Ted Gould <ted@gould.cx>
+ *
+ * Copyright (C) 2004-2005 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifndef __GRID_H
+
+#include "extension/implementation/implementation.h"
+
+
+#include <glib.h>
+#include <gmodule.h>
+#include "inkscape-version.cpp"
+
+
+
+namespace Inkscape {
+namespace Extension {
+
+class Effect;
+class Extension;
+
+namespace Internal {
+
+/** \brief Implementation class of the GIMP gradient plugin. This mostly
+ just creates a namespace for the GIMP gradient plugin today.
+*/
+class Grid : public Inkscape::Extension::Implementation::Implementation {
+
+public:
+ bool load(Inkscape::Extension::Extension *module);
+ void effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document, Inkscape::Extension::Implementation::ImplementationDocumentCache * docCache);
+ Gtk::Widget * prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view, sigc::signal<void> * changeSignal, Inkscape::Extension::Implementation::ImplementationDocumentCache * docCache);
+
+};
+
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
+
+extern "C" G_MODULE_EXPORT Inkscape::Extension::Implementation::Implementation* GetImplementation() { return new Inkscape::Extension::Internal::Grid(); }
+extern "C" G_MODULE_EXPORT const gchar* GetInkscapeVersion() { return Inkscape::version_string; }
+#endif
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/extension/plugins/grid2/libgrid2.inx b/src/extension/plugins/grid2/libgrid2.inx
new file mode 100644
index 000000000..0360d37e3
--- /dev/null
+++ b/src/extension/plugins/grid2/libgrid2.inx
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
+<_name>Grid2</_name>
+<id>org.inkscape.effect.grid2</id>
+<param name="lineWidth" _gui-text="Line Width:" type="float">1.0</param>
+<param name="xspacing" _gui-text="Horizontal Spacing:" type="float" min="0.1" max="1000">10.0</param>
+<param name="yspacing" _gui-text="Vertical Spacing:" type="float" min="0.1" max="1000">10.0</param>
+<param name="xoffset" _gui-text="Horizontal Offset:" type="float" min="0.0" max="1000">0.0</param>
+<param name="yoffset" _gui-text="Vertical Offset:" type="float" min="0.0" max="1000">0.0</param>
+<effect>
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Render" >
+ <submenu _name="Grids" />
+ </submenu>
+ </effects-menu>
+<_menu-tip>Draw a path which is a grid</_menu-tip>
+</effect>
+<plugin name="libgrid2" />
+</inkscape-extension>
diff --git a/src/extension/system.cpp b/src/extension/system.cpp
index 6a95717f2..3c623455a 100644
--- a/src/extension/system.cpp
+++ b/src/extension/system.cpp
@@ -39,6 +39,7 @@
#include "io/sys.h"
#include "inkscape.h"
#include "document-undo.h"
+#include "loader.h"
namespace Inkscape {
@@ -46,7 +47,7 @@ namespace Extension {
static void open_internal(Inkscape::Extension::Extension *in_plug, gpointer in_data);
static void save_internal(Inkscape::Extension::Extension *in_plug, gpointer in_data);
-static Extension *build_from_reprdoc(Inkscape::XML::Document *doc, Implementation::Implementation *in_imp);
+static Extension *build_from_reprdoc(Inkscape::XML::Document *doc, Implementation::Implementation *in_imp, std::string* baseDir);
/**
* \return A new document created from the filename passed in
@@ -421,12 +422,12 @@ get_print(gchar const *key)
* case could apply to modules that are built in (like the SVG load/save functions).
*/
static Extension *
-build_from_reprdoc(Inkscape::XML::Document *doc, Implementation::Implementation *in_imp)
+build_from_reprdoc(Inkscape::XML::Document *doc, Implementation::Implementation *in_imp, std::string* baseDir)
{
enum {
MODULE_EXTENSION,
MODULE_XSLT,
- /* MODULE_PLUGIN, */
+ MODULE_PLUGIN,
MODULE_UNKNOWN_IMP
} module_implementation_type = MODULE_UNKNOWN_IMP;
enum {
@@ -465,10 +466,8 @@ build_from_reprdoc(Inkscape::XML::Document *doc, Implementation::Implementation
module_implementation_type = MODULE_EXTENSION;
} else if (!strcmp(element_name, INKSCAPE_EXTENSION_NS "xslt")) {
module_implementation_type = MODULE_XSLT;
-#if 0
- } else if (!strcmp(element_name, "plugin")) {
+ } else if (!strcmp(element_name, INKSCAPE_EXTENSION_NS "plugin")) {
module_implementation_type = MODULE_PLUGIN;
-#endif
}
//Inkscape::XML::Node *old_repr = child_repr;
@@ -489,13 +488,14 @@ build_from_reprdoc(Inkscape::XML::Document *doc, Implementation::Implementation
imp = static_cast<Implementation::Implementation *>(xslt);
break;
}
-#if 0
case MODULE_PLUGIN: {
- Implementation::Plugin *plugin = new Implementation::Plugin();
- imp = static_cast<Implementation::Implementation *>(plugin);
+ Inkscape::Extension::Loader loader = Inkscape::Extension::Loader();
+ if( baseDir != NULL){
+ loader.set_base_directory ( *baseDir );
+ }
+ imp = loader.load_implementation(doc);
break;
}
-#endif
default: {
imp = NULL;
break;
@@ -528,6 +528,7 @@ build_from_reprdoc(Inkscape::XML::Document *doc, Implementation::Implementation
break;
}
default: {
+ module = new Extension(repr, imp);
break;
}
}
@@ -547,7 +548,8 @@ Extension *
build_from_file(gchar const *filename)
{
Inkscape::XML::Document *doc = sp_repr_read_file(filename, INKSCAPE_EXTENSION_URI);
- Extension *ext = build_from_reprdoc(doc, NULL);
+ std::string dir = Glib::path_get_dirname(filename);
+ Extension *ext = build_from_reprdoc(doc, NULL, &dir);
if (ext != NULL)
Inkscape::GC::release(doc);
else
@@ -569,7 +571,7 @@ build_from_mem(gchar const *buffer, Implementation::Implementation *in_imp)
{
Inkscape::XML::Document *doc = sp_repr_read_mem(buffer, strlen(buffer), INKSCAPE_EXTENSION_URI);
g_return_val_if_fail(doc != NULL, NULL);
- Extension *ext = build_from_reprdoc(doc, in_imp);
+ Extension *ext = build_from_reprdoc(doc, in_imp, NULL);
Inkscape::GC::release(doc);
return ext;
}
diff --git a/src/helper/geom-pathstroke.cpp b/src/helper/geom-pathstroke.cpp
index 52871ae2a..d2e9f9a1b 100644
--- a/src/helper/geom-pathstroke.cpp
+++ b/src/helper/geom-pathstroke.cpp
@@ -163,7 +163,9 @@ void miter_join_internal(join_data jd, bool clip)
if (p.isFinite()) {
// check size of miter
Point point_on_path = incoming.finalPoint() + rot90(tang1)*width;
- satisfied = distance(p, point_on_path) <= miter * 2.0 * width;
+ // SVG defines miter length as distance between inner intersection and outer intersection,
+ // which is twice the distance from p to point_on_path but width is half stroke width.
+ satisfied = distance(p, point_on_path) <= miter * width;
if (satisfied) {
// miter OK, check to see if we can do a relocation
if (inc_ls) {
@@ -175,7 +177,7 @@ void miter_join_internal(join_data jd, bool clip)
// std::cout << " Clipping ------------ " << std::endl;
// miter needs clipping, find two points
Point bisector_versor = Line(point_on_path, p).versor();
- Point point_limit = point_on_path + miter * 2.0 * width * bisector_versor;
+ Point point_limit = point_on_path + miter * width * bisector_versor;
// std::cout << " bisector_versor: " << bisector_versor << std::endl;
// std::cout << " point_limit: " << point_limit << std::endl;
Point p1 = intersection_point(incoming.finalPoint(), tang1, point_limit, bisector_versor.cw());
@@ -555,7 +557,7 @@ void extrapolate_join_internal(join_data jd, int alternative)
Geom::Line bisector_chord = make_bisector_line(chord);
Geom::Line limit_line;
- double miter_limit = 2.0 * width * miter;
+ double miter_limit = width * miter;
bool clipped = false;
if (are_parallel(bisector_chord, ortho)) {
diff --git a/src/inkscape-version.cpp.in b/src/inkscape-version.cpp.in
new file mode 100644
index 000000000..b4ea5028d
--- /dev/null
+++ b/src/inkscape-version.cpp.in
@@ -0,0 +1,7 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+namespace Inkscape {
+ char const *version_string = VERSION " " "${INKSCAPE_REVISION}";
+}
diff --git a/src/inkview.cpp b/src/inkview.cpp
index c0c6f0b2c..db4b1aeb0 100644
--- a/src/inkview.cpp
+++ b/src/inkview.cpp
@@ -102,66 +102,67 @@ static GtkWidget *ctrlwin = NULL;
int sp_main_gui (int, char const**) { return 0; }
int sp_main_console (int, char const**) { return 0; }
-static int
-sp_svgview_main_delete (GtkWidget */*widget*/, GdkEvent */*event*/, struct SPSlideShow */*ss*/)
+static int sp_svgview_main_delete (GtkWidget */*widget*/,
+ GdkEvent */*event*/,
+ struct SPSlideShow */*ss*/)
{
gtk_main_quit ();
return FALSE;
}
-static int
-sp_svgview_main_key_press (GtkWidget */*widget*/, GdkEventKey *event, struct SPSlideShow *ss)
+static int sp_svgview_main_key_press (GtkWidget */*widget*/,
+ GdkEventKey *event,
+ struct SPSlideShow *ss)
{
switch (event->keyval) {
- case GDK_KEY_Up:
- case GDK_KEY_Home:
- sp_svgview_goto_first(ss);
- break;
- case GDK_KEY_Down:
- case GDK_KEY_End:
- sp_svgview_goto_last(ss);
- break;
- case GDK_KEY_F11:
- if (ss->fullscreen) {
- gtk_window_unfullscreen (GTK_WINDOW(ss->window));
- ss->fullscreen = false;
- } else {
- gtk_window_fullscreen (GTK_WINDOW(ss->window));
- ss->fullscreen = true;
- }
- break;
- case GDK_KEY_Return:
- sp_svgview_control_show (ss);
- break;
- case GDK_KEY_KP_Page_Down:
- case GDK_KEY_Page_Down:
- case GDK_KEY_Right:
- case GDK_KEY_space:
- sp_svgview_show_next (ss);
- break;
- case GDK_KEY_KP_Page_Up:
- case GDK_KEY_Page_Up:
- case GDK_KEY_Left:
- case GDK_KEY_BackSpace:
- sp_svgview_show_prev (ss);
- break;
- case GDK_KEY_Escape:
- case GDK_KEY_q:
- case GDK_KEY_Q:
- gtk_main_quit();
- break;
- default:
- break;
+ case GDK_KEY_Up:
+ case GDK_KEY_Home:
+ sp_svgview_goto_first(ss);
+ break;
+ case GDK_KEY_Down:
+ case GDK_KEY_End:
+ sp_svgview_goto_last(ss);
+ break;
+ case GDK_KEY_F11:
+ if (ss->fullscreen) {
+ gtk_window_unfullscreen (GTK_WINDOW(ss->window));
+ ss->fullscreen = false;
+ } else {
+ gtk_window_fullscreen (GTK_WINDOW(ss->window));
+ ss->fullscreen = true;
+ }
+ break;
+ case GDK_KEY_Return:
+ sp_svgview_control_show (ss);
+ break;
+ case GDK_KEY_KP_Page_Down:
+ case GDK_KEY_Page_Down:
+ case GDK_KEY_Right:
+ case GDK_KEY_space:
+ sp_svgview_show_next (ss);
+ break;
+ case GDK_KEY_KP_Page_Up:
+ case GDK_KEY_Page_Up:
+ case GDK_KEY_Left:
+ case GDK_KEY_BackSpace:
+ sp_svgview_show_prev (ss);
+ break;
+ case GDK_KEY_Escape:
+ case GDK_KEY_q:
+ case GDK_KEY_Q:
+ gtk_main_quit();
+ break;
+ default:
+ break;
}
gtk_window_set_title(GTK_WINDOW(ss->window), ss->doc->getName());
return TRUE;
}
-int
-main (int argc, const char **argv)
+int main (int argc, const char **argv)
{
if (argc == 1) {
- usage();
+ usage();
}
// Prevents errors like "Unable to wrap GdkPixbuf..." (in nr-filter-image.cpp for example)
@@ -171,8 +172,7 @@ main (int argc, const char **argv)
struct SPSlideShow ss;
- int option,
- num_parsed_options = 0;
+ int num_parsed_options = 0;
// the list of arguments is in the net line
for (int i = 1; i < argc; i++) {
@@ -233,82 +233,84 @@ main (int argc, const char **argv)
// starting at where the commandline options stopped parsing because
// we want all the files to be in the list
for (i = num_parsed_options + 1 ; i < argc; i++) {
- struct stat st;
- if (stat (argv[i], &st)
- || !S_ISREG (st.st_mode)
- || (st.st_size < 64)) {
- fprintf(stderr, "could not open file %s\n", argv[i]);
- } else {
-
-#ifdef WITH_INKJAR
- if (is_jar(argv[i])) {
- Inkjar::JarFileReader jar_file_reader(argv[i]);
- for (;;) {
- GByteArray *gba = jar_file_reader.get_next_file();
- if (gba == NULL) {
- char *c_ptr;
- gchar *last_filename = jar_file_reader.get_last_filename();
- if (last_filename == NULL)
- break;
- if ((c_ptr = std::strrchr(last_filename, '/')) != NULL) {
- if (*(++c_ptr) == '\0') {
- g_free(last_filename);
- continue;
- }
- }
- } else if (gba->len > 0) {
- //::write(1, gba->data, gba->len);
- /* Append to list */
- if (ss.length >= ss.size) {
- /* Expand */
- ss.size <<= 1;
- ss.slides = g_renew (char *, ss.slides, ss.size);
- }
-
- ss.doc = SPDocument::createNewDocFromMem ((const gchar *)gba->data,
- gba->len,
- TRUE);
- gchar *last_filename = jar_file_reader.get_last_filename();
- if (ss.doc) {
- ss.slides[ss.length++] = strdup (last_filename);
- (ss.doc)->setUri (last_filename);
- }
- g_byte_array_free(gba, TRUE);
- g_free(last_filename);
- } else
- break;
- }
- } else {
-#endif /* WITH_INKJAR */
- /* Append to list */
- if (ss.length >= ss.size) {
- /* Expand */
- ss.size <<= 1;
- ss.slides = g_renew (char *, ss.slides, ss.size);
-
- }
+ struct stat st;
+ if (stat (argv[i], &st)
+ || !S_ISREG (st.st_mode)
+ || (st.st_size < 64)) {
+ fprintf(stderr, "could not open file %s\n", argv[i]);
+ } else {
+
+ #ifdef WITH_INKJAR
+ if (is_jar(argv[i])) {
+ Inkjar::JarFileReader jar_file_reader(argv[i]);
+ for (;;) {
+ GByteArray *gba = jar_file_reader.get_next_file();
+ if (gba == NULL) {
+ char *c_ptr;
+ gchar *last_filename = jar_file_reader.get_last_filename();
+ if (last_filename == NULL)
+ break;
+ if ((c_ptr = std::strrchr(last_filename, '/')) != NULL) {
+ if (*(++c_ptr) == '\0') {
+ g_free(last_filename);
+ continue;
+ }
+ }
+ } else if (gba->len > 0) {
+ //::write(1, gba->data, gba->len);
+ /* Append to list */
+ if (ss.length >= ss.size) {
+ /* Expand */
+ ss.size <<= 1;
+ ss.slides = g_renew (char *, ss.slides, ss.size);
+ }
+
+ ss.doc = SPDocument::createNewDocFromMem ((const gchar *)gba->data,
+ gba->len,
+ TRUE);
+ gchar *last_filename = jar_file_reader.get_last_filename();
+ if (ss.doc) {
+ ss.slides[ss.length++] = strdup (last_filename);
+ (ss.doc)->setUri (last_filename);
+ }
+ g_byte_array_free(gba, TRUE);
+ g_free(last_filename);
+ } else {
+ break;
+ }
+ }
+ } else {
+ #endif /* WITH_INKJAR */
+ /* Append to list */
+ if (ss.length >= ss.size) {
+ /* Expand */
+ ss.size <<= 1;
+ ss.slides = g_renew (char *, ss.slides, ss.size);
+ }
- ss.slides[ss.length++] = strdup (argv[i]);
+ ss.slides[ss.length++] = strdup (argv[i]);
+ if (!ss.doc) {
+ ss.doc = SPDocument::createNewDoc (ss.slides[ss.current], TRUE, false);
if (!ss.doc) {
- ss.doc = SPDocument::createNewDoc (ss.slides[ss.current], TRUE, false);
- if (!ss.doc)
- ++ss.current;
- }
-#ifdef WITH_INKJAR
- }
-#endif
- }
+ ++ss.current;
+ }
+ }
+ #ifdef WITH_INKJAR
+ }
+ #endif
+ }
}
- if(!ss.doc)
+ if(!ss.doc) {
return 1; /* none of the slides loadable */
-
+ }
+
w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title( GTK_WINDOW(w), ss.doc->getName() );
gtk_window_set_default_size (GTK_WINDOW (w),
- MIN ((int)(ss.doc)->getWidth().value("px"), (int)gdk_screen_width() - 64),
- MIN ((int)(ss.doc)->getHeight().value("px"), (int)gdk_screen_height() - 64));
+ MIN ((int)(ss.doc)->getWidth().value("px"), (int)gdk_screen_width() - 64),
+ MIN ((int)(ss.doc)->getHeight().value("px"), (int)gdk_screen_height() - 64));
ss.window = w;
g_signal_connect (G_OBJECT (w), "delete_event", (GCallback) sp_svgview_main_delete, &ss);
@@ -328,8 +330,9 @@ main (int argc, const char **argv)
return 0;
}
-static int
-sp_svgview_ctrlwin_delete (GtkWidget */*widget*/, GdkEvent */*event*/, void */*data*/)
+static int sp_svgview_ctrlwin_delete (GtkWidget */*widget*/,
+ GdkEvent */*event*/,
+ void */*data*/)
{
ctrlwin = NULL;
return FALSE;
@@ -338,99 +341,95 @@ sp_svgview_ctrlwin_delete (GtkWidget */*widget*/, GdkEvent */*event*/, void */*d
static GtkWidget* sp_svgview_control_show(struct SPSlideShow *ss)
{
if (!ctrlwin) {
- ctrlwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ ctrlwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_resizable(GTK_WINDOW(ctrlwin), FALSE);
gtk_window_set_transient_for(GTK_WINDOW(ctrlwin), GTK_WINDOW(ss->window));
g_signal_connect(G_OBJECT (ctrlwin), "key_press_event", (GCallback) sp_svgview_main_key_press, ss);
g_signal_connect(G_OBJECT (ctrlwin), "delete_event", (GCallback) sp_svgview_ctrlwin_delete, NULL);
#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *t = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
+ GtkWidget *t = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
#else
- GtkWidget *t = gtk_hbutton_box_new();
+ GtkWidget *t = gtk_hbutton_box_new();
#endif
- gtk_container_add(GTK_CONTAINER(ctrlwin), t);
+ gtk_container_add(GTK_CONTAINER(ctrlwin), t);
#if GTK_CHECK_VERSION(3,10,0)
GtkWidget *b = gtk_button_new_from_icon_name(INKSCAPE_ICON("go-first"), GTK_ICON_SIZE_BUTTON);
#else
- GtkWidget *b = gtk_button_new();
+ GtkWidget *b = gtk_button_new();
GtkWidget *img = gtk_image_new_from_icon_name(INKSCAPE_ICON("go-first"), GTK_ICON_SIZE_BUTTON);
gtk_button_set_image(GTK_BUTTON(b), img);
#endif
- gtk_container_add(GTK_CONTAINER(t), b);
+ gtk_container_add(GTK_CONTAINER(t), b);
- g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_goto_first_cb, ss);
+ g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_goto_first_cb, ss);
#if GTK_CHECK_VERSION(3,10,0)
b = gtk_button_new_from_icon_name(INKSCAPE_ICON("go-previous"), GTK_ICON_SIZE_BUTTON);
#else
- b = gtk_button_new();
+ b = gtk_button_new();
img = gtk_image_new_from_icon_name(INKSCAPE_ICON("go-previous"), GTK_ICON_SIZE_BUTTON);
gtk_button_set_image(GTK_BUTTON(b), img);
#endif
- gtk_container_add(GTK_CONTAINER(t), b);
+ gtk_container_add(GTK_CONTAINER(t), b);
- g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_show_prev_cb, ss);
+ g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_show_prev_cb, ss);
#if GTK_CHECK_VERSION(3,10,0)
b = gtk_button_new_from_icon_name(INKSCAPE_ICON("go-next"), GTK_ICON_SIZE_BUTTON);
#else
- b = gtk_button_new();
+ b = gtk_button_new();
img = gtk_image_new_from_icon_name(INKSCAPE_ICON("go-next"), GTK_ICON_SIZE_BUTTON);
gtk_button_set_image(GTK_BUTTON(b), img);
#endif
- gtk_container_add(GTK_CONTAINER(t), b);
+ gtk_container_add(GTK_CONTAINER(t), b);
- g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_show_next_cb, ss);
+ g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_show_next_cb, ss);
#if GTK_CHECK_VERSION(3,10,0)
b = gtk_button_new_from_icon_name(INKSCAPE_ICON("go-last"), GTK_ICON_SIZE_BUTTON);
#else
- b = gtk_button_new();
+ b = gtk_button_new();
img = gtk_image_new_from_icon_name(INKSCAPE_ICON("go-last"), GTK_ICON_SIZE_BUTTON);
gtk_button_set_image(GTK_BUTTON(b), img);
#endif
- gtk_container_add(GTK_CONTAINER(t), b);
- g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_goto_last_cb, ss);
- gtk_widget_show_all(ctrlwin);
+ gtk_container_add(GTK_CONTAINER(t), b);
+ g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_goto_last_cb, ss);
+ gtk_widget_show_all(ctrlwin);
} else {
- gtk_window_present(GTK_WINDOW(ctrlwin));
+ gtk_window_present(GTK_WINDOW(ctrlwin));
}
return NULL;
}
-static int
-sp_svgview_show_next_cb (GtkWidget */*widget*/, void *data)
+static int sp_svgview_show_next_cb (GtkWidget */*widget*/, void *data)
{
sp_svgview_show_next(static_cast<struct SPSlideShow *>(data));
return FALSE;
}
-static int
-sp_svgview_show_prev_cb (GtkWidget */*widget*/, void *data)
+static int sp_svgview_show_prev_cb (GtkWidget */*widget*/, void *data)
{
sp_svgview_show_prev(static_cast<struct SPSlideShow *>(data));
return FALSE;
}
-static int
-sp_svgview_goto_first_cb (GtkWidget */*widget*/, void *data)
+static int sp_svgview_goto_first_cb (GtkWidget */*widget*/, void *data)
{
sp_svgview_goto_first(static_cast<struct SPSlideShow *>(data));
return FALSE;
}
-static int
-sp_svgview_goto_last_cb (GtkWidget */*widget*/, void *data)
+static int sp_svgview_goto_last_cb (GtkWidget */*widget*/, void *data)
{
sp_svgview_goto_last(static_cast<struct SPSlideShow *>(data));
return FALSE;
}
-static void
-sp_svgview_waiting_cursor(struct SPSlideShow *ss)
+static void sp_svgview_waiting_cursor(struct SPSlideShow *ss)
{
- GdkCursor *waiting = gdk_cursor_new(GDK_WATCH);
+ GdkDisplay *display = gdk_display_get_default();
+ GdkCursor *waiting = gdk_cursor_new_for_display(display, GDK_WATCH);
gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(ss->window)), waiting);
#if GTK_CHECK_VERSION(3,0,0)
g_object_unref(waiting);
@@ -438,7 +437,7 @@ sp_svgview_waiting_cursor(struct SPSlideShow *ss)
gdk_cursor_unref(waiting);
#endif
if (ctrlwin) {
- GdkCursor *waiting = gdk_cursor_new(GDK_WATCH);
+ GdkCursor *waiting = gdk_cursor_new_for_display(display, GDK_WATCH);
gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(ctrlwin)), waiting);
#if GTK_CHECK_VERSION(3,0,0)
g_object_unref(waiting);
@@ -446,12 +445,12 @@ sp_svgview_waiting_cursor(struct SPSlideShow *ss)
gdk_cursor_unref(waiting);
#endif
}
- while(gtk_events_pending())
+ while(gtk_events_pending()) {
gtk_main_iteration();
+ }
}
-static void
-sp_svgview_normal_cursor(struct SPSlideShow *ss)
+static void sp_svgview_normal_cursor(struct SPSlideShow *ss)
{
gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(ss->window)), NULL);
if (ctrlwin) {
@@ -459,8 +458,9 @@ sp_svgview_normal_cursor(struct SPSlideShow *ss)
}
}
-static void
-sp_svgview_set_document(struct SPSlideShow *ss, SPDocument *doc, int current)
+static void sp_svgview_set_document(struct SPSlideShow *ss,
+ SPDocument *doc,
+ int current)
{
if (doc && doc != ss->doc) {
doc->ensureUpToDate();
@@ -470,8 +470,7 @@ sp_svgview_set_document(struct SPSlideShow *ss, SPDocument *doc, int current)
}
}
-static void
-sp_svgview_show_next (struct SPSlideShow *ss)
+static void sp_svgview_show_next (struct SPSlideShow *ss)
{
sp_svgview_waiting_cursor(ss);
@@ -486,8 +485,7 @@ sp_svgview_show_next (struct SPSlideShow *ss)
sp_svgview_normal_cursor(ss);
}
-static void
-sp_svgview_show_prev (struct SPSlideShow *ss)
+static void sp_svgview_show_prev (struct SPSlideShow *ss)
{
sp_svgview_waiting_cursor(ss);
@@ -502,16 +500,16 @@ sp_svgview_show_prev (struct SPSlideShow *ss)
sp_svgview_normal_cursor(ss);
}
-static void
-sp_svgview_goto_first (struct SPSlideShow *ss)
+static void sp_svgview_goto_first (struct SPSlideShow *ss)
{
sp_svgview_waiting_cursor(ss);
SPDocument *doc = NULL;
int current = 0;
while ( !doc && (current < ss->length - 1)) {
- if (current == ss->current)
+ if (current == ss->current) {
break;
+ }
doc = SPDocument::createNewDoc (ss->slides[current++], TRUE, false);
}
@@ -520,16 +518,16 @@ sp_svgview_goto_first (struct SPSlideShow *ss)
sp_svgview_normal_cursor(ss);
}
-static void
-sp_svgview_goto_last (struct SPSlideShow *ss)
+static void sp_svgview_goto_last (struct SPSlideShow *ss)
{
sp_svgview_waiting_cursor(ss);
SPDocument *doc = NULL;
int current = ss->length - 1;
while (!doc && (current >= 0)) {
- if (current == ss->current)
+ if (current == ss->current) {
break;
+ }
doc = SPDocument::createNewDoc (ss->slides[current--], TRUE, false);
}
@@ -539,8 +537,7 @@ sp_svgview_goto_last (struct SPSlideShow *ss)
}
#ifdef WITH_INKJAR
-static bool
-is_jar(char const *filename)
+static bool is_jar(char const *filename)
{
/* fixme: Check MIME type or something. /usr/share/misc/file/magic suggests that checking for
initial string "PK\003\004" in content should suffice. */
@@ -557,12 +554,12 @@ is_jar(char const *filename)
static void usage()
{
fprintf(stderr,
- "Usage: inkview [OPTIONS...] [FILES ...]\n"
- "\twhere FILES are SVG (.svg or .svgz)"
+ "Usage: inkview [OPTIONS...] [FILES ...]\n"
+ "\twhere FILES are SVG (.svg or .svgz)"
#ifdef WITH_INKJAR
- " or archives of SVGs (.sxw, .jar)"
+ " or archives of SVGs (.sxw, .jar)"
#endif
- "\n");
+ "\n");
exit(1);
}
diff --git a/src/io/inkjar.h b/src/io/inkjar.h
index 637c05d80..d7de9ff4a 100644
--- a/src/io/inkjar.h
+++ b/src/io/inkjar.h
@@ -18,13 +18,7 @@
# include <zlib.h>
#endif
-#ifdef HAVE_INTTYPES_H
-# include <inttypes.h>
-#else
-# ifdef HAVE_STDINT_H
-# include <stdint.h>
-# endif
-#endif
+#include <stdint.h>
#include <glib.h>
#include <cstdio>
diff --git a/src/libgdl/gdl-dock-bar.c b/src/libgdl/gdl-dock-bar.c
index 1d7b33b5f..c1fe21872 100644
--- a/src/libgdl/gdl-dock-bar.c
+++ b/src/libgdl/gdl-dock-bar.c
@@ -314,7 +314,7 @@ gdl_dock_bar_add_item (GdlDockBar *dockbar,
} else if (pixbuf_icon) {
image = gtk_image_new_from_pixbuf (pixbuf_icon);
} else {
- image = gtk_image_new_from_stock (GTK_STOCK_NEW,
+ image = gtk_image_new_from_stock ("gtk-new",
GTK_ICON_SIZE_SMALL_TOOLBAR);
}
gtk_box_pack_start (GTK_BOX (box), image, TRUE, TRUE, 0);
diff --git a/src/libnrtype/Layout-TNG-Compute.cpp b/src/libnrtype/Layout-TNG-Compute.cpp
index e862f0657..337d2a656 100644
--- a/src/libnrtype/Layout-TNG-Compute.cpp
+++ b/src/libnrtype/Layout-TNG-Compute.cpp
@@ -14,6 +14,7 @@
#include "svg/svg-length.h"
#include "sp-object.h"
#include "Layout-TNG-Scanline-Maker.h"
+#include <limits>
namespace Inkscape {
namespace Text {
@@ -1569,8 +1570,8 @@ bool Layout::Calculator::_buildChunksInScanRun(ParagraphInfo const &para,
new_span_height.computeEffective( new_span.start.iter_span->line_height_multiplier );
/* floating point 80-bit/64-bit rounding problems require epsilon. See
discussion http://inkscape.gristle.org/2005-03-16.txt around 22:00 */
- if ( new_span_height.ascent > line_height->ascent + FLT_EPSILON ||
- new_span_height.descent > line_height->descent + FLT_EPSILON) {
+ if ( new_span_height.ascent > line_height->ascent + std::numeric_limits<float>::epsilon() ||
+ new_span_height.descent > line_height->descent + std::numeric_limits<float>::epsilon() ) {
// Take larger of each of the two ascents and two descents per CSS
line_height->max(new_span_height);
if (!_scanline_maker->canExtendCurrentScanline(*line_height)) {
diff --git a/src/libnrtype/Layout-TNG-Scanline-Makers.cpp b/src/libnrtype/Layout-TNG-Scanline-Makers.cpp
index dcc973a24..0d6112d19 100644
--- a/src/libnrtype/Layout-TNG-Scanline-Makers.cpp
+++ b/src/libnrtype/Layout-TNG-Scanline-Makers.cpp
@@ -11,6 +11,7 @@
#include "Layout-TNG-Scanline-Maker.h"
#include "livarot/Shape.h"
#include "livarot/float-line.h"
+#include <limits>
namespace Inkscape {
namespace Text {
@@ -43,7 +44,7 @@ std::vector<Layout::ScanlineMaker::ScanRun> Layout::InfiniteScanlineMaker::makeS
{
std::vector<ScanRun> runs(1);
runs[0].x_start = _x;
- runs[0].x_end = FLT_MAX; // we could use DBL_MAX, but this just seems safer
+ runs[0].x_end = std::numeric_limits<float>::max(); // we could use DBL_MAX, but this just seems safer
runs[0].y = _y;
_current_line_height = line_height;
return runs;
diff --git a/src/livarot/LivarotDefs.h b/src/livarot/LivarotDefs.h
index 49f954586..abeff3861 100644
--- a/src/livarot/LivarotDefs.h
+++ b/src/livarot/LivarotDefs.h
@@ -9,21 +9,11 @@
#ifndef my_defs
#define my_defs
-#if defined(WIN32) || defined(__WIN32__)
-# include <inttypes.h>
-#endif
-
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
-#ifdef HAVE_INTTYPES_H
-# include <inttypes.h>
-#else
-# ifdef HAVE_STDINT_H
-# include <stdint.h>
-# endif
-#endif
+#include <stdint.h>
// error codes (mostly obsolete)
enum
diff --git a/src/livarot/PathOutline.cpp b/src/livarot/PathOutline.cpp
index e146bb908..1c42301da 100644
--- a/src/livarot/PathOutline.cpp
+++ b/src/livarot/PathOutline.cpp
@@ -471,8 +471,13 @@ void Path::SubContractOutline(int off, int num_pd,
// test de nullité du segment
if (IsNulCurve (descr_cmd, curD, curX))
{
- stTgt = dest->descr_cmd.size() ? Geom::Point(1, 0) : Geom::Point(-1, 0); // reverse direction
- enTgt = stTgt;
+ if (descr_cmd.size() == 2) { // single point, see LP Bug 1006666
+ stTgt = dest->descr_cmd.size() ? Geom::Point(1, 0) : Geom::Point(-1, 0); // reverse direction
+ enTgt = stTgt;
+ } else {
+ curP++;
+ continue;
+ }
}
stNor=stTgt.cw();
enNor=enTgt.cw();
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index fe7bf3a97..732c67304 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -104,16 +104,15 @@ const Util::EnumData<EffectType> LPETypeData[] = {
{EXTRUDE, N_("Extrude"), "extrude"},
{LATTICE, N_("Lattice Deformation"), "lattice"},
{LINE_SEGMENT, N_("Line Segment"), "line_segment"},
- {MIRROR_SYMMETRY, N_("Mirror symmetry"), "mirror_symmetry"},
{OFFSET, N_("Offset"), "offset"},
{PARALLEL, N_("Parallel"), "parallel"},
{PATH_LENGTH, N_("Path length"), "path_length"},
{PERP_BISECTOR, N_("Perpendicular bisector"), "perp_bisector"},
{PERSPECTIVE_PATH, N_("Perspective path"), "perspective_path"},
- {COPY_ROTATE, N_("Rotate copies"), "copy_rotate"},
{RECURSIVE_SKELETON, N_("Recursive skeleton"), "recursive_skeleton"},
{TANGENT_TO_CURVE, N_("Tangent to curve"), "tangent_to_curve"},
{TEXT_LABEL, N_("Text label"), "text_label"},
+ {FILLET_CHAMFER, N_("Fillet/Chamfer"), "fillet-chamfer"},
#endif
/* 0.46 */
{BEND_PATH, N_("Bend"), "bend_path"},
@@ -133,25 +132,25 @@ const Util::EnumData<EffectType> LPETypeData[] = {
/* 0.91 */
{POWERSTROKE, N_("Power stroke"), "powerstroke"},
{CLONE_ORIGINAL, N_("Clone original path"), "clone_original"},
-/* EXPERIMENTAL */
+/* 0.92 */
+ {SIMPLIFY, N_("Simplify"), "simplify"},
+ {LATTICE2, N_("Lattice Deformation 2"), "lattice2"},
+ {PERSPECTIVE_ENVELOPE, N_("Perspective/Envelope"), "perspective-envelope"},
+ {INTERPOLATE_POINTS, N_("Interpolate points"), "interpolate_points"},
+ {TRANSFORM_2PTS, N_("Transform by 2 points"), "transform_2pts"},
{SHOW_HANDLES, N_("Show handles"), "show_handles"},
{ROUGHEN, N_("Roughen"), "roughen"},
{BSPLINE, N_("BSpline"), "bspline"},
{JOIN_TYPE, N_("Join type"), "join_type"},
{TAPER_STROKE, N_("Taper stroke"), "taper_stroke"},
-/* Ponyscape */
+ {MIRROR_SYMMETRY, N_("Mirror symmetry"), "mirror_symmetry"},
+ {COPY_ROTATE, N_("Rotate copies"), "copy_rotate"},
+/* Ponyscape -> Inkscape 0.92*/
{ATTACH_PATH, N_("Attach path"), "attach_path"},
{FILL_BETWEEN_STROKES, N_("Fill between strokes"), "fill_between_strokes"},
{FILL_BETWEEN_MANY, N_("Fill between many"), "fill_between_many"},
{ELLIPSE_5PTS, N_("Ellipse by 5 points"), "ellipse_5pts"},
{BOUNDING_BOX, N_("Bounding Box"), "bounding_box"},
-/* 0.91 */
- {SIMPLIFY, N_("Simplify"), "simplify"},
- {LATTICE2, N_("Lattice Deformation 2"), "lattice2"},
- {PERSPECTIVE_ENVELOPE, N_("Perspective/Envelope"), "perspective-envelope"},
- {FILLET_CHAMFER, N_("Fillet/Chamfer"), "fillet-chamfer"},
- {INTERPOLATE_POINTS, N_("Interpolate points"), "interpolate_points"},
- {TRANSFORM_2PTS, N_("Transform by 2 points"), "transform_2pts"},
};
const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData));
@@ -356,7 +355,8 @@ Effect::createAndApply(EffectType type, SPDocument *doc, SPItem *item)
}
Effect::Effect(LivePathEffectObject *lpeobject)
- : _provides_knotholder_entities(false),
+ : apply_to_clippath_and_mask(false),
+ _provides_knotholder_entities(false),
oncanvasedit_it(0),
is_visible(_("Is visible?"), _("If unchecked, the effect remains applied to the object but is temporarily disabled on canvas"), "is_visible", &wr, this, true),
show_orig_path(false),
@@ -467,6 +467,10 @@ void Effect::doBeforeEffect_impl(SPLPEItem const* lpeitem)
pathvector_before_effect = sp_curve->get_pathvector();
}
doBeforeEffect(lpeitem);
+ if (apply_to_clippath_and_mask && SP_IS_GROUP(sp_lpe_item)) {
+ sp_lpe_item->apply_to_clippath(sp_lpe_item);
+ sp_lpe_item->apply_to_mask(sp_lpe_item);
+ }
}
/**
diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h
index ea57ff243..898e089b7 100644
--- a/src/live_effects/effect.h
+++ b/src/live_effects/effect.h
@@ -121,6 +121,7 @@ public:
inline bool isVisible() const { return is_visible; }
void editNextParamOncanvas(SPItem * item, SPDesktop * desktop);
+ bool apply_to_clippath_and_mask;
protected:
Effect(LivePathEffectObject *lpeobject);
@@ -144,6 +145,7 @@ protected:
std::vector<Parameter *> param_vector;
bool _provides_knotholder_entities;
+
int oncanvasedit_it;
BoolParam is_visible;
diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp
index d7c0b69a4..bc112285f 100644
--- a/src/live_effects/lpe-bendpath.cpp
+++ b/src/live_effects/lpe-bendpath.cpp
@@ -81,6 +81,7 @@ LPEBendPath::LPEBendPath(LivePathEffectObject *lpeobject) :
prop_scale.param_set_increments(0.01, 0.10);
_provides_knotholder_entities = true;
+ apply_to_clippath_and_mask = true;
concatenate_before_pwd2 = true;
}
@@ -95,10 +96,6 @@ LPEBendPath::doBeforeEffect (SPLPEItem const* lpeitem)
// get the item bounding box
original_bbox(lpeitem);
original_height = boundingbox_Y.max() - boundingbox_Y.min();
- SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem);
-
- item->apply_to_clippath(item);
- item->apply_to_mask(item);
}
Geom::Piecewise<Geom::D2<Geom::SBasis> >
diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp
index 87d8f05a9..efea76039 100644
--- a/src/live_effects/lpe-copy_rotate.cpp
+++ b/src/live_effects/lpe-copy_rotate.cpp
@@ -5,7 +5,7 @@
* Authors:
* Maximilian Albert <maximilian.albert@gmail.com>
* Johan Engelen <j.b.c.engelen@alumnus.utwente.nl>
- *
+ * Jabiertxo Arraiza Cenoz <jabier.arraiza@marker.es>
* Copyright (C) Authors 2007-2012
*
* Released under GNU GPL, read the file 'COPYING' for more information
@@ -13,7 +13,8 @@
#include <glibmm/i18n.h>
#include <gdk/gdk.h>
-
+#include <2geom/path-intersection.h>
+#include <2geom/sbasis-to-bezier.h>
#include "live_effects/lpe-copy_rotate.h"
#include <2geom/path.h>
#include <2geom/transforms.h>
@@ -41,34 +42,45 @@ public:
virtual Geom::Point knot_get() const;
};
-class KnotHolderEntityOrigin : public LPEKnotHolderEntity {
-public:
- KnotHolderEntityOrigin(LPECopyRotate *effect) : LPEKnotHolderEntity(effect) {};
- virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state);
- virtual Geom::Point knot_get() const;
-};
-
} // namespace CR
+bool
+pointInTriangle(Geom::Point const &p, Geom::Point const &p1, Geom::Point const &p2, Geom::Point const &p3)
+{
+ //http://totologic.blogspot.com.es/2014/01/accurate-point-in-triangle-test.html
+ using Geom::X;
+ using Geom::Y;
+ double denominator = (p1[X]*(p2[Y] - p3[Y]) + p1[Y]*(p3[X] - p2[X]) + p2[X]*p3[Y] - p2[Y]*p3[X]);
+ double t1 = (p[X]*(p3[Y] - p1[Y]) + p[Y]*(p1[X] - p3[X]) - p1[X]*p3[Y] + p1[Y]*p3[X]) / denominator;
+ double t2 = (p[X]*(p2[Y] - p1[Y]) + p[Y]*(p1[X] - p2[X]) - p1[X]*p2[Y] + p1[Y]*p2[X]) / -denominator;
+ double s = t1 + t2;
+
+ return 0 <= t1 && t1 <= 1 && 0 <= t2 && t2 <= 1 && s <= 1;
+}
+
+
LPECopyRotate::LPECopyRotate(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
origin(_("Origin"), _("Origin of the rotation"), "origin", &wr, this, "Adjust the origin of the rotation"),
starting_angle(_("Starting:"), _("Angle of the first copy"), "starting_angle", &wr, this, 0.0),
- rotation_angle(_("Rotation angle:"), _("Angle between two successive copies"), "rotation_angle", &wr, this, 30.0),
- num_copies(_("Number of copies:"), _("Number of copies of the original path"), "num_copies", &wr, this, 5),
- copiesTo360(_("360º Copies"), _("No rotation angle, fixed to 360º"), "copiesTo360", &wr, this, true),
+ rotation_angle(_("Rotation angle:"), _("Angle between two successive copies"), "rotation_angle", &wr, this, 60.0),
+ num_copies(_("Number of copies:"), _("Number of copies of the original path"), "num_copies", &wr, this, 6),
+ copies_to_360(_("360º Copies"), _("No rotation angle, fixed to 360º"), "copies_to_360", &wr, this, true),
+ fuse_paths(_("Fuse paths"), _("Fuse paths by helper line, use fill-rule: evenodd for best result"), "fuse_paths", &wr, this, false),
dist_angle_handle(100.0)
{
show_orig_path = true;
_provides_knotholder_entities = true;
+ apply_to_clippath_and_mask = true;
// register all your parameters here, so Inkscape knows which parameters this effect has:
- registerParameter(&copiesTo360);
+ registerParameter(&copies_to_360);
+ registerParameter(&fuse_paths);
registerParameter(&starting_angle);
registerParameter(&rotation_angle);
registerParameter(&num_copies);
registerParameter(&origin);
-
+
num_copies.param_make_integer(true);
num_copies.param_set_range(0, 1000);
}
@@ -92,15 +104,46 @@ LPECopyRotate::doOnApply(SPLPEItem const* lpeitem)
dir = unit_vector(B - A);
}
+void
+LPECopyRotate::transform_multiply(Geom::Affine const& postmul, bool set)
+{
+ if(fuse_paths) {
+ Geom::Coord angle = Geom::deg_from_rad(atan(-postmul[1]/postmul[0]));
+ angle += starting_angle;
+ starting_angle.param_set_value(angle);
+ }
+ // cycle through all parameters. Most parameters will not need transformation, but path and point params do.
+
+ for (std::vector<Parameter *>::iterator it = param_vector.begin(); it != param_vector.end(); ++it) {
+ Parameter * param = *it;
+ param->param_transform_multiply(postmul, set);
+ }
+}
void
LPECopyRotate::doBeforeEffect (SPLPEItem const* lpeitem)
{
using namespace Geom;
original_bbox(lpeitem);
- if(copiesTo360 ){
+ if (copies_to_360) {
rotation_angle.param_set_value(360.0/(double)num_copies);
- }
+ }
+ if (fuse_paths && rotation_angle * num_copies > 360 && rotation_angle > 0) {
+ num_copies.param_set_value(floor(360/rotation_angle));
+ }
+ if (fuse_paths && copies_to_360) {
+ num_copies.param_set_increments(2,2);
+ if ((int)num_copies%2 !=0) {
+ num_copies.param_set_value(num_copies+1);
+ rotation_angle.param_set_value(360.0/(double)num_copies);
+ }
+ } else {
+ num_copies.param_set_increments(1,1);
+ }
+
+ if (dist_angle_handle < 1.0) {
+ dist_angle_handle = 1.0;
+ }
A = Point(boundingbox_X.min(), boundingbox_Y.middle());
B = Point(boundingbox_X.middle(), boundingbox_Y.middle());
dir = unit_vector(B - A);
@@ -108,31 +151,251 @@ LPECopyRotate::doBeforeEffect (SPLPEItem const* lpeitem)
// likely due to SVG's choice of coordinate system orientation (max)
start_pos = origin + dir * Rotate(-rad_from_deg(starting_angle)) * dist_angle_handle;
rot_pos = origin + dir * Rotate(-rad_from_deg(rotation_angle+starting_angle)) * dist_angle_handle;
- if(copiesTo360 ){
+ if ( fuse_paths || copies_to_360 ) {
rot_pos = origin;
}
SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem);
item->apply_to_clippath(item);
item->apply_to_mask(item);
+}
+void
+LPECopyRotate::split(Geom::PathVector &path_on, Geom::Path const &divider)
+{
+ Geom::PathVector tmp_path;
+ double time_start = 0.0;
+ Geom::Path original = path_on[0];
+ int position = 0;
+ Geom::Crossings cs = crossings(original,divider);
+ std::vector<double> crossed;
+ for(unsigned int i = 0; i < cs.size(); i++) {
+ crossed.push_back(cs[i].ta);
+ }
+ std::sort(crossed.begin(), crossed.end());
+ for (unsigned int i = 0; i < crossed.size(); i++) {
+ double time_end = crossed[i];
+ if (time_start == time_end || time_end - time_start < Geom::EPSILON) {
+ continue;
+ }
+ Geom::Path portion_original = original.portion(time_start,time_end);
+ if (!portion_original.empty()) {
+ Geom::Point side_checker = portion_original.pointAt(0.0001);
+ position = Geom::sgn(Geom::cross(divider[1].finalPoint() - divider[0].finalPoint(), side_checker - divider[0].finalPoint()));
+ if (rotation_angle != 180) {
+ position = pointInTriangle(side_checker, divider.initialPoint(), divider[0].finalPoint(), divider[1].finalPoint());
+ }
+ if (position == 1) {
+ tmp_path.push_back(portion_original);
+ }
+ portion_original.clear();
+ time_start = time_end;
+ }
+ }
+ position = Geom::sgn(Geom::cross(divider[1].finalPoint() - divider[0].finalPoint(), original.finalPoint() - divider[0].finalPoint()));
+ if (rotation_angle != 180) {
+ position = pointInTriangle(original.finalPoint(), divider.initialPoint(), divider[0].finalPoint(), divider[1].finalPoint());
+ }
+ if (cs.size() > 0 && position == 1) {
+ Geom::Path portion_original = original.portion(time_start, original.size());
+ if(!portion_original.empty()){
+ if (!original.closed()) {
+ tmp_path.push_back(portion_original);
+ } else {
+ if (tmp_path.size() > 0 && tmp_path[0].size() > 0 ) {
+ portion_original.setFinal(tmp_path[0].initialPoint());
+ portion_original.append(tmp_path[0]);
+ tmp_path[0] = portion_original;
+ } else {
+ tmp_path.push_back(portion_original);
+ }
+ }
+ portion_original.clear();
+ }
+ }
+ if (cs.size()==0 && position == 1) {
+ tmp_path.push_back(original);
+ }
+ path_on = tmp_path;
}
+void
+LPECopyRotate::setFusion(Geom::PathVector &path_on, Geom::Path divider, double size_divider)
+{
+ split(path_on,divider);
+ Geom::PathVector tmp_path;
+ Geom::Affine pre = Geom::Translate(-origin);
+ for (Geom::PathVector::const_iterator path_it = path_on.begin(); path_it != path_on.end(); ++path_it) {
+ Geom::Path original = *path_it;
+ if (path_it->empty()) {
+ continue;
+ }
+ Geom::PathVector tmp_path_helper;
+ Geom::Path append_path = original;
+
+ for (int i = 0; i < num_copies; ++i) {
+ Geom::Rotate rot(-Geom::rad_from_deg(rotation_angle * (i)));
+ Geom::Affine m = pre * rot * Geom::Translate(origin);
+ if (i%2 != 0) {
+ Geom::Point A = (Geom::Point)origin;
+ Geom::Point B = origin + dir * Geom::Rotate(-Geom::rad_from_deg((rotation_angle*i)+starting_angle)) * size_divider;
+ Geom::Translate m1(A[0], A[1]);
+ double hyp = Geom::distance(A, B);
+ double c = (B[0] - A[0]) / hyp; // cos(alpha)
+ double s = (B[1] - A[1]) / hyp; // sin(alpha)
+
+ Geom::Affine m2(c, -s, s, c, 0.0, 0.0);
+ Geom::Scale sca(1.0, -1.0);
+
+ Geom::Affine tmp_m = m1.inverse() * m2;
+ m = tmp_m;
+ m = m * sca;
+ m = m * m2.inverse();
+ m = m * m1;
+ } else {
+ append_path = original;
+ }
+ append_path *= m;
+ if (tmp_path_helper.size() > 0) {
+ if (Geom::are_near(tmp_path_helper[tmp_path_helper.size()-1].finalPoint(), append_path.finalPoint())) {
+ Geom::Path tmp_append = append_path.reversed();
+ tmp_append.setInitial(tmp_path_helper[tmp_path_helper.size()-1].finalPoint());
+ tmp_path_helper[tmp_path_helper.size()-1].append(tmp_append);
+ } else if (Geom::are_near(tmp_path_helper[tmp_path_helper.size()-1].initialPoint(), append_path.initialPoint())) {
+ Geom::Path tmp_append = append_path;
+ tmp_path_helper[tmp_path_helper.size()-1] = tmp_path_helper[tmp_path_helper.size()-1].reversed();
+ tmp_append.setInitial(tmp_path_helper[tmp_path_helper.size()-1].finalPoint());
+ tmp_path_helper[tmp_path_helper.size()-1].append(tmp_append);
+ } else if (Geom::are_near(tmp_path_helper[tmp_path_helper.size()-1].finalPoint(), append_path.initialPoint())) {
+ Geom::Path tmp_append = append_path;
+ tmp_append.setInitial(tmp_path_helper[tmp_path_helper.size()-1].finalPoint());
+ tmp_path_helper[tmp_path_helper.size()-1].append(tmp_append);
+ } else if (Geom::are_near(tmp_path_helper[tmp_path_helper.size()-1].initialPoint(), append_path.finalPoint())) {
+ Geom::Path tmp_append = append_path.reversed();
+ tmp_path_helper[tmp_path_helper.size()-1] = tmp_path_helper[tmp_path_helper.size()-1].reversed();
+ tmp_append.setInitial(tmp_path_helper[tmp_path_helper.size()-1].finalPoint());
+ tmp_path_helper[tmp_path_helper.size()-1].append(tmp_append);
+ } else if (Geom::are_near(tmp_path_helper[0].finalPoint(), append_path.finalPoint())) {
+ Geom::Path tmp_append = append_path.reversed();
+ tmp_append.setInitial(tmp_path_helper[0].finalPoint());
+ tmp_path_helper[0].append(tmp_append);
+ } else if (Geom::are_near(tmp_path_helper[0].initialPoint(), append_path.initialPoint())) {
+ Geom::Path tmp_append = append_path;
+ tmp_path_helper[0] = tmp_path_helper[0].reversed();
+ tmp_append.setInitial(tmp_path_helper[0].finalPoint());
+ tmp_path_helper[0].append(tmp_append);
+ } else {
+ tmp_path_helper.push_back(append_path);
+ }
+ if ( Geom::are_near(tmp_path_helper[tmp_path_helper.size()-1].finalPoint(),tmp_path_helper[tmp_path_helper.size()-1].initialPoint())) {
+ tmp_path_helper[tmp_path_helper.size()-1].close();
+ }
+ } else {
+ tmp_path_helper.push_back(append_path);
+ }
+ }
+ if (tmp_path_helper.size() > 0) {
+ tmp_path_helper[tmp_path_helper.size()-1] = tmp_path_helper[tmp_path_helper.size()-1];
+ tmp_path_helper[0] = tmp_path_helper[0];
+ if (rotation_angle * num_copies != 360) {
+ Geom::Ray base_a(divider.pointAt(1),divider.pointAt(0));
+ double diagonal = Geom::distance(Geom::Point(boundingbox_X.min(),boundingbox_Y.min()),Geom::Point(boundingbox_X.max(),boundingbox_Y.max()));
+ Geom::Rect bbox(Geom::Point(boundingbox_X.min(),boundingbox_Y.min()),Geom::Point(boundingbox_X.max(),boundingbox_Y.max()));
+ double size_divider = Geom::distance(origin,bbox) + (diagonal * 2);
+ Geom::Point base_point = origin + dir * Geom::Rotate(-Geom::rad_from_deg((rotation_angle * num_copies) + starting_angle)) * size_divider;
+ Geom::Ray base_b(divider.pointAt(1), base_point);
+ if (Geom::are_near(tmp_path_helper[0].initialPoint(),base_a) &&
+ Geom::are_near(tmp_path_helper[0].finalPoint(),base_a))
+ {
+ tmp_path_helper[0].close();
+ if (tmp_path_helper.size() > 1) {
+ tmp_path_helper[tmp_path_helper.size()-1].close();
+ }
+ } else if (Geom::are_near(tmp_path_helper[tmp_path_helper.size()-1].initialPoint(),base_b) &&
+ Geom::are_near(tmp_path_helper[tmp_path_helper.size()-1].finalPoint(),base_b))
+ {
+ tmp_path_helper[0].close();
+ if (tmp_path_helper.size() > 1) {
+ tmp_path_helper[tmp_path_helper.size()-1].close();
+ }
+ } else if ((Geom::are_near(tmp_path_helper[0].initialPoint(),base_a) &&
+ Geom::are_near(tmp_path_helper[tmp_path_helper.size()-1].finalPoint(),base_b)) ||
+ (Geom::are_near(tmp_path_helper[0].initialPoint(),base_b) &&
+ Geom::are_near(tmp_path_helper[tmp_path_helper.size()-1].finalPoint(),base_a)))
+ {
+ Geom::Path close_path = Geom::Path(tmp_path_helper[tmp_path_helper.size()-1].finalPoint());
+ close_path.appendNew<Geom::LineSegment>((Geom::Point)origin);
+ close_path.appendNew<Geom::LineSegment>(tmp_path_helper[0].initialPoint());
+ tmp_path_helper[0].append(close_path);
+ }
+ }
+
+ if (Geom::are_near(tmp_path_helper[0].finalPoint(),tmp_path_helper[0].initialPoint())) {
+ tmp_path_helper[0].close();
+ }
+ }
+ tmp_path.insert(tmp_path.end(), tmp_path_helper.begin(), tmp_path_helper.end());
+ tmp_path_helper.clear();
+ }
+ path_on = tmp_path;
+ tmp_path.clear();
+}
Geom::Piecewise<Geom::D2<Geom::SBasis> >
LPECopyRotate::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in)
{
using namespace Geom;
- if(num_copies == 1){
+ if (num_copies == 1 && !fuse_paths) {
return pwd2_in;
}
+ double diagonal = Geom::distance(Geom::Point(boundingbox_X.min(),boundingbox_Y.min()),Geom::Point(boundingbox_X.max(),boundingbox_Y.max()));
+ Geom::Rect bbox(Geom::Point(boundingbox_X.min(),boundingbox_Y.min()),Geom::Point(boundingbox_X.max(),boundingbox_Y.max()));
+ double size_divider = Geom::distance(origin,bbox) + (diagonal * 2);
+ Geom::Point line_start = origin + dir * Rotate(-rad_from_deg(starting_angle)) * size_divider;
+ Geom::Point line_end = origin + dir * Rotate(-rad_from_deg(rotation_angle + starting_angle)) * size_divider;
+ //Note:: beter way to do this
+ //Whith AppendNew have problems whith the crossing order
+ Geom::Path divider = Geom::Path(line_start);
+ divider.appendNew<Geom::LineSegment>((Geom::Point)origin);
+ divider.appendNew<Geom::LineSegment>(line_end);
Piecewise<D2<SBasis> > output;
Affine pre = Translate(-origin) * Rotate(-rad_from_deg(starting_angle));
- for (int i = 0; i < num_copies; ++i) {
- Rotate rot(-rad_from_deg(rotation_angle * i));
- Affine t = pre * rot * Translate(origin);
- output.concat(pwd2_in * t);
+ if (fuse_paths) {
+ Geom::PathVector path_out;
+ Geom::PathVector tmp_path;
+ PathVector const original_pathv = path_from_piecewise(remove_short_cuts(pwd2_in, 0.1), 0.001);
+ for (Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) {
+ if (path_it->empty()) {
+ continue;
+ }
+ bool end_open = false;
+ if (path_it->closed()) {
+ const Geom::Curve &closingline = path_it->back_closed();
+ if (!are_near(closingline.initialPoint(), closingline.finalPoint())) {
+ end_open = true;
+ }
+ }
+ Geom::Path original = (Geom::Path)(*path_it);
+ if (end_open && path_it->closed()) {
+ original.close(false);
+ original.appendNew<Geom::LineSegment>( original.initialPoint() );
+ original.close(true);
+ }
+ tmp_path.push_back(original);
+ setFusion(tmp_path, divider, size_divider);
+ path_out.insert(path_out.end(), tmp_path.begin(), tmp_path.end());
+ tmp_path.clear();
+ }
+ if (path_out.size()>0) {
+ output = paths_to_pw(path_out);
+ }
+ } else {
+ for (int i = 0; i < num_copies; ++i) {
+ Rotate rot(-rad_from_deg(rotation_angle * i));
+ Affine t = pre * rot * Translate(origin);
+ output.concat(pwd2_in * t);
+ }
}
return output;
}
@@ -151,8 +414,16 @@ LPECopyRotate::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geo
hp_vec.push_back(pathv);
}
+void
+LPECopyRotate::resetDefaults(SPItem const* item)
+{
+ Effect::resetDefaults(item);
+ original_bbox(SP_LPE_ITEM(item));
+}
-void LPECopyRotate::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) {
+void
+LPECopyRotate::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item)
+{
{
KnotHolderEntity *e = new CR::KnotHolderEntityStartingAngle(this);
e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN,
@@ -165,13 +436,6 @@ void LPECopyRotate::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *des
_("Adjust the rotation angle"));
knotholder->add(e);
}
-}
-
-void
-LPECopyRotate::resetDefaults(SPItem const* item)
-{
- Effect::resetDefaults(item);
- original_bbox(SP_LPE_ITEM(item));
};
namespace CR {
diff --git a/src/live_effects/lpe-copy_rotate.h b/src/live_effects/lpe-copy_rotate.h
index 9392026a7..87af867df 100644
--- a/src/live_effects/lpe-copy_rotate.h
+++ b/src/live_effects/lpe-copy_rotate.h
@@ -22,24 +22,22 @@ namespace Inkscape {
namespace LivePathEffect {
namespace CR {
- // we need a separate namespace to avoid clashes with LPEPerpBisector
- class KnotHolderEntityStartingAngle;
- class KnotHolderEntityRotationAngle;
+// we need a separate namespace to avoid clashes with LPEPerpBisector
+class KnotHolderEntityStartingAngle;
+class KnotHolderEntityRotationAngle;
}
class LPECopyRotate : public Effect, GroupBBoxEffect {
public:
LPECopyRotate(LivePathEffectObject *lpeobject);
virtual ~LPECopyRotate();
-
virtual void doOnApply (SPLPEItem const* lpeitem);
-
virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in);
-
virtual void doBeforeEffect (SPLPEItem const* lpeitem);
-
+ virtual void setFusion(Geom::PathVector &path_in, Geom::Path divider, double sizeDivider);
+ virtual void split(Geom::PathVector &path_in, Geom::Path const &divider);
virtual void resetDefaults(SPItem const* item);
-
+ virtual void transform_multiply(Geom::Affine const& postmul, bool set);
/* the knotholder entity classes must be declared friends */
friend class CR::KnotHolderEntityStartingAngle;
friend class CR::KnotHolderEntityRotationAngle;
@@ -53,16 +51,14 @@ private:
ScalarParam starting_angle;
ScalarParam rotation_angle;
ScalarParam num_copies;
- BoolParam copiesTo360;
-
+ BoolParam copies_to_360;
+ BoolParam fuse_paths;
Geom::Point A;
Geom::Point B;
Geom::Point dir;
-
Geom::Point start_pos;
Geom::Point rot_pos;
double dist_angle_handle;
-
LPECopyRotate(const LPECopyRotate&);
LPECopyRotate& operator=(const LPECopyRotate&);
};
diff --git a/src/live_effects/lpe-envelope.cpp b/src/live_effects/lpe-envelope.cpp
index 05a672ae8..e873c0b15 100644
--- a/src/live_effects/lpe-envelope.cpp
+++ b/src/live_effects/lpe-envelope.cpp
@@ -42,6 +42,7 @@ LPEEnvelope::LPEEnvelope(LivePathEffectObject *lpeobject) :
registerParameter( dynamic_cast<Parameter *>(&bend_path3) );
registerParameter( dynamic_cast<Parameter *>(&bend_path4) );
concatenate_before_pwd2 = true;
+ apply_to_clippath_and_mask = true;
}
LPEEnvelope::~LPEEnvelope()
@@ -54,9 +55,6 @@ LPEEnvelope::doBeforeEffect (SPLPEItem const* lpeitem)
{
// get the item bounding box
original_bbox(lpeitem);
- SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem);
- item->apply_to_clippath(item);
- item->apply_to_mask(item);
}
Geom::Piecewise<Geom::D2<Geom::SBasis> >
diff --git a/src/live_effects/lpe-jointype.cpp b/src/live_effects/lpe-jointype.cpp
index 2eef315dd..fe42932be 100644
--- a/src/live_effects/lpe-jointype.cpp
+++ b/src/live_effects/lpe-jointype.cpp
@@ -4,7 +4,7 @@
*
* Copyright (C) 2014 Authors
*
-* Released under GNU GPL v2, read the file 'COPYING' for more information
+* Released under GNU GPL v2+, read the file 'COPYING' for more information
*/
#include "live_effects/parameter/enum.h"
diff --git a/src/live_effects/lpe-jointype.h b/src/live_effects/lpe-jointype.h
index fddaeb619..ef7abdcc7 100644
--- a/src/live_effects/lpe-jointype.h
+++ b/src/live_effects/lpe-jointype.h
@@ -3,7 +3,7 @@
*
* Copyright (C) 2014 Authors
*
- * Released under GNU GPL v2, read the file COPYING for more information
+ * Released under GNU GPL v2+, read the file COPYING for more information
*/
#ifndef INKSCAPE_LPE_JOINTYPE_H
diff --git a/src/live_effects/lpe-lattice.cpp b/src/live_effects/lpe-lattice.cpp
index c05bae7e1..3c23e349e 100644
--- a/src/live_effects/lpe-lattice.cpp
+++ b/src/live_effects/lpe-lattice.cpp
@@ -78,7 +78,7 @@ LPELattice::LPELattice(LivePathEffectObject *lpeobject) :
registerParameter( dynamic_cast<Parameter *>(&grid_point14) );
registerParameter( dynamic_cast<Parameter *>(&grid_point15) );
-
+ apply_to_clippath_and_mask = true;
}
LPELattice::~LPELattice()
@@ -176,9 +176,6 @@ void
LPELattice::doBeforeEffect (SPLPEItem const* lpeitem)
{
original_bbox(lpeitem);
- SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem);
- item->apply_to_clippath(item);
- item->apply_to_mask(item);
}
void
diff --git a/src/live_effects/lpe-lattice2.cpp b/src/live_effects/lpe-lattice2.cpp
index b749370fa..0c403daec 100644
--- a/src/live_effects/lpe-lattice2.cpp
+++ b/src/live_effects/lpe-lattice2.cpp
@@ -103,6 +103,7 @@ LPELattice2::LPELattice2(LivePathEffectObject *lpeobject) :
registerParameter(&grid_point_28x30);
registerParameter(&grid_point_29x31);
registerParameter(&grid_point_32x33x34x35);
+ apply_to_clippath_and_mask = true;
}
LPELattice2::~LPELattice2()
@@ -358,9 +359,6 @@ LPELattice2::doBeforeEffect (SPLPEItem const* lpeitem)
horizontal(grid_point_17, grid_point_19,horiz);
horizontal(grid_point_20x21, grid_point_22x23,horiz);
}
- SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem);
- item->apply_to_clippath(item);
- item->apply_to_mask(item);
}
void
diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp
index 783053df2..9f3070ff4 100644
--- a/src/live_effects/lpe-mirror_symmetry.cpp
+++ b/src/live_effects/lpe-mirror_symmetry.cpp
@@ -6,36 +6,84 @@
* Maximilian Albert
* Johan Engelen
* Abhishek Sharma
+ * Jabiertxof
*
* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
* Copyright (C) Maximilin Albert 2008 <maximilian.albert@gmail.com>
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-
+#include <gtkmm.h>
#include <glibmm/i18n.h>
#include "live_effects/lpe-mirror_symmetry.h"
#include <sp-path.h>
#include <display/curve.h>
#include <svg/path-string.h>
-
+#include "helper/geom.h"
#include <2geom/path.h>
+#include <2geom/path-intersection.h>
#include <2geom/transforms.h>
#include <2geom/affine.h>
+#include "knot-holder-entity.h"
+#include "knotholder.h"
+#include "inkscape.h"
namespace Inkscape {
namespace LivePathEffect {
+static const Util::EnumData<ModeType> ModeTypeData[MT_END] = {
+ { MT_V, N_("Vertical Page Center"), "Vertical Page Center, use select tool to move item instead line" },
+ { MT_H, N_("Horizontal Page Center"), "Horizontal Page Center, use select tool to move item instead line" },
+ { MT_FREE, N_("Free from reflection line"), "Free from path" },
+ { MT_X, N_("X from middle knot"), "X from middle knot" },
+ { MT_Y, N_("Y from middle knot"), "Y from middle knot" }
+};
+static const Util::EnumDataConverter<ModeType>
+MTConverter(ModeTypeData, MT_END);
+
+namespace MS {
+
+class KnotHolderEntityCenterMirrorSymmetry : public LPEKnotHolderEntity {
+public:
+ KnotHolderEntityCenterMirrorSymmetry(LPEMirrorSymmetry *effect) : LPEKnotHolderEntity(effect){};
+ virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state);
+ virtual Geom::Point knot_get() const;
+};
+
+class KnotHolderEntityStartMirrorSymmetry : public LPEKnotHolderEntity {
+public:
+ KnotHolderEntityStartMirrorSymmetry(LPEMirrorSymmetry *effect) : LPEKnotHolderEntity(effect){};
+ virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state);
+ virtual Geom::Point knot_get() const;
+};
+
+class KnotHolderEntityEndMirrorSymmetry : public LPEKnotHolderEntity {
+public:
+ KnotHolderEntityEndMirrorSymmetry(LPEMirrorSymmetry *effect) : LPEKnotHolderEntity(effect){};
+ virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state);
+ virtual Geom::Point knot_get() const;
+};
+
+} // namespace MS
+
LPEMirrorSymmetry::LPEMirrorSymmetry(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
+ mode(_("Mode"), _("Symmetry move mode"), "mode", MTConverter, &wr, this, MT_FREE),
discard_orig_path(_("Discard original path?"), _("Check this to only keep the mirrored part of the path"), "discard_orig_path", &wr, this, false),
- reflection_line(_("Reflection line:"), _("Line which serves as 'mirror' for the reflection"), "reflection_line", &wr, this, "M0,0 L100,100")
+ fuse_paths(_("Fuse paths"), _("Fuse original and the reflection into a single path"), "fuse_paths", &wr, this, false),
+ oposite_fuse(_("Opposite fuse"), _("Picks the other side of the mirror as the original"), "oposite_fuse", &wr, this, false),
+ start_point(_("Start mirror line"), _("Start mirror line"), "start_point", &wr, this, "Adjust the start of mirroring"),
+ end_point(_("End mirror line"), _("End mirror line"), "end_point", &wr, this, "Adjust end of mirroring")
{
show_orig_path = true;
-
- registerParameter( dynamic_cast<Parameter *>(&discard_orig_path) );
- registerParameter( dynamic_cast<Parameter *>(&reflection_line) );
+ registerParameter(&mode);
+ registerParameter( &discard_orig_path);
+ registerParameter( &fuse_paths);
+ registerParameter( &oposite_fuse);
+ registerParameter( &start_point);
+ registerParameter( &end_point);
+ apply_to_clippath_and_mask = true;
}
LPEMirrorSymmetry::~LPEMirrorSymmetry()
@@ -43,11 +91,65 @@ LPEMirrorSymmetry::~LPEMirrorSymmetry()
}
void
+
LPEMirrorSymmetry::doBeforeEffect (SPLPEItem const* lpeitem)
{
- SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem);
- item->apply_to_clippath(item);
- item->apply_to_mask(item);
+ using namespace Geom;
+
+ Point point_a(boundingbox_X.max(), boundingbox_Y.min());
+ Point point_b(boundingbox_X.max(), boundingbox_Y.max());
+ Point point_c(boundingbox_X.max(), boundingbox_Y.middle());
+ if (mode == MT_Y) {
+ point_a = Geom::Point(boundingbox_X.min(),center_point[Y]);
+ point_b = Geom::Point(boundingbox_X.max(),center_point[Y]);
+ }
+ if (mode == MT_X) {
+ point_a = Geom::Point(center_point[X],boundingbox_Y.min());
+ point_b = Geom::Point(center_point[X],boundingbox_Y.max());
+ }
+ line_separation.setPoints(point_a, point_b);
+ if ( mode == MT_X || mode == MT_Y ) {
+ start_point.param_setValue(point_a);
+ end_point.param_setValue(point_b);
+ center_point = Geom::middle_point(point_a, point_b);
+ } else if ( mode == MT_FREE) {
+ if(!are_near(previous_center,center_point, 0.01)) {
+ Geom::Point trans = center_point - previous_center;
+ start_point.param_setValue(start_point * trans);
+ end_point.param_setValue(end_point * trans);
+ line_separation.setPoints(start_point, end_point);
+ } else {
+ center_point = Geom::middle_point((Geom::Point)start_point, (Geom::Point)end_point);
+ line_separation.setPoints(start_point, end_point);
+ }
+ } else if ( mode == MT_V){
+ if(SP_ACTIVE_DESKTOP){
+ SPDocument * doc = SP_ACTIVE_DESKTOP->getDocument();
+ Geom::Rect view_box_rect = doc->getViewBox();
+ Geom::Point sp = Geom::Point(view_box_rect.width()/2.0, 0);
+ sp *= i2anc_affine(SP_OBJECT(lpeitem), SP_OBJECT(SP_ACTIVE_DESKTOP->currentLayer()->parent)) .inverse();
+ start_point.param_setValue(sp);
+ Geom::Point ep = Geom::Point(view_box_rect.width()/2.0, view_box_rect.height());
+ ep *= i2anc_affine(SP_OBJECT(lpeitem), SP_OBJECT(SP_ACTIVE_DESKTOP->currentLayer()->parent)) .inverse();
+ end_point.param_setValue(ep);
+ center_point = Geom::middle_point((Geom::Point)start_point, (Geom::Point)end_point);
+ line_separation.setPoints(start_point, end_point);
+ }
+ } else { //horizontal page
+ if(SP_ACTIVE_DESKTOP){
+ SPDocument * doc = SP_ACTIVE_DESKTOP->getDocument();
+ Geom::Rect view_box_rect = doc->getViewBox();
+ Geom::Point sp = Geom::Point(0, view_box_rect.height()/2.0);
+ sp *= i2anc_affine(SP_OBJECT(lpeitem), SP_OBJECT(SP_ACTIVE_DESKTOP->currentLayer()->parent)) .inverse();
+ start_point.param_setValue(sp);
+ Geom::Point ep = Geom::Point(view_box_rect.width(), view_box_rect.height()/2.0);
+ ep *= i2anc_affine(SP_OBJECT(lpeitem), SP_OBJECT(SP_ACTIVE_DESKTOP->currentLayer()->parent)) .inverse();
+ end_point.param_setValue(ep);
+ center_point = Geom::middle_point((Geom::Point)start_point, (Geom::Point)end_point);
+ line_separation.setPoints(start_point, end_point);
+ }
+ }
+ previous_center = center_point;
}
void
@@ -55,56 +157,210 @@ LPEMirrorSymmetry::doOnApply (SPLPEItem const* lpeitem)
{
using namespace Geom;
- // fixme: what happens if the bbox is empty?
- // fixme: this is probably wrong
- Geom::Affine t = lpeitem->i2dt_affine();
- Geom::Rect bbox = *lpeitem->desktopVisualBounds();
-
- Point A(bbox.left(), bbox.bottom());
- Point B(bbox.left(), bbox.top());
- A *= t;
- B *= t;
- Piecewise<D2<SBasis> > rline = Piecewise<D2<SBasis> >(D2<SBasis>(SBasis(A[X], B[X]), SBasis(A[Y], B[Y])));
- reflection_line.set_new_value(rline, true);
+ original_bbox(lpeitem);
+
+ Point point_a(boundingbox_X.max(), boundingbox_Y.min());
+ Point point_b(boundingbox_X.max(), boundingbox_Y.max());
+ Point point_c(boundingbox_X.max(), boundingbox_Y.middle());
+ start_point.param_setValue(point_a);
+ start_point.param_update_default(point_a);
+ end_point.param_setValue(point_b);
+ end_point.param_update_default(point_b);
+ center_point = point_c;
+ previous_center = center_point;
}
+
Geom::PathVector
LPEMirrorSymmetry::doEffect_path (Geom::PathVector const & path_in)
{
- // Don't allow empty path parameter:
- if ( reflection_line.get_pathvector().empty() ) {
- return path_in;
- }
-
+ Geom::PathVector const original_pathv = pathv_to_linear_and_cubic_beziers(path_in);
Geom::PathVector path_out;
- if (!discard_orig_path) {
- path_out = path_in;
+
+ if (!discard_orig_path && !fuse_paths) {
+ path_out = pathv_to_linear_and_cubic_beziers(path_in);
}
- Geom::PathVector mline(reflection_line.get_pathvector());
- Geom::Point A(mline.front().initialPoint());
- Geom::Point B(mline.back().finalPoint());
+ Geom::Point point_a(line_separation.initialPoint());
+ Geom::Point point_b(line_separation.finalPoint());
- Geom::Affine m1(1.0, 0.0, 0.0, 1.0, A[0], A[1]);
- double hyp = Geom::distance(A, B);
- double c = (B[0] - A[0]) / hyp; // cos(alpha)
- double s = (B[1] - A[1]) / hyp; // sin(alpha)
+ Geom::Translate m1(point_a[0], point_a[1]);
+ double hyp = Geom::distance(point_a, point_b);
+ double c = (point_b[0] - point_a[0]) / hyp; // cos(alpha)
+ double s = (point_b[1] - point_a[1]) / hyp; // sin(alpha)
Geom::Affine m2(c, -s, s, c, 0.0, 0.0);
- Geom::Affine sca(1.0, 0.0, 0.0, -1.0, 0.0, 0.0);
+ Geom::Scale sca(1.0, -1.0);
Geom::Affine m = m1.inverse() * m2;
m = m * sca;
m = m * m2.inverse();
m = m * m1;
- for (int i = 0; i < static_cast<int>(path_in.size()); ++i) {
- path_out.push_back(path_in[i] * m);
+ if (fuse_paths && !discard_orig_path) {
+ for (Geom::PathVector::const_iterator path_it = original_pathv.begin();
+ path_it != original_pathv.end(); ++path_it)
+ {
+ if (path_it->empty()) {
+ continue;
+ }
+ Geom::PathVector tmp_path;
+ double time_start = 0.0;
+ int position = 0;
+ bool end_open = false;
+ if (path_it->closed()) {
+ const Geom::Curve &closingline = path_it->back_closed();
+ if (!are_near(closingline.initialPoint(), closingline.finalPoint())) {
+ end_open = true;
+ }
+ }
+ Geom::Path original = *path_it;
+ if (end_open && path_it->closed()) {
+ original.close(false);
+ original.appendNew<Geom::LineSegment>( original.initialPoint() );
+ original.close(true);
+ }
+ Geom::Point s = start_point;
+ Geom::Point e = end_point;
+ double dir = line_separation.angle();
+ double diagonal = Geom::distance(Geom::Point(boundingbox_X.min(),boundingbox_Y.min()),Geom::Point(boundingbox_X.max(),boundingbox_Y.max()));
+ Geom::Rect bbox(Geom::Point(boundingbox_X.min(),boundingbox_Y.min()),Geom::Point(boundingbox_X.max(),boundingbox_Y.max()));
+ double size_divider = Geom::distance(center_point, bbox) + diagonal;
+ s = Geom::Point::polar(dir,size_divider) + center_point;
+ e = Geom::Point::polar(dir + Geom::rad_from_deg(180),size_divider) + center_point;
+ Geom::Path divider = Geom::Path(s);
+ divider.appendNew<Geom::LineSegment>(e);
+ Geom::Crossings cs = crossings(original, divider);
+ std::vector<double> crossed;
+ for(unsigned int i = 0; i < cs.size(); i++) {
+ crossed.push_back(cs[i].ta);
+ }
+ std::sort(crossed.begin(), crossed.end());
+ for (unsigned int i = 0; i < crossed.size(); i++) {
+ double time_end = crossed[i];
+ if (time_start != time_end && time_end - time_start > Geom::EPSILON) {
+ Geom::Path portion = original.portion(time_start, time_end);
+ if (!portion.empty()) {
+ Geom::Point middle = portion.pointAt((double)portion.size()/2.0);
+ position = Geom::sgn(Geom::cross(e - s, middle - s));
+ if (!oposite_fuse) {
+ position *= -1;
+ }
+ if (position == 1) {
+ Geom::Path mirror = portion.reversed() * m;
+ mirror.setInitial(portion.finalPoint());
+ portion.append(mirror);
+ if(i!=0) {
+ portion.setFinal(portion.initialPoint());
+ portion.close();
+ }
+ tmp_path.push_back(portion);
+ }
+ portion.clear();
+ }
+ }
+ time_start = time_end;
+ }
+ position = Geom::sgn(Geom::cross(e - s, original.finalPoint() - s));
+ if (!oposite_fuse) {
+ position *= -1;
+ }
+ if (cs.size()!=0 && position == 1) {
+ if (time_start != original.size() && original.size() - time_start > Geom::EPSILON) {
+ Geom::Path portion = original.portion(time_start, original.size());
+ if (!portion.empty()) {
+ portion = portion.reversed();
+ Geom::Path mirror = portion.reversed() * m;
+ mirror.setInitial(portion.finalPoint());
+ portion.append(mirror);
+ portion = portion.reversed();
+ if (!original.closed()) {
+ tmp_path.push_back(portion);
+ } else {
+ if (cs.size() > 1 && tmp_path.size() > 0 && tmp_path[0].size() > 0 ) {
+ portion.setFinal(tmp_path[0].initialPoint());
+ portion.setInitial(tmp_path[0].finalPoint());
+ tmp_path[0].append(portion);
+ } else {
+ tmp_path.push_back(portion);
+ }
+ tmp_path[0].close();
+ }
+ portion.clear();
+ }
+ }
+ }
+ if (cs.size() == 0 && position == 1) {
+ tmp_path.push_back(original);
+ tmp_path.push_back(original * m);
+ }
+ path_out.insert(path_out.end(), tmp_path.begin(), tmp_path.end());
+ tmp_path.clear();
+ }
+ }
+
+ if (!fuse_paths || discard_orig_path) {
+ for (int i = 0; i < static_cast<int>(path_in.size()); ++i) {
+ path_out.push_back(path_in[i] * m);
+ }
}
return path_out;
}
+void
+LPEMirrorSymmetry::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec)
+{
+ using namespace Geom;
+ hp_vec.clear();
+ Geom::Path path;
+ Geom::Point s = start_point;
+ Geom::Point e = end_point;
+ path.start( s );
+ path.appendNew<Geom::LineSegment>( e );
+ Geom::PathVector helper;
+ helper.push_back(path);
+ hp_vec.push_back(helper);
+}
+
+void
+LPEMirrorSymmetry::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item)
+{
+ SPKnotShapeType knot_shape = SP_KNOT_SHAPE_CIRCLE;
+ SPKnotModeType knot_mode = SP_KNOT_MODE_XOR;
+ guint32 knot_color = 0x0000ff00;
+ {
+ KnotHolderEntity *c = new MS::KnotHolderEntityCenterMirrorSymmetry(this);
+ c->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN,
+ _("Adjust the center"), knot_shape, knot_mode, knot_color );
+ knotholder->add(c);
+ }
+};
+
+namespace MS {
+
+using namespace Geom;
+
+void
+KnotHolderEntityCenterMirrorSymmetry::knot_set(Geom::Point const &p, Geom::Point const &origin, guint state)
+{
+ LPEMirrorSymmetry* lpe = dynamic_cast<LPEMirrorSymmetry *>(_effect);
+ Geom::Point const s = snap_knot_position(p, state);
+ lpe->center_point = s;
+
+ // FIXME: this should not directly ask for updating the item. It should write to SVG, which triggers updating.
+ sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true);
+}
+
+Geom::Point
+KnotHolderEntityCenterMirrorSymmetry::knot_get() const
+{
+ LPEMirrorSymmetry const *lpe = dynamic_cast<LPEMirrorSymmetry const*>(_effect);
+ return lpe->center_point;
+}
+
+} // namespace CR
+
} //namespace LivePathEffect
} /* namespace Inkscape */
diff --git a/src/live_effects/lpe-mirror_symmetry.h b/src/live_effects/lpe-mirror_symmetry.h
index 7a484a473..3a244cb7e 100644
--- a/src/live_effects/lpe-mirror_symmetry.h
+++ b/src/live_effects/lpe-mirror_symmetry.h
@@ -8,6 +8,7 @@
* Authors:
* Maximilian Albert
* Johan Engelen
+ * Jabiertxof
*
* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
* Copyright (C) Maximilin Albert 2008 <maximilian.albert@gmail.com>
@@ -19,24 +20,50 @@
#include "live_effects/parameter/parameter.h"
#include "live_effects/parameter/point.h"
#include "live_effects/parameter/path.h"
+#include "live_effects/parameter/enum.h"
+#include "live_effects/lpegroupbbox.h"
namespace Inkscape {
namespace LivePathEffect {
-class LPEMirrorSymmetry : public Effect {
+namespace MS {
+// we need a separate namespace to avoid clashes with LPEPerpBisector
+class KnotHolderEntityCenterMirrorSymmetry;
+}
+
+enum ModeType {
+ MT_V,
+ MT_H,
+ MT_FREE,
+ MT_X,
+ MT_Y,
+ MT_END
+};
+
+class LPEMirrorSymmetry : public Effect, GroupBBoxEffect {
public:
LPEMirrorSymmetry(LivePathEffectObject *lpeobject);
virtual ~LPEMirrorSymmetry();
-
virtual void doOnApply (SPLPEItem const* lpeitem);
-
virtual void doBeforeEffect (SPLPEItem const* lpeitem);
-
virtual Geom::PathVector doEffect_path (Geom::PathVector const & path_in);
+ /* the knotholder entity classes must be declared friends */
+ friend class MS::KnotHolderEntityCenterMirrorSymmetry;
+ void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
+
+protected:
+ virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector<Geom::PathVector> &hp_vec);
private:
+ EnumParam<ModeType> mode;
BoolParam discard_orig_path;
- PathParam reflection_line;
+ BoolParam fuse_paths;
+ BoolParam oposite_fuse;
+ PointParam start_point;
+ PointParam end_point;
+ Geom::Line line_separation;
+ Geom::Point previous_center;
+ Geom::Point center_point;
LPEMirrorSymmetry(const LPEMirrorSymmetry&);
LPEMirrorSymmetry& operator=(const LPEMirrorSymmetry&);
diff --git a/src/live_effects/lpe-offset.cpp b/src/live_effects/lpe-offset.cpp
index dd7af92a2..d611b88a1 100644
--- a/src/live_effects/lpe-offset.cpp
+++ b/src/live_effects/lpe-offset.cpp
@@ -31,7 +31,7 @@ LPEOffset::LPEOffset(LivePathEffectObject *lpeobject) :
offset_pt(_("Offset"), _("Handle to control the distance of the offset from the curve"), "offset_pt", &wr, this)
{
show_orig_path = true;
-
+ apply_to_clippath_and_mask = true;
registerParameter(dynamic_cast<Parameter *>(&offset_pt));
}
@@ -57,14 +57,6 @@ static void append_half_circle(Geom::Piecewise<Geom::D2<Geom::SBasis> > &pwd2,
pwd2.continuousConcat(cap_pwd2);
}
-void
-LPEOffset::doBeforeEffect (SPLPEItem const* lpeitem)
-{
- SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem);
- item->apply_to_clippath(item);
- item->apply_to_mask(item);
-}
-
Geom::Piecewise<Geom::D2<Geom::SBasis> >
LPEOffset::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in)
{
diff --git a/src/live_effects/lpe-offset.h b/src/live_effects/lpe-offset.h
index 997311c7d..9966fd45d 100644
--- a/src/live_effects/lpe-offset.h
+++ b/src/live_effects/lpe-offset.h
@@ -28,8 +28,6 @@ public:
virtual void doOnApply (SPLPEItem const* lpeitem);
- virtual void doBeforeEffect (SPLPEItem const* lpeitem);
-
virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in);
private:
diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp
index 9397d848f..911c410f9 100644
--- a/src/live_effects/lpe-patternalongpath.cpp
+++ b/src/live_effects/lpe-patternalongpath.cpp
@@ -259,9 +259,16 @@ LPEPatternAlongPath::transform_multiply(Geom::Affine const& postmul, bool set)
// overriding the Effect class default method, disabling transform forwarding to the parameters.
// only take translations into account
+ // Check if proportional stroke-width scaling is on
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool transform_stroke = prefs ? prefs->getBool("/options/transform/stroke", true) : true;
+ if (transform_stroke && !scale_y_rel) {
+ prop_scale.param_set_value(prop_scale * ((postmul.expansionX() + postmul.expansionY()) / 2));
+ }
if (postmul.isTranslation()) {
pattern.param_transform_multiply(postmul, set);
}
+ sp_lpe_item_update_patheffect (sp_lpe_item, false, true);
}
void
diff --git a/src/live_effects/lpe-patternalongpath.h b/src/live_effects/lpe-patternalongpath.h
index 3b9a17ab0..3d7fc02bc 100644
--- a/src/live_effects/lpe-patternalongpath.h
+++ b/src/live_effects/lpe-patternalongpath.h
@@ -42,7 +42,7 @@ public:
virtual void transform_multiply(Geom::Affine const& postmul, bool set);
void addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec);
-
+
virtual void addKnotHolderEntities(KnotHolder * knotholder, SPDesktop * desktop, SPItem * item);
PathParam pattern;
diff --git a/src/live_effects/lpe-perspective-envelope.cpp b/src/live_effects/lpe-perspective-envelope.cpp
index 72c1b0e99..5b29df4a7 100644
--- a/src/live_effects/lpe-perspective-envelope.cpp
+++ b/src/live_effects/lpe-perspective-envelope.cpp
@@ -56,6 +56,7 @@ LPEPerspectiveEnvelope::LPEPerspectiveEnvelope(LivePathEffectObject *lpeobject)
registerParameter(&up_right_point);
registerParameter(&down_left_point);
registerParameter(&down_right_point);
+ apply_to_clippath_and_mask = true;
}
LPEPerspectiveEnvelope::~LPEPerspectiveEnvelope()
@@ -371,9 +372,6 @@ LPEPerspectiveEnvelope::doBeforeEffect (SPLPEItem const* lpeitem)
horizontal(up_left_point, down_left_point,horiz);
horizontal(up_right_point, down_right_point,horiz);
}
- SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem);
- item->apply_to_clippath(item);
- item->apply_to_mask(item);
setDefaults();
}
diff --git a/src/live_effects/lpe-perspective_path.cpp b/src/live_effects/lpe-perspective_path.cpp
index 901519b4f..c8cdd7912 100644
--- a/src/live_effects/lpe-perspective_path.cpp
+++ b/src/live_effects/lpe-perspective_path.cpp
@@ -64,6 +64,7 @@ LPEPerspectivePath::LPEPerspectivePath(LivePathEffectObject *lpeobject) :
concatenate_before_pwd2 = true; // don't split the path into its subpaths
_provides_knotholder_entities = true;
+ apply_to_clippath_and_mask = true;
}
LPEPerspectivePath::~LPEPerspectivePath()
@@ -100,8 +101,6 @@ LPEPerspectivePath::doBeforeEffect (SPLPEItem const* lpeitem)
Geom::Affine doc2d = Geom::Scale(1, -1) * Geom::Translate(0, item->document->getHeight().value("px"));
pmat = pmat * doc2d;
pmat.copy_tmat(tmat);
- item->apply_to_clippath(item);
- item->apply_to_mask(item);
}
void LPEPerspectivePath::refresh(Gtk::Entry* perspective) {
diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp
index b4ee54f1a..105fe2fc4 100644
--- a/src/live_effects/lpe-roughen.cpp
+++ b/src/live_effects/lpe-roughen.cpp
@@ -87,6 +87,7 @@ LPERoughen::LPERoughen(LivePathEffectObject *lpeobject)
segments.param_set_increments(1, 1);
segments.param_set_digits(0);
seed = 0;
+ apply_to_clippath_and_mask = true;
}
LPERoughen::~LPERoughen() {}
@@ -102,9 +103,6 @@ void LPERoughen::doBeforeEffect(SPLPEItem const *lpeitem)
displace_y.resetRandomizer();
global_randomize.resetRandomizer();
srand(1);
- SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem);
- item->apply_to_clippath(item);
- item->apply_to_mask(item);
}
Gtk::Widget *LPERoughen::newWidget()
diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp
index 4b62c6c65..f807bdc8d 100644
--- a/src/live_effects/lpe-simplify.cpp
+++ b/src/live_effects/lpe-simplify.cpp
@@ -60,6 +60,7 @@ LPESimplify::LPESimplify(LivePathEffectObject *lpeobject)
helper_size.param_set_digits(2);
radius_helper_nodes = 6.0;
+ apply_to_clippath_and_mask = true;
}
LPESimplify::~LPESimplify() {}
@@ -71,10 +72,7 @@ LPESimplify::doBeforeEffect (SPLPEItem const* lpeitem)
hp.clear();
}
bbox = SP_ITEM(lpeitem)->visualBounds();
- SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem);
radius_helper_nodes = helper_size;
- item->apply_to_clippath(item);
- item->apply_to_mask(item);
}
Gtk::Widget *
diff --git a/src/live_effects/lpe-transform_2pts.cpp b/src/live_effects/lpe-transform_2pts.cpp
index dd1a29689..1cd59b7fa 100644
--- a/src/live_effects/lpe-transform_2pts.cpp
+++ b/src/live_effects/lpe-transform_2pts.cpp
@@ -78,6 +78,7 @@ LPETransform2Pts::LPETransform2Pts(LivePathEffectObject *lpeobject) :
strech.param_set_range(0, 999.0);
strech.param_set_increments(0.01, 0.01);
strech.param_set_digits(4);
+ apply_to_clippath_and_mask = true;
}
LPETransform2Pts::~LPETransform2Pts()
@@ -167,8 +168,6 @@ LPETransform2Pts::doBeforeEffect (SPLPEItem const* lpeitem)
previous_angle = transformed.angle();
previous_lenght = Geom::distance((Geom::Point)start, (Geom::Point)end);
previous_start = start;
- splpeitem->apply_to_clippath(splpeitem);
- splpeitem->apply_to_mask(splpeitem);
}
void
diff --git a/src/live_effects/lpe-vonkoch.cpp b/src/live_effects/lpe-vonkoch.cpp
index 7b424e019..7eda7446e 100644
--- a/src/live_effects/lpe-vonkoch.cpp
+++ b/src/live_effects/lpe-vonkoch.cpp
@@ -64,7 +64,7 @@ LPEVonKoch::LPEVonKoch(LivePathEffectObject *lpeobject) :
registerParameter( dynamic_cast<Parameter *>(&drawall) );
registerParameter( dynamic_cast<Parameter *>(&maxComplexity) );
//registerParameter( dynamic_cast<Parameter *>(&draw_boxes) );
-
+ apply_to_clippath_and_mask = true;
nbgenerations.param_make_integer();
nbgenerations.param_set_range(0, Geom::infinity());
maxComplexity.param_make_integer();
@@ -262,9 +262,6 @@ LPEVonKoch::doBeforeEffect (SPLPEItem const* lpeitem)
tmp_pathv.push_back(tmp_path);
ref_path.set_new_value(tmp_pathv,true);
}
- SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem);
- item->apply_to_clippath(item);
- item->apply_to_mask(item);
}
diff --git a/src/live_effects/parameter/filletchamferpointarray.cpp b/src/live_effects/parameter/filletchamferpointarray.cpp
index 117d57460..b321a5831 100644
--- a/src/live_effects/parameter/filletchamferpointarray.cpp
+++ b/src/live_effects/parameter/filletchamferpointarray.cpp
@@ -491,7 +491,7 @@ std::vector<double> FilletChamferPointArrayParam::get_times(int index, Geom::Pat
curve_it1 = subpaths[positions.first][positions.second].duplicate();
Coord it1_length = (*curve_it1).length(tolerance);
double time_it1, time_it2, time_it1_B, intpart;
- if(_vector.size() <= index){
+ if (static_cast<int>(_vector.size()) <= index){
std::vector<double> out;
out.push_back(0);
out.push_back(1);
diff --git a/src/live_effects/parameter/originalpatharray.cpp b/src/live_effects/parameter/originalpatharray.cpp
index 7e3a6f5fe..4ee068ebf 100644
--- a/src/live_effects/parameter/originalpatharray.cpp
+++ b/src/live_effects/parameter/originalpatharray.cpp
@@ -144,7 +144,7 @@ Gtk::Widget* OriginalPathArrayParam::param_newWidget()
{ // Paste path to link button
- Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( GTK_STOCK_PASTE, Inkscape::ICON_SIZE_BUTTON) );
+ Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon("gtk-stock", Inkscape::ICON_SIZE_BUTTON) );
Gtk::Button *pButton = Gtk::manage(new Gtk::Button());
pButton->set_relief(Gtk::RELIEF_NONE);
pIcon->show();
@@ -156,7 +156,7 @@ Gtk::Widget* OriginalPathArrayParam::param_newWidget()
}
{ // Remove linked path
- Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( GTK_STOCK_REMOVE, Inkscape::ICON_SIZE_BUTTON) );
+ Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon("gtk-remove", Inkscape::ICON_SIZE_BUTTON) );
Gtk::Button *pButton = Gtk::manage(new Gtk::Button());
pButton->set_relief(Gtk::RELIEF_NONE);
pIcon->show();
@@ -168,7 +168,7 @@ Gtk::Widget* OriginalPathArrayParam::param_newWidget()
}
{ // Move Down
- Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( GTK_STOCK_GO_DOWN, Inkscape::ICON_SIZE_BUTTON) );
+ Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( "gtk-go-down", Inkscape::ICON_SIZE_BUTTON) );
Gtk::Button *pButton = Gtk::manage(new Gtk::Button());
pButton->set_relief(Gtk::RELIEF_NONE);
pIcon->show();
@@ -180,7 +180,7 @@ Gtk::Widget* OriginalPathArrayParam::param_newWidget()
}
{ // Move Down
- Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( GTK_STOCK_GO_UP, Inkscape::ICON_SIZE_BUTTON) );
+ Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( "gtk-go-up", Inkscape::ICON_SIZE_BUTTON) );
Gtk::Button *pButton = Gtk::manage(new Gtk::Button());
pButton->set_relief(Gtk::RELIEF_NONE);
pIcon->show();
diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp
index e0369e662..7ea1d465c 100644
--- a/src/live_effects/parameter/path.cpp
+++ b/src/live_effects/parameter/path.cpp
@@ -294,7 +294,12 @@ void
PathParam::set_new_value (Geom::PathVector const &newpath, bool write_to_svg)
{
remove_link();
- _pathvector = newpath;
+ if (newpath.empty()) {
+ param_set_and_write_default();
+ return;
+ } else {
+ _pathvector = newpath;
+ }
must_recalculate_pwd2 = true;
if (write_to_svg) {
diff --git a/src/main-cmdlineact.cpp b/src/main-cmdlineact.cpp
index ade83dfda..496c16d5d 100644
--- a/src/main-cmdlineact.cpp
+++ b/src/main-cmdlineact.cpp
@@ -4,7 +4,7 @@
*
* Copyright (C) 2007 Authors
*
- * Released under GNU GPL v2, read the file 'COPYING' for more information
+ * Released under GNU GPL v2+, read the file 'COPYING' for more information
*/
#include <ui/view/view.h>
diff --git a/src/main-cmdlineact.h b/src/main-cmdlineact.h
index c8ef64f10..b8ec4403b 100644
--- a/src/main-cmdlineact.h
+++ b/src/main-cmdlineact.h
@@ -12,7 +12,7 @@
*
* Copyright (C) 2007 Authors
*
- * Released under GNU GPL v2.x, read the file 'COPYING' for more information
+ * Released under GNU GPL v2+, read the file 'COPYING' for more information
*/
namespace Inkscape {
diff --git a/src/main.cpp b/src/main.cpp
index 840643a90..8cf52127b 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -52,6 +52,11 @@
#include <glib-object.h>
#include <gtk/gtk.h>
+#if GTK_CHECK_VERSION(3,0,0)
+#include <gtkmm/cssprovider.h>
+#include <gdkmm/screen.h>
+#endif
+
#include "inkgc/gc-core.h"
#ifdef AND
@@ -488,7 +493,7 @@ struct poptOption options[] = {
POPT_ARG_NONE, &sp_vacuum_defs, SP_ARG_VACUUM_DEFS,
N_("Remove unused definitions from the defs section(s) of the document"),
NULL},
-
+
#ifdef WITH_DBUS
{"dbus-listen", 0,
POPT_ARG_NONE, &sp_dbus_listen, SP_ARG_DBUS_LISTEN,
@@ -546,7 +551,7 @@ static void _win32_set_inkscape_env(gchar const *exe)
gchar *perl = g_build_filename(exe, "python", NULL);
gchar *pythonlib = g_build_filename(exe, "python", "Lib", NULL);
gchar *pythondll = g_build_filename(exe, "python", "DLLs", NULL);
-
+
// Python 2.x needs short paths in PYTHONPATH.
// Otherwise it doesn't work when Inkscape is installed in Unicode directories.
// g_win32_locale_filename_from_utf8 is the GLib wrapper for GetShortPathName.
@@ -597,14 +602,14 @@ static void _win32_set_inkscape_env(gchar const *exe)
g_free(perl);
g_free(pythonlib);
g_free(pythondll);
-
+
g_free(python_s);
g_free(pythonlib_s);
g_free(pythondll_s);
g_free(new_path);
g_free(new_pythonpath);
-
+
g_free(localepath);
}
#endif
@@ -614,7 +619,7 @@ static void set_extensions_env()
gchar const *pythonpath = g_getenv("PYTHONPATH");
gchar *extdir;
gchar *new_pythonpath;
-
+
#ifdef WIN32
extdir = g_win32_locale_filename_from_utf8(INKSCAPE_EXTENSIONDIR);
#else
@@ -900,7 +905,7 @@ static int sp_common_main( int argc, char const **argv, GSList **flDest )
if ( sp_global_printer )
sp_global_printer_utf8 = g_strdup( sp_global_printer );
}
-
+
#ifdef WITH_DBUS
// Before initializing extensions, we must set the DBus bus name if required
if (sp_dbus_name != NULL) {
@@ -1051,6 +1056,66 @@ sp_main_gui(int argc, char const **argv)
#endif
g_free(usericondir);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ // Add style sheet (GTK3)
+ Glib::RefPtr<Gdk::Screen> screen = Gdk::Screen::get_default();
+
+ Glib::ustring inkscape_style = INKSCAPE_UIDIR;
+ inkscape_style += "/style.css";
+ // std::cout << "CSS Stylesheet Inkscape: " << inkscape_style << std::endl;
+
+ if (g_file_test (inkscape_style.c_str(), G_FILE_TEST_EXISTS)) {
+ Glib::RefPtr<Gtk::CssProvider> provider = Gtk::CssProvider::create();
+
+ // From 3.16, throws an error which we must catch.
+ try {
+ provider->load_from_path (inkscape_style);
+ }
+#if GTK_CHECK_VERSION(3,16,0)
+ // Gtk::CssProviderError not defined until 3.16.
+ catch (const Gtk::CssProviderError& ex)
+ {
+ std::cerr << "CSSProviderError::load_from_path(): failed to load: " << inkscape_style
+ << "\n (" << ex.what() << ")" << std::endl;
+ }
+#else
+ catch (...)
+ {}
+#endif
+
+ Gtk::StyleContext::add_provider_for_screen (screen, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ } else {
+ std::cerr << "sp_main_gui: Cannot find default style file:\n (" << inkscape_style
+ << ")" << std::endl;
+ }
+
+ Glib::ustring user_style = Inkscape::Application::profile_path("ui/style.css");
+ // std::cout << "CSS Stylesheet User: " << user_style << std::endl;
+
+ if (g_file_test (user_style.c_str(), G_FILE_TEST_EXISTS)) {
+ Glib::RefPtr<Gtk::CssProvider> provider2 = Gtk::CssProvider::create();
+
+ // From 3.16, throws an error which we must catch.
+ try {
+ provider2->load_from_path (user_style);
+ }
+#if GTK_CHECK_VERSION(3,16,0)
+ // Gtk::CssProviderError not defined until 3.16.
+ catch (const Gtk::CssProviderError& ex)
+ {
+ std::cerr << "CSSProviderError::load_from_path(): failed to load: " << user_style
+ << "\n (" << ex.what() << ")" << std::endl;
+ }
+#else
+ catch (...)
+ {}
+#endif
+
+ Gtk::StyleContext::add_provider_for_screen (screen, provider2, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ }
+#endif
+
gdk_event_handler_set((GdkEventFunc)snooper, NULL, NULL);
Inkscape::Debug::log_display_config();
@@ -1134,7 +1199,7 @@ static int sp_process_file_list(GSList *fl)
if (sp_vacuum_defs) {
doc->vacuumDocument();
}
-
+
// Execute command-line actions (selections and verbs) using our local models
bool has_performed_actions = Inkscape::CmdLineAction::doList(INKSCAPE.active_action_context());
@@ -1645,9 +1710,9 @@ static int sp_do_export_png(SPDocument *doc)
g_print("Background RRGGBBAA: %08x\n", bgcolor);
g_print("Area %g:%g:%g:%g exported to %lu x %lu pixels (%g dpi)\n", area[Geom::X][0], area[Geom::Y][0], area[Geom::X][1], area[Geom::Y][1], width, height, dpi);
-
+
reverse(items.begin(),items.end());
-
+
if ((width >= 1) && (height >= 1) && (width <= PNG_UINT_31_MAX) && (height <= PNG_UINT_31_MAX)) {
if( sp_export_png_file(doc, path.c_str(), area, width, height, dpi,
dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : std::vector<SPItem*>()) == 1 ) {
@@ -1817,7 +1882,7 @@ static int do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime)
}
/**
- * Export a document to EMF or WMF
+ * Export a document to EMF or WMF
*
* \param doc Document to export.
* \param uri URI to export to.
diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h
index 8cdfbeb05..9c7c65140 100644
--- a/src/menus-skeleton.h
+++ b/src/menus-skeleton.h
@@ -86,6 +86,8 @@ static char const menus_skeleton[] =
" <verb verb-id=\"EditInvert\" />\n"
" <verb verb-id=\"EditDeselect\" />\n"
" <separator/>\n"
+" <verb verb-id=\"FitCanvasToSelectionOrDrawing\" />\n"
+" <separator/>\n"
" <verb verb-id=\"EditGuidesAroundPage\" />\n"
" <verb verb-id=\"EditGuidesToggleLock\" check=\"yes\" />\n"
" <verb verb-id=\"EditRemoveAllGuides\" />\n"
@@ -188,6 +190,7 @@ static char const menus_skeleton[] =
" <separator/>\n"
" <verb verb-id=\"SelectionGroup\" />\n"
" <verb verb-id=\"SelectionUnGroup\" />\n"
+" <verb verb-id=\"SelectionUnGroupPopSelection\" />\n"
" <separator/>\n"
" <submenu name=\"" N_("Cli_p") "\">\n"
" <verb verb-id=\"ObjectSetClipPath\" />\n"
diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp
index 7b52ac2e1..1a345b565 100644
--- a/src/path-chemistry.cpp
+++ b/src/path-chemistry.cpp
@@ -1,4 +1,4 @@
-/*
+ /*
* Here are handlers for modifying selections, specific to paths
*
* Authors:
@@ -52,7 +52,7 @@ inline bool less_than_items(SPItem const *first, SPItem const *second)
}
void
-sp_selected_path_combine(SPDesktop *desktop)
+sp_selected_path_combine(SPDesktop *desktop, bool skip_undo)
{
Inkscape::Selection *selection = desktop->getSelection();
SPDocument *doc = desktop->getDocument();
@@ -172,10 +172,10 @@ sp_selected_path_combine(SPDesktop *desktop)
// move to the position of the topmost, reduced by the number of deleted items
repr->setPosition(position > 0 ? position : 0);
-
- DocumentUndo::done(desktop->getDocument(), SP_VERB_SELECTION_COMBINE,
- _("Combine"));
-
+ if ( !skip_undo ) {
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_SELECTION_COMBINE,
+ _("Combine"));
+ }
selection->set(repr);
Inkscape::GC::release(repr);
@@ -188,7 +188,7 @@ sp_selected_path_combine(SPDesktop *desktop)
}
void
-sp_selected_path_break_apart(SPDesktop *desktop)
+sp_selected_path_break_apart(SPDesktop *desktop, bool skip_undo)
{
Inkscape::Selection *selection = desktop->getSelection();
@@ -217,7 +217,6 @@ sp_selected_path_break_apart(SPDesktop *desktop)
if (curve == NULL) {
continue;
}
-
did = true;
Inkscape::XML::Node *parent = item->getRepr()->parent();
@@ -228,16 +227,10 @@ sp_selected_path_break_apart(SPDesktop *desktop)
gchar *style = g_strdup(item->getRepr()->attribute("style"));
// XML Tree being used directly here while it shouldn't be...
gchar *path_effect = g_strdup(item->getRepr()->attribute("inkscape:path-effect"));
-
- Geom::PathVector apv = curve->get_pathvector() * path->transform;
-
- curve->unref();
-
+ Geom::Affine transform = path->transform;
// it's going to resurrect as one of the pieces, so we delete without advertisement
item->deleteObject(false);
- curve = new SPCurve(apv);
- g_assert(curve != NULL);
GSList *list = curve->split();
@@ -258,7 +251,8 @@ sp_selected_path_break_apart(SPDesktop *desktop)
else
repr->setAttribute("d", str);
g_free(str);
-
+ repr->setAttribute("transform", sp_svg_transform_write(transform));
+
// add the new repr to the parent
parent->appendChild(repr);
@@ -283,8 +277,10 @@ sp_selected_path_break_apart(SPDesktop *desktop)
desktop->clearWaitingCursor();
if (did) {
- DocumentUndo::done(desktop->getDocument(), SP_VERB_SELECTION_BREAK_APART,
- _("Break apart"));
+ if ( !skip_undo ) {
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_SELECTION_BREAK_APART,
+ _("Break apart"));
+ }
} else {
desktop->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No path(s)</b> to break apart in the selection."));
}
diff --git a/src/path-chemistry.h b/src/path-chemistry.h
index 35ab923c0..7b9beaed8 100644
--- a/src/path-chemistry.h
+++ b/src/path-chemistry.h
@@ -25,8 +25,8 @@ class Node;
typedef unsigned int guint32;
-void sp_selected_path_combine (SPDesktop *desktop);
-void sp_selected_path_break_apart (SPDesktop *desktop);
+void sp_selected_path_combine (SPDesktop *desktop, bool skip_undo = false);
+void sp_selected_path_break_apart (SPDesktop *desktop, bool skip_undo = false);
// interactive=true only has an effect if desktop != NULL, i.e. if a GUI is available
void sp_selected_path_to_curves (Inkscape::Selection *selection, SPDesktop *desktop, bool interactive = true);
void sp_selected_to_lpeitems(SPDesktop *desktop);
diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h
index b428cbe7a..9f2e68b1d 100644
--- a/src/preferences-skeleton.h
+++ b/src/preferences-skeleton.h
@@ -216,7 +216,6 @@ static char const preferences_skeleton[] =
" <group id=\"input\" />\n"
" <group id=\"colorpickerwindow\" />\n"
" <group id=\"undo-history\" />\n"
-" <group id=\"filtereffects\" />\n"
" <group id=\"transparency\"\n"
" on-focus=\"1.0\"\n"
" on-blur=\"0.50\"\n"
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index e6d5f174e..7d32477a1 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -791,6 +791,38 @@ static gint clone_depth_descending(gconstpointer a, gconstpointer b) {
return -1;
}
}
+
+void sp_selection_ungroup_pop_selection(Inkscape::Selection *selection, SPDesktop *desktop)
+{
+ if (selection->isEmpty()) {
+ selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("<b>No objects selected</b> to pop out of group."));
+ return;
+ }
+ std::vector<SPItem*> selection_list = selection->itemList();
+
+ std::vector<SPItem*>::const_iterator item = selection_list.begin(); // leaving this because it will be useful for
+ // future implementation of complex pop ungrouping
+ SPItem *obj = *item;
+ SPItem *parent_group = static_cast<SPItem*>(obj->parent);
+ if (!SP_IS_GROUP(parent_group) || SP_IS_LAYER(parent_group)) {
+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Selection <b>not in a group</b>."));
+ return;
+ }
+ if (parent_group->firstChild()->getNext() == NULL) {
+ std::vector<SPItem*> children;
+ sp_item_group_ungroup(static_cast<SPGroup*>(parent_group), children, false);
+ }
+ else {
+ sp_selection_to_next_layer(desktop, 1); // suppress done
+ }
+
+ parent_group->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+
+ DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_UNGROUP_POP_SELECTION,
+ _("Pop selection from group"));
+
+}
+
void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop)
{
@@ -1126,7 +1158,7 @@ void
sp_undo(SPDesktop *desktop, SPDocument *)
{
// No re/undo while dragging, too dangerous.
- if(desktop->getCanvas()->is_dragging) return;
+ if(desktop->getCanvas()->_is_dragging) return;
if (!DocumentUndo::undo(desktop->getDocument())) {
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing to undo."));
@@ -1137,7 +1169,7 @@ void
sp_redo(SPDesktop *desktop, SPDocument *)
{
// No re/undo while dragging, too dangerous.
- if(desktop->getCanvas()->is_dragging) return;
+ if(desktop->getCanvas()->_is_dragging) return;
if (!DocumentUndo::redo(desktop->getDocument())) {
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing to redo."));
diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h
index 4bfa2c0aa..82b91c617 100644
--- a/src/selection-chemistry.h
+++ b/src/selection-chemistry.h
@@ -76,6 +76,7 @@ void sp_selection_untile(SPDesktop *desktop);
void sp_selection_group(Inkscape::Selection *selection, SPDesktop *desktop);
void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop);
+void sp_selection_ungroup_pop_selection(Inkscape::Selection *selection, SPDesktop *desktop);
void sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop);
void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *desktop);
diff --git a/src/sp-flowtext.h b/src/sp-flowtext.h
index 9e6046469..9ee676893 100644
--- a/src/sp-flowtext.h
+++ b/src/sp-flowtext.h
@@ -49,6 +49,11 @@ public:
bool _optimizeScaledText;
+ /** Converts the text object to its component curves */
+ SPCurve *getNormalizedBpath() const {
+ return layout.convertToCurves();
+ }
+
/** Optimize scaled flow text on next set_transform. */
void optimizeScaledText()
{_optimizeScaledText = true;}
diff --git a/src/sp-item.cpp b/src/sp-item.cpp
index 4937e6c76..af81194c2 100644
--- a/src/sp-item.cpp
+++ b/src/sp-item.cpp
@@ -568,6 +568,7 @@ void SPItem::clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item)
clip->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
}
+ item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
void SPItem::mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item)
diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp
index 98b77cfe8..fdc2949d5 100644
--- a/src/sp-lpe-item.cpp
+++ b/src/sp-lpe-item.cpp
@@ -209,7 +209,7 @@ Inkscape::XML::Node* SPLPEItem::write(Inkscape::XML::Document *xml_doc, Inkscape
/**
* returns true when LPE was successful.
*/
-bool SPLPEItem::performPathEffect(SPCurve *curve) {
+bool SPLPEItem::performPathEffect(SPCurve *curve, bool is_clip_or_mask) {
if (!this) {
return false;
}
@@ -217,7 +217,6 @@ bool SPLPEItem::performPathEffect(SPCurve *curve) {
if (!curve) {
return false;
}
-
if (this->hasPathEffect() && this->pathEffectsEnabled()) {
for (PathEffectList::iterator it = this->path_effect_list->begin(); it != this->path_effect_list->end(); ++it)
{
@@ -237,37 +236,40 @@ bool SPLPEItem::performPathEffect(SPCurve *curve) {
g_warning("SPLPEItem::performPathEffect - lpeobj with invalid lpe in the stack!");
return false;
}
-
if (lpe->isVisible()) {
if (lpe->acceptsNumClicks() > 0 && !lpe->isReady()) {
// if the effect expects mouse input before being applied and the input is not finished
// yet, we don't alter the path
return false;
}
+ if (!is_clip_or_mask || (is_clip_or_mask && lpe->apply_to_clippath_and_mask)) {
+ // Groups have their doBeforeEffect called elsewhere
+ if (!SP_IS_GROUP(this)) {
+ lpe->doBeforeEffect_impl(this);
+ }
- // Groups have their doBeforeEffect called elsewhere
- if (!SP_IS_GROUP(this)) {
- lpe->doBeforeEffect_impl(this);
- }
-
- try {
- lpe->doEffect(curve);
- }
- catch (std::exception & e) {
- g_warning("Exception during LPE %s execution. \n %s", lpe->getName().c_str(), e.what());
- if (SP_ACTIVE_DESKTOP && SP_ACTIVE_DESKTOP->messageStack()) {
- SP_ACTIVE_DESKTOP->messageStack()->flash( Inkscape::WARNING_MESSAGE,
- _("An exception occurred during execution of the Path Effect.") );
+ try {
+ lpe->doEffect(curve);
+ }
+ catch (std::exception & e) {
+ g_warning("Exception during LPE %s execution. \n %s", lpe->getName().c_str(), e.what());
+ if (SP_ACTIVE_DESKTOP && SP_ACTIVE_DESKTOP->messageStack()) {
+ SP_ACTIVE_DESKTOP->messageStack()->flash( Inkscape::WARNING_MESSAGE,
+ _("An exception occurred during execution of the Path Effect.") );
+ }
+ return false;
+ }
+ if (!SP_IS_GROUP(this)) {
+ lpe->doAfterEffect(this);
}
- return false;
- }
- if (!SP_IS_GROUP(this)) {
- lpe->doAfterEffect(this);
}
}
}
+ if(!SP_IS_GROUP(this) && !is_clip_or_mask){
+ this->apply_to_clippath(this);
+ this->apply_to_mask(this);
+ }
}
-
return true;
}
@@ -641,43 +643,7 @@ SPLPEItem::apply_to_clippath(SPItem *item)
SPClipPath *clipPath = item->clip_ref->getObject();
if(clipPath) {
SPObject * clip_data = clipPath->firstChild();
- SPCurve * clip_curve = NULL;
-
- if (SP_IS_PATH(clip_data)) {
- clip_curve = SP_PATH(clip_data)->get_original_curve();
- } else if(SP_IS_SHAPE(clip_data)) {
- clip_curve = SP_SHAPE(clip_data)->getCurve();
- } else if(SP_IS_GROUP(clip_data)) {
- apply_to_clip_or_mask_group(SP_ITEM(clip_data), item);
- return;
- }
- if(clip_curve) {
- bool success = false;
- if(SP_IS_GROUP(this)){
- clip_curve->transform(i2anc_affine(SP_GROUP(item), SP_GROUP(this)));
- success = this->performPathEffect(clip_curve);
- clip_curve->transform(i2anc_affine(SP_GROUP(item), SP_GROUP(this)).inverse());
- } else {
- success = this->performPathEffect(clip_curve);
- }
- Inkscape::XML::Node *reprClip = clip_data->getRepr();
- if (success) {
- gchar *str = sp_svg_write_path(clip_curve->get_pathvector());
- reprClip->setAttribute("d", str);
- g_free(str);
- } else {
- // LPE was unsuccesfull. Read the old 'd'-attribute.
- if (gchar const * value = reprClip->attribute("d")) {
- Geom::PathVector pv = sp_svg_read_pathv(value);
- SPCurve *oldcurve = new SPCurve(pv);
- if (oldcurve) {
- SP_SHAPE(clip_data)->setCurve(oldcurve, TRUE);
- oldcurve->unref();
- }
- }
- }
- clip_curve->unref();
- }
+ apply_to_clip_or_mask(SP_ITEM(clip_data), item);
}
if(SP_IS_GROUP(item)){
std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(item));
@@ -694,42 +660,7 @@ SPLPEItem::apply_to_mask(SPItem *item)
SPMask *mask = item->mask_ref->getObject();
if(mask) {
SPObject *mask_data = mask->firstChild();
- SPCurve * mask_curve = NULL;
- if (SP_IS_PATH(mask_data)) {
- mask_curve = SP_PATH(mask_data)->get_original_curve();
- } else if(SP_IS_SHAPE(mask_data)) {
- mask_curve = SP_SHAPE(mask_data)->getCurve();
- } else if(SP_IS_GROUP(mask_data)) {
- apply_to_clip_or_mask_group(SP_ITEM(mask_data), item);
- return;
- }
- if(mask_curve) {
- bool success = false;
- if(SP_IS_GROUP(this)){
- mask_curve->transform(i2anc_affine(SP_GROUP(item), SP_GROUP(this)));
- success = this->performPathEffect(mask_curve);
- mask_curve->transform(i2anc_affine(SP_GROUP(item), SP_GROUP(this)).inverse());
- } else {
- success = this->performPathEffect(mask_curve);
- }
- Inkscape::XML::Node *reprmask = mask_data->getRepr();
- if (success) {
- gchar *str = sp_svg_write_path(mask_curve->get_pathvector());
- reprmask->setAttribute("d", str);
- g_free(str);
- } else {
- // LPE was unsuccesfull. Read the old 'd'-attribute.
- if (gchar const * value = reprmask->attribute("d")) {
- Geom::PathVector pv = sp_svg_read_pathv(value);
- SPCurve *oldcurve = new SPCurve(pv);
- if (oldcurve) {
- SP_SHAPE(mask_data)->setCurve(oldcurve, TRUE);
- oldcurve->unref();
- }
- }
- }
- mask_curve->unref();
- }
+ apply_to_clip_or_mask(SP_ITEM(mask_data), item);
}
if(SP_IS_GROUP(item)){
std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(item));
@@ -741,51 +672,57 @@ SPLPEItem::apply_to_mask(SPItem *item)
}
void
-SPLPEItem::apply_to_clip_or_mask_group(SPItem *group, SPItem *item)
+SPLPEItem::apply_to_clip_or_mask(SPItem *clip_mask, SPItem *item)
{
- if (!SP_IS_GROUP(group)) {
- return;
- }
- std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(group));
- for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) {
- SPObject *subitem = *iter;
- if (SP_IS_GROUP(subitem)) {
- apply_to_clip_or_mask_group(SP_ITEM(subitem), item);
- } else if (SP_IS_SHAPE(subitem)) {
- SPCurve * c = NULL;
-
- if (SP_IS_PATH(subitem)) {
- c = SP_PATH(subitem)->get_original_curve();
- } else {
- c = SP_SHAPE(subitem)->getCurve();
- }
- if (c) {
- bool success = false;
- if(SP_IS_GROUP(group)){
+ if (SP_IS_GROUP(clip_mask)) {
+ std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(clip_mask));
+ for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) {
+ SPItem *subitem = *iter;
+ apply_to_clip_or_mask(subitem, item);
+ }
+ } else if (SP_IS_SHAPE(clip_mask)) {
+ SPCurve * c = NULL;
+
+ if (SP_IS_PATH(clip_mask)) {
+ c = SP_PATH(clip_mask)->get_original_curve();
+ } else {
+ c = SP_SHAPE(clip_mask)->getCurve();
+ }
+ if (c) {
+ bool success = false;
+ try {
+ if(SP_IS_GROUP(this)){
c->transform(i2anc_affine(SP_GROUP(item), SP_GROUP(this)));
- success = this->performPathEffect(c);
+ success = this->performPathEffect(c, true);
c->transform(i2anc_affine(SP_GROUP(item), SP_GROUP(this)).inverse());
} else {
- success = this->performPathEffect(c);
+ success = this->performPathEffect(c, true);
}
- Inkscape::XML::Node *repr = subitem->getRepr();
- if (success) {
- gchar *str = sp_svg_write_path(c->get_pathvector());
- repr->setAttribute("d", str);
- g_free(str);
- } else {
- // LPE was unsuccesfull. Read the old 'd'-attribute.
- if (gchar const * value = repr->attribute("d")) {
- Geom::PathVector pv = sp_svg_read_pathv(value);
- SPCurve *oldcurve = new SPCurve(pv);
- if (oldcurve) {
- SP_SHAPE(subitem)->setCurve(oldcurve, TRUE);
- oldcurve->unref();
- }
+ } catch (std::exception & e) {
+ g_warning("Exception during LPE execution. \n %s", e.what());
+ if (SP_ACTIVE_DESKTOP && SP_ACTIVE_DESKTOP->messageStack()) {
+ SP_ACTIVE_DESKTOP->messageStack()->flash( Inkscape::WARNING_MESSAGE,
+ _("An exception occurred during execution of the Path Effect.") );
+ }
+ success = false;
+ }
+ Inkscape::XML::Node *repr = clip_mask->getRepr();
+ if (success) {
+ gchar *str = sp_svg_write_path(c->get_pathvector());
+ repr->setAttribute("d", str);
+ g_free(str);
+ } else {
+ // LPE was unsuccesfull. Read the old 'd'-attribute.
+ if (gchar const * value = repr->attribute("d")) {
+ Geom::PathVector pv = sp_svg_read_pathv(value);
+ SPCurve *oldcurve = new SPCurve(pv);
+ if (oldcurve) {
+ SP_SHAPE(clip_mask)->setCurve(oldcurve, TRUE);
+ oldcurve->unref();
}
}
- c->unref();
}
+ c->unref();
}
}
}
diff --git a/src/sp-lpe-item.h b/src/sp-lpe-item.h
index c35ad8411..9e5cb3329 100644
--- a/src/sp-lpe-item.h
+++ b/src/sp-lpe-item.h
@@ -69,7 +69,7 @@ public:
virtual void update_patheffect(bool write);
- bool performPathEffect(SPCurve *curve);
+ bool performPathEffect(SPCurve *curve, bool is_clip_or_mask = false);
bool pathEffectsEnabled() const;
bool hasPathEffect() const;
@@ -93,7 +93,7 @@ public:
void addPathEffect(LivePathEffectObject * new_lpeobj);
void apply_to_mask(SPItem * item);
void apply_to_clippath(SPItem * item);
- void apply_to_clip_or_mask_group(SPItem * group, SPItem * item);
+ void apply_to_clip_or_mask(SPItem * clip_mask, SPItem * item);
bool forkPathEffectsIfNecessary(unsigned int nr_of_allowed_users = 1);
void editNextParamOncanvas(SPDesktop *dt);
diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp
index 7c3d0bd03..d84bdbdd3 100644
--- a/src/sp-offset.cpp
+++ b/src/sp-offset.cpp
@@ -83,7 +83,9 @@ static void sp_offset_source_modified (SPObject *iSource, guint flags, SPItem *i
// fast is not mathematically correct, because computing the offset of a single
// cubic bezier patch is not trivial; in particular, there are problems with holes
// reappearing in offset when the radius becomes too large
-static bool use_slow_but_correct_offset_method=true;
+//TODO: need fix for bug: #384688 with fix released in r.14156
+//but reverted because bug #1507049 seems has more priority.
+static bool use_slow_but_correct_offset_method = false;
SPOffset::SPOffset() : SPShape() {
this->rad = 1.0;
diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp
index dd351a8d5..55110f3c5 100644
--- a/src/sp-pattern.cpp
+++ b/src/sp-pattern.cpp
@@ -390,10 +390,11 @@ const gchar *SPPattern::produce(const std::vector<Inkscape::XML::Node *> &reprs,
repr->setAttribute("patternUnits", "userSpaceOnUse");
sp_repr_set_svg_double(repr, "width", bounds.dimensions()[Geom::X]);
sp_repr_set_svg_double(repr, "height", bounds.dimensions()[Geom::Y]);
-
- Glib::ustring t = sp_svg_transform_write(transform);
- repr->setAttribute("patternTransform", t);
-
+ //TODO: Maybe is better handle it in sp_svg_transform_write
+ if(transform != Geom::Affine()){
+ Glib::ustring t = sp_svg_transform_write(transform);
+ repr->setAttribute("patternTransform", t);
+ }
defsrepr->appendChild(repr);
const gchar *pat_id = repr->attribute("id");
SPObject *pat_object = document->getObjectById(pat_id);
diff --git a/src/sp-text.cpp b/src/sp-text.cpp
index afbe0b147..6ae1c4fba 100644
--- a/src/sp-text.cpp
+++ b/src/sp-text.cpp
@@ -645,6 +645,13 @@ void SPText::_adjustFontsizeRecursive(SPItem *item, double ex, bool is_root)
style->font_size.computed *= ex;
style->letter_spacing.computed *= ex;
style->word_spacing.computed *= ex;
+ if (style->line_height.unit != SP_CSS_UNIT_NONE &&
+ style->line_height.unit != SP_CSS_UNIT_PERCENT &&
+ style->line_height.unit != SP_CSS_UNIT_EM &&
+ style->line_height.unit != SP_CSS_UNIT_EX) {
+ // No unit on 'line-height' property has special behavior.
+ style->line_height.computed *= ex;
+ }
item->updateRepr();
}
@@ -828,8 +835,8 @@ void TextTagAttributes::setFirstXY(Geom::Point &point)
attributes.x.resize(1, zero_length);
if (attributes.y.empty())
attributes.y.resize(1, zero_length);
- attributes.x[0].computed = point[Geom::X];
- attributes.y[0].computed = point[Geom::Y];
+ attributes.x[0] = point[Geom::X];
+ attributes.y[0] = point[Geom::Y];
}
void TextTagAttributes::mergeInto(Inkscape::Text::Layout::OptionalTextTagAttrs *output, Inkscape::Text::Layout::OptionalTextTagAttrs const &parent_attrs, unsigned parent_attrs_offset, bool copy_xy, bool copy_dxdyrotate) const
diff --git a/src/splivarot.cpp b/src/splivarot.cpp
index 9b2890bb8..1bc6da3e1 100644
--- a/src/splivarot.cpp
+++ b/src/splivarot.cpp
@@ -105,6 +105,13 @@ sp_selected_path_cut(Inkscape::Selection *selection, SPDesktop *desktop)
{
sp_selected_path_boolop(selection, desktop, bool_op_cut, SP_VERB_SELECTION_CUT, _("Division"));
}
+
+void
+sp_selected_path_cut_skip_undo(Inkscape::Selection *selection, SPDesktop *desktop)
+{
+ sp_selected_path_boolop(selection, desktop, bool_op_cut, SP_VERB_NONE, _("Division"));
+}
+
void
sp_selected_path_slice(Inkscape::Selection *selection, SPDesktop *desktop)
{
@@ -855,7 +862,7 @@ void sp_selected_path_outline_add_marker( SPObject *marker_object, Geom::Affine
if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
tr = stroke_scale * tr;
}
-
+
// total marker transform
tr = marker_item->transform * marker->c2p * tr * transform;
@@ -1146,7 +1153,9 @@ sp_selected_path_outline(SPDesktop *desktop)
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>stroked path(s)</b> to convert stroke to path."));
return;
}
-
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool scale_stroke = prefs->getBool("/options/transform/stroke", true);
+ prefs->setBool("/options/transform/stroke", true);
bool did = false;
std::vector<SPItem*> il(selection->itemList());
for (std::vector<SPItem*>::const_iterator l = il.begin(); l != il.end(); l++){
@@ -1496,7 +1505,7 @@ sp_selected_path_outline(SPDesktop *desktop)
delete res;
delete orig;
}
-
+ prefs->setBool("/options/transform/stroke", scale_stroke);
if (did) {
DocumentUndo::done(desktop->getDocument(), SP_VERB_SELECTION_OUTLINE,
_("Convert stroke to path"));
@@ -1767,11 +1776,14 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset)
SPItem *item = *l;
SPCurve *curve = NULL;
- if (!SP_IS_SHAPE(item) && !SP_IS_TEXT(item))
+ if (!SP_IS_SHAPE(item) && !SP_IS_TEXT(item) && !SP_IS_FLOWTEXT(item))
continue;
else if (SP_IS_SHAPE(item)) {
curve = SP_SHAPE(item)->getCurve();
}
+ else if (SP_IS_FLOWTEXT(item)) {
+ curve = SP_FLOWTEXT(item)->getNormalizedBpath();
+ }
else { // Item must be SP_TEXT
curve = SP_TEXT(item)->getNormalizedBpath();
}
diff --git a/src/splivarot.h b/src/splivarot.h
index ba314399f..421c9c4b8 100644
--- a/src/splivarot.h
+++ b/src/splivarot.h
@@ -33,6 +33,7 @@ void sp_selected_path_diff (Inkscape::Selection *selection, SPDesktop *desktop);
void sp_selected_path_diff_skip_undo (Inkscape::Selection *selection, SPDesktop *desktop);
void sp_selected_path_symdiff (Inkscape::Selection *selection, SPDesktop *desktop);
void sp_selected_path_cut (Inkscape::Selection *selection, SPDesktop *desktop);
+void sp_selected_path_cut_skip_undo (Inkscape::Selection *selection, SPDesktop *desktop);
void sp_selected_path_slice (Inkscape::Selection *selection, SPDesktop *desktop);
// offset/inset of a curve
diff --git a/src/style.cpp b/src/style.cpp
index 35138d25b..c24818f2a 100644
--- a/src/style.cpp
+++ b/src/style.cpp
@@ -1510,7 +1510,8 @@ gchar const *
sp_style_get_css_unit_string(int unit)
{
// specify px by default, see inkscape bug 1221626, mozilla bug 234789
-
+ // This is a problematic fix as some properties (e.g. 'line-height') have
+ // different behaviour if there is no unit.
switch (unit) {
case SP_CSS_UNIT_NONE: return "px";
@@ -1899,8 +1900,9 @@ sp_css_attr_scale_property_single(SPCSSAttr *css, gchar const *property,
if (w == units) {// nothing converted, non-numeric value
return;
}
- if (only_with_units && (units == NULL || *units == '\0' || *units == '%')) {
+ if (only_with_units && (units == NULL || *units == '\0' || *units == '%' || *units == 'e')) {
// only_with_units, but no units found, so do nothing.
+ // 'e' matches 'em' or 'ex'
return;
}
Inkscape::CSSOStringStream os;
diff --git a/src/svg-view-widget.cpp b/src/svg-view-widget.cpp
index c568d3ca7..b1fddd7e6 100644
--- a/src/svg-view-widget.cpp
+++ b/src/svg-view-widget.cpp
@@ -91,8 +91,18 @@ static void sp_svg_view_widget_init(SPSVGSPViewWidget *vw)
vw->canvas = SPCanvas::createAA();
#if GTK_CHECK_VERSION(3,0,0)
- GdkRGBA white = {1,1,1,0};
- gtk_widget_override_background_color(vw->canvas, GTK_STATE_FLAG_NORMAL, &white);
+ GtkCssProvider *css_provider = gtk_css_provider_new();
+ GtkStyleContext *style_context = gtk_widget_get_style_context(GTK_WIDGET(vw->canvas));
+
+ gtk_css_provider_load_from_data(css_provider,
+ "SPCanvas {\n"
+ " background-color: white;\n"
+ "}\n",
+ -1, NULL);
+
+ gtk_style_context_add_provider(style_context,
+ GTK_STYLE_PROVIDER(css_provider),
+ GTK_STYLE_PROVIDER_PRIORITY_USER);
#else
gtk_widget_pop_colormap ();
GtkStyle *style = gtk_style_copy (gtk_widget_get_style (vw->canvas));
@@ -100,7 +110,7 @@ static void sp_svg_view_widget_init(SPSVGSPViewWidget *vw)
gtk_widget_set_style (vw->canvas, style);
#endif
-#if GTK_CHECK_VERSION(3,8,0)
+#if GTK_CHECK_VERSION(3,0,0)
gtk_container_add (GTK_CONTAINER (vw->sw), vw->canvas);
#else
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (vw->sw), vw->canvas);
diff --git a/src/svg-view.cpp b/src/svg-view.cpp
index f52608420..53fa8633f 100644
--- a/src/svg-view.cpp
+++ b/src/svg-view.cpp
@@ -103,7 +103,8 @@ void SPSVGView::doRescale(bool event)
void SPSVGView::mouseover()
{
- GdkCursor *cursor = gdk_cursor_new(GDK_HAND2);
+ GdkDisplay *display = gdk_display_get_default();
+ GdkCursor *cursor = gdk_cursor_new_for_display(display, GDK_HAND2);
GdkWindow *window = gtk_widget_get_window (GTK_WIDGET(SP_CANVAS_ITEM(_drawing)->canvas));
gdk_window_set_cursor(window, cursor);
#if GTK_CHECK_VERSION(3,0,0)
diff --git a/src/svg/svg-length-test.h b/src/svg/svg-length-test.h
index 0dac4854a..e73211ade 100644
--- a/src/svg/svg-length-test.h
+++ b/src/svg/svg-length-test.h
@@ -102,10 +102,7 @@ public:
for ( int i = (static_cast<int>(SVGLength::NONE) + 1); i <= static_cast<int>(SVGLength::LAST_UNIT); i++ ) {
SVGLength::Unit target = static_cast<SVGLength::Unit>(i);
// PX is a special case where we don't have a unit string
- // FOOT and MITRE are not CSS/SVG Units
- if ( (target != SVGLength::PX) &&
- (target != SVGLength::FOOT) &&
- (target != SVGLength::MITRE) ) {
+ if ( (target != SVGLength::PX) ) {
gchar const* val = sp_svg_length_get_css_units(target);
TSM_ASSERT_DIFFERS(i, val, "");
}
diff --git a/src/svg/svg-length.cpp b/src/svg/svg-length.cpp
index cd995582d..d22da69cd 100644
--- a/src/svg/svg-length.cpp
+++ b/src/svg/svg-length.cpp
@@ -411,14 +411,6 @@ So after the number, the string does not necessarily have a \0 or a unit, it mig
*computed = Inkscape::Util::Quantity::convert(v, "in", "px");
}
break;
- case UVAL('f','t'):
- if (unit) {
- *unit = SVGLength::FOOT;
- }
- if (computed) {
- *computed = Inkscape::Util::Quantity::convert(v, "ft", "px");
- }
- break;
case UVAL('e','m'):
if (unit) {
*unit = SVGLength::EM;
@@ -495,12 +487,6 @@ void SVGLength::set(SVGLength::Unit u, float v)
case INCH:
hack = "pt";
break;
- case FOOT:
- hack = "pt";
- break;
- case MITRE:
- hack = "m";
- break;
default:
break;
}
@@ -572,8 +558,6 @@ gchar const *sp_svg_length_get_css_units(SVGLength::Unit unit)
case SVGLength::MM: return "mm";
case SVGLength::CM: return "cm";
case SVGLength::INCH: return "in";
- case SVGLength::FOOT: return ""; // Not in SVG/CSS specification.
- case SVGLength::MITRE: return ""; // Not in SVG/CSS specification.
case SVGLength::EM: return "em";
case SVGLength::EX: return "ex";
case SVGLength::PERCENT: return "%";
@@ -590,10 +574,6 @@ std::string sp_svg_length_write_with_units(SVGLength const &length)
Inkscape::SVGOStringStream os;
if (length.unit == SVGLength::PERCENT) {
os << 100*length.value << sp_svg_length_get_css_units(length.unit);
- } else if (length.unit == SVGLength::FOOT) {
- os << 12*length.value << sp_svg_length_get_css_units(SVGLength::INCH);
- } else if (length.unit == SVGLength::MITRE) {
- os << 100*length.value << sp_svg_length_get_css_units(SVGLength::CM);
} else {
os << length.value << sp_svg_length_get_css_units(length.unit);
}
diff --git a/src/svg/svg-length.h b/src/svg/svg-length.h
index 2aaf248b1..bd3435ca6 100644
--- a/src/svg/svg-length.h
+++ b/src/svg/svg-length.h
@@ -27,8 +27,6 @@ public:
MM,
CM,
INCH,
- FOOT,
- MITRE,
EM,
EX,
PERCENT,
diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp
index 18f03aa1b..379682668 100644
--- a/src/trace/trace.cpp
+++ b/src/trace/trace.cpp
@@ -274,6 +274,7 @@ Glib::RefPtr<Gdk::Pixbuf> Tracer::sioxProcessImage(SPImage *img, Glib::RefPtr<Gd
for (aIter = arenaItems.begin() ; aIter!=arenaItems.end() ; ++aIter)
{
Inkscape::DrawingItem *arenaItem = *aIter;
+ arenaItem->drawing().update();
if (arenaItem->pick(point, 1.0f, 1))
{
weHaveAHit = true;
diff --git a/src/ui/cache/svg_preview_cache.cpp b/src/ui/cache/svg_preview_cache.cpp
index f1d6304cb..eeb99e045 100644
--- a/src/ui/cache/svg_preview_cache.cpp
+++ b/src/ui/cache/svg_preview_cache.cpp
@@ -1,5 +1,5 @@
/** \file
- * SPIcon: Generic icon widget
+ * SVGPreview: Preview cache
*/
/*
* Authors:
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index f04d8a591..d581dbf7e 100644
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
@@ -146,8 +146,6 @@ private:
void _setClipboardColor(guint32);
void _userWarn(SPDesktop *, char const *);
- void _inkscape_wait_for_targets(std::list<Glib::ustring> &);
-
// private properites
SPDocument *_clipboardSPDoc; ///< Document that stores the clipboard until someone requests it
Inkscape::XML::Node *_defs; ///< Reference to the clipboard document's defs node
@@ -759,7 +757,7 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection)
void ClipboardManagerImpl::_copyUsedDefs(SPItem *item)
{
SPUse *use=dynamic_cast<SPUse *>(item);
- if(use){
+ if (use && use->get_original()) {
if(cloned_elements.insert(use->get_original()).second)
_copyUsedDefs(use->get_original());
}
@@ -1302,9 +1300,11 @@ Geom::Scale ClipboardManagerImpl::_getScale(SPDesktop *desktop, Geom::Point cons
*/
Glib::ustring ClipboardManagerImpl::_getBestTarget()
{
- // GTKmm's wait_for_targets() is broken, see the comment in _inkscape_wait_for_targets()
- std::list<Glib::ustring> targets; // = _clipboard->wait_for_targets();
- _inkscape_wait_for_targets(targets);
+#if WITH_GTKMM_3_0
+ std::vector<Glib::ustring> targets = _clipboard->wait_for_targets();
+#else
+ std::list<Glib::ustring> targets = _clipboard->wait_for_targets();
+#endif
// clipboard target debugging snippet
/*
@@ -1456,39 +1456,6 @@ void ClipboardManagerImpl::_userWarn(SPDesktop *desktop, char const *msg)
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, msg);
}
-
-// GTKMM's clipboard::wait_for_targets is buggy and might return bogus, see
-//
-// https://bugs.launchpad.net/inkscape/+bug/296778
-// http://mail.gnome.org/archives/gtk-devel-list/2009-June/msg00062.html
-//
-// for details. Until this has been fixed upstream we will use our own implementation
-// of this method, as copied from /gtkmm-2.16.0/gtk/gtkmm/clipboard.cc.
-void ClipboardManagerImpl::_inkscape_wait_for_targets(std::list<Glib::ustring> &listTargets)
-{
- //Get a newly-allocated array of atoms:
- GdkAtom* targets = NULL;
- gint n_targets = 0;
- gboolean test = gtk_clipboard_wait_for_targets( gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), &targets, &n_targets );
- if (!test || (targets == NULL)) {
- return;
- }
-
- //Add the targets to the C++ container:
- for (int i = 0; i < n_targets; i++)
- {
- //Convert the atom to a string:
- gchar* const atom_name = gdk_atom_name(targets[i]);
-
- Glib::ustring target;
- if (atom_name) {
- target = Glib::ScopedPtr<char>(atom_name).get(); //This frees the gchar*.
- }
-
- listTargets.push_back(target);
- }
-}
-
/* #######################################
ClipboardManager class
####################################### */
diff --git a/src/ui/control-manager.cpp b/src/ui/control-manager.cpp
index cedaea405..a2c977533 100644
--- a/src/ui/control-manager.cpp
+++ b/src/ui/control-manager.cpp
@@ -54,9 +54,6 @@ ControlFlags& operator ^=(ControlFlags &lhs, ControlFlags rhs)
} // namespace
-#define FILL_COLOR_NORMAL 0xffffff7f
-#define FILL_COLOR_MOUSEOVER 0xff0000ff
-
// Default color for line:
#define LINE_COLOR_PRIMARY 0x0000ff7f
#define LINE_COLOR_SECONDARY 0xff00007f
@@ -83,6 +80,8 @@ public:
bool setControlType(SPCanvasItem *item, ControlType type);
+ bool setControlResize(SPCanvasItem *item, int ctrlResize);
+
void setSelected(SPCanvasItem *item, bool selected);
private:
@@ -108,12 +107,13 @@ private:
ControlManager &_manager;
sigc::signal<void> _sizeChangedSignal;
PrefListener _prefHook;
- int _size;
+ int _size; // Size from the grabsize preference
+ int _resize; // Way size should change from grabsize
std::vector<SPCanvasItem *> _itemList;
std::map<Inkscape::ControlType, std::vector<int> > _sizeTable;
std::map<Inkscape::ControlType, GType> _typeTable;
std::map<Inkscape::ControlType, SPCtrlShapeType> _ctrlToShape;
- std::set<Inkscape::ControlType> _sizeChangers;
+ std::set<Inkscape::ControlType> _resizeOnSelect;
};
ControlManagerImpl::ControlManagerImpl(ControlManager &manager) :
@@ -121,6 +121,7 @@ ControlManagerImpl::ControlManagerImpl(ControlManager &manager) :
_sizeChangedSignal(),
_prefHook(*this),
_size(3),
+ _resize(3),
_itemList(),
_sizeTable()
{
@@ -153,10 +154,10 @@ ControlManagerImpl::ControlManagerImpl(ControlManager &manager) :
// -------
- _sizeChangers.insert(CTRL_TYPE_NODE_AUTO);
- _sizeChangers.insert(CTRL_TYPE_NODE_CUSP);
- _sizeChangers.insert(CTRL_TYPE_NODE_SMOOTH);
- _sizeChangers.insert(CTRL_TYPE_NODE_SYMETRICAL);
+ _resizeOnSelect.insert(CTRL_TYPE_NODE_AUTO);
+ _resizeOnSelect.insert(CTRL_TYPE_NODE_CUSP);
+ _resizeOnSelect.insert(CTRL_TYPE_NODE_SMOOTH);
+ _resizeOnSelect.insert(CTRL_TYPE_NODE_SYMETRICAL);
// -------
@@ -234,7 +235,7 @@ SPCanvasItem *ControlManagerImpl::createControl(SPCanvasGroup *parent, ControlTy
item = sp_canvas_item_new(parent, SP_TYPE_CTRL,
"size", targetSize,
"filled", 1,
- "fill_color", FILL_COLOR_NORMAL,
+ "fill_color", 0xffffff7f,
"stroked", 1,
"stroke_color", 0x000000ff,
NULL);
@@ -284,11 +285,8 @@ sigc::connection ControlManagerImpl::connectCtrlSizeChanged(const sigc::slot<voi
void ControlManagerImpl::updateItem(SPCanvasItem *item)
{
if (item) {
- double target = _sizeTable[item->ctrlType][_size - 1];
+ double target = _sizeTable[item->ctrlType][_size - 1] + item->ctrlResize;
- if (_sizeChangers.count(item->ctrlType) && _manager.isSelected(item)) {
- target += 2;
- }
g_object_set(item, "size", target, NULL);
sp_canvas_item_request_update(item);
@@ -303,11 +301,9 @@ bool ControlManagerImpl::setControlType(SPCanvasItem *item, ControlType type)
accepted = true;
} else if (item) {
if (_ctrlToShape.count(type) && (_typeTable[type] == _typeTable[item->ctrlType])) { // compatible?
- double targetSize = _sizeTable[type][_size - 1];
- if (_manager.isSelected(item) && _sizeChangers.count(item->ctrlType)) {
- targetSize += 2.0;
- }
+ double targetSize = _sizeTable[type][_size - 1] + item->ctrlResize;
SPCtrlShapeType targetShape = _ctrlToShape[type];
+
g_object_set(item, "shape", targetShape, "size", targetSize, NULL);
item->ctrlType = type;
accepted = true;
@@ -317,17 +313,28 @@ bool ControlManagerImpl::setControlType(SPCanvasItem *item, ControlType type)
return accepted;
}
+bool ControlManagerImpl::setControlResize(SPCanvasItem *item, int ctrlResize)
+{
+ if(item) {
+ item->ctrlResize = ctrlResize;
+ double targetSize = _sizeTable[item->ctrlType][_size - 1] + item->ctrlResize;
+ g_object_set(item, "size", targetSize, NULL);
+ return true;
+ }
+ return false;
+}
void ControlManagerImpl::setSelected(SPCanvasItem *item, bool selected)
{
if (_manager.isSelected(item) != selected) {
item->ctrlFlags ^= CTRL_FLAG_SELECTED; // toggle, since we know it is different
- // TODO refresh colors
- double targetSize = _sizeTable[item->ctrlType][_size - 1];
- if (selected && _sizeChangers.count(item->ctrlType)) {
- targetSize += 2.0;
+ if (selected && _resizeOnSelect.count(item->ctrlType)) {
+ item->ctrlResize = 2;
}
+
+ // TODO refresh colors
+ double targetSize = _sizeTable[item->ctrlType][_size - 1] + _resize;
g_object_set(item, "size", targetSize, NULL);
}
}
@@ -431,6 +438,11 @@ bool ControlManager::setControlType(SPCanvasItem *item, ControlType type)
return _impl->setControlType(item, type);
}
+bool ControlManager::setControlResize(SPCanvasItem *item, int ctrlResize)
+{
+ return _impl->setControlResize(item, ctrlResize);
+}
+
bool ControlManager::isActive(SPCanvasItem *item) const
{
return (item->ctrlFlags & CTRL_FLAG_ACTIVE) != 0;
diff --git a/src/ui/control-manager.h b/src/ui/control-manager.h
index 964ad0a29..3f090d0bd 100644
--- a/src/ui/control-manager.h
+++ b/src/ui/control-manager.h
@@ -63,6 +63,8 @@ public:
bool setControlType(SPCanvasItem *item, ControlType type);
+ bool setControlResize(SPCanvasItem *item, int ctrlResize);
+
bool isActive(SPCanvasItem *item) const;
void setActive(SPCanvasItem *item, bool active);
diff --git a/src/ui/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp
index 81f48e6ef..1a87a9718 100644
--- a/src/ui/dialog/aboutbox.cpp
+++ b/src/ui/dialog/aboutbox.cpp
@@ -120,10 +120,22 @@ AboutBox::AboutBox() : Gtk::Dialog(_("About Inkscape")) {
label->set_selectable(true);
label->show();
+ Gtk::Label *link = new Gtk::Label();
+ const gchar *website_link =
+ "<a href=\"https://www.inkscape.org\"> https://www.inkscape.org</a>";
+
+ link->set_markup(website_link);
+ link->set_alignment(Gtk::ALIGN_END);
+ link->set_padding(5,5);
+ link->set_selectable(true);
+ link->show();
+
#if WITH_GTKMM_3_0
get_content_area()->pack_start(*manage(label), false, false);
+ get_content_area()->pack_start(*manage(link), false, false);
#else
get_vbox()->pack_start(*manage(label), false, false);
+ get_vbox()->pack_start(*manage(link), false, false);
#endif
Gtk::Requisition requisition;
@@ -606,288 +618,629 @@ void AboutBox::initStrings() {
* This text is copied from the COPYING file
*/
license_text =
- " GNU GENERAL PUBLIC LICENSE\n"
- " Version 2, June 1991\n"
+ " GNU GENERAL PUBLIC LICENSE\n"
+ " Version 3, 29 June 2007\n"
"\n"
- " Copyright (C) 1989, 1991 Free Software Foundation, Inc.\n"
- " 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n"
+ " Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n"
" Everyone is permitted to copy and distribute verbatim copies\n"
" of this license document, but changing it is not allowed.\n"
"\n"
- " Preamble\n"
+ " Preamble\n"
"\n"
- " The licenses for most software are designed to take away your\n"
- "freedom to share and change it. By contrast, the GNU General Public\n"
- "License is intended to guarantee your freedom to share and change free\n"
- "software--to make sure the software is free for all its users. This\n"
- "General Public License applies to most of the Free Software\n"
- "Foundation's software and to any other program whose authors commit to\n"
- "using it. (Some other Free Software Foundation software is covered by\n"
- "the GNU Library General Public License instead.) You can apply it to\n"
+ " The GNU General Public License is a free, copyleft license for\n"
+ "software and other kinds of works.\n"
+ "\n"
+ " The licenses for most software and other practical works are designed\n"
+ "to take away your freedom to share and change the works. By contrast,\n"
+ "the GNU General Public License is intended to guarantee your freedom to\n"
+ "share and change all versions of a program--to make sure it remains free\n"
+ "software for all its users. We, the Free Software Foundation, use the\n"
+ "GNU General Public License for most of our software; it applies also to\n"
+ "any other work released this way by its authors. You can apply it to\n"
"your programs, too.\n"
"\n"
" When we speak of free software, we are referring to freedom, not\n"
"price. Our General Public Licenses are designed to make sure that you\n"
"have the freedom to distribute copies of free software (and charge for\n"
- "this service if you wish), that you receive source code or can get it\n"
- "if you want it, that you can change the software or use pieces of it\n"
- "in new free programs; and that you know you can do these things.\n"
+ "them if you wish), that you receive source code or can get it if you\n"
+ "want it, that you can change the software or use pieces of it in new\n"
+ "free programs, and that you know you can do these things.\n"
"\n"
- " To protect your rights, we need to make restrictions that forbid\n"
- "anyone to deny you these rights or to ask you to surrender the rights.\n"
- "These restrictions translate to certain responsibilities for you if you\n"
- "distribute copies of the software, or if you modify it.\n"
+ " To protect your rights, we need to prevent others from denying you\n"
+ "these rights or asking you to surrender the rights. Therefore, you have\n"
+ "certain responsibilities if you distribute copies of the software, or if\n"
+ "you modify it: responsibilities to respect the freedom of others.\n"
"\n"
" For example, if you distribute copies of such a program, whether\n"
- "gratis or for a fee, you must give the recipients all the rights that\n"
- "you have. You must make sure that they, too, receive or can get the\n"
- "source code. And you must show them these terms so they know their\n"
- "rights.\n"
- "\n"
- " We protect your rights with two steps: (1) copyright the software, and\n"
- "(2) offer you this license which gives you legal permission to copy,\n"
- "distribute and/or modify the software.\n"
- "\n"
- " Also, for each author's protection and ours, we want to make certain\n"
- "that everyone understands that there is no warranty for this free\n"
- "software. If the software is modified by someone else and passed on, we\n"
- "want its recipients to know that what they have is not the original, so\n"
- "that any problems introduced by others will not reflect on the original\n"
- "authors' reputations.\n"
- "\n"
- " Finally, any free program is threatened constantly by software\n"
- "patents. We wish to avoid the danger that redistributors of a free\n"
- "program will individually obtain patent licenses, in effect making the\n"
- "program proprietary. To prevent this, we have made it clear that any\n"
- "patent must be licensed for everyone's free use or not licensed at all.\n"
+ "gratis or for a fee, you must pass on to the recipients the same\n"
+ "freedoms that you received. You must make sure that they, too, receive\n"
+ "or can get the source code. And you must show them these terms so they\n"
+ "know their rights.\n"
+ "\n"
+ " Developers that use the GNU GPL protect your rights with two steps:\n"
+ "(1) assert copyright on the software, and (2) offer you this License\n"
+ "giving you legal permission to copy, distribute and/or modify it.\n"
+ "\n"
+ " For the developers' and authors' protection, the GPL clearly explains\n"
+ "that there is no warranty for this free software. For both users' and\n"
+ "authors' sake, the GPL requires that modified versions be marked as\n"
+ "changed, so that their problems will not be attributed erroneously to\n"
+ "authors of previous versions.\n"
+ "\n"
+ " Some devices are designed to deny users access to install or run\n"
+ "modified versions of the software inside them, although the manufacturer\n"
+ "can do so. This is fundamentally incompatible with the aim of\n"
+ "protecting users' freedom to change the software. The systematic\n"
+ "pattern of such abuse occurs in the area of products for individuals to\n"
+ "use, which is precisely where it is most unacceptable. Therefore, we\n"
+ "have designed this version of the GPL to prohibit the practice for those\n"
+ "products. If such problems arise substantially in other domains, we\n"
+ "stand ready to extend this provision to those domains in future versions\n"
+ "of the GPL, as needed to protect the freedom of users.\n"
+ "\n"
+ " Finally, every program is threatened constantly by software patents.\n"
+ "States should not allow patents to restrict development and use of\n"
+ "software on general-purpose computers, but in those that do, we wish to\n"
+ "avoid the special danger that patents applied to a free program could\n"
+ "make it effectively proprietary. To prevent this, the GPL assures that\n"
+ "patents cannot be used to render the program non-free.\n"
"\n"
" The precise terms and conditions for copying, distribution and\n"
"modification follow.\n"
"\n"
- " GNU GENERAL PUBLIC LICENSE\n"
- " TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n"
- "\n"
- " 0. This License applies to any program or other work which contains\n"
- "a notice placed by the copyright holder saying it may be distributed\n"
- "under the terms of this General Public License. The \"Program\", below,\n"
- "refers to any such program or work, and a \"work based on the Program\"\n"
- "means either the Program or any derivative work under copyright law:\n"
- "that is to say, a work containing the Program or a portion of it,\n"
- "either verbatim or with modifications and/or translated into another\n"
- "language. (Hereinafter, translation is included without limitation in\n"
- "the term \"modification\".) Each licensee is addressed as \"you\".\n"
- "\n"
- "Activities other than copying, distribution and modification are not\n"
- "covered by this License; they are outside its scope. The act of\n"
- "running the Program is not restricted, and the output from the Program\n"
- "is covered only if its contents constitute a work based on the\n"
- "Program (independent of having been made by running the Program).\n"
- "Whether that is true depends on what the Program does.\n"
- "\n"
- " 1. You may copy and distribute verbatim copies of the Program's\n"
- "source code as you receive it, in any medium, provided that you\n"
- "conspicuously and appropriately publish on each copy an appropriate\n"
- "copyright notice and disclaimer of warranty; keep intact all the\n"
- "notices that refer to this License and to the absence of any warranty;\n"
- "and give any other recipients of the Program a copy of this License\n"
- "along with the Program.\n"
- "\n"
- "You may charge a fee for the physical act of transferring a copy, and\n"
- "you may at your option offer warranty protection in exchange for a fee.\n"
- "\n"
- " 2. You may modify your copy or copies of the Program or any portion\n"
- "of it, thus forming a work based on the Program, and copy and\n"
- "distribute such modifications or work under the terms of Section 1\n"
- "above, provided that you also meet all of these conditions:\n"
- "\n"
- " a) You must cause the modified files to carry prominent notices\n"
- " stating that you changed the files and the date of any change.\n"
- "\n"
- " b) You must cause any work that you distribute or publish, that in\n"
- " whole or in part contains or is derived from the Program or any\n"
- " part thereof, to be licensed as a whole at no charge to all third\n"
- " parties under the terms of this License.\n"
- "\n"
- " c) If the modified program normally reads commands interactively\n"
- " when run, you must cause it, when started running for such\n"
- " interactive use in the most ordinary way, to print or display an\n"
- " announcement including an appropriate copyright notice and a\n"
- " notice that there is no warranty (or else, saying that you provide\n"
- " a warranty) and that users may redistribute the program under\n"
- " these conditions, and telling the user how to view a copy of this\n"
- " License. (Exception: if the Program itself is interactive but\n"
- " does not normally print such an announcement, your work based on\n"
- " the Program is not required to print an announcement.)\n"
- "\n"
- "These requirements apply to the modified work as a whole. If\n"
- "identifiable sections of that work are not derived from the Program,\n"
- "and can be reasonably considered independent and separate works in\n"
- "themselves, then this License, and its terms, do not apply to those\n"
- "sections when you distribute them as separate works. But when you\n"
- "distribute the same sections as part of a whole which is a work based\n"
- "on the Program, the distribution of the whole must be on the terms of\n"
- "this License, whose permissions for other licensees extend to the\n"
- "entire whole, and thus to each and every part regardless of who wrote it.\n"
- "\n"
- "Thus, it is not the intent of this section to claim rights or contest\n"
- "your rights to work written entirely by you; rather, the intent is to\n"
- "exercise the right to control the distribution of derivative or\n"
- "collective works based on the Program.\n"
- "\n"
- "In addition, mere aggregation of another work not based on the Program\n"
- "with the Program (or with a work based on the Program) on a volume of\n"
- "a storage or distribution medium does not bring the other work under\n"
- "the scope of this License.\n"
- "\n"
- " 3. You may copy and distribute the Program (or a work based on it,\n"
- "under Section 2) in object code or executable form under the terms of\n"
- "Sections 1 and 2 above provided that you also do one of the following:\n"
- "\n"
- " a) Accompany it with the complete corresponding machine-readable\n"
- " source code, which must be distributed under the terms of Sections\n"
- " 1 and 2 above on a medium customarily used for software interchange; or,\n"
- "\n"
- " b) Accompany it with a written offer, valid for at least three\n"
- " years, to give any third party, for a charge no more than your\n"
- " cost of physically performing source distribution, a complete\n"
- " machine-readable copy of the corresponding source code, to be\n"
- " distributed under the terms of Sections 1 and 2 above on a medium\n"
- " customarily used for software interchange; or,\n"
- "\n"
- " c) Accompany it with the information you received as to the offer\n"
- " to distribute corresponding source code. (This alternative is\n"
- " allowed only for noncommercial distribution and only if you\n"
- " received the program in object code or executable form with such\n"
- " an offer, in accord with Subsection b above.)\n"
- "\n"
- "The source code for a work means the preferred form of the work for\n"
- "making modifications to it. For an executable work, complete source\n"
- "code means all the source code for all modules it contains, plus any\n"
- "associated interface definition files, plus the scripts used to\n"
- "control compilation and installation of the executable. However, as a\n"
- "special exception, the source code distributed need not include\n"
- "anything that is normally distributed (in either source or binary\n"
- "form) with the major components (compiler, kernel, and so on) of the\n"
- "operating system on which the executable runs, unless that component\n"
- "itself accompanies the executable.\n"
- "\n"
- "If distribution of executable or object code is made by offering\n"
- "access to copy from a designated place, then offering equivalent\n"
- "access to copy the source code from the same place counts as\n"
- "distribution of the source code, even though third parties are not\n"
- "compelled to copy the source along with the object code.\n"
- "\n"
- " 4. You may not copy, modify, sublicense, or distribute the Program\n"
- "except as expressly provided under this License. Any attempt\n"
- "otherwise to copy, modify, sublicense or distribute the Program is\n"
- "void, and will automatically terminate your rights under this License.\n"
- "However, parties who have received copies, or rights, from you under\n"
- "this License will not have their licenses terminated so long as such\n"
- "parties remain in full compliance.\n"
- "\n"
- " 5. You are not required to accept this License, since you have not\n"
- "signed it. However, nothing else grants you permission to modify or\n"
- "distribute the Program or its derivative works. These actions are\n"
- "prohibited by law if you do not accept this License. Therefore, by\n"
- "modifying or distributing the Program (or any work based on the\n"
- "Program), you indicate your acceptance of this License to do so, and\n"
- "all its terms and conditions for copying, distributing or modifying\n"
- "the Program or works based on it.\n"
- "\n"
- " 6. Each time you redistribute the Program (or any work based on the\n"
- "Program), the recipient automatically receives a license from the\n"
- "original licensor to copy, distribute or modify the Program subject to\n"
- "these terms and conditions. You may not impose any further\n"
- "restrictions on the recipients' exercise of the rights granted herein.\n"
- "You are not responsible for enforcing compliance by third parties to\n"
+ " TERMS AND CONDITIONS\n"
+ "\n"
+ " 0. Definitions.\n"
+ "\n"
+ " \"This License\" refers to version 3 of the GNU General Public License.\n"
+ "\n"
+ " \"Copyright\" also means copyright-like laws that apply to other kinds of\n"
+ "works, such as semiconductor masks.\n"
+ "\n"
+ " \"The Program\" refers to any copyrightable work licensed under this\n"
+ "License. Each licensee is addressed as \"you\". \"Licensees\" and\n"
+ "\"recipients\" may be individuals or organizations.\n"
+ "\n"
+ " To \"modify\" a work means to copy from or adapt all or part of the work\n"
+ "in a fashion requiring copyright permission, other than the making of an\n"
+ "exact copy. The resulting work is called a \"modified version\" of the\n"
+ "earlier work or a work \"based on\" the earlier work.\n"
+ "\n"
+ " A \"covered work\" means either the unmodified Program or a work based\n"
+ "on the Program.\n"
+ "\n"
+ " To \"propagate\" a work means to do anything with it that, without\n"
+ "permission, would make you directly or secondarily liable for\n"
+ "infringement under applicable copyright law, except executing it on a\n"
+ "computer or modifying a private copy. Propagation includes copying,\n"
+ "distribution (with or without modification), making available to the\n"
+ "public, and in some countries other activities as well.\n"
+ "\n"
+ " To \"convey\" a work means any kind of propagation that enables other\n"
+ "parties to make or receive copies. Mere interaction with a user through\n"
+ "a computer network, with no transfer of a copy, is not conveying.\n"
+ "\n"
+ " An interactive user interface displays \"Appropriate Legal Notices\"\n"
+ "to the extent that it includes a convenient and prominently visible\n"
+ "feature that (1) displays an appropriate copyright notice, and (2)\n"
+ "tells the user that there is no warranty for the work (except to the\n"
+ "extent that warranties are provided), that licensees may convey the\n"
+ "work under this License, and how to view a copy of this License. If\n"
+ "the interface presents a list of user commands or options, such as a\n"
+ "menu, a prominent item in the list meets this criterion.\n"
+ "\n"
+ " 1. Source Code.\n"
+ "\n"
+ " The \"source code\" for a work means the preferred form of the work\n"
+ "for making modifications to it. \"Object code\" means any non-source\n"
+ "form of a work.\n"
+ "\n"
+ " A \"Standard Interface\" means an interface that either is an official\n"
+ "standard defined by a recognized standards body, or, in the case of\n"
+ "interfaces specified for a particular programming language, one that\n"
+ "is widely used among developers working in that language.\n"
+ "\n"
+ " The \"System Libraries\" of an executable work include anything, other\n"
+ "than the work as a whole, that (a) is included in the normal form of\n"
+ "packaging a Major Component, but which is not part of that Major\n"
+ "Component, and (b) serves only to enable use of the work with that\n"
+ "Major Component, or to implement a Standard Interface for which an\n"
+ "implementation is available to the public in source code form. A\n"
+ "\"Major Component\", in this context, means a major essential component\n"
+ "(kernel, window system, and so on) of the specific operating system\n"
+ "(if any) on which the executable work runs, or a compiler used to\n"
+ "produce the work, or an object code interpreter used to run it.\n"
+ "\n"
+ " The \"Corresponding Source\" for a work in object code form means all\n"
+ "the source code needed to generate, install, and (for an executable\n"
+ "work) run the object code and to modify the work, including scripts to\n"
+ "control those activities. However, it does not include the work's\n"
+ "System Libraries, or general-purpose tools or generally available free\n"
+ "programs which are used unmodified in performing those activities but\n"
+ "which are not part of the work. For example, Corresponding Source\n"
+ "includes interface definition files associated with source files for\n"
+ "the work, and the source code for shared libraries and dynamically\n"
+ "linked subprograms that the work is specifically designed to require,\n"
+ "such as by intimate data communication or control flow between those\n"
+ "subprograms and other parts of the work.\n"
+ "\n"
+ " The Corresponding Source need not include anything that users\n"
+ "can regenerate automatically from other parts of the Corresponding\n"
+ "Source.\n"
+ "\n"
+ " The Corresponding Source for a work in source code form is that\n"
+ "same work.\n"
+ "\n"
+ " 2. Basic Permissions.\n"
+ "\n"
+ " All rights granted under this License are granted for the term of\n"
+ "copyright on the Program, and are irrevocable provided the stated\n"
+ "conditions are met. This License explicitly affirms your unlimited\n"
+ "permission to run the unmodified Program. The output from running a\n"
+ "covered work is covered by this License only if the output, given its\n"
+ "content, constitutes a covered work. This License acknowledges your\n"
+ "rights of fair use or other equivalent, as provided by copyright law.\n"
+ "\n"
+ " You may make, run and propagate covered works that you do not\n"
+ "convey, without conditions so long as your license otherwise remains\n"
+ "in force. You may convey covered works to others for the sole purpose\n"
+ "of having them make modifications exclusively for you, or provide you\n"
+ "with facilities for running those works, provided that you comply with\n"
+ "the terms of this License in conveying all material for which you do\n"
+ "not control copyright. Those thus making or running the covered works\n"
+ "for you must do so exclusively on your behalf, under your direction\n"
+ "and control, on terms that prohibit them from making any copies of\n"
+ "your copyrighted material outside their relationship with you.\n"
+ "\n"
+ " Conveying under any other circumstances is permitted solely under\n"
+ "the conditions stated below. Sublicensing is not allowed; section 10\n"
+ "makes it unnecessary.\n"
+ "\n"
+ " 3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n"
+ "\n"
+ " No covered work shall be deemed part of an effective technological\n"
+ "measure under any applicable law fulfilling obligations under article\n"
+ "11 of the WIPO copyright treaty adopted on 20 December 1996, or\n"
+ "similar laws prohibiting or restricting circumvention of such\n"
+ "measures.\n"
+ "\n"
+ " When you convey a covered work, you waive any legal power to forbid\n"
+ "circumvention of technological measures to the extent such circumvention\n"
+ "is effected by exercising rights under this License with respect to\n"
+ "the covered work, and you disclaim any intention to limit operation or\n"
+ "modification of the work as a means of enforcing, against the work's\n"
+ "users, your or third parties' legal rights to forbid circumvention of\n"
+ "technological measures.\n"
+ "\n"
+ " 4. Conveying Verbatim Copies.\n"
+ "\n"
+ " You may convey verbatim copies of the Program's source code as you\n"
+ "receive it, in any medium, provided that you conspicuously and\n"
+ "appropriately publish on each copy an appropriate copyright notice;\n"
+ "keep intact all notices stating that this License and any\n"
+ "non-permissive terms added in accord with section 7 apply to the code;\n"
+ "keep intact all notices of the absence of any warranty; and give all\n"
+ "recipients a copy of this License along with the Program.\n"
+ "\n"
+ " You may charge any price or no price for each copy that you convey,\n"
+ "and you may offer support or warranty protection for a fee.\n"
+ "\n"
+ " 5. Conveying Modified Source Versions.\n"
+ "\n"
+ " You may convey a work based on the Program, or the modifications to\n"
+ "produce it from the Program, in the form of source code under the\n"
+ "terms of section 4, provided that you also meet all of these conditions:\n"
+ "\n"
+ " a) The work must carry prominent notices stating that you modified\n"
+ " it, and giving a relevant date.\n"
+ "\n"
+ " b) The work must carry prominent notices stating that it is\n"
+ " released under this License and any conditions added under section\n"
+ " 7. This requirement modifies the requirement in section 4 to\n"
+ " \"keep intact all notices\".\n"
+ "\n"
+ " c) You must license the entire work, as a whole, under this\n"
+ " License to anyone who comes into possession of a copy. This\n"
+ " License will therefore apply, along with any applicable section 7\n"
+ " additional terms, to the whole of the work, and all its parts,\n"
+ " regardless of how they are packaged. This License gives no\n"
+ " permission to license the work in any other way, but it does not\n"
+ " invalidate such permission if you have separately received it.\n"
+ "\n"
+ " d) If the work has interactive user interfaces, each must display\n"
+ " Appropriate Legal Notices; however, if the Program has interactive\n"
+ " interfaces that do not display Appropriate Legal Notices, your\n"
+ " work need not make them do so.\n"
+ "\n"
+ " A compilation of a covered work with other separate and independent\n"
+ "works, which are not by their nature extensions of the covered work,\n"
+ "and which are not combined with it such as to form a larger program,\n"
+ "in or on a volume of a storage or distribution medium, is called an\n"
+ "\"aggregate\" if the compilation and its resulting copyright are not\n"
+ "used to limit the access or legal rights of the compilation's users\n"
+ "beyond what the individual works permit. Inclusion of a covered work\n"
+ "in an aggregate does not cause this License to apply to the other\n"
+ "parts of the aggregate.\n"
+ "\n"
+ " 6. Conveying Non-Source Forms.\n"
+ "\n"
+ " You may convey a covered work in object code form under the terms\n"
+ "of sections 4 and 5, provided that you also convey the\n"
+ "machine-readable Corresponding Source under the terms of this License,\n"
+ "in one of these ways:\n"
+ "\n"
+ " a) Convey the object code in, or embodied in, a physical product\n"
+ " (including a physical distribution medium), accompanied by the\n"
+ " Corresponding Source fixed on a durable physical medium\n"
+ " customarily used for software interchange.\n"
+ "\n"
+ " b) Convey the object code in, or embodied in, a physical product\n"
+ " (including a physical distribution medium), accompanied by a\n"
+ " written offer, valid for at least three years and valid for as\n"
+ " long as you offer spare parts or customer support for that product\n"
+ " model, to give anyone who possesses the object code either (1) a\n"
+ " copy of the Corresponding Source for all the software in the\n"
+ " product that is covered by this License, on a durable physical\n"
+ " medium customarily used for software interchange, for a price no\n"
+ " more than your reasonable cost of physically performing this\n"
+ " conveying of source, or (2) access to copy the\n"
+ " Corresponding Source from a network server at no charge.\n"
+ "\n"
+ " c) Convey individual copies of the object code with a copy of the\n"
+ " written offer to provide the Corresponding Source. This\n"
+ " alternative is allowed only occasionally and noncommercially, and\n"
+ " only if you received the object code with such an offer, in accord\n"
+ " with subsection 6b.\n"
+ "\n"
+ " d) Convey the object code by offering access from a designated\n"
+ " place (gratis or for a charge), and offer equivalent access to the\n"
+ " Corresponding Source in the same way through the same place at no\n"
+ " further charge. You need not require recipients to copy the\n"
+ " Corresponding Source along with the object code. If the place to\n"
+ " copy the object code is a network server, the Corresponding Source\n"
+ " may be on a different server (operated by you or a third party)\n"
+ " that supports equivalent copying facilities, provided you maintain\n"
+ " clear directions next to the object code saying where to find the\n"
+ " Corresponding Source. Regardless of what server hosts the\n"
+ " Corresponding Source, you remain obligated to ensure that it is\n"
+ " available for as long as needed to satisfy these requirements.\n"
+ "\n"
+ " e) Convey the object code using peer-to-peer transmission, provided\n"
+ " you inform other peers where the object code and Corresponding\n"
+ " Source of the work are being offered to the general public at no\n"
+ " charge under subsection 6d.\n"
+ "\n"
+ " A separable portion of the object code, whose source code is excluded\n"
+ "from the Corresponding Source as a System Library, need not be\n"
+ "included in conveying the object code work.\n"
+ "\n"
+ " A \"User Product\" is either (1) a \"consumer product\", which means any\n"
+ "tangible personal property which is normally used for personal, family,\n"
+ "or household purposes, or (2) anything designed or sold for incorporation\n"
+ "into a dwelling. In determining whether a product is a consumer product,\n"
+ "doubtful cases shall be resolved in favor of coverage. For a particular\n"
+ "product received by a particular user, \"normally used\" refers to a\n"
+ "typical or common use of that class of product, regardless of the status\n"
+ "of the particular user or of the way in which the particular user\n"
+ "actually uses, or expects or is expected to use, the product. A product\n"
+ "is a consumer product regardless of whether the product has substantial\n"
+ "commercial, industrial or non-consumer uses, unless such uses represent\n"
+ "the only significant mode of use of the product.\n"
+ "\n"
+ " \"Installation Information\" for a User Product means any methods,\n"
+ "procedures, authorization keys, or other information required to install\n"
+ "and execute modified versions of a covered work in that User Product from\n"
+ "a modified version of its Corresponding Source. The information must\n"
+ "suffice to ensure that the continued functioning of the modified object\n"
+ "code is in no case prevented or interfered with solely because\n"
+ "modification has been made.\n"
+ "\n"
+ " If you convey an object code work under this section in, or with, or\n"
+ "specifically for use in, a User Product, and the conveying occurs as\n"
+ "part of a transaction in which the right of possession and use of the\n"
+ "User Product is transferred to the recipient in perpetuity or for a\n"
+ "fixed term (regardless of how the transaction is characterized), the\n"
+ "Corresponding Source conveyed under this section must be accompanied\n"
+ "by the Installation Information. But this requirement does not apply\n"
+ "if neither you nor any third party retains the ability to install\n"
+ "modified object code on the User Product (for example, the work has\n"
+ "been installed in ROM).\n"
+ "\n"
+ " The requirement to provide Installation Information does not include a\n"
+ "requirement to continue to provide support service, warranty, or updates\n"
+ "for a work that has been modified or installed by the recipient, or for\n"
+ "the User Product in which it has been modified or installed. Access to a\n"
+ "network may be denied when the modification itself materially and\n"
+ "adversely affects the operation of the network or violates the rules and\n"
+ "protocols for communication across the network.\n"
+ "\n"
+ " Corresponding Source conveyed, and Installation Information provided,\n"
+ "in accord with this section must be in a format that is publicly\n"
+ "documented (and with an implementation available to the public in\n"
+ "source code form), and must require no special password or key for\n"
+ "unpacking, reading or copying.\n"
+ "\n"
+ " 7. Additional Terms.\n"
+ "\n"
+ " \"Additional permissions\" are terms that supplement the terms of this\n"
+ "License by making exceptions from one or more of its conditions.\n"
+ "Additional permissions that are applicable to the entire Program shall\n"
+ "be treated as though they were included in this License, to the extent\n"
+ "that they are valid under applicable law. If additional permissions\n"
+ "apply only to part of the Program, that part may be used separately\n"
+ "under those permissions, but the entire Program remains governed by\n"
+ "this License without regard to the additional permissions.\n"
+ "\n"
+ " When you convey a copy of a covered work, you may at your option\n"
+ "remove any additional permissions from that copy, or from any part of\n"
+ "it. (Additional permissions may be written to require their own\n"
+ "removal in certain cases when you modify the work.) You may place\n"
+ "additional permissions on material, added by you to a covered work,\n"
+ "for which you have or can give appropriate copyright permission.\n"
+ "\n"
+ " Notwithstanding any other provision of this License, for material you\n"
+ "add to a covered work, you may (if authorized by the copyright holders of\n"
+ "that material) supplement the terms of this License with terms:\n"
+ "\n"
+ " a) Disclaiming warranty or limiting liability differently from the\n"
+ " terms of sections 15 and 16 of this License; or\n"
+ "\n"
+ " b) Requiring preservation of specified reasonable legal notices or\n"
+ " author attributions in that material or in the Appropriate Legal\n"
+ " Notices displayed by works containing it; or\n"
+ "\n"
+ " c) Prohibiting misrepresentation of the origin of that material, or\n"
+ " requiring that modified versions of such material be marked in\n"
+ " reasonable ways as different from the original version; or\n"
+ "\n"
+ " d) Limiting the use for publicity purposes of names of licensors or\n"
+ " authors of the material; or\n"
+ "\n"
+ " e) Declining to grant rights under trademark law for use of some\n"
+ " trade names, trademarks, or service marks; or\n"
+ "\n"
+ " f) Requiring indemnification of licensors and authors of that\n"
+ " material by anyone who conveys the material (or modified versions of\n"
+ " it) with contractual assumptions of liability to the recipient, for\n"
+ " any liability that these contractual assumptions directly impose on\n"
+ " those licensors and authors.\n"
+ "\n"
+ " All other non-permissive additional terms are considered \"further\n"
+ "restrictions\" within the meaning of section 10. If the Program as you\n"
+ "received it, or any part of it, contains a notice stating that it is\n"
+ "governed by this License along with a term that is a further\n"
+ "restriction, you may remove that term. If a license document contains\n"
+ "a further restriction but permits relicensing or conveying under this\n"
+ "License, you may add to a covered work material governed by the terms\n"
+ "of that license document, provided that the further restriction does\n"
+ "not survive such relicensing or conveying.\n"
+ "\n"
+ " If you add terms to a covered work in accord with this section, you\n"
+ "must place, in the relevant source files, a statement of the\n"
+ "additional terms that apply to those files, or a notice indicating\n"
+ "where to find the applicable terms.\n"
+ "\n"
+ " Additional terms, permissive or non-permissive, may be stated in the\n"
+ "form of a separately written license, or stated as exceptions;\n"
+ "the above requirements apply either way.\n"
+ "\n"
+ " 8. Termination.\n"
+ "\n"
+ " You may not propagate or modify a covered work except as expressly\n"
+ "provided under this License. Any attempt otherwise to propagate or\n"
+ "modify it is void, and will automatically terminate your rights under\n"
+ "this License (including any patent licenses granted under the third\n"
+ "paragraph of section 11).\n"
+ "\n"
+ " However, if you cease all violation of this License, then your\n"
+ "license from a particular copyright holder is reinstated (a)\n"
+ "provisionally, unless and until the copyright holder explicitly and\n"
+ "finally terminates your license, and (b) permanently, if the copyright\n"
+ "holder fails to notify you of the violation by some reasonable means\n"
+ "prior to 60 days after the cessation.\n"
+ "\n"
+ " Moreover, your license from a particular copyright holder is\n"
+ "reinstated permanently if the copyright holder notifies you of the\n"
+ "violation by some reasonable means, this is the first time you have\n"
+ "received notice of violation of this License (for any work) from that\n"
+ "copyright holder, and you cure the violation prior to 30 days after\n"
+ "your receipt of the notice.\n"
+ "\n"
+ " Termination of your rights under this section does not terminate the\n"
+ "licenses of parties who have received copies or rights from you under\n"
+ "this License. If your rights have been terminated and not permanently\n"
+ "reinstated, you do not qualify to receive new licenses for the same\n"
+ "material under section 10.\n"
+ "\n"
+ " 9. Acceptance Not Required for Having Copies.\n"
+ "\n"
+ " You are not required to accept this License in order to receive or\n"
+ "run a copy of the Program. Ancillary propagation of a covered work\n"
+ "occurring solely as a consequence of using peer-to-peer transmission\n"
+ "to receive a copy likewise does not require acceptance. However,\n"
+ "nothing other than this License grants you permission to propagate or\n"
+ "modify any covered work. These actions infringe copyright if you do\n"
+ "not accept this License. Therefore, by modifying or propagating a\n"
+ "covered work, you indicate your acceptance of this License to do so.\n"
+ "\n"
+ " 10. Automatic Licensing of Downstream Recipients.\n"
+ "\n"
+ " Each time you convey a covered work, the recipient automatically\n"
+ "receives a license from the original licensors, to run, modify and\n"
+ "propagate that work, subject to this License. You are not responsible\n"
+ "for enforcing compliance by third parties with this License.\n"
+ "\n"
+ " An \"entity transaction\" is a transaction transferring control of an\n"
+ "organization, or substantially all assets of one, or subdividing an\n"
+ "organization, or merging organizations. If propagation of a covered\n"
+ "work results from an entity transaction, each party to that\n"
+ "transaction who receives a copy of the work also receives whatever\n"
+ "licenses to the work the party's predecessor in interest had or could\n"
+ "give under the previous paragraph, plus a right to possession of the\n"
+ "Corresponding Source of the work from the predecessor in interest, if\n"
+ "the predecessor has it or can get it with reasonable efforts.\n"
+ "\n"
+ " You may not impose any further restrictions on the exercise of the\n"
+ "rights granted or affirmed under this License. For example, you may\n"
+ "not impose a license fee, royalty, or other charge for exercise of\n"
+ "rights granted under this License, and you may not initiate litigation\n"
+ "(including a cross-claim or counterclaim in a lawsuit) alleging that\n"
+ "any patent claim is infringed by making, using, selling, offering for\n"
+ "sale, or importing the Program or any portion of it.\n"
+ "\n"
+ " 11. Patents.\n"
+ "\n"
+ " A \"contributor\" is a copyright holder who authorizes use under this\n"
+ "License of the Program or a work on which the Program is based. The\n"
+ "work thus licensed is called the contributor's \"contributor version\".\n"
+ "\n"
+ " A contributor's \"essential patent claims\" are all patent claims\n"
+ "owned or controlled by the contributor, whether already acquired or\n"
+ "hereafter acquired, that would be infringed by some manner, permitted\n"
+ "by this License, of making, using, or selling its contributor version,\n"
+ "but do not include claims that would be infringed only as a\n"
+ "consequence of further modification of the contributor version. For\n"
+ "purposes of this definition, \"control\" includes the right to grant\n"
+ "patent sublicenses in a manner consistent with the requirements of\n"
"this License.\n"
"\n"
- " 7. If, as a consequence of a court judgment or allegation of patent\n"
- "infringement or for any other reason (not limited to patent issues),\n"
- "conditions are imposed on you (whether by court order, agreement or\n"
+ " Each contributor grants you a non-exclusive, worldwide, royalty-free\n"
+ "patent license under the contributor's essential patent claims, to\n"
+ "make, use, sell, offer for sale, import and otherwise run, modify and\n"
+ "propagate the contents of its contributor version.\n"
+ "\n"
+ " In the following three paragraphs, a \"patent license\" is any express\n"
+ "agreement or commitment, however denominated, not to enforce a patent\n"
+ "(such as an express permission to practice a patent or covenant not to\n"
+ "sue for patent infringement). To \"grant\" such a patent license to a\n"
+ "party means to make such an agreement or commitment not to enforce a\n"
+ "patent against the party.\n"
+ "\n"
+ " If you convey a covered work, knowingly relying on a patent license,\n"
+ "and the Corresponding Source of the work is not available for anyone\n"
+ "to copy, free of charge and under the terms of this License, through a\n"
+ "publicly available network server or other readily accessible means,\n"
+ "then you must either (1) cause the Corresponding Source to be so\n"
+ "available, or (2) arrange to deprive yourself of the benefit of the\n"
+ "patent license for this particular work, or (3) arrange, in a manner\n"
+ "consistent with the requirements of this License, to extend the patent\n"
+ "license to downstream recipients. \"Knowingly relying\" means you have\n"
+ "actual knowledge that, but for the patent license, your conveying the\n"
+ "covered work in a country, or your recipient's use of the covered work\n"
+ "in a country, would infringe one or more identifiable patents in that\n"
+ "country that you have reason to believe are valid.\n"
+ "\n"
+ " If, pursuant to or in connection with a single transaction or\n"
+ "arrangement, you convey, or propagate by procuring conveyance of, a\n"
+ "covered work, and grant a patent license to some of the parties\n"
+ "receiving the covered work authorizing them to use, propagate, modify\n"
+ "or convey a specific copy of the covered work, then the patent license\n"
+ "you grant is automatically extended to all recipients of the covered\n"
+ "work and works based on it.\n"
+ "\n"
+ " A patent license is \"discriminatory\" if it does not include within\n"
+ "the scope of its coverage, prohibits the exercise of, or is\n"
+ "conditioned on the non-exercise of one or more of the rights that are\n"
+ "specifically granted under this License. You may not convey a covered\n"
+ "work if you are a party to an arrangement with a third party that is\n"
+ "in the business of distributing software, under which you make payment\n"
+ "to the third party based on the extent of your activity of conveying\n"
+ "the work, and under which the third party grants, to any of the\n"
+ "parties who would receive the covered work from you, a discriminatory\n"
+ "patent license (a) in connection with copies of the covered work\n"
+ "conveyed by you (or copies made from those copies), or (b) primarily\n"
+ "for and in connection with specific products or compilations that\n"
+ "contain the covered work, unless you entered into that arrangement,\n"
+ "or that patent license was granted, prior to 28 March 2007.\n"
+ "\n"
+ " Nothing in this License shall be construed as excluding or limiting\n"
+ "any implied license or other defenses to infringement that may\n"
+ "otherwise be available to you under applicable patent law.\n"
+ "\n"
+ " 12. No Surrender of Others' Freedom.\n"
+ "\n"
+ " If conditions are imposed on you (whether by court order, agreement or\n"
"otherwise) that contradict the conditions of this License, they do not\n"
- "excuse you from the conditions of this License. If you cannot\n"
- "distribute so as to satisfy simultaneously your obligations under this\n"
- "License and any other pertinent obligations, then as a consequence you\n"
- "may not distribute the Program at all. For example, if a patent\n"
- "license would not permit royalty-free redistribution of the Program by\n"
- "all those who receive copies directly or indirectly through you, then\n"
- "the only way you could satisfy both it and this License would be to\n"
- "refrain entirely from distribution of the Program.\n"
- "\n"
- "If any portion of this section is held invalid or unenforceable under\n"
- "any particular circumstance, the balance of the section is intended to\n"
- "apply and the section as a whole is intended to apply in other\n"
- "circumstances.\n"
- "\n"
- "It is not the purpose of this section to induce you to infringe any\n"
- "patents or other property right claims or to contest validity of any\n"
- "such claims; this section has the sole purpose of protecting the\n"
- "integrity of the free software distribution system, which is\n"
- "implemented by public license practices. Many people have made\n"
- "generous contributions to the wide range of software distributed\n"
- "through that system in reliance on consistent application of that\n"
- "system; it is up to the author/donor to decide if he or she is willing\n"
- "to distribute software through any other system and a licensee cannot\n"
- "impose that choice.\n"
- "\n"
- "This section is intended to make thoroughly clear what is believed to\n"
- "be a consequence of the rest of this License.\n"
- "\n"
- " 8. If the distribution and/or use of the Program is restricted in\n"
- "certain countries either by patents or by copyrighted interfaces, the\n"
- "original copyright holder who places the Program under this License\n"
- "may add an explicit geographical distribution limitation excluding\n"
- "those countries, so that distribution is permitted only in or among\n"
- "countries not thus excluded. In such case, this License incorporates\n"
- "the limitation as if written in the body of this License.\n"
- "\n"
- " 9. The Free Software Foundation may publish revised and/or new versions\n"
- "of the General Public License from time to time. Such new versions will\n"
+ "excuse you from the conditions of this License. If you cannot convey a\n"
+ "covered work so as to satisfy simultaneously your obligations under this\n"
+ "License and any other pertinent obligations, then as a consequence you may\n"
+ "not convey it at all. For example, if you agree to terms that obligate you\n"
+ "to collect a royalty for further conveying from those to whom you convey\n"
+ "the Program, the only way you could satisfy both those terms and this\n"
+ "License would be to refrain entirely from conveying the Program.\n"
+ "\n"
+ " 13. Use with the GNU Affero General Public License.\n"
+ "\n"
+ " Notwithstanding any other provision of this License, you have\n"
+ "permission to link or combine any covered work with a work licensed\n"
+ "under version 3 of the GNU Affero General Public License into a single\n"
+ "combined work, and to convey the resulting work. The terms of this\n"
+ "License will continue to apply to the part which is the covered work,\n"
+ "but the special requirements of the GNU Affero General Public License,\n"
+ "section 13, concerning interaction through a network will apply to the\n"
+ "combination as such.\n"
+ "\n"
+ " 14. Revised Versions of this License.\n"
+ "\n"
+ " The Free Software Foundation may publish revised and/or new versions of\n"
+ "the GNU General Public License from time to time. Such new versions will\n"
"be similar in spirit to the present version, but may differ in detail to\n"
"address new problems or concerns.\n"
"\n"
- "Each version is given a distinguishing version number. If the Program\n"
- "specifies a version number of this License which applies to it and \"any\n"
- "later version\", you have the option of following the terms and conditions\n"
- "either of that version or of any later version published by the Free\n"
- "Software Foundation. If the Program does not specify a version number of\n"
- "this License, you may choose any version ever published by the Free Software\n"
- "Foundation.\n"
- "\n"
- " 10. If you wish to incorporate parts of the Program into other free\n"
- "programs whose distribution conditions are different, write to the author\n"
- "to ask for permission. For software which is copyrighted by the Free\n"
- "Software Foundation, write to the Free Software Foundation; we sometimes\n"
- "make exceptions for this. Our decision will be guided by the two goals\n"
- "of preserving the free status of all derivatives of our free software and\n"
- "of promoting the sharing and reuse of software generally.\n"
- "\n"
- " NO WARRANTY\n"
- "\n"
- " 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\n"
- "FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN\n"
- "OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES\n"
- "PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED\n"
- "OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n"
- "MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS\n"
- "TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE\n"
- "PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,\n"
- "REPAIR OR CORRECTION.\n"
- "\n"
- " 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\n"
- "WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR\n"
- "REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\n"
- "INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING\n"
- "OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED\n"
- "TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY\n"
- "YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER\n"
- "PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\n"
- "POSSIBILITY OF SUCH DAMAGES.\n"
- "\n"
- " END OF TERMS AND CONDITIONS\n"
- "\n"
- " How to Apply These Terms to Your New Programs\n"
+ " Each version is given a distinguishing version number. If the\n"
+ "Program specifies that a certain numbered version of the GNU General\n"
+ "Public License \"or any later version\" applies to it, you have the\n"
+ "option of following the terms and conditions either of that numbered\n"
+ "version or of any later version published by the Free Software\n"
+ "Foundation. If the Program does not specify a version number of the\n"
+ "GNU General Public License, you may choose any version ever published\n"
+ "by the Free Software Foundation.\n"
+ "\n"
+ " If the Program specifies that a proxy can decide which future\n"
+ "versions of the GNU General Public License can be used, that proxy's\n"
+ "public statement of acceptance of a version permanently authorizes you\n"
+ "to choose that version for the Program.\n"
+ "\n"
+ " Later license versions may give you additional or different\n"
+ "permissions. However, no additional obligations are imposed on any\n"
+ "author or copyright holder as a result of your choosing to follow a\n"
+ "later version.\n"
+ "\n"
+ " 15. Disclaimer of Warranty.\n"
+ "\n"
+ " THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\n"
+ "APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\n"
+ "HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\n"
+ "OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\n"
+ "THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n"
+ "PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\n"
+ "IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\n"
+ "ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n"
+ "\n"
+ " 16. Limitation of Liability.\n"
+ "\n"
+ " IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\n"
+ "WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\n"
+ "THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\n"
+ "GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\n"
+ "USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\n"
+ "DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\n"
+ "PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\n"
+ "EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\n"
+ "SUCH DAMAGES.\n"
+ "\n"
+ " 17. Interpretation of Sections 15 and 16.\n"
+ "\n"
+ " If the disclaimer of warranty and limitation of liability provided\n"
+ "above cannot be given local legal effect according to their terms,\n"
+ "reviewing courts shall apply local law that most closely approximates\n"
+ "an absolute waiver of all civil liability in connection with the\n"
+ "Program, unless a warranty or assumption of liability accompanies a\n"
+ "copy of the Program in return for a fee.\n"
+ "\n"
+ " END OF TERMS AND CONDITIONS\n"
+ "\n"
+ " How to Apply These Terms to Your New Programs\n"
"\n"
" If you develop a new program, and you want it to be of the greatest\n"
"possible use to the public, the best way to achieve this is to make it\n"
@@ -895,15 +1248,15 @@ void AboutBox::initStrings() {
"\n"
" To do so, attach the following notices to the program. It is safest\n"
"to attach them to the start of each source file to most effectively\n"
- "convey the exclusion of warranty; and each file should have at least\n"
+ "state the exclusion of warranty; and each file should have at least\n"
"the \"copyright\" line and a pointer to where the full notice is found.\n"
"\n"
" <one line to give the program's name and a brief idea of what it does.>\n"
" Copyright (C) <year> <name of author>\n"
"\n"
- " This program is free software; you can redistribute it and/or modify\n"
+ " This program is free software: you can redistribute it and/or modify\n"
" it under the terms of the GNU General Public License as published by\n"
- " the Free Software Foundation; either version 2 of the License, or\n"
+ " the Free Software Foundation, either version 3 of the License, or\n"
" (at your option) any later version.\n"
"\n"
" This program is distributed in the hope that it will be useful,\n"
@@ -912,40 +1265,33 @@ void AboutBox::initStrings() {
" GNU General Public License for more details.\n"
"\n"
" You should have received a copy of the GNU General Public License\n"
- " along with this program; if not, write to the Free Software\n"
- " Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n"
- "\n"
+ " along with this program. If not, see <http://www.gnu.org/licenses/>.\n"
"\n"
"Also add information on how to contact you by electronic and paper mail.\n"
"\n"
- "If the program is interactive, make it output a short notice like this\n"
- "when it starts in an interactive mode:\n"
+ " If the program does terminal interaction, make it output a short\n"
+ "notice like this when it starts in an interactive mode:\n"
"\n"
- " Gnomovision version 69, Copyright (C) year name of author\n"
- " Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n"
+ " <program> Copyright (C) <year> <name of author>\n"
+ " This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n"
" This is free software, and you are welcome to redistribute it\n"
" under certain conditions; type `show c' for details.\n"
"\n"
"The hypothetical commands `show w' and `show c' should show the appropriate\n"
- "parts of the General Public License. Of course, the commands you use may\n"
- "be called something other than `show w' and `show c'; they could even be\n"
- "mouse-clicks or menu items--whatever suits your program.\n"
- "\n"
- "You should also get your employer (if you work as a programmer) or your\n"
- "school, if any, to sign a \"copyright disclaimer\" for the program, if\n"
- "necessary. Here is a sample; alter the names:\n"
- "\n"
- " Yoyodyne, Inc., hereby disclaims all copyright interest in the program\n"
- " `Gnomovision' (which makes passes at compilers) written by James Hacker.\n"
+ "parts of the General Public License. Of course, your program's commands\n"
+ "might be different; for a GUI interface, you would use an \"about box\".\n"
"\n"
- " <signature of Ty Coon>, 1 April 1989\n"
- " Ty Coon, President of Vice\n"
+ " You should also get your employer (if you work as a programmer) or school,\n"
+ "if any, to sign a \"copyright disclaimer\" for the program, if necessary.\n"
+ "For more information on this, and how to apply and follow the GNU GPL, see\n"
+ "<http://www.gnu.org/licenses/>.\n"
"\n"
- "This General Public License does not permit incorporating your program into\n"
- "proprietary programs. If your program is a subroutine library, you may\n"
- "consider it more useful to permit linking proprietary applications with the\n"
- "library. If this is what you want to do, use the GNU Library General\n"
- "Public License instead of this License.\n"
+ " The GNU General Public License does not permit incorporating your program\n"
+ "into proprietary programs. If your program is a subroutine library, you\n"
+ "may consider it more useful to permit linking proprietary applications with\n"
+ "the library. If this is what you want to do, use the GNU Lesser General\n"
+ "Public License instead of this License. But first, please read\n"
+ "<http://www.gnu.org/philosophy/why-not-lgpl.html>."
;
}
diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp
index 9e7861217..8f87932b8 100644
--- a/src/ui/dialog/align-and-distribute.cpp
+++ b/src/ui/dialog/align-and-distribute.cpp
@@ -42,6 +42,7 @@
#include "ui/icon-names.h"
#include "ui/tools/node-tool.h"
#include "ui/tool/multi-path-manipulator.h"
+#include "ui/tool/control-point-selection.h"
#include "verbs.h"
#include "widgets/icon.h"
#include "sp-root.h"
@@ -88,6 +89,42 @@ Action::Action(const Glib::ustring &id,
}
+void ActionAlign::do_node_action(Inkscape::UI::Tools::NodeTool *nt, int verb)
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int prev_pref = prefs->getInt("/dialogs/align/align-nodes-to");
+ switch(verb){
+ case SP_VERB_ALIGN_HORIZONTAL_LEFT:
+ prefs->setInt("/dialogs/align/align-nodes-to", MIN_NODE );
+ nt->_multipath->alignNodes(Geom::Y);
+ break;
+ case SP_VERB_ALIGN_HORIZONTAL_CENTER:
+ nt->_multipath->alignNodes(Geom::Y);
+ break;
+ case SP_VERB_ALIGN_HORIZONTAL_RIGHT:
+ prefs->setInt("/dialogs/align/align-nodes-to", MAX_NODE );
+ nt->_multipath->alignNodes(Geom::Y);
+ break;
+ case SP_VERB_ALIGN_VERTICAL_TOP:
+ prefs->setInt("/dialogs/align/align-nodes-to", MAX_NODE );
+ nt->_multipath->alignNodes(Geom::X);
+ break;
+ case SP_VERB_ALIGN_VERTICAL_CENTER:
+ nt->_multipath->alignNodes(Geom::X);
+ break;
+ case SP_VERB_ALIGN_VERTICAL_BOTTOM:
+ prefs->setInt("/dialogs/align/align-nodes-to", MIN_NODE );
+ nt->_multipath->alignNodes(Geom::X);
+ break;
+ case SP_VERB_ALIGN_VERTICAL_HORIZONTAL_CENTER:
+ nt->_multipath->alignNodes(Geom::X);
+ nt->_multipath->alignNodes(Geom::Y);
+ break;
+ default:return;
+ }
+ prefs->setInt("/dialogs/align/align-nodes-to", prev_pref );
+}
+
void ActionAlign::do_action(SPDesktop *desktop, int index)
{
Inkscape::Selection *selection = desktop->getSelection();
@@ -187,6 +224,14 @@ ActionAlign::Coeffs const ActionAlign::_allCoeffs[11] = {
void ActionAlign::do_verb_action(SPDesktop *desktop, int verb)
{
+ Inkscape::UI::Tools::ToolBase *event_context = desktop->getEventContext();
+ if (INK_IS_NODE_TOOL(event_context)) {
+ Inkscape::UI::Tools::NodeTool *nt = INK_NODE_TOOL(event_context);
+ if(!nt->_selected_nodes->empty()){
+ do_node_action(nt, verb);
+ return;
+ }
+ }
do_action(desktop, verb_to_coeff(verb));
}
@@ -741,7 +786,6 @@ private :
if (!selection) return;
std::vector<SPItem*> selected(selection->itemList());
- if (selected.empty()) return;
//Check 2 or more selected objects
if (selected.size() < 2) return;
@@ -794,7 +838,51 @@ private :
_("Distribute text baselines"));
}
- } else {
+ } else { //align
+ Geom::Point ref_point;
+ SPItem *focus = NULL;
+ Geom::OptRect b = Geom::OptRect();
+
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
+ switch (AlignTarget(prefs->getInt("/dialogs/align/align-to", 6)))
+ {
+ case LAST:
+ focus = SP_ITEM(*selected.begin());
+ break;
+ case FIRST:
+ focus = SP_ITEM(*--(selected.end()));
+ break;
+ case BIGGEST:
+ focus = selection->largestItem(Selection::AREA);
+ break;
+ case SMALLEST:
+ focus = selection->smallestItem(Selection::AREA);
+ break;
+ case PAGE:
+ b = desktop->getDocument()->preferredBounds();
+ break;
+ case DRAWING:
+ b = desktop->getDocument()->getRoot()->desktopPreferredBounds();
+ break;
+ case SELECTION:
+ b = selection->preferredBounds();
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ };
+
+ if(focus) {
+ if (SP_IS_TEXT (focus) || SP_IS_FLOWTEXT (focus)) {
+ ref_point = *(te_get_layout(focus)->baselineAnchorPoint())*(focus->i2dt_affine());
+ } else {
+ ref_point = focus->desktopPreferredBounds()->min();
+ }
+ } else {
+ ref_point = b->min();
+ }
+
for (std::vector<SPItem*>::iterator it(selected.begin());
it != selected.end();
++it)
@@ -806,7 +894,7 @@ private :
if (pt) {
Geom::Point base = *pt * (item)->i2dt_affine();
Geom::Point t(0.0, 0.0);
- t[_orientation] = b_min[_orientation] - base[_orientation];
+ t[_orientation] = ref_point[_orientation] - base[_orientation];
sp_item_move_rel(item, Geom::Translate(t));
changed = true;
}
@@ -828,6 +916,9 @@ static void on_tool_changed(AlignAndDistribute *daad)
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
if (desktop && desktop->getEventContext())
daad->setMode(tools_active(desktop) == TOOLS_NODES);
+ else
+ daad->setMode(false);
+
}
static void on_selection_changed(AlignAndDistribute *daad)
@@ -862,6 +953,7 @@ AlignAndDistribute::AlignAndDistribute()
_nodesTable(1, 4, true),
#endif
_anchorLabel(_("Relative to: ")),
+ _anchorLabelNode(_("Relative to: ")),
_selgrpLabel(_("_Treat selection as group: "), 1)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -1000,9 +1092,20 @@ AlignAndDistribute::AlignAndDistribute()
_combo.set_active(prefs->getInt("/dialogs/align/align-to", 6));
_combo.signal_changed().connect(sigc::mem_fun(*this, &AlignAndDistribute::on_ref_change));
+ _comboNode.append(_("Last selected"));
+ _comboNode.append(_("First selected"));
+ _comboNode.append(_("Middle of selection"));
+ _comboNode.append(_("Min value"));
+ _comboNode.append(_("Max value"));
+ _comboNode.set_active(prefs->getInt("/dialogs/align/align-nodes-to", 2));
+ _comboNode.signal_changed().connect(sigc::mem_fun(*this, &AlignAndDistribute::on_node_ref_change));
+
_anchorBox.pack_end(_combo, false, false);
_anchorBox.pack_end(_anchorLabel, false, false);
+ _anchorBoxNode.pack_end(_comboNode, false, false);
+ _anchorBoxNode.pack_end(_anchorLabelNode, false, false);
+
_selgrpLabel.set_mnemonic_widget(_selgrp);
_selgrpBox.pack_end(_selgrp, false, false);
_selgrpBox.pack_end(_selgrpLabel, false, false);
@@ -1020,11 +1123,15 @@ AlignAndDistribute::AlignAndDistribute()
_alignBox.pack_start(_selgrpBox);
_alignBox.pack_start(_alignTableBox);
+ _alignBoxNode.pack_start(_anchorBoxNode, false, false);
+ _alignBoxNode.pack_start(_nodesTableBox);
+
+
_alignFrame.add(_alignBox);
_distributeFrame.add(_distributeTableBox);
_rearrangeFrame.add(_rearrangeTableBox);
_removeOverlapFrame.add(_removeOverlapTableBox);
- _nodesFrame.add(_nodesTableBox);
+ _nodesFrame.add(_alignBoxNode);
Gtk::Box *contents = _getContents();
contents->set_spacing(4);
@@ -1035,7 +1142,7 @@ AlignAndDistribute::AlignAndDistribute()
contents->pack_start(_distributeFrame, true, true);
contents->pack_start(_rearrangeFrame, true, true);
contents->pack_start(_removeOverlapFrame, true, true);
- contents->pack_start(_nodesFrame, true, true);
+ contents->pack_start(_nodesFrame, true, false);
//Connect to the global tool change signal
_toolChangeConn = INKSCAPE.signal_eventcontext_set.connect(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_tool_changed), this)));
@@ -1081,6 +1188,13 @@ void AlignAndDistribute::on_ref_change(){
//Make blink the master
}
+void AlignAndDistribute::on_node_ref_change(){
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt("/dialogs/align/align-nodes-to", _comboNode.get_active_row_number());
+
+ //Make blink the master
+}
+
void AlignAndDistribute::on_selgrp_toggled(){
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setInt("/dialogs/align/sel-as-groups", _selgrp.get_active());
@@ -1106,6 +1220,7 @@ void AlignAndDistribute::setMode(bool nodeEdit)
((_rearrangeFrame).*(mSel))();
((_removeOverlapFrame).*(mSel))();
((_nodesFrame).*(mNode))();
+ _getContents()->queue_resize();
}
void AlignAndDistribute::addAlignButton(const Glib::ustring &id, const Glib::ustring tiptext,
diff --git a/src/ui/dialog/align-and-distribute.h b/src/ui/dialog/align-and-distribute.h
index eecc30ff8..f8cc61af2 100644
--- a/src/ui/dialog/align-and-distribute.h
+++ b/src/ui/dialog/align-and-distribute.h
@@ -18,6 +18,7 @@
#include <list>
#include "ui/widget/panel.h"
#include "ui/widget/frame.h"
+
#include <gtkmm/frame.h>
#include <gtkmm/comboboxtext.h>
#include <gtkmm/label.h>
@@ -35,6 +36,9 @@ class SPItem;
namespace Inkscape {
namespace UI {
+namespace Tools{
+class NodeTool;
+}
namespace Dialog {
class Action;
@@ -68,6 +72,7 @@ public:
protected:
void on_ref_change();
+ void on_node_ref_change();
void on_selgrp_toggled();
void addDistributeButton(const Glib::ustring &id, const Glib::ustring tiptext,
guint row, guint col, bool onInterSpace,
@@ -114,15 +119,19 @@ protected:
Gtk::HBox _anchorBox;
Gtk::HBox _selgrpBox;
Gtk::VBox _alignBox;
+ Gtk::VBox _alignBoxNode;
Gtk::HBox _alignTableBox;
Gtk::HBox _distributeTableBox;
Gtk::HBox _rearrangeTableBox;
Gtk::HBox _removeOverlapTableBox;
Gtk::HBox _nodesTableBox;
Gtk::Label _anchorLabel;
+ Gtk::Label _anchorLabelNode;
Gtk::Label _selgrpLabel;
Gtk::CheckButton _selgrp;
Gtk::ComboBoxText _combo;
+ Gtk::HBox _anchorBoxNode;
+ Gtk::ComboBoxText _comboNode;
SPDesktop *_desktop;
DesktopTracker _deskTrack;
@@ -149,6 +158,8 @@ bool operator< (const BBoxSort &a, const BBoxSort &b);
class Action {
public :
+ enum AlignTarget { LAST=0, FIRST, BIGGEST, SMALLEST, PAGE, DRAWING, SELECTION };
+ enum AlignTargetNode { LAST_NODE=0, FIRST_NODE, MID_NODE, MIN_NODE, MAX_NODE };
Action(const Glib::ustring &id,
const Glib::ustring &tiptext,
guint row, guint column,
@@ -183,7 +194,6 @@ public :
double sx0, sx1, sy0, sy1;
int verb_id;
};
- enum AlignTarget { LAST=0, FIRST, BIGGEST, SMALLEST, PAGE, DRAWING, SELECTION };
ActionAlign(const Glib::ustring &id,
const Glib::ustring &tiptext,
guint row, guint column,
@@ -213,6 +223,7 @@ private :
}
static void do_action(SPDesktop *desktop, int index);
+ static void do_node_action(Inkscape::UI::Tools::NodeTool *nt, int index);
guint _index;
AlignAndDistribute &_dialog;
diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp
index fbd050f8e..9656878e0 100644
--- a/src/ui/dialog/clonetiler.cpp
+++ b/src/ui/dialog/clonetiler.cpp
@@ -1061,7 +1061,11 @@ CloneTiler::CloneTiler () :
{
GtkWidget *l = gtk_label_new ("");
gtk_label_set_markup (GTK_LABEL(l), "&#215;");
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_halign(l, GTK_ALIGN_END);
+#else
gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5);
+#endif
gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0);
}
@@ -1135,7 +1139,11 @@ CloneTiler::CloneTiler () :
{
GtkWidget *l = gtk_label_new ("");
gtk_label_set_markup (GTK_LABEL(l), "&#215;");
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_halign(l, GTK_ALIGN_END);
+#else
gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5);
+#endif
gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0);
}
@@ -2777,7 +2785,12 @@ GtkWidget * CloneTiler::clonetiler_spinbox(const char *tip, const char *attr, do
{
GtkWidget *l = gtk_label_new ("");
gtk_label_set_markup (GTK_LABEL(l), suffix);
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_halign(l, GTK_ALIGN_END);
+ gtk_widget_set_valign(l, GTK_ALIGN_START);
+#else
gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0);
+#endif
gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0);
}
@@ -2853,14 +2866,13 @@ void CloneTiler::clonetiler_reset(GtkWidget */*widget*/, GtkWidget *dlg)
void CloneTiler::clonetiler_table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col)
{
- GtkWidget *a = gtk_alignment_new (align, 0, 0, 0);
- gtk_container_add(GTK_CONTAINER(a), widget);
-
#if GTK_CHECK_VERSION(3,0,0)
- gtk_widget_set_halign(table, GTK_ALIGN_FILL);
- gtk_widget_set_valign(table, GTK_ALIGN_CENTER);
- gtk_grid_attach(GTK_GRID(table), a, col, row, 1, 1);
+ gtk_widget_set_halign(widget, GTK_ALIGN_FILL);
+ gtk_widget_set_valign(widget, GTK_ALIGN_START);
+ gtk_grid_attach(GTK_GRID(table), widget, col, row, 1, 1);
#else
+ GtkWidget *a = gtk_alignment_new (align, 0, 0, 0);
+ gtk_container_add(GTK_CONTAINER(a), widget);
gtk_table_attach ( GTK_TABLE (table), a, col, col + 1, row, row + 1, GTK_FILL, (GtkAttachOptions)0, 0, 0 );
#endif
}
diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp
index 6603d5c69..34cdb92e3 100644
--- a/src/ui/dialog/color-item.cpp
+++ b/src/ui/dialog/color-item.cpp
@@ -571,6 +571,8 @@ Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, ::PreviewS
widget = lbl;
} else {
GtkWidget* eekWidget = eek_preview_new();
+ gtk_widget_set_name( eekWidget, "ColorItemPreview" );
+
EekPreview * preview = EEK_PREVIEW(eekWidget);
Gtk::Widget* newBlot = Glib::wrap(eekWidget);
_regenPreview(preview);
diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp
index 7e9d8481a..ce08ed1f7 100644
--- a/src/ui/dialog/filter-effects-dialog.cpp
+++ b/src/ui/dialog/filter-effects-dialog.cpp
@@ -1364,6 +1364,7 @@ FilterEffectsDialog::FilterModifier::FilterModifier(FilterEffectsDialog& d)
_list.append_column("#", _columns.count);
_list.get_column(2)->set_sizing(Gtk::TREE_VIEW_COLUMN_AUTOSIZE);
_list.get_column(2)->set_expand(false);
+ _list.get_column(2)->set_reorderable(true);
sw->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
_list.get_column(1)->set_resizable(true);
@@ -1868,7 +1869,7 @@ void FilterEffectsDialog::PrimitiveList::update()
if(f) {
bool active_found = false;
- _dialog._primitive_box.set_sensitive(true);
+ _dialog._primitive_box->set_sensitive(true);
_dialog.update_filter_general_settings_view();
for(SPObject *prim_obj = f->children;
prim_obj && SP_IS_FILTER_PRIMITIVE(prim_obj);
@@ -1913,7 +1914,7 @@ void FilterEffectsDialog::PrimitiveList::update()
}
}
else {
- _dialog._primitive_box.set_sensitive(false);
+ _dialog._primitive_box->set_sensitive(false);
set_size_request(-1, -1);
}
}
@@ -2760,37 +2761,61 @@ FilterEffectsDialog::FilterEffectsDialog()
// Initialize widget hierarchy
#if WITH_GTKMM_3_0
Gtk::Paned* hpaned = Gtk::manage(new Gtk::Paned);
+ _primitive_box = Gtk::manage(new Gtk::Paned);
#else
Gtk::HPaned* hpaned = Gtk::manage(new Gtk::HPaned);
+ _primitive_box = Gtk::manage(new Gtk::VPaned);
#endif
+ _sw_infobox = Gtk::manage(new Gtk::ScrolledWindow);
Gtk::ScrolledWindow* sw_prims = Gtk::manage(new Gtk::ScrolledWindow);
- Gtk::ScrolledWindow* sw_infobox = Gtk::manage(new Gtk::ScrolledWindow);
Gtk::HBox* infobox = Gtk::manage(new Gtk::HBox(/*homogeneous:*/false, /*spacing:*/4));
Gtk::HBox* hb_prims = Gtk::manage(new Gtk::HBox);
Gtk::VBox* vb_prims = Gtk::manage(new Gtk::VBox);
+ Gtk::VBox* vb_desc = Gtk::manage(new Gtk::VBox);
+
+ Gtk::VBox* prim_vbox_p = Gtk::manage(new Gtk::VBox);
+ Gtk::VBox* prim_vbox_i = Gtk::manage(new Gtk::VBox);
- _getContents()->add(*hpaned);
- hpaned->pack1(_filter_modifier);
- hpaned->pack2(_primitive_box);
- _primitive_box.pack_start(*sw_prims);
- _primitive_box.pack_start(*sw_infobox, false, false);
sw_prims->add(_primitive_list);
- sw_infobox->add(*vb_prims);
- infobox->pack_start(_infobox_icon, false, false);
- infobox->pack_start(_infobox_desc, false, false);
+
+ prim_vbox_p->pack_start(*sw_prims, true, true);
+ prim_vbox_i->pack_start(*vb_prims, true, true);
+
+ _primitive_box->pack1(*prim_vbox_p);
+ _primitive_box->pack2(*prim_vbox_i, false, false);
+
+ hpaned->pack1(_filter_modifier);
+ hpaned->pack2(*_primitive_box);
+ _getContents()->add(*hpaned);
+
+ _infobox_icon.set_alignment(0, 0);
+ _infobox_desc.set_alignment(0, 0);
+ _infobox_desc.set_justify(Gtk::JUSTIFY_LEFT);
_infobox_desc.set_line_wrap(true);
- _infobox_desc.set_size_request(250, -1);
-
- vb_prims->pack_start(*hb_prims);
- vb_prims->pack_start(*infobox);
-
- hb_prims->pack_start(_add_primitive, false, false);
- hb_prims->pack_start(_add_primitive_type, false, false);
+ _infobox_desc.set_size_request(200, -1);
+
+ vb_desc->pack_start(_infobox_desc, true, true);
+
+ infobox->pack_start(_infobox_icon, false, false);
+ infobox->pack_start(*vb_desc, true, true);
+
+ //_sw_infobox->set_size_request(-1, -1);
+ _sw_infobox->set_size_request(200, -1);
+ _sw_infobox->add(*infobox);
+
+ //vb_prims->set_size_request(-1, 50);
+ vb_prims->pack_start(*hb_prims, false, false);
+ vb_prims->pack_start(*_sw_infobox, true, true);
+
+ hb_prims->pack_start(_add_primitive, false, false);
+ hb_prims->pack_start(_add_primitive_type, true, true);
_getContents()->pack_start(_settings_tabs, false, false);
_settings_tabs.append_page(_settings_tab1, _("Effect parameters"));
_settings_tabs.append_page(_settings_tab2, _("Filter General Settings"));
+
+
_primitive_list.signal_primitive_changed().connect(
sigc::mem_fun(*this, &FilterEffectsDialog::update_settings_view));
_filter_modifier.signal_filter_changed().connect(
@@ -2801,7 +2826,7 @@ FilterEffectsDialog::FilterEffectsDialog()
sw_prims->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
sw_prims->set_shadow_type(Gtk::SHADOW_IN);
- sw_infobox->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_NEVER);
+ _sw_infobox->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
// al_settings->set_padding(0, 0, 12, 0);
// fr_settings->set_shadow_type(Gtk::SHADOW_NONE);
@@ -2951,11 +2976,9 @@ void FilterEffectsDialog::update_primitive_infobox()
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/options/showfiltersinfobox/value", true)){
- _infobox_icon.show();
- _infobox_desc.show();
+ _sw_infobox->show();
} else {
- _infobox_icon.hide();
- _infobox_desc.hide();
+ _sw_infobox->hide();
}
switch(_add_primitive_type.get_active_data()->id){
case(NR_FILTER_BLEND):
@@ -3026,7 +3049,8 @@ void FilterEffectsDialog::update_primitive_infobox()
g_assert(false);
break;
}
- _infobox_icon.set_pixel_size(96);
+ //_infobox_icon.set_pixel_size(96);
+ _infobox_icon.set_pixel_size(64);
}
void FilterEffectsDialog::duplicate_primitive()
@@ -3138,11 +3162,9 @@ void FilterEffectsDialog::update_settings_view()
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/options/showfiltersinfobox/value", true)){
- _infobox_icon.show();
- _infobox_desc.show();
+ _sw_infobox->show();
} else {
- _infobox_icon.hide();
- _infobox_desc.hide();
+ _sw_infobox->hide();
}
SPFilterPrimitive* prim = _primitive_list.get_selected();
diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h
index 283abb5b0..7c715327e 100644
--- a/src/ui/dialog/filter-effects-dialog.h
+++ b/src/ui/dialog/filter-effects-dialog.h
@@ -28,6 +28,9 @@
#include <gtkmm/notebook.h>
#include <gtkmm/sizegroup.h>
+#include <gtkmm/paned.h>
+#include <gtkmm/scrolledwindow.h>
+
namespace Inkscape {
namespace UI {
namespace Dialog {
@@ -277,9 +280,15 @@ private:
// Primitives Info Box
Gtk::Label _infobox_desc;
Gtk::Image _infobox_icon;
+ Gtk::ScrolledWindow* _sw_infobox;
// View/add primitives
- Gtk::VBox _primitive_box;
+#if WITH_GTKMM_3_0
+ Gtk::Paned* _primitive_box;
+#else
+ Gtk::VPaned* _primitive_box;
+#endif
+
UI::Widget::ComboBoxEnum<Inkscape::Filters::FilterPrimitiveType> _add_primitive_type;
Gtk::Button _add_primitive;
diff --git a/src/ui/dialog/glyphs.h b/src/ui/dialog/glyphs.h
index 3d0571244..00c3ffa07 100644
--- a/src/ui/dialog/glyphs.h
+++ b/src/ui/dialog/glyphs.h
@@ -27,8 +27,6 @@ class font_instance;
namespace Inkscape {
namespace UI {
-class PreviewHolder;
-
namespace Dialog {
class GlyphColumns;
diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp
index b6d7e25ec..30bbd95c9 100644
--- a/src/ui/dialog/inkscape-preferences.cpp
+++ b/src/ui/dialog/inkscape-preferences.cpp
@@ -206,6 +206,15 @@ void InkscapePreferences::AddDotSizeSpinbutton(DialogPage &p, Glib::ustring cons
false );
}
+void InkscapePreferences::AddBaseSimplifySpinbutton(DialogPage &p, Glib::ustring const &prefs_path, double def_value)
+{
+ PrefSpinButton* sb = Gtk::manage( new PrefSpinButton);
+ sb->init ( prefs_path + "/base-simplify", 0.0, 100.0, 1.0, 10.0, def_value, false, false);
+ p.add_line( false, _("Base simplify:"), *sb, _("on dynamic LPE simplify"),
+ _("Base simplify of dynamic LPE based simplify"),
+ false );
+}
+
static void StyleFromSelectionToTool(Glib::ustring const &prefs_path, StyleSwatch *swatch)
{
@@ -425,6 +434,7 @@ void InkscapePreferences::initPageTools()
this->AddSelcueCheckbox(_page_pencil, "/tools/freehand/pencil", true);
this->AddNewObjectsStyle(_page_pencil, "/tools/freehand/pencil");
this->AddDotSizeSpinbutton(_page_pencil, "/tools/freehand/pencil", 3.0);
+ this->AddBaseSimplifySpinbutton(_page_pencil, "/tools/freehand/pencil", 25.0);
_page_pencil.add_group_header( _("Sketch mode"));
_page_pencil.add_line( true, "", _pencil_average_all_sketches, "",
_("If on, the sketch result will be the normal average of all sketches made, instead of averaging the old result with the new sketch"));
@@ -603,8 +613,9 @@ void InkscapePreferences::initPageUI()
_("Set the language for menus and number formats"), false);
{
- Glib::ustring sizeLabels[] = {C_("Icon size", "Large"), C_("Icon size", "Small"), C_("Icon size", "Smaller")};
- int sizeValues[] = {0, 1, 2};
+ Glib::ustring sizeLabels[] = {C_("Icon size", "Larger"), C_("Icon size", "Large"), C_("Icon size", "Small"), C_("Icon size", "Smaller")};
+ int sizeValues[] = {3, 0, 1, 2};
+ // "Larger" is 3 to not break existing preference files. Should fix in GTK3
_misc_small_tools.init( "/toolbox/tools/small", sizeLabels, sizeValues, G_N_ELEMENTS(sizeLabels), 0 );
_page_ui.add_line( false, _("Toolbox icon size:"), _misc_small_tools, "",
diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h
index b7696ab8c..d1abcfc58 100644
--- a/src/ui/dialog/inkscape-preferences.h
+++ b/src/ui/dialog/inkscape-preferences.h
@@ -502,6 +502,7 @@ protected:
static void AddConvertGuidesCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value);
static void AddFirstAndLastCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value);
static void AddDotSizeSpinbutton(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, double def_value);
+ static void AddBaseSimplifySpinbutton(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, double def_value);
static void AddNewObjectsStyle(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, const gchar* banner = NULL);
void on_pagelist_selection_changed();
diff --git a/src/ui/dialog/new-from-template.cpp b/src/ui/dialog/new-from-template.cpp
index e30b148bb..74ec7111e 100644
--- a/src/ui/dialog/new-from-template.cpp
+++ b/src/ui/dialog/new-from-template.cpp
@@ -29,10 +29,12 @@ NewFromTemplate::NewFromTemplate()
set_title(_("New From Template"));
resize(400, 400);
+ _main_widget = new TemplateLoadTab(this);
+
#if WITH_GTKMM_3_0
- get_content_area()->pack_start(_main_widget);
+ get_content_area()->pack_start(*_main_widget);
#else
- get_vbox()->pack_start(_main_widget);
+ get_vbox()->pack_start(*_main_widget);
#endif
Gtk::Alignment *align;
@@ -49,14 +51,24 @@ NewFromTemplate::NewFromTemplate()
_create_template_button.signal_clicked().connect(
sigc::mem_fun(*this, &NewFromTemplate::_createFromTemplate));
+ _create_template_button.set_sensitive(false);
show_all();
}
+NewFromTemplate::~NewFromTemplate()
+{
+ delete _main_widget;
+}
+
+void NewFromTemplate::setCreateButtonSensitive(bool value)
+{
+ _create_template_button.set_sensitive(value);
+}
void NewFromTemplate::_createFromTemplate()
{
- _main_widget.createTemplate();
+ _main_widget->createTemplate();
_onClose();
}
diff --git a/src/ui/dialog/new-from-template.h b/src/ui/dialog/new-from-template.h
index 2b40af2a6..c0b65affb 100644
--- a/src/ui/dialog/new-from-template.h
+++ b/src/ui/dialog/new-from-template.h
@@ -27,11 +27,13 @@ class NewFromTemplate : public Gtk::Dialog
friend class TemplateLoadTab;
public:
static void load_new_from_template();
-
+ void setCreateButtonSensitive(bool value);
+ virtual ~NewFromTemplate();
+
private:
NewFromTemplate();
Gtk::Button _create_template_button;
- TemplateLoadTab _main_widget;
+ TemplateLoadTab* _main_widget;
void _createFromTemplate();
void _onClose();
diff --git a/src/ui/dialog/object-properties.cpp b/src/ui/dialog/object-properties.cpp
index 75430ed44..be46129c4 100644
--- a/src/ui/dialog/object-properties.cpp
+++ b/src/ui/dialog/object-properties.cpp
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (C) 2012 Kris De Gussem <Kris.DeGussem@gmail.com>
- * c++ version based on former C-version (GPL v2) with authors:
+ * c++ version based on former C-version (GPL v2+) with authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* Johan Engelen <goejendaagh@zonnet.nl>
diff --git a/src/ui/dialog/object-properties.h b/src/ui/dialog/object-properties.h
index 093f273f6..dc28c0bad 100644
--- a/src/ui/dialog/object-properties.h
+++ b/src/ui/dialog/object-properties.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (C) 2012 Kris De Gussem <Kris.DeGussem@gmail.com>
- * c++version based on former C-version (GPL v2) with authors:
+ * c++version based on former C-version (GPL v2+) with authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* Johan Engelen <goejendaagh@zonnet.nl>
diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp
index 891048beb..27694a9ac 100644
--- a/src/ui/dialog/objects.cpp
+++ b/src/ui/dialog/objects.cpp
@@ -1907,8 +1907,8 @@ ObjectsPanel::ObjectsPanel() :
_popupMenu.append(*Gtk::manage(new Gtk::SeparatorMenuItem()));
- _watchingNonTop.push_back( &_addPopupItem( targetDesktop, SP_VERB_SELECTION_RAISE, GTK_STOCK_GO_UP, _("Up"), (int)BUTTON_UP ) );
- _watchingNonBottom.push_back( &_addPopupItem( targetDesktop, SP_VERB_SELECTION_LOWER, GTK_STOCK_GO_DOWN, _("Down"), (int)BUTTON_DOWN ) );
+ _watchingNonTop.push_back( &_addPopupItem( targetDesktop, SP_VERB_SELECTION_RAISE, "gtk-go-up", _("Up"), (int)BUTTON_UP ) );
+ _watchingNonBottom.push_back( &_addPopupItem( targetDesktop, SP_VERB_SELECTION_LOWER, "gtk-go-down", _("Down"), (int)BUTTON_DOWN ) );
_popupMenu.append(*Gtk::manage(new Gtk::SeparatorMenuItem()));
diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp
index a1c7d41bd..f2ee79d06 100644
--- a/src/ui/dialog/ocaldialogs.cpp
+++ b/src/ui/dialog/ocaldialogs.cpp
@@ -573,7 +573,7 @@ void StatusWidget::end_process()
clear();
}
-#if !GTK_CHECK_VERSION(3,6,0)
+#if !GTK_CHECK_VERSION(3,0,0)
SearchEntry::SearchEntry() : Gtk::Entry()
{
signal_changed().connect(sigc::mem_fun(*this, &SearchEntry::_on_changed));
@@ -1222,7 +1222,7 @@ ImportDialog::ImportDialog(Gtk::Window& parent_window, FileDialogType file_types
label_not_found = new Gtk::Label();
label_description = new Gtk::Label();
-#if GTK_CHECK_VERSION(3,6,0)
+#if GTK_CHECK_VERSION(3,0,0)
entry_search = new Gtk::SearchEntry();
#else
entry_search = new SearchEntry();
diff --git a/src/ui/dialog/ocaldialogs.h b/src/ui/dialog/ocaldialogs.h
index 6ceceb9ef..9de24d821 100644
--- a/src/ui/dialog/ocaldialogs.h
+++ b/src/ui/dialog/ocaldialogs.h
@@ -26,7 +26,7 @@
#include <cairomm/refptr.h>
-#if GTK_CHECK_VERSION(3,6,0)
+#if GTK_CHECK_VERSION(3,0,0)
# include <gtkmm/searchentry.h>
#endif
@@ -336,7 +336,7 @@ public:
Gtk::Label* label;
};
-#if !GTK_CHECK_VERSION(3,6,0)
+#if !GTK_CHECK_VERSION(3,0,0)
/**
* A Gtk::Entry with search & clear icons
*/
@@ -460,7 +460,7 @@ private:
Glib::ustring filename_image;
Glib::ustring filename_thumbnail;
-#if GTK_CHECK_VERSION(3,6,0)
+#if GTK_CHECK_VERSION(3,0,0)
Gtk::SearchEntry *entry_search;
#else
SearchEntry *entry_search;
diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp
index ed1cd2079..f2298b59b 100644
--- a/src/ui/dialog/swatches.cpp
+++ b/src/ui/dialog/swatches.cpp
@@ -393,10 +393,10 @@ static bool parseNum( char*& str, int& val ) {
}
-void _loadPaletteFile( gchar const *filename, gboolean user/*=FALSE*/ )
+void _loadPaletteFile( gchar const *filename, gchar const *path, gboolean user/*=FALSE*/ )
{
char block[1024];
- FILE *f = Inkscape::IO::fopen_utf8name( filename, "r" );
+ FILE *f = Inkscape::IO::fopen_utf8name(path, "r" );
if ( f ) {
char* result = fgets( block, sizeof(block), f );
if ( result ) {
@@ -405,6 +405,7 @@ void _loadPaletteFile( gchar const *filename, gboolean user/*=FALSE*/ )
bool hasErr = false;
SwatchPage *onceMore = new SwatchPage();
+ onceMore->_name = filename;
do {
result = fgets( block, sizeof(block), f );
@@ -521,7 +522,7 @@ compare_swatch_names(SwatchPage const *a, SwatchPage const *b) {
static void loadEmUp()
{
static bool beenHere = false;
- gboolean userPalete = true;
+ gboolean userPalette = true;
if ( !beenHere ) {
beenHere = true;
@@ -549,7 +550,7 @@ static void loadEmUp()
if ( !g_str_has_suffix(lower, "~") ) {
gchar* full = g_build_filename(dirname, filename, NULL);
if ( !Inkscape::IO::file_test( full, G_FILE_TEST_IS_DIR ) ) {
- _loadPaletteFile(full, userPalete);
+ _loadPaletteFile(filename, full, userPalette);
}
g_free(full);
}
@@ -563,7 +564,7 @@ static void loadEmUp()
// toss the dirname
g_free(dirname);
sources.pop_front();
- userPalete = false;
+ userPalette = false;
}
}
@@ -593,6 +594,7 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) :
_currentDesktop(0),
_currentDocument(0)
{
+ set_name( "SwatchesPanel" );
Gtk::RadioMenuItem* hotItem = 0;
_holder = new PreviewHolder();
_clear = new ColorItem( ege::PaintDef::CLEAR );
diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp
index cbb2fb953..c99c1bff3 100644
--- a/src/ui/dialog/tags.cpp
+++ b/src/ui/dialog/tags.cpp
@@ -935,7 +935,17 @@ TagsPanel::TagsPanel() :
_tree.set_headers_visible(false);
_tree.set_reorderable(true);
_tree.enable_model_drag_dest (Gdk::ACTION_MOVE);
-
+
+ // This string is constructed to use already translated strings.
+ // The tooltip applies to the whole tree area. It would be better
+ // if the tooltip was split into parts and only applied to the
+ // icons but doing that is quite complicated.
+ Glib::ustring tooltip_string = "'+': ";
+ tooltip_string += (_("Add selection to set"));
+ tooltip_string += "; '×': ";
+ tooltip_string += (_("Remove from selection set"));
+ _tree.set_tooltip_text( tooltip_string );
+
Inkscape::UI::Widget::AddToIcon * addRenderer = manage( new Inkscape::UI::Widget::AddToIcon());
int addColNum = _tree.append_column("type", *addRenderer) - 1;
Gtk::TreeViewColumn *col = _tree.get_column(addColNum);
diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp
index fca1f7b30..7eb04ff79 100644
--- a/src/ui/dialog/template-load-tab.cpp
+++ b/src/ui/dialog/template-load-tab.cpp
@@ -35,10 +35,11 @@
namespace Inkscape {
namespace UI {
-TemplateLoadTab::TemplateLoadTab()
+TemplateLoadTab::TemplateLoadTab(NewFromTemplate* parent)
: _current_keyword("")
, _keywords_combo(true)
, _current_search_type(ALL)
+ , _parent_widget(parent)
{
set_border_width(10);
@@ -94,7 +95,8 @@ void TemplateLoadTab::_displayTemplateInfo()
if (templateSelectionRef->get_selected()) {
_current_template = (*templateSelectionRef->get_selected())[_columns.textValue];
- _info_widget->display(_tdata[_current_template]);
+ _info_widget->display(_tdata[_current_template]);
+ _parent_widget->setCreateButtonSensitive(true);
}
}
@@ -148,11 +150,10 @@ void TemplateLoadTab::_keywordSelected()
void TemplateLoadTab::_refreshTemplatesList()
{
- _tlist_store->clear();
-
+ _tlist_store->clear();
+
switch (_current_search_type){
case ALL :{
-
for (std::map<Glib::ustring, TemplateData>::iterator it = _tdata.begin() ; it != _tdata.end() ; ++it) {
Gtk::TreeModel::iterator iter = _tlist_store->append();
Gtk::TreeModel::Row row = *iter;
@@ -160,7 +161,7 @@ void TemplateLoadTab::_refreshTemplatesList()
}
break;
}
-
+
case LIST_KEYWORD: {
for (std::map<Glib::ustring, TemplateData>::iterator it = _tdata.begin() ; it != _tdata.end() ; ++it) {
if (it->second.keywords.count(_current_keyword.lowercase()) != 0){
@@ -171,10 +172,10 @@ void TemplateLoadTab::_refreshTemplatesList()
}
break;
}
-
+
case USER_SPECIFIED : {
for (std::map<Glib::ustring, TemplateData>::iterator it = _tdata.begin() ; it != _tdata.end() ; ++it) {
- if (it->second.keywords.count(_current_keyword.lowercase()) != 0 ||
+ if (it->second.keywords.count(_current_keyword.lowercase()) != 0 ||
it->second.display_name.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos ||
it->second.author.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos ||
it->second.short_description.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos ||
@@ -188,6 +189,27 @@ void TemplateLoadTab::_refreshTemplatesList()
break;
}
}
+
+ // reselect item
+ Gtk::TreeIter* item_to_select = NULL;
+ for (Gtk::TreeModel::Children::iterator it = _tlist_store->children().begin(); it != _tlist_store->children().end(); ++it) {
+ Gtk::TreeModel::Row row = *it;
+ if (_current_template == row[_columns.textValue]) {
+ item_to_select = new Gtk::TreeIter(it);
+ break;
+ }
+ }
+ if (_tlist_store->children().size() == 1) {
+ item_to_select = new Gtk::TreeIter(_tlist_store->children().begin());
+ }
+ if (item_to_select) {
+ _tlist_view.get_selection()->select(*item_to_select);
+ delete item_to_select;
+ } else {
+ _current_template = "";
+ _info_widget->clear();
+ _parent_widget->setCreateButtonSensitive(false);
+ }
}
diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h
index 920ae6ca2..d11c4c77f 100644
--- a/src/ui/dialog/template-load-tab.h
+++ b/src/ui/dialog/template-load-tab.h
@@ -28,6 +28,7 @@ namespace Inkscape {
namespace UI {
class TemplateWidget;
+class NewFromTemplate;
class TemplateLoadTab : public Gtk::HBox
{
@@ -47,7 +48,7 @@ public:
Inkscape::Extension::Effect *tpl_effect;
};
- TemplateLoadTab();
+ TemplateLoadTab(NewFromTemplate* parent);
virtual ~TemplateLoadTab();
virtual void createTemplate();
@@ -95,6 +96,7 @@ private:
};
SearchType _current_search_type;
+ NewFromTemplate* _parent_widget;
void _getDataFromNode(Inkscape::XML::Node *, TemplateData &);
void _getProceduralTemplates();
diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp
index eff75b311..0d110d853 100644
--- a/src/ui/dialog/template-widget.cpp
+++ b/src/ui/dialog/template-widget.cpp
@@ -56,6 +56,7 @@ TemplateWidget::TemplateWidget()
_more_info_button.signal_clicked().connect(
sigc::mem_fun(*this, &TemplateWidget::_displayTemplateDetails));
+ _more_info_button.set_sensitive(false);
}
@@ -85,14 +86,12 @@ void TemplateWidget::create()
void TemplateWidget::display(TemplateLoadTab::TemplateData data)
{
+ clear();
_current_template = data;
_template_name_label.set_text(_current_template.display_name);
_short_description_label.set_text(_current_template.short_description);
-
- _preview_render.hide();
- _preview_image.hide();
-
+
std::string imagePath = Glib::build_filename(Glib::path_get_dirname(_current_template.path), _current_template.preview_name);
if (data.preview_name != ""){
_preview_image.set(imagePath);
@@ -103,17 +102,26 @@ void TemplateWidget::display(TemplateLoadTab::TemplateData data)
_preview_render.showImage(gPath);
_preview_render.show();
}
-
- if (_effect_prefs != NULL){
- remove (*_effect_prefs);
- _effect_prefs = NULL;
- }
+
if (data.is_procedural){
_effect_prefs = data.tpl_effect->get_imp()->prefs_effect(data.tpl_effect, SP_ACTIVE_DESKTOP, NULL, NULL);
pack_start(*_effect_prefs);
}
+ _more_info_button.set_sensitive(true);
}
+void TemplateWidget::clear()
+{
+ _template_name_label.set_text("");
+ _short_description_label.set_text("");
+ _preview_render.hide();
+ _preview_image.hide();
+ if (_effect_prefs != NULL){
+ remove (*_effect_prefs);
+ _effect_prefs = NULL;
+ }
+ _more_info_button.set_sensitive(false);
+}
void TemplateWidget::_displayTemplateDetails()
{
diff --git a/src/ui/dialog/template-widget.h b/src/ui/dialog/template-widget.h
index bb35d26a0..13488089c 100644
--- a/src/ui/dialog/template-widget.h
+++ b/src/ui/dialog/template-widget.h
@@ -28,6 +28,7 @@ public:
TemplateWidget ();
void create();
void display(TemplateLoadTab::TemplateData);
+ void clear();
private:
TemplateLoadTab::TemplateData _current_template;
diff --git a/src/ui/draw-anchor.cpp b/src/ui/draw-anchor.cpp
index 6b9a88ed7..c3bc5676d 100644
--- a/src/ui/draw-anchor.cpp
+++ b/src/ui/draw-anchor.cpp
@@ -78,6 +78,7 @@ SPDrawAnchor *sp_draw_anchor_test(SPDrawAnchor *anchor, Geom::Point w, bool acti
if ( activate && ( Geom::LInfty( w - anchor->dc->getDesktop().d2w(anchor->dp) ) <= (ctrl->box.width() / 2.0) ) ) {
if (!anchor->active) {
+ ControlManager::getManager().setControlResize(anchor->ctrl, 4);
g_object_set(anchor->ctrl, "fill_color", FILL_COLOR_MOUSEOVER, NULL);
anchor->active = TRUE;
}
@@ -85,9 +86,11 @@ SPDrawAnchor *sp_draw_anchor_test(SPDrawAnchor *anchor, Geom::Point w, bool acti
}
if (anchor->active) {
+ ControlManager::getManager().setControlResize(anchor->ctrl, 0);
g_object_set(anchor->ctrl, "fill_color", FILL_COLOR_NORMAL, NULL);
anchor->active = FALSE;
}
+
return NULL;
}
diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp
index 69b229519..3e2a2004c 100644
--- a/src/ui/interface.cpp
+++ b/src/ui/interface.cpp
@@ -79,6 +79,10 @@
#include "message-stack.h"
#include "ui/dialog/layer-properties.h"
+#if GTK_CHECK_VERSION(3,0,0)
+ #include "widgets/image-menu-item.h"
+#endif
+
#include <gdk/gdkkeysyms.h>
#include <glibmm/miscutils.h>
@@ -413,7 +417,11 @@ sp_ui_menuitem_add_icon( GtkWidget *item, gchar *icon_name )
icon = sp_icon_new( Inkscape::ICON_SIZE_MENU, icon_name );
gtk_widget_show(icon);
+#if GTK_CHECK_VERSION(3,0,0)
+ image_menu_item_set_image((ImageMenuItem *) item, icon);
+#else
gtk_image_menu_item_set_image((GtkImageMenuItem *) item, icon);
+#endif
} // end of sp_ui_menu_add_icon
void
@@ -467,7 +475,11 @@ static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb
if (radio) {
item = gtk_radio_menu_item_new_with_mnemonic(group, action->name);
} else {
+#if GTK_CHECK_VERSION(3,0,0)
+ item = image_menu_item_new_with_mnemonic(action->name);
+#else
item = gtk_image_menu_item_new_with_mnemonic(action->name);
+#endif
}
gtk_label_set_markup_with_mnemonic( GTK_LABEL(gtk_bin_get_child(GTK_BIN (item))), action->name);
@@ -1018,7 +1030,7 @@ sp_ui_drag_data_received(GtkWidget *widget,
{
int destX = 0;
int destY = 0;
- gtk_widget_translate_coordinates( widget, &(desktop->canvas->widget), x, y, &destX, &destY );
+ gtk_widget_translate_coordinates( widget, GTK_WIDGET(desktop->canvas), x, y, &destX, &destY );
Geom::Point where( sp_canvas_window_to_world( desktop->canvas, Geom::Point( destX, destY ) ) );
Geom::Point const button_dt(desktop->w2d(where));
Geom::Point const button_doc(desktop->dt2doc(button_dt));
@@ -1141,7 +1153,7 @@ sp_ui_drag_data_received(GtkWidget *widget,
if ( worked ) {
int destX = 0;
int destY = 0;
- gtk_widget_translate_coordinates( widget, &(desktop->canvas->widget), x, y, &destX, &destY );
+ gtk_widget_translate_coordinates( widget, GTK_WIDGET(desktop->canvas), x, y, &destX, &destY );
Geom::Point where( sp_canvas_window_to_world( desktop->canvas, Geom::Point( destX, destY ) ) );
Geom::Point const button_dt(desktop->w2d(where));
Geom::Point const button_doc(desktop->dt2doc(button_dt));
@@ -1511,6 +1523,12 @@ ContextMenu::ContextMenu(SPDesktop *desktop, SPItem *item) :
MIParent.signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::LeaveGroup));
MIParent.show();
append(MIParent);
+
+ /* Pop selection out of group */
+ Gtk::MenuItem* miu = Gtk::manage(new Gtk::MenuItem(_("_Pop selection out of group"), 1));
+ miu->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ActivateUngroupPopSelection));
+ miu->show();
+ append(*miu);
}
}
}
@@ -1786,7 +1804,7 @@ void ContextMenu::MakeItemMenu (void)
/* Group */
mi = Gtk::manage(new Gtk::MenuItem(_("_Group"), 1));
mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ActivateGroup));
- if (_desktop->selection->isEmpty() || _desktop->selection->single()) {
+ if (_desktop->selection->isEmpty()) {
mi->set_sensitive(FALSE);
} else {
mi->set_sensitive(TRUE);
@@ -1908,6 +1926,12 @@ void ContextMenu::ActivateUngroup(void)
sp_item_group_ungroup(static_cast<SPGroup*>(_item), children);
_desktop->selection->setList(children);
}
+
+void ContextMenu::ActivateUngroupPopSelection(void)
+{
+ sp_selection_ungroup_pop_selection(_desktop->selection, _desktop);
+}
+
void ContextMenu::MakeAnchorMenu(void)
{
diff --git a/src/ui/interface.h b/src/ui/interface.h
index 6fb74046f..52074f0f0 100644
--- a/src/ui/interface.h
+++ b/src/ui/interface.h
@@ -194,6 +194,7 @@ class ContextMenu : public Gtk::Menu
/**
* callback, is executed on clicking the anchor "Group" and "Ungroup" menu entry
*/
+ void ActivateUngroupPopSelection(void);
void ActivateUngroup(void);
void ActivateGroup(void);
diff --git a/src/ui/previewholder.cpp b/src/ui/previewholder.cpp
index 21f3f38d7..5e75179a3 100644
--- a/src/ui/previewholder.cpp
+++ b/src/ui/previewholder.cpp
@@ -49,16 +49,20 @@ PreviewHolder::PreviewHolder() :
_wrap(false),
_border(BORDER_NONE)
{
+ set_name( "PreviewHolder" );
_scroller = Gtk::manage(new Gtk::ScrolledWindow());
+ _scroller->set_name( "PreviewHolderScroller" );
((Gtk::ScrolledWindow *)_scroller)->set_policy(Gtk::POLICY_AUTOMATIC,
Gtk::POLICY_AUTOMATIC);
#if WITH_GTKMM_3_0
_insides = Gtk::manage(new Gtk::Grid());
+ _insides->set_name( "PreviewHolderGrid" );
_insides->set_column_spacing(8);
// Add a container with the scroller and a spacer
Gtk::Grid* spaceHolder = Gtk::manage(new Gtk::Grid());
+ spaceHolder->set_name( "PreviewHolderSpaceHolder" );
_scroller->set_hexpand();
_scroller->set_vexpand();
@@ -340,6 +344,12 @@ void PreviewHolder::calcGridSize( const Gtk::Widget* thing, int itemCount, int&
width = itemCount;
height = 1;
+#if GTK_CHECK_VERSION(3,16,0)
+ // Disable overlay scrolling as the scrollbar covers up swatches.
+ // For some reason this also makes the height 55px.
+ ((Gtk::ScrolledWindow *)_scroller)->set_overlay_scrolling(false);
+#endif
+
if ( _anchor == SP_ANCHOR_SOUTH || _anchor == SP_ANCHOR_NORTH ) {
Gtk::Requisition req;
#if GTK_CHECK_VERSION(3,0,0)
diff --git a/src/ui/previewholder.h b/src/ui/previewholder.h
index f6d1985cc..28c0fd865 100644
--- a/src/ui/previewholder.h
+++ b/src/ui/previewholder.h
@@ -3,6 +3,7 @@
#define SEEN_PREVIEW_HOLDER_H
/*
* A simple interface for previewing representations.
+ * Used by Swatches
*
* Authors:
* Jon A. Cruz
diff --git a/src/ui/selected-color.cpp b/src/ui/selected-color.cpp
index 8c37ee7e0..846d50a5b 100644
--- a/src/ui/selected-color.cpp
+++ b/src/ui/selected-color.cpp
@@ -139,7 +139,6 @@ void SelectedColor::setHeld(bool held) {
if (released) {
signal_released.emit();
- signal_changed.emit();
}
_updating = false;
}
diff --git a/src/ui/tool/control-point-selection.cpp b/src/ui/tool/control-point-selection.cpp
index 998f74ee0..f36ad7374 100644
--- a/src/ui/tool/control-point-selection.cpp
+++ b/src/ui/tool/control-point-selection.cpp
@@ -19,6 +19,8 @@
#include "ui/tool/transform-handle-set.h"
#include "ui/tool/node.h"
+
+
#include <gdk/gdkkeysyms.h>
namespace Inkscape {
@@ -82,6 +84,7 @@ std::pair<ControlPointSelection::iterator, bool> ControlPointSelection::insert(c
}
found = _points.insert(x).first;
+ _points_list.push_back(x);
x->updateState();
_pointChanged(x, true);
@@ -97,6 +100,7 @@ std::pair<ControlPointSelection::iterator, bool> ControlPointSelection::insert(c
void ControlPointSelection::erase(iterator pos)
{
SelectableControlPoint *erased = *pos;
+ _points_list.remove(*pos);
_points.erase(pos);
erased->updateState();
_pointChanged(erased, false);
@@ -219,8 +223,11 @@ void ControlPointSelection::transform(Geom::Affine const &m)
/** Align control points on the specified axis. */
void ControlPointSelection::align(Geom::Dim2 axis)
{
+ enum AlignTargetNode { LAST_NODE=0, FIRST_NODE, MID_NODE, MIN_NODE, MAX_NODE };
if (empty()) return;
Geom::Dim2 d = static_cast<Geom::Dim2>((axis + 1) % 2);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
Geom::OptInterval bound;
for (iterator i = _points.begin(); i != _points.end(); ++i) {
@@ -229,7 +236,27 @@ void ControlPointSelection::align(Geom::Dim2 axis)
if (!bound) { return; }
- double new_coord = bound->middle();
+ double new_coord;
+ switch (AlignTargetNode(prefs->getInt("/dialogs/align/align-nodes-to", 2))){
+ case FIRST_NODE:
+ new_coord=(_points_list.front())->position()[d];
+ break;
+ case LAST_NODE:
+ new_coord=(_points_list.back())->position()[d];
+ break;
+ case MID_NODE:
+ new_coord=bound->middle();
+ break;
+ case MIN_NODE:
+ new_coord=bound->min();
+ break;
+ case MAX_NODE:
+ new_coord=bound->max();
+ break;
+ default:
+ return;
+ }
+
for (iterator i = _points.begin(); i != _points.end(); ++i) {
Geom::Point pos = (*i)->position();
pos[d] = new_coord;
diff --git a/src/ui/tool/control-point-selection.h b/src/ui/tool/control-point-selection.h
index 2d812c0a3..f122a468d 100644
--- a/src/ui/tool/control-point-selection.h
+++ b/src/ui/tool/control-point-selection.h
@@ -12,6 +12,7 @@
#ifndef SEEN_UI_TOOL_CONTROL_POINT_SELECTION_H
#define SEEN_UI_TOOL_CONTROL_POINT_SELECTION_H
+#include <list>
#include <memory>
#include <boost/optional.hpp>
#include <stddef.h>
@@ -140,6 +141,8 @@ private:
double _rotationRadius(Geom::Point const &);
set_type _points;
+ //the purpose of this list is to keep track of first and last selected
+ std::list<SelectableControlPoint *> _points_list;
set_type _all_points;
INK_UNORDERED_MAP<SelectableControlPoint *, Geom::Point> _original_positions;
INK_UNORDERED_MAP<SelectableControlPoint *, Geom::Affine> _last_trans;
diff --git a/src/ui/tool/event-utils.cpp b/src/ui/tool/event-utils.cpp
index 079275d63..6b8d5f0dc 100644
--- a/src/ui/tool/event-utils.cpp
+++ b/src/ui/tool/event-utils.cpp
@@ -60,8 +60,8 @@ unsigned combine_motion_events(SPCanvas *canvas, GdkEventMotion &event, gint mas
}
GdkEvent *event_next;
gint i = 0;
- event.x -= canvas->x0;
- event.y -= canvas->y0;
+ event.x -= canvas->_x0;
+ event.y -= canvas->_y0;
event_next = gdk_event_get();
// while the next event is also a motion notify
@@ -92,8 +92,8 @@ unsigned combine_motion_events(SPCanvas *canvas, GdkEventMotion &event, gint mas
if (event_next) {
gdk_event_put(event_next);
}
- event.x += canvas->x0;
- event.y += canvas->y0;
+ event.x += canvas->_x0;
+ event.y += canvas->_y0;
return i;
}
diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp
index f4790c317..3b25439f3 100644
--- a/src/ui/tool/path-manipulator.cpp
+++ b/src/ui/tool/path-manipulator.cpp
@@ -1492,7 +1492,6 @@ void PathManipulator::_getGeometry()
void PathManipulator::_setGeometry()
{
using namespace Inkscape::LivePathEffect;
- if (empty()) return;
if (!_lpe_key.empty()) {
// copied from nodepath.cpp
@@ -1505,6 +1504,7 @@ void PathManipulator::_setGeometry()
LIVEPATHEFFECT(_path)->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
} else {
+ if (empty()) return;
//XML Tree being used here directly while it shouldn't be.
if (_path->getRepr()->attribute("inkscape:original-d"))
_path->set_original_curve(_spcurve, false, false);
diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp
index b84d16686..74f2664fe 100644
--- a/src/ui/tools/connector-tool.cpp
+++ b/src/ui/tools/connector-tool.cpp
@@ -247,7 +247,7 @@ void ConnectorTool::setup() {
// Make sure we see all enter events for canvas items,
// even if a mouse button is depressed.
- this->desktop->canvas->gen_all_enter_events = true;
+ this->desktop->canvas->_gen_all_enter_events = true;
}
void ConnectorTool::set(const Inkscape::Preferences::Entry& val) {
@@ -276,7 +276,7 @@ void ConnectorTool::finish() {
this->cc_clear_active_conn();
// Restore the default event generating behaviour.
- this->desktop->canvas->gen_all_enter_events = false;
+ this->desktop->canvas->_gen_all_enter_events = false;
}
//-----------------------------------------------------------------------------
diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp
index 83ecf7a0a..6b32b5901 100644
--- a/src/ui/tools/eraser-tool.cpp
+++ b/src/ui/tools/eraser-tool.cpp
@@ -64,8 +64,11 @@
#include "livarot/Shape.h"
#include "document-undo.h"
#include "verbs.h"
+#include "style.h"
+#include "style-enums.h"
#include <2geom/math-utils.h>
#include <2geom/pathvector.h>
+#include "path-chemistry.h"
#include "display/curve.h"
#include "ui/tools/eraser-tool.h"
@@ -96,6 +99,7 @@ const std::string EraserTool::prefsPath = "/tools/eraser";
EraserTool::EraserTool()
: DynamicBase(cursor_eraser_xpm, 4, 4)
+ , nowidth(false)
{
}
@@ -145,6 +149,7 @@ static ProfileFloatElement f_profile[PROFILE_FLOAT_SIZE] = {
sp_event_context_read(this, "cap_rounding");
this->is_drawing = false;
+ //TODO not sure why get 0.01 if slider width == 0, maybe a double/int problem
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/tools/eraser/selcue", 0) != 0) {
@@ -339,7 +344,10 @@ void EraserTool::brush() {
this->point1[this->npoints] = brush + del_left;
this->point2[this->npoints] = brush - del_right;
-
+
+ if (this->nowidth) {
+ this->point1[this->npoints] = Geom::middle_point(this->point1[this->npoints],this->point2[this->npoints]);
+ }
this->del = 0.5*(del_left + del_right);
this->npoints++;
@@ -371,7 +379,8 @@ void EraserTool::cancel() {
bool EraserTool::root_handler(GdkEvent* event) {
gint ret = FALSE;
-
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0;
switch (event->type) {
case GDK_BUTTON_PRESS:
if (event->button.button == 1 && !this->space_panning) {
@@ -391,10 +400,10 @@ bool EraserTool::root_handler(GdkEvent* event) {
if (this->repr) {
this->repr = NULL;
}
-
- Inkscape::Rubberband::get(desktop)->start(desktop, button_dt);
- Inkscape::Rubberband::get(desktop)->setMode(RUBBERBAND_MODE_TOUCHPATH);
-
+ if ( ! eraserMode ) {
+ Inkscape::Rubberband::get(desktop)->start(desktop, button_dt);
+ Inkscape::Rubberband::get(desktop)->setMode(RUBBERBAND_MODE_TOUCHPATH);
+ }
/* initialize first point */
this->npoints = 0;
@@ -439,8 +448,10 @@ bool EraserTool::root_handler(GdkEvent* event) {
ret = TRUE;
}
-
- Inkscape::Rubberband::get(desktop)->move(motion_dt);
+ if ( !eraserMode ) {
+ this->accumulated->reset();
+ Inkscape::Rubberband::get(desktop)->move(motion_dt);
+ }
}
break;
@@ -480,7 +491,7 @@ bool EraserTool::root_handler(GdkEvent* event) {
ret = TRUE;
}
- if (Inkscape::Rubberband::get(desktop)->is_started()) {
+ if (!eraserMode && Inkscape::Rubberband::get(desktop)->is_started()) {
Inkscape::Rubberband::get(desktop)->stop();
}
@@ -489,33 +500,32 @@ bool EraserTool::root_handler(GdkEvent* event) {
case GDK_KEY_PRESS:
switch (get_group0_keyval (&event->key)) {
- case GDK_KEY_Up:
- case GDK_KEY_KP_Up:
- if (!MOD__CTRL_ONLY(event)) {
- this->angle += 5.0;
-
- if (this->angle > 90.0) {
- this->angle = 90.0;
- }
-
- sp_erc_update_toolbox (desktop, "eraser-angle", this->angle);
- ret = TRUE;
- }
- break;
-
- case GDK_KEY_Down:
- case GDK_KEY_KP_Down:
- if (!MOD__CTRL_ONLY(event)) {
- this->angle -= 5.0;
-
- if (this->angle < -90.0) {
- this->angle = -90.0;
- }
-
- sp_erc_update_toolbox (desktop, "eraser-angle", this->angle);
- ret = TRUE;
- }
- break;
+// case GDK_KEY_Up:
+// case GDK_KEY_KP_Up:
+// if (!MOD__CTRL_ONLY(event)) {
+// this->angle += 5.0;
+
+// if (this->angle > 90.0) {
+// this->angle = 90.0;
+// }
+// sp_erc_update_toolbox (desktop, "eraser-angle", this->angle);
+// ret = TRUE;
+// }
+// break;
+
+// case GDK_KEY_Down:
+// case GDK_KEY_KP_Down:
+// if (!MOD__CTRL_ONLY(event)) {
+// this->angle -= 5.0;
+
+// if (this->angle < -90.0) {
+// this->angle = -90.0;
+// }
+
+// sp_erc_update_toolbox (desktop, "eraser-angle", this->angle);
+// ret = TRUE;
+// }
+// break;
case GDK_KEY_Right:
case GDK_KEY_KP_Right:
@@ -568,8 +578,9 @@ bool EraserTool::root_handler(GdkEvent* event) {
break;
case GDK_KEY_Escape:
- Inkscape::Rubberband::get(desktop)->stop();
-
+ if ( !eraserMode ) {
+ Inkscape::Rubberband::get(desktop)->stop();
+ }
if (this->is_drawing) {
// if drawing, cancel, otherwise pass it up for deselecting
this->cancel();
@@ -640,15 +651,12 @@ void EraserTool::set_to_accumulated() {
sp_desktop_apply_style_tool (desktop, repr, "/tools/eraser", false);
this->repr = repr;
-
- SPItem *item=SP_ITEM(desktop->currentLayer()->appendChildRepr(this->repr));
- Inkscape::GC::release(this->repr);
-
- item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse();
- item->updateRepr();
}
-
+ SPItem *item = SP_ITEM(desktop->currentLayer()->appendChildRepr(this->repr));
+ Inkscape::GC::release(this->repr);
+ item->updateRepr();
Geom::PathVector pathv = this->accumulated->get_pathvector() * desktop->dt2doc();
+ pathv *= item->i2doc_affine().inverse();
gchar *str = sp_svg_write_path(pathv);
g_assert( str != NULL );
this->repr->setAttribute("d", str);
@@ -658,49 +666,86 @@ void EraserTool::set_to_accumulated() {
bool wasSelection = false;
Inkscape::Selection *selection = desktop->getSelection();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
-
gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0;
Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
SPItem* acid = SP_ITEM(desktop->doc()->getObjectByRepr(this->repr));
- Geom::OptRect eraserBbox = acid->visualBounds();
- Geom::Rect bounds = (*eraserBbox) * desktop->doc2dt();
+ Geom::OptRect eraserBbox = acid->desktopVisualBounds();
std::vector<SPItem*> remainingItems;
std::vector<SPItem*> toWorkOn;
if (selection->isEmpty()) {
if ( eraserMode ) {
- toWorkOn = desktop->getDocument()->getItemsPartiallyInBox(desktop->dkey, bounds);
+ toWorkOn = desktop->getDocument()->getItemsPartiallyInBox(desktop->dkey, *eraserBbox);
} else {
Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop);
toWorkOn = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints());
}
toWorkOn.erase(std::remove(toWorkOn.begin(), toWorkOn.end(), acid), toWorkOn.end());
} else {
- toWorkOn= selection->itemList();
+ if ( !eraserMode ) {
+ Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop);
+ std::vector<SPItem*> touched;
+ touched = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints());
+ for (std::vector<SPItem*>::const_iterator i = touched.begin();i!=touched.end();++i) {
+ if(selection->includes(*i)){
+ toWorkOn.push_back((*i));
+ }
+ }
+ } else {
+ toWorkOn = selection->itemList();
+ }
wasSelection = true;
}
if ( !toWorkOn.empty() ) {
if ( eraserMode ) {
for (std::vector<SPItem*>::const_iterator i = toWorkOn.begin(); i != toWorkOn.end(); ++i){
- SPItem *item = *i;
-
- if ( eraserMode ) {
- Geom::OptRect bbox = item->visualBounds();
-
+ SPItem *item = *i;
+ SPUse *use = dynamic_cast<SPUse *>(item);
+ if (SP_IS_PATH(item) && SP_PATH(item)->nodesInPath () == 2){
+ sp_object_ref( *i, 0 );
+ SPItem *item = *i;
+ item->deleteObject(true);
+ sp_object_unref(item);
+ workDone = true;
+ workDone = true;
+ } else if (SP_IS_GROUP(item) || use ) {
+ /*Do nothing*/
+ } else {
+ Geom::OptRect bbox = item->desktopVisualBounds();
if (bbox && bbox->intersects(*eraserBbox)) {
Inkscape::XML::Node* dup = this->repr->duplicate(xml_doc);
this->repr->parent()->appendChild(dup);
Inkscape::GC::release(dup); // parent takes over
-
- selection->set(item);
- selection->add(dup);
- sp_selected_path_diff_skip_undo(selection, desktop);
+ selection->set(dup);
+ if (!this->nowidth) {
+ sp_selected_path_union_skip_undo(selection, desktop);
+ }
+ selection->add(item);
+ if(item->style->fill_rule.value == SP_WIND_RULE_EVENODD){
+ SPCSSAttr *css = sp_repr_css_attr_new();
+ sp_repr_css_set_property(css, "fill-rule", "evenodd");
+ sp_desktop_set_style(desktop, css);
+ sp_repr_css_attr_unref(css);
+ css = 0;
+ }
+ if (this->nowidth) {
+ sp_selected_path_cut_skip_undo(selection, desktop);
+ } else {
+ sp_selected_path_diff_skip_undo(selection, desktop);
+ }
workDone = true; // TODO set this only if something was cut.
-
+ bool break_apart = prefs->getBool("/tools/eraser/break_apart", false);
+ if(!break_apart){
+ sp_selected_path_combine(desktop, true);
+ } else {
+ if(!this->nowidth){
+ sp_selected_path_break_apart(desktop, true);
+ }
+ }
if ( !selection->isEmpty() ) {
// If the item was not completely erased, track the new remainder.
- std::vector<SPItem*> nowSel(selection->itemList());
+ std::vector<SPItem*> nowSel(selection->itemList());
for (std::vector<SPItem*>::const_iterator i2 = nowSel.begin();i2!=nowSel.end();++i2) {
remainingItems.push_back(*i2);
}
@@ -736,7 +781,6 @@ void EraserTool::set_to_accumulated() {
}
}
}
-
// Remove the eraser stroke itself:
sp_repr_unparent( this->repr );
this->repr = 0;
@@ -811,24 +855,25 @@ void EraserTool::accumulate() {
g_assert( rev_cal2_lastseg );
this->accumulated->append(this->cal1, FALSE);
-
- add_cap(this->accumulated,
- dc_cal1_lastseg->finalPoint() - dc_cal1_lastseg->unitTangentAt(1),
- dc_cal1_lastseg->finalPoint(),
- rev_cal2_firstseg->initialPoint(),
- rev_cal2_firstseg->initialPoint() + rev_cal2_firstseg->unitTangentAt(0),
- this->cap_rounding);
-
- this->accumulated->append(rev_cal2, TRUE);
-
- add_cap(this->accumulated,
- rev_cal2_lastseg->finalPoint() - rev_cal2_lastseg->unitTangentAt(1),
- rev_cal2_lastseg->finalPoint(),
- dc_cal1_firstseg->initialPoint(),
- dc_cal1_firstseg->initialPoint() + dc_cal1_firstseg->unitTangentAt(0),
- this->cap_rounding);
-
- this->accumulated->closepath();
+ if(!this->nowidth) {
+ add_cap(this->accumulated,
+ dc_cal1_lastseg->finalPoint() - dc_cal1_lastseg->unitTangentAt(1),
+ dc_cal1_lastseg->finalPoint(),
+ rev_cal2_firstseg->initialPoint(),
+ rev_cal2_firstseg->initialPoint() + rev_cal2_firstseg->unitTangentAt(0),
+ this->cap_rounding);
+
+ this->accumulated->append(rev_cal2, TRUE);
+
+ add_cap(this->accumulated,
+ rev_cal2_lastseg->finalPoint() - rev_cal2_lastseg->unitTangentAt(1),
+ rev_cal2_lastseg->finalPoint(),
+ dc_cal1_firstseg->initialPoint(),
+ dc_cal1_firstseg->initialPoint() + dc_cal1_firstseg->unitTangentAt(0),
+ this->cap_rounding);
+
+ this->accumulated->closepath();
+ }
rev_cal2->unref();
@@ -844,6 +889,8 @@ static double square(double const x)
void EraserTool::fit_and_split(bool release) {
double const tolerance_sq = square( desktop->w2d().descrim() * TOLERANCE_ERASER );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ this->nowidth = prefs->getDouble( "/tools/eraser/width", 1) == 0;
#ifdef ERASER_VERBOSE
g_print("[F&S:R=%c]", release?'T':'F');
@@ -940,7 +987,6 @@ void EraserTool::fit_and_split(bool release) {
g_print("[%d]Yup\n", this->npoints);
#endif
if (!release) {
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0;
g_assert(!this->currentcurve->is_empty());
diff --git a/src/ui/tools/eraser-tool.h b/src/ui/tools/eraser-tool.h
index 110f57ba3..50ce6b6e3 100644
--- a/src/ui/tools/eraser-tool.h
+++ b/src/ui/tools/eraser-tool.h
@@ -58,6 +58,7 @@ private:
void accumulate();
void fit_and_split(bool release);
void draw_temporary_box();
+ bool nowidth;
};
}
diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp
index 613857626..c98ecb686 100644
--- a/src/ui/tools/freehand-base.cpp
+++ b/src/ui/tools/freehand-base.cpp
@@ -43,6 +43,7 @@
#include "snap.h"
#include "sp-path.h"
#include "sp-use.h"
+#include "sp-item-group.h"
#include "sp-namedview.h"
#include "live_effects/lpe-powerstroke.h"
#include "style.h"
@@ -432,7 +433,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item,
if(cm->paste(SP_ACTIVE_DESKTOP,true) == true){
gchar const *svgd = item->getRepr()->attribute("d");
bend_item = dc->selection->singleItem();
- if(bend_item){
+ if(bend_item && (SP_IS_SHAPE(bend_item) || SP_IS_GROUP(bend_item))){
bend_item->moveTo(item,false);
bend_item->transform.setTranslation(Geom::Point());
spdc_apply_bend_shape(svgd, dc, bend_item);
@@ -440,9 +441,11 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item,
shape = BEND_CLIPBOARD;
} else {
+ bend_item = NULL;
shape = NONE;
}
} else {
+ bend_item = NULL;
shape = NONE;
}
break;
diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp
index a2a440ef4..287828d32 100644
--- a/src/ui/tools/measure-tool.cpp
+++ b/src/ui/tools/measure-tool.cpp
@@ -1198,8 +1198,7 @@ void MeasureTool::showCanvasItems(bool to_guides, bool to_item, bool to_phantom,
curve->unref();
continue;
}
-
- curve->transform(item->i2doc_affine());
+ curve->transform(item->transform);
calculate_intersections(desktop, item, lineseg, curve, intersection_times);
if (iter == te_get_layout(item)->end()) {
@@ -1288,9 +1287,9 @@ void MeasureTool::showCanvasItems(bool to_guides, bool to_item, bool to_phantom,
if(to_guides) {
gchar *cross_number;
if (!prefs->getBool("/tools/measure/ignore_1st_and_last", true)) {
- cross_number= g_strdup_printf(_("Crossing %u"), idx);
+ cross_number= g_strdup_printf(_("Crossing %lu"), static_cast<unsigned long>(idx));
} else {
- cross_number= g_strdup_printf(_("Crossing %u"), idx + 1);
+ cross_number= g_strdup_printf(_("Crossing %lu"), static_cast<unsigned long>(idx + 1));
}
if (!prefs->getBool("/tools/measure/ignore_1st_and_last", true) && idx == 0) {
setGuide(desktop->doc2dt(intersections[idx]), angle + Geom::rad_from_deg(90), "");
diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp
index 2ed366a7d..18af8e105 100644
--- a/src/ui/tools/pen-tool.cpp
+++ b/src/ui/tools/pen-tool.cpp
@@ -1220,7 +1220,18 @@ bool PenTool::_handleKeyPress(GdkEvent *event) {
case GDK_KEY_KP_Enter:
if (this->npoints != 0) {
this->ea = NULL; // unset end anchor if set (otherwise crashes)
- this->_finish(false);
+ if(MOD__SHIFT_ONLY(event)) {
+ // All this is needed to stop the last control
+ // point dispeating and stop making an n-1 shape.
+ Geom::Point const p(0, 0);
+ if(this->red_curve->is_empty()) {
+ this->red_curve->moveto(p);
+ }
+ this->_finishSegment(p, 0);
+ this->_finish(true);
+ } else {
+ this->_finish(false);
+ }
ret = true;
}
break;
@@ -1783,12 +1794,12 @@ void PenTool::_setSubsequentPoint(Geom::Point const p, bool statusbar, guint sta
if (statusbar) {
gchar *message = is_curve ?
- _("<b>Curve segment</b>: angle %3.2f&#176;, distance %s; with <b>Ctrl</b> to snap angle, <b>Enter</b> to finish the path" ):
- _("<b>Line segment</b>: angle %3.2f&#176;, distance %s; with <b>Ctrl</b> to snap angle, <b>Enter</b> to finish the path");
+ _("<b>Curve segment</b>: angle %3.2f&#176;, distance %s; with <b>Ctrl</b> to snap angle, <b>Enter</b> or <b>Shift+Enter</b> to finish the path" ):
+ _("<b>Line segment</b>: angle %3.2f&#176;, distance %s; with <b>Ctrl</b> to snap angle, <b>Enter</b> or <b>Shift+Enter</b> to finish the path");
if(this->spiro || this->bspline){
message = is_curve ?
- _("<b>Curve segment</b>: angle %3.2f&#176;, distance %s; with <b>Shift+Click</b> make a cusp node, <b>Enter</b> to finish the path" ):
- _("<b>Line segment</b>: angle %3.2f&#176;, distance %s; with <b>Shift+Click</b> make a cusp node, <b>Enter</b> to finish the path");
+ _("<b>Curve segment</b>: angle %3.2f&#176;, distance %s; with <b>Shift+Click</b> make a cusp node, <b>Enter</b> or <b>Shift+Enter</b> to finish the path" ):
+ _("<b>Line segment</b>: angle %3.2f&#176;, distance %s; with <b>Shift+Click</b> make a cusp node, <b>Enter</b> or <b>Shift+Enter</b> to finish the path");
}
this->_setAngleDistanceStatusMessage(p, 0, message);
}
diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp
index bfb1c67f0..b029ca613 100644
--- a/src/ui/tools/pencil-tool.cpp
+++ b/src/ui/tools/pencil-tool.cpp
@@ -634,12 +634,14 @@ void PencilTool::_interpolate() {
using Geom::Y;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- double const tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0) * 0.4;
- double tolerance_sq = 0.02 * square(this->desktop->w2d().descrim() * tol) * exp(0.2 * tol - 2);
+ double tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0) * 0.4;
bool simplify = prefs->getInt("/tools/freehand/pencil/simplify", 0);
if(simplify){
- tolerance_sq = 0;
+ double tol2 = prefs->getDoubleLimited("/tools/freehand/pencil/base-simplify", 25.0, 1.0, 100.0) * 0.4;
+ tol = std::min(tol,tol2);
}
+ double tolerance_sq = 0.02 * square(this->desktop->w2d().descrim() * tol) * exp(0.2 * tol - 2);
+
g_assert(is_zero(this->req_tangent) || is_unit_vector(this->req_tangent));
this->green_curve->reset();
@@ -705,12 +707,14 @@ void PencilTool::_sketchInterpolate() {
}
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- double const tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0) * 0.4;
- double tolerance_sq = 0.02 * square(this->desktop->w2d().descrim() * tol) * exp(0.2 * tol - 2);
+ double tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0) * 0.4;
bool simplify = prefs->getInt("/tools/freehand/pencil/simplify", 0);
if(simplify){
- tolerance_sq = 0;
+ double tol2 = prefs->getDoubleLimited("/tools/freehand/pencil/base-simplify", 25.0, 1.0, 100.0) * 0.4;
+ tol = std::min(tol,tol2);
}
+ double tolerance_sq = 0.02 * square(this->desktop->w2d().descrim() * tol) * exp(0.2 * tol - 2);
+
bool average_all_sketches = prefs->getBool("/tools/freehand/pencil/average_all_sketches", true);
g_assert(is_zero(this->req_tangent) || is_unit_vector(this->req_tangent));
diff --git a/src/ui/tools/zoom-tool.cpp b/src/ui/tools/zoom-tool.cpp
index 6a4d4dbbd..13e097c18 100644
--- a/src/ui/tools/zoom-tool.cpp
+++ b/src/ui/tools/zoom-tool.cpp
@@ -142,7 +142,7 @@ bool ZoomTool::root_handler(GdkEvent* event) {
if ( event->button.button == 1 && !this->space_panning) {
Geom::OptRect const b = Inkscape::Rubberband::get(desktop)->getRectangle();
- if (b && !within_tolerance) {
+ if (b && !within_tolerance && !(GDK_SHIFT_MASK & event->button.state) ) {
desktop->set_display_area(*b, 10);
} else if (!escaped) {
double const zoom_rel( (event->button.state & GDK_SHIFT_MASK)
diff --git a/src/ui/widget/addtoicon.cpp b/src/ui/widget/addtoicon.cpp
index 823e24a00..10294125d 100644
--- a/src/ui/widget/addtoicon.cpp
+++ b/src/ui/widget/addtoicon.cpp
@@ -48,7 +48,6 @@ AddToIcon::AddToIcon() :
//
// _property_pixbuf_add = Gtk::Widget::
- //property_stock_id() = GTK_STOCK_ADD;
set_pixbuf();
}
diff --git a/src/ui/widget/color-icc-selector.cpp b/src/ui/widget/color-icc-selector.cpp
index 2fe4a0704..ec2e69fb3 100644
--- a/src/ui/widget/color-icc-selector.cpp
+++ b/src/ui/widget/color-icc-selector.cpp
@@ -377,7 +377,6 @@ void ColorICCSelector::init()
(gpointer)_impl);
gtk_widget_set_sensitive(_impl->_fixupBtn, FALSE);
gtk_widget_set_tooltip_text(_impl->_fixupBtn, _("Fix RGB fallback to match icc-color() value."));
- // gtk_misc_set_alignment( GTK_MISC (_impl->_fixupBtn), 1.0, 0.5 );
gtk_widget_show(_impl->_fixupBtn);
attachToGridOrTable(t, _impl->_fixupBtn, 0, row, 1, 1);
@@ -431,7 +430,13 @@ void ColorICCSelector::init()
#endif
_impl->_compUI[i]._label = gtk_label_new_with_mnemonic(labelStr.c_str());
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_halign(_impl->_compUI[i]._label, GTK_ALIGN_END);
+#else
gtk_misc_set_alignment(GTK_MISC(_impl->_compUI[i]._label), 1.0, 0.5);
+#endif
+
gtk_widget_show(_impl->_compUI[i]._label);
gtk_widget_set_no_show_all(_impl->_compUI[i]._label, TRUE);
@@ -489,7 +494,13 @@ void ColorICCSelector::init()
// Label
_impl->_label = gtk_label_new_with_mnemonic(_("_A:"));
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_halign(_impl->_label, GTK_ALIGN_END);
+#else
gtk_misc_set_alignment(GTK_MISC(_impl->_label), 1.0, 0.5);
+#endif
+
gtk_widget_show(_impl->_label);
attachToGridOrTable(t, _impl->_label, 0, row, 1, 1);
diff --git a/src/ui/widget/color-notebook.cpp b/src/ui/widget/color-notebook.cpp
index 60abf43bf..6d7ada734 100644
--- a/src/ui/widget/color-notebook.cpp
+++ b/src/ui/widget/color-notebook.cpp
@@ -210,7 +210,11 @@ void ColorNotebook::_initUI()
/* Create RGBA entry and color preview */
_rgbal = gtk_label_new_with_mnemonic(_("RGBA_:"));
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_halign(_rgbal, GTK_ALIGN_END);
+#else
gtk_misc_set_alignment(GTK_MISC(_rgbal), 1.0, 0.5);
+#endif
gtk_box_pack_start(GTK_BOX(rgbabox), _rgbal, TRUE, TRUE, 2);
ColorEntry *rgba_entry = Gtk::manage(new ColorEntry(_selected_color));
diff --git a/src/ui/widget/color-preview.cpp b/src/ui/widget/color-preview.cpp
index 5bcd16528..62c7cca1d 100644
--- a/src/ui/widget/color-preview.cpp
+++ b/src/ui/widget/color-preview.cpp
@@ -23,6 +23,7 @@ ColorPreview::ColorPreview (guint32 rgba)
{
_rgba = rgba;
set_has_window(false);
+ set_name("ColorPreview");
}
void
diff --git a/src/ui/widget/color-scales.cpp b/src/ui/widget/color-scales.cpp
index 170f83887..48a2693bc 100644
--- a/src/ui/widget/color-scales.cpp
+++ b/src/ui/widget/color-scales.cpp
@@ -92,7 +92,13 @@ void ColorScales::_initUI(SPColorScalesMode mode)
for (i = 0; i < static_cast<gint>(G_N_ELEMENTS(_a)); i++) {
/* Label */
_l[i] = gtk_label_new("");
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_halign(_l[i], GTK_ALIGN_END);
+#else
gtk_misc_set_alignment(GTK_MISC(_l[i]), 1.0, 0.5);
+#endif
+
gtk_widget_show(_l[i]);
#if GTK_CHECK_VERSION(3, 0, 0)
diff --git a/src/ui/widget/color-wheel-selector.cpp b/src/ui/widget/color-wheel-selector.cpp
index ed3400bb5..22c616325 100644
--- a/src/ui/widget/color-wheel-selector.cpp
+++ b/src/ui/widget/color-wheel-selector.cpp
@@ -245,22 +245,24 @@ void ColorWheelSelector::_wheelChanged(GimpColorWheel *wheel, ColorWheelSelector
guint32 mid = color.toRGBA32(0x7f);
guint32 end = color.toRGBA32(0xff);
+ wheelSelector->_updating = true;
wheelSelector->_slider->setColors(start, mid, end);
-
wheelSelector->_color.preserveICC();
wheelSelector->_color.setHeld(gimp_color_wheel_is_adjusting(wheel));
wheelSelector->_color.setColor(color);
+ wheelSelector->_updating = false;
}
void ColorWheelSelector::_updateDisplay()
{
+ if(_updating) { return; }
+
#ifdef DUMP_CHANGE_INFO
g_message("ColorWheelSelector::_colorChanged( this=%p, %f, %f, %f, %f)", this, _color.color().v.c[0],
_color.color().v.c[1], _color.color().v.c[2], alpha);
#endif
- bool oldval = _updating;
_updating = true;
{
float hsv[3] = { 0, 0, 0 };
@@ -276,7 +278,7 @@ void ColorWheelSelector::_updateDisplay()
ColorScales::setScaled(_alpha_adjustment->gobj(), _color.alpha());
- _updating = oldval;
+ _updating = false;
}
diff --git a/src/ui/widget/dock.cpp b/src/ui/widget/dock.cpp
index c5e14d4f0..fda647182 100644
--- a/src/ui/widget/dock.cpp
+++ b/src/ui/widget/dock.cpp
@@ -56,6 +56,7 @@ Dock::Dock(Gtk::Orientation orientation)
#endif
_scrolled_window (Gtk::manage(new Gtk::ScrolledWindow))
{
+ _scrolled_window->set_name("Dock");
#if WITH_GDL_3_6
gtk_orientable_set_orientation(GTK_ORIENTABLE(_gdl_dock_bar),
static_cast<GtkOrientation>(orientation));
diff --git a/src/ui/widget/gimpcolorwheel.c b/src/ui/widget/gimpcolorwheel.c
index f632331d8..d54486505 100644
--- a/src/ui/widget/gimpcolorwheel.c
+++ b/src/ui/widget/gimpcolorwheel.c
@@ -303,7 +303,9 @@ gimp_color_wheel_realize (GtkWidget *widget)
priv->window = gdk_window_new (parent_window, &attr, attr_mask);
gdk_window_set_user_data (priv->window, wheel);
+#if !GTK_CHECK_VERSION(3,0,0)
gtk_widget_style_attach (widget);
+#endif
}
static void
@@ -1246,7 +1248,7 @@ paint_triangle (GimpColorWheel *wheel,
#endif
}
-#if GTK_CHECK_VERSION(3,2,0)
+#if GTK_CHECK_VERSION(3,0,0)
static gboolean
gimp_color_wheel_draw (GtkWidget *widget,
cairo_t *cr)
@@ -1412,6 +1414,10 @@ gimp_color_wheel_set_color (GimpColorWheel *wheel,
priv = wheel->priv;
+ if(h == 0.0 && s == 0.0) {
+ h = priv->h;
+ }
+
priv->h = h;
priv->s = s;
priv->v = v;
diff --git a/src/ui/widget/layer-selector.cpp b/src/ui/widget/layer-selector.cpp
index dc89d233f..1a9ce617f 100644
--- a/src/ui/widget/layer-selector.cpp
+++ b/src/ui/widget/layer-selector.cpp
@@ -32,7 +32,6 @@
#include "util/reverse-list.h"
#include "verbs.h"
#include "widgets/icon.h"
-#include "widgets/shrink-wrap-button.h"
#include "xml/node-event-vector.h"
#include "widgets/gradient-vector.h"
@@ -46,6 +45,7 @@ public:
AlternateIcons(Inkscape::IconSize size, gchar const *a, gchar const *b)
: _a(NULL), _b(NULL)
{
+ set_name("AlternateIcons");
if (a) {
_a = Gtk::manage(sp_icon_get_icon(a, size));
_a->set_no_show_all(true);
@@ -95,6 +95,7 @@ private:
LayerSelector::LayerSelector(SPDesktop *desktop)
: _desktop(NULL), _layer(NULL)
{
+ set_name("LayerSelector");
AlternateIcons *label;
label = Gtk::manage(new AlternateIcons(Inkscape::ICON_SIZE_DECORATION,
@@ -114,7 +115,6 @@ LayerSelector::LayerSelector(SPDesktop *desktop)
);
_visibility_toggle.set_relief(Gtk::RELIEF_NONE);
- shrink_wrap_button(_visibility_toggle);
_visibility_toggle.set_tooltip_text(_("Toggle current layer visibility"));
pack_start(_visibility_toggle, Gtk::PACK_EXPAND_PADDING);
@@ -135,7 +135,6 @@ LayerSelector::LayerSelector(SPDesktop *desktop)
);
_lock_toggle.set_relief(Gtk::RELIEF_NONE);
- shrink_wrap_button(_lock_toggle);
_lock_toggle.set_tooltip_text(_("Lock or unlock current layer"));
pack_start(_lock_toggle, Gtk::PACK_EXPAND_PADDING);
diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp
index 8a1e98a63..ab13577d7 100644
--- a/src/ui/widget/panel.cpp
+++ b/src/ui/widget/panel.cpp
@@ -73,6 +73,10 @@ Panel::Panel(Glib::ustring const &label, gchar const *prefs_path,
_action_area(0),
_fillable(0)
{
+ set_name( "InkscapePanel" );
+#if WITH_GTKMM_3_0
+ set_orientation( Gtk::ORIENTATION_VERTICAL );
+#endif
_init();
}
@@ -92,7 +96,6 @@ void Panel::_popper(GdkEventButton* event)
void Panel::_init()
{
- Glib::ustring tmp("<");
_anchor = SP_ANCHOR_CENTER;
guint panel_size = 0, panel_mode = 0, panel_ratio = 100, panel_border = 0;
@@ -282,7 +285,10 @@ void Panel::_init()
pack_start(_top_bar, false, false);
Gtk::HBox* boxy = Gtk::manage(new Gtk::HBox());
-
+ boxy->set_name( "PanelBoxY" );
+ _contents.set_name( "PanelContents" );
+ _right_bar.set_name( "PanelRightBar" );
+ _top_bar.set_name( "PanelTopBar" );
boxy->pack_start(_contents, true, true);
boxy->pack_start(_right_bar, false, true);
diff --git a/src/ui/widget/panel.h b/src/ui/widget/panel.h
index a90060e17..7b2836fe8 100644
--- a/src/ui/widget/panel.h
+++ b/src/ui/widget/panel.h
@@ -64,7 +64,11 @@ namespace Widget {
* @see UI::Dialog::DesktopTracker to handle desktop change, selection change and selected object modifications.
* @see UI::Dialog::DialogManager manages the dialogs within inkscape.
*/
+#if WITH_GTKMM_3_0
+class Panel : public Gtk::Box {
+#else
class Panel : public Gtk::VBox {
+#endif
public:
static void prep();
diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp
index e906762e3..d56506d62 100644
--- a/src/ui/widget/preferences-widget.cpp
+++ b/src/ui/widget/preferences-widget.cpp
@@ -468,12 +468,8 @@ ZoomCorrRuler::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
Glib::ustring abbr = prefs->getString("/options/zoomcorrection/unit");
if (abbr == "cm") {
draw_marks(cr, 0.1, 10);
- } else if (abbr == "ft") {
- draw_marks(cr, 1/12.0, 12);
} else if (abbr == "in") {
draw_marks(cr, 0.25, 4);
- } else if (abbr == "m") {
- draw_marks(cr, 1/10.0, 10);
} else if (abbr == "mm") {
draw_marks(cr, 10, 10);
} else if (abbr == "pc") {
diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp
index 9e283fc64..f7fd63f51 100644
--- a/src/ui/widget/selected-style.cpp
+++ b/src/ui/widget/selected-style.cpp
@@ -155,6 +155,7 @@ SelectedStyle::SelectedStyle(bool /*layout*/)
_unit_mis(NULL),
_sw_unit(NULL)
{
+ set_name("SelectedStyle");
_drop[0] = _drop[1] = 0;
_dropEnabled[0] = _dropEnabled[1] = false;
@@ -363,19 +364,6 @@ SelectedStyle::SelectedStyle(bool /*layout*/)
_popup_sw.show_all();
}
- _fill_place.signal_button_release_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_fill_click));
- _stroke_place.signal_button_release_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_stroke_click));
- _opacity_place.signal_button_press_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_click));
- _stroke_width_place.signal_button_press_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_sw_click));
- _stroke_width_place.signal_button_release_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_sw_click));
-
-
- _opacity_sb.signal_populate_popup().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_menu));
- _opacity_sb.signal_value_changed().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_changed));
- // Connect to key-press to ensure focus is consistent with other spin buttons when using the keys vs mouse-click
- g_signal_connect (G_OBJECT (_opacity_sb.gobj()), "key-press-event", G_CALLBACK (spinbutton_keypress), _opacity_sb.gobj());
- g_signal_connect (G_OBJECT (_opacity_sb.gobj()), "focus-in-event", G_CALLBACK (spinbutton_focus_in), _opacity_sb.gobj());
-
_fill_place.add(_na[SS_FILL]);
_fill_place.set_tooltip_text(__na[SS_FILL]);
@@ -452,6 +440,17 @@ SelectedStyle::SelectedStyle(bool /*layout*/)
"drag_data_received",
G_CALLBACK(dragDataReceived),
_drop[SS_FILL]);
+
+ _fill_place.signal_button_release_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_fill_click));
+ _stroke_place.signal_button_release_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_stroke_click));
+ _opacity_place.signal_button_press_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_click));
+ _stroke_width_place.signal_button_press_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_sw_click));
+ _stroke_width_place.signal_button_release_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_sw_click));
+ _opacity_sb.signal_populate_popup().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_menu));
+ _opacity_sb.signal_value_changed().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_changed));
+ // Connect to key-press to ensure focus is consistent with other spin buttons when using the keys vs mouse-click
+ g_signal_connect (G_OBJECT (_opacity_sb.gobj()), "key-press-event", G_CALLBACK (spinbutton_keypress), _opacity_sb.gobj());
+ g_signal_connect (G_OBJECT (_opacity_sb.gobj()), "focus-in-event", G_CALLBACK (spinbutton_focus_in), _opacity_sb.gobj());
}
SelectedStyle::~SelectedStyle()
diff --git a/src/ui/widget/style-swatch.cpp b/src/ui/widget/style-swatch.cpp
index fa8543c46..188be705d 100644
--- a/src/ui/widget/style-swatch.cpp
+++ b/src/ui/widget/style-swatch.cpp
@@ -124,6 +124,8 @@ StyleSwatch::StyleSwatch(SPCSSAttr *css, gchar const *main_tip)
#endif
_sw_unit(NULL)
{
+ set_name("StyleSwatch");
+
_label[SS_FILL].set_markup(_("Fill:"));
_label[SS_STROKE].set_markup(_("Stroke:"));
diff --git a/src/ui/widget/unit-tracker.cpp b/src/ui/widget/unit-tracker.cpp
index c6318db25..a1501c229 100644
--- a/src/ui/widget/unit-tracker.cpp
+++ b/src/ui/widget/unit-tracker.cpp
@@ -12,6 +12,7 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
+#include "style-internal.h"
#include "unit-tracker.h"
#include "widgets/ege-select-one-action.h"
@@ -121,6 +122,15 @@ void UnitTracker::addUnit(Inkscape::Util::Unit const *u)
gtk_list_store_set(_store, &iter, COLUMN_STRING, u ? u->abbr.c_str() : "NULL", -1);
}
+void UnitTracker::prependUnit(Inkscape::Util::Unit const *u)
+{
+ GtkTreeIter iter;
+ gtk_list_store_prepend(_store, &iter);
+ gtk_list_store_set(_store, &iter, COLUMN_STRING, u ? u->abbr.c_str() : "NULL", -1);
+ /* Re-shuffle our default selection here (_active gets out of sync) */
+ setActiveUnit(_activeUnit);
+}
+
void UnitTracker::setFullVal(GtkAdjustment *adj, gdouble val)
{
_priorValues[adj] = val;
diff --git a/src/ui/widget/unit-tracker.h b/src/ui/widget/unit-tracker.h
index 06245930e..8fa9ff304 100644
--- a/src/ui/widget/unit-tracker.h
+++ b/src/ui/widget/unit-tracker.h
@@ -43,6 +43,7 @@ public:
void addUnit(Inkscape::Util::Unit const *u);
void addAdjustment(GtkAdjustment *adj);
+ void prependUnit(Inkscape::Util::Unit const *u);
void setFullVal(GtkAdjustment *adj, gdouble val);
GtkAction *createAction(gchar const *name, gchar const *label, gchar const *tooltip);
diff --git a/src/unclump.cpp b/src/unclump.cpp
index 2c6840425..5ec5cfce4 100644
--- a/src/unclump.cpp
+++ b/src/unclump.cpp
@@ -342,7 +342,9 @@ unclump (std::vector<SPItem*> &items)
std::list<SPItem*> nei;
std::list<SPItem*> rest;
- for(int i=0;i<items.size();i++)rest.push_front(items[items.size()-i-1]);
+ for (int i=0; i < static_cast<int>(items.size()); i++) {
+ rest.push_front(items[items.size() - i - 1]);
+ }
rest.remove(item);
while (!rest.empty()) {
@@ -352,7 +354,9 @@ unclump (std::vector<SPItem*> &items)
rest.remove(closest);
std::vector<SPItem*> new_rest = unclump_remove_behind (item, closest, rest);
rest.clear();
- for(int i=0;i<new_rest.size();i++)rest.push_front(new_rest[new_rest.size()-i-1]);
+ for (int i=0; i < static_cast<int>(new_rest.size()); i++) {
+ rest.push_front(new_rest[new_rest.size() - i - 1]);
+ }
} else {
break;
}
diff --git a/src/util/units.cpp b/src/util/units.cpp
index 2c72ec3ae..cf4bfd146 100644
--- a/src/util/units.cpp
+++ b/src/util/units.cpp
@@ -231,6 +231,30 @@ int Unit::svgUnit() const
return 0;
}
+double Unit::convert(double from_dist, Unit const *to) const
+{
+ // Percentage
+ if (to->type == UNIT_TYPE_DIMENSIONLESS) {
+ return from_dist * to->factor;
+ }
+
+ // Incompatible units
+ if (type != to->type) {
+ return -1;
+ }
+
+ // Compatible units
+ return from_dist * factor / to->factor;
+}
+double Unit::convert(double from_dist, Glib::ustring const &to) const
+{
+ return convert(from_dist, unit_table.getUnit(to));
+}
+double Unit::convert(double from_dist, char const *to) const
+{
+ return convert(from_dist, unit_table.getUnit(to));
+}
+
Unit UnitTable::_empty_unit;
@@ -505,18 +529,7 @@ Glib::ustring Quantity::string() const {
double Quantity::convert(double from_dist, Unit const *from, Unit const *to)
{
- // Percentage
- if (to->type == UNIT_TYPE_DIMENSIONLESS) {
- return from_dist * to->factor;
- }
-
- // Incompatible units
- if (from->type != to->type) {
- return -1;
- }
-
- // Compatible units
- return from_dist * from->factor / to->factor;
+ return from->convert(from_dist, to);
}
double Quantity::convert(double from_dist, Glib::ustring const &from, Unit const *to)
{
diff --git a/src/util/units.h b/src/util/units.h
index 13777fd1b..fa70058ba 100644
--- a/src/util/units.h
+++ b/src/util/units.h
@@ -75,6 +75,11 @@ public:
/** Get SVG unit code. */
int svgUnit() const;
+
+ /** Convert value from this unit **/
+ double convert(double from_dist, Unit const *to) const;
+ double convert(double from_dist, Glib::ustring const &to) const;
+ double convert(double from_dist, char const *to) const;
};
class Quantity
diff --git a/src/verbs.cpp b/src/verbs.cpp
index a78bde2f7..299cfe8e7 100644
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
@@ -952,10 +952,6 @@ void EditVerb::perform(SPAction *action, void *data)
g_return_if_fail(ensure_desktop_valid(action));
SPDesktop *dt = sp_action_get_desktop(action);
- SPDocument *doc = dt->getDocument();
-
- Inkscape::XML::Node *repr = dt->namedview->getRepr();
-
switch (reinterpret_cast<std::size_t>(data)) {
case SP_VERB_EDIT_UNDO:
sp_undo(dt, dt->getDocument());
@@ -1154,6 +1150,9 @@ void SelectionVerb::perform(SPAction *action, void *data)
case SP_VERB_SELECTION_UNGROUP:
sp_selection_ungroup(selection, dt);
break;
+ case SP_VERB_SELECTION_UNGROUP_POP_SELECTION:
+ sp_selection_ungroup_pop_selection(selection, dt);
+ break;
default:
handled = false;
break;
@@ -2563,6 +2562,8 @@ Verb *Verb::_base_verbs[] = {
N_("Group selected objects"), INKSCAPE_ICON("object-group")),
new SelectionVerb(SP_VERB_SELECTION_UNGROUP, "SelectionUnGroup", N_("_Ungroup"),
N_("Ungroup selected groups"), INKSCAPE_ICON("object-ungroup")),
+ new SelectionVerb(SP_VERB_SELECTION_UNGROUP_POP_SELECTION, "SelectionUnGroupPopSelection", N_("_Pop selected objects out of group"),
+ N_("Pop selected objects out of group"), INKSCAPE_ICON("object-ungroup-pop-selection")),
new SelectionVerb(SP_VERB_SELECTION_TEXTTOPATH, "SelectionTextToPath", N_("_Put on Path"),
N_("Put text on path"), INKSCAPE_ICON("text-put-on-path")),
@@ -2949,7 +2950,7 @@ Verb *Verb::_base_verbs[] = {
new DialogVerb(SP_VERB_DIALOG_TAGS, "DialogTags", N_("Selection se_ts..."),
N_("View Tags"), INKSCAPE_ICON("edit-select-all-layers")),
new DialogVerb(SP_VERB_DIALOG_LIVE_PATH_EFFECT, "DialogLivePathEffect", N_("Path E_ffects ..."),
- N_("Manage, edit, and apply path effects"), NULL),
+ N_("Manage, edit, and apply path effects"), INKSCAPE_ICON("dialog-path-effects")),
new DialogVerb(SP_VERB_DIALOG_FILTER_EFFECTS, "DialogFilterEffects", N_("Filter _Editor..."),
N_("Manage, edit, and apply SVG filters"), INKSCAPE_ICON("dialog-filters")),
new DialogVerb(SP_VERB_DIALOG_SVG_FONTS, "DialogSVGFonts", N_("SVG Font Editor..."),
@@ -3004,7 +3005,7 @@ Verb *Verb::_base_verbs[] = {
N_("Fit the page to the current selection"), NULL),
new FitCanvasVerb(SP_VERB_FIT_CANVAS_TO_DRAWING, "FitCanvasToDrawing", N_("Fit Page to Drawing"),
N_("Fit the page to the drawing"), NULL),
- new FitCanvasVerb(SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING, "FitCanvasToSelectionOrDrawing", N_("Fit Page to Selection or Drawing"),
+ new FitCanvasVerb(SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING, "FitCanvasToSelectionOrDrawing", N_("_Resize Page to Selection"),
N_("Fit the page to the current selection or the drawing if there is no selection"), NULL),
// LockAndHide
new LockAndHideVerb(SP_VERB_UNLOCK_ALL, "UnlockAll", N_("Unlock All"),
diff --git a/src/verbs.h b/src/verbs.h
index 4f453761e..ffb9b23d8 100644
--- a/src/verbs.h
+++ b/src/verbs.h
@@ -116,6 +116,7 @@ enum {
SP_VERB_SELECTION_LOWER,
SP_VERB_SELECTION_GROUP,
SP_VERB_SELECTION_UNGROUP,
+ SP_VERB_SELECTION_UNGROUP_POP_SELECTION,
SP_VERB_SELECTION_TEXTTOPATH,
SP_VERB_SELECTION_TEXTFROMPATH,
SP_VERB_SELECTION_REMOVE_KERNS,
diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt
index c38bde5cf..225afe317 100644
--- a/src/widgets/CMakeLists.txt
+++ b/src/widgets/CMakeLists.txt
@@ -38,7 +38,6 @@ set(widgets_SRC
paint-selector.cpp
ruler.cpp
select-toolbar.cpp
- shrink-wrap-button.cpp
sp-attribute-widget.cpp
sp-color-selector.cpp
sp-widget.cpp
@@ -94,7 +93,6 @@ set(widgets_SRC
paint-selector.h
ruler.h
select-toolbar.h
- shrink-wrap-button.h
sp-attribute-widget.h
sp-color-selector.h
sp-widget.h
@@ -110,6 +108,11 @@ set(widgets_SRC
widget-sizes.h
)
+if(${WITH_GTK3_EXPERIMENTAL})
+ set(image_menu_item_SRC image-menu-item.h image-menu-item.c)
+ add_inkscape_source("${image_menu_item_SRC}")
+endif()
+
# add_inkscape_lib(widgets_LIB "${widgets_SRC}")
add_inkscape_source("${widgets_SRC}")
@@ -121,3 +124,6 @@ set ( widgets_paintbucket_SRC
if ("${HAVE_POTRACE}")
add_inkscape_source("${widgets_paintbucket_SRC}")
endif()
+
+
+
diff --git a/src/widgets/Makefile_insert b/src/widgets/Makefile_insert
index 6913f4a58..c9f04de14 100644
--- a/src/widgets/Makefile_insert
+++ b/src/widgets/Makefile_insert
@@ -1,5 +1,11 @@
## Makefile.am fragment sourced by src/Makefile.am.
+if WITH_GTKMM_3_0
+ink_common_sources += \
+ widgets/image-menu-item.c \
+ widgets/image-menu-item.h
+endif
+
ink_common_sources += \
widgets/arc-toolbar.cpp \
widgets/arc-toolbar.h \
@@ -66,8 +72,6 @@ ink_common_sources += \
widgets/ruler.h \
widgets/select-toolbar.cpp \
widgets/select-toolbar.h \
- widgets/shrink-wrap-button.cpp \
- widgets/shrink-wrap-button.h \
widgets/spray-toolbar.cpp \
widgets/spray-toolbar.h \
widgets/spiral-toolbar.cpp \
diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp
index 1776e28c4..6ea8c1360 100644
--- a/src/widgets/button.cpp
+++ b/src/widgets/button.cpp
@@ -96,7 +96,6 @@ static void sp_button_dispose(GObject *object)
static void sp_button_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width)
{
GtkWidget *child = gtk_bin_get_child(GTK_BIN(widget));
- GtkStyle *style = gtk_widget_get_style(widget);
if (child) {
gtk_widget_get_preferred_width(GTK_WIDGET(child), minimal_width, natural_width);
@@ -105,14 +104,20 @@ static void sp_button_get_preferred_width(GtkWidget *widget, gint *minimal_width
*natural_width = 0;
}
- *minimal_width += 2 + 2 * MAX(2, style->xthickness);
- *natural_width += 2 + 2 * MAX(2, style->xthickness);
+ GtkStyleContext *context = gtk_widget_get_style_context (widget);
+ GtkBorder padding;
+ GtkBorder border;
+
+ gtk_style_context_get_padding(context, GTK_STATE_FLAG_NORMAL, &padding);
+ gtk_style_context_get_border( context, GTK_STATE_FLAG_NORMAL, &border );
+
+ *minimal_width += MAX(2, padding.left + padding.right + border.left + border.right);
+ *natural_width += MAX(2, padding.left + padding.right + border.left + border.right);
}
static void sp_button_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height)
{
GtkWidget *child = gtk_bin_get_child(GTK_BIN(widget));
- GtkStyle *style = gtk_widget_get_style(widget);
if (child) {
gtk_widget_get_preferred_height(GTK_WIDGET(child), minimal_height, natural_height);
@@ -121,8 +126,15 @@ static void sp_button_get_preferred_height(GtkWidget *widget, gint *minimal_heig
*natural_height = 0;
}
- *minimal_height += 2 + 2 * MAX(2, style->ythickness);
- *natural_height += 2 + 2 * MAX(2, style->ythickness);
+ GtkStyleContext *context = gtk_widget_get_style_context (widget);
+ GtkBorder padding;
+ GtkBorder border;
+
+ gtk_style_context_get_padding(context, GTK_STATE_FLAG_NORMAL, &padding);
+ gtk_style_context_get_border( context, GTK_STATE_FLAG_NORMAL, &border );
+
+ *minimal_height += MAX(2, padding.top + padding.bottom + border.top + border.bottom);
+ *natural_height += MAX(2, padding.top + padding.bottom + border.top + border.bottom);
}
#else
static void sp_button_size_request(GtkWidget *widget, GtkRequisition *requisition)
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp
index 1fdd3ca6d..0cee426b6 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -249,7 +249,7 @@ SPDesktopWidget::setMessage (Inkscape::MessageType type, const gchar *message)
gdk_window_process_updates(gtk_widget_get_window(GTK_WIDGET(sb)), TRUE);
}
- gtk_widget_set_tooltip_text (this->select_status_eventbox, gtk_label_get_text (sb));
+ gtk_widget_set_tooltip_text (this->select_status, gtk_label_get_text (sb));
}
Geom::Point
@@ -346,6 +346,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
/* Main table */
#if GTK_CHECK_VERSION(3,0,0)
dtw->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+ gtk_widget_set_name(dtw->vbox, "DesktopMainTable");
#else
dtw->vbox = gtk_vbox_new (FALSE, 0);
#endif
@@ -353,6 +354,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
#if GTK_CHECK_VERSION(3,0,0)
dtw->statusbar = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_widget_set_name(dtw->statusbar, "DesktopStatusBar");
#else
dtw->statusbar = gtk_hbox_new (FALSE, 0);
#endif
@@ -364,7 +366,6 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
dtw->panels = new SwatchesPanel("/embedded/swatches" /*false*/);
dtw->panels->setOrientation(SP_ANCHOR_SOUTH);
-
#if GTK_CHECK_VERSION(3,0,0)
dtw->panels->set_vexpand(false);
#endif
@@ -374,6 +375,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
#if GTK_CHECK_VERSION(3,0,0)
dtw->hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_widget_set_name(dtw->hbox, "DesktopHbox");
#else
dtw->hbox = gtk_hbox_new(FALSE, 0);
#endif
@@ -404,6 +406,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
Glib::RefPtr<Gtk::CssProvider> guides_lock_style_provider = Gtk::CssProvider::create();
guides_lock_style_provider->load_from_data("GtkWidget { padding-left: 0; padding-right: 0; padding-top: 0; padding-bottom: 0; }");
Gtk::Widget * wnd = Glib::wrap(dtw->guides_lock);
+ wnd->set_name("LockGuides");
Glib::RefPtr<Gtk::StyleContext> context = wnd->get_style_context();
context->add_provider(guides_lock_style_provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
#endif
@@ -411,6 +414,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
/* Horizontal ruler */
GtkWidget *eventbox = gtk_event_box_new ();
dtw->hruler = sp_ruler_new(GTK_ORIENTATION_HORIZONTAL);
+ gtk_widget_set_name(dtw->hruler, "HorizontalRuler");
dtw->hruler_box = eventbox;
Inkscape::Util::Unit const *pt = unit_table.getUnit("pt");
sp_ruler_set_unit(SP_RULER(dtw->hruler), pt);
@@ -421,13 +425,15 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
g_signal_connect (G_OBJECT (eventbox), "motion_notify_event", G_CALLBACK (sp_dt_hruler_event), dtw);
#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *tbl = gtk_grid_new();
+ GtkWidget *tbl_wrapper = gtk_grid_new(); // Is this widget really needed?
+ gtk_widget_set_name(tbl_wrapper, "CanvasTableWrapper");
dtw->canvas_tbl = gtk_grid_new();
+ gtk_widget_set_name(dtw->canvas_tbl, "CanvasTable");
gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), dtw->guides_lock, 0, 0, 1, 1);
gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), eventbox, 1, 0, 1, 1);
#else
- GtkWidget *tbl = gtk_table_new(2, 3, FALSE);
+ GtkWidget *tbl_wrapper = gtk_table_new(2, 3, FALSE);
dtw->canvas_tbl = gtk_table_new(3, 3, FALSE);
gtk_table_attach(GTK_TABLE(dtw->canvas_tbl),
@@ -442,11 +448,12 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
0, 0);
#endif
g_signal_connect (G_OBJECT (dtw->guides_lock), "toggled", G_CALLBACK (sp_update_guides_lock), dtw);
- gtk_box_pack_start( GTK_BOX(dtw->hbox), tbl, TRUE, TRUE, 1 );
+ gtk_box_pack_start( GTK_BOX(dtw->hbox), tbl_wrapper, TRUE, TRUE, 1 );
/* Vertical ruler */
eventbox = gtk_event_box_new ();
dtw->vruler = sp_ruler_new(GTK_ORIENTATION_VERTICAL);
+ gtk_widget_set_name(dtw->vruler, "VerticalRuler");
/* Vertical ruler */
dtw->vruler_box = eventbox;
@@ -471,11 +478,9 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
// Horizontal scrollbar
dtw->hadj = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, -4000.0, 4000.0, 10.0, 100.0, 4.0));
-
-
-
#if GTK_CHECK_VERSION(3,0,0)
dtw->hscrollbar = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT (dtw->hadj));
+ gtk_widget_set_name(dtw->hscrollbar, "HorizontalScrollbar");
gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), dtw->hscrollbar, 1, 2, 1, 1);
dtw->vscrollbar_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
#else
@@ -492,6 +497,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
NULL,
INKSCAPE_ICON("zoom-original"),
_("Zoom drawing if window size changes"));
+ gtk_widget_set_name(dtw->sticky_zoom, "StickyZoom");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dtw->sticky_zoom), prefs->getBool("/options/stickyzoom/value"));
gtk_box_pack_start (GTK_BOX (dtw->vscrollbar_box), dtw->sticky_zoom, FALSE, FALSE, 0);
g_signal_connect (G_OBJECT (dtw->sticky_zoom), "toggled", G_CALLBACK (sp_dtw_sticky_zoom_toggled), dtw);
@@ -501,6 +507,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
#if GTK_CHECK_VERSION(3,0,0)
dtw->vscrollbar = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, GTK_ADJUSTMENT(dtw->vadj));
+ gtk_widget_set_name(dtw->vscrollbar, "VerticalScrollbar");
#else
dtw->vscrollbar = gtk_vscrollbar_new (GTK_ADJUSTMENT (dtw->vadj));
#endif
@@ -528,6 +535,8 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
NULL,
INKSCAPE_ICON("color-management"),
tip );
+ gtk_widget_set_name(dtw->cms_adjust, "CMS_Adjust");
+
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
{
Glib::ustring current = prefs->getString("/options/displayprofile/uri");
@@ -564,7 +573,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
/* Canvas */
dtw->canvas = SP_CANVAS(SPCanvas::createAA());
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
- dtw->canvas->enable_cms_display_adj = prefs->getBool("/options/displayprofile/enable");
+ dtw->canvas->_enable_cms_display_adj = prefs->getBool("/options/displayprofile/enable");
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
gtk_widget_set_can_focus (GTK_WIDGET (dtw->canvas), TRUE);
@@ -572,10 +581,18 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
sp_ruler_add_track_widget (SP_RULER(dtw->vruler), GTK_WIDGET(dtw->canvas));
#if GTK_CHECK_VERSION(3,0,0)
- GdkRGBA white = {1,1,1,1};
- gtk_widget_override_background_color(GTK_WIDGET(dtw->canvas),
- GTK_STATE_FLAG_NORMAL,
- &white);
+ GtkCssProvider *css_provider = gtk_css_provider_new();
+ GtkStyleContext *style_context = gtk_widget_get_style_context(GTK_WIDGET(dtw->canvas));
+
+ gtk_css_provider_load_from_data(css_provider,
+ "SPCanvas {\n"
+ " background-color: white;\n"
+ "}\n",
+ -1, NULL);
+
+ gtk_style_context_add_provider(style_context,
+ GTK_STYLE_PROVIDER(css_provider),
+ GTK_STYLE_PROVIDER_PRIORITY_USER);
#else
GtkStyle *style = gtk_style_copy(gtk_widget_get_style(GTK_WIDGET(dtw->canvas)));
style->bg[GTK_STATE_NORMAL] = style->white;
@@ -599,9 +616,9 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
if (create_dock) {
dtw->dock = new Inkscape::UI::Widget::Dock();
-
#if WITH_GTKMM_3_0
Gtk::Paned *paned = new Gtk::Paned();
+ paned->set_name("Canvas_and_Dock");
#else
Gtk::HPaned *paned = new Gtk::HPaned();
#endif
@@ -618,9 +635,9 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_hexpand(GTK_WIDGET(paned->gobj()), TRUE);
gtk_widget_set_vexpand(GTK_WIDGET(paned->gobj()), TRUE);
- gtk_grid_attach(GTK_GRID(tbl), GTK_WIDGET (paned->gobj()), 1, 1, 1, 1);
+ gtk_grid_attach(GTK_GRID(tbl_wrapper), GTK_WIDGET (paned->gobj()), 1, 1, 1, 1);
#else
- gtk_table_attach (GTK_TABLE (tbl), GTK_WIDGET (paned->gobj()), 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
+ gtk_table_attach (GTK_TABLE (tbl_wrapper), GTK_WIDGET (paned->gobj()), 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
(GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0);
#endif
@@ -628,17 +645,26 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_hexpand(GTK_WIDGET(dtw->canvas_tbl), TRUE);
gtk_widget_set_vexpand(GTK_WIDGET(dtw->canvas_tbl), TRUE);
- gtk_grid_attach(GTK_GRID(tbl), GTK_WIDGET (dtw->canvas_tbl), 1, 1, 1, 1);
+ gtk_grid_attach(GTK_GRID(tbl_wrapper), GTK_WIDGET (dtw->canvas_tbl), 1, 1, 1, 1);
#else
- gtk_table_attach (GTK_TABLE (tbl), GTK_WIDGET (dtw->canvas_tbl), 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
+ gtk_table_attach (GTK_TABLE (tbl_wrapper), GTK_WIDGET (dtw->canvas_tbl), 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
(GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0);
#endif
}
+ // connect scrollbar signals
+ g_signal_connect (G_OBJECT (dtw->hadj), "value-changed", G_CALLBACK (sp_desktop_widget_adjustment_value_changed), dtw);
+ g_signal_connect (G_OBJECT (dtw->vadj), "value-changed", G_CALLBACK (sp_desktop_widget_adjustment_value_changed), dtw);
+
+
+ // --------------- Status Tool Bar ------------------//
+
+ // Selected Style (Fill/Stroke/Opacity)
dtw->selected_style = new Inkscape::UI::Widget::SelectedStyle(true);
GtkHBox *ss_ = dtw->selected_style->gobj();
gtk_box_pack_start (GTK_BOX (dtw->statusbar), GTK_WIDGET(ss_), FALSE, FALSE, 0);
+ // Separator
gtk_box_pack_start(GTK_BOX(dtw->statusbar),
#if GTK_CHECK_VERSION(3,0,0)
gtk_separator_new(GTK_ORIENTATION_VERTICAL),
@@ -647,15 +673,39 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
#endif
FALSE, FALSE, 0);
- // connect scrollbar signals
- g_signal_connect (G_OBJECT (dtw->hadj), "value-changed", G_CALLBACK (sp_desktop_widget_adjustment_value_changed), dtw);
- g_signal_connect (G_OBJECT (dtw->vadj), "value-changed", G_CALLBACK (sp_desktop_widget_adjustment_value_changed), dtw);
+ // Layer Selector
+ dtw->layer_selector = new Inkscape::Widgets::LayerSelector(NULL);
+ // FIXME: need to unreference on container destruction to avoid leak
+ dtw->layer_selector->reference();
+ //dtw->layer_selector->set_size_request(-1, SP_ICON_SIZE_BUTTON);
+ gtk_box_pack_start(GTK_BOX(dtw->statusbar), GTK_WIDGET(dtw->layer_selector->gobj()), FALSE, FALSE, 1);
- GtkWidget *statusbar_tail=gtk_statusbar_new();
- gtk_box_pack_end (GTK_BOX (dtw->statusbar), statusbar_tail, FALSE, FALSE, 0);
+ // Select Status
+ dtw->select_status = gtk_label_new (NULL);
+ gtk_widget_set_name( dtw->select_status, "SelectStatus");
+ gtk_label_set_ellipsize (GTK_LABEL(dtw->select_status), PANGO_ELLIPSIZE_END);
+#if GTK_CHECK_VERSION(3,10,0)
+ gtk_label_set_line_wrap (GTK_LABEL(dtw->select_status), true);
+ gtk_label_set_lines (GTK_LABEL(dtw->select_status), 2);
+#endif
- // zoom status spinbutton
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_halign(dtw->select_status, GTK_ALIGN_START);
+#else
+ gtk_misc_set_alignment (GTK_MISC (dtw->select_status), 0.0, 0.5);
+#endif
+
+ gtk_widget_set_size_request (dtw->select_status, 1, -1);
+
+ // Display the initial welcome message in the statusbar
+ gtk_label_set_markup (GTK_LABEL (dtw->select_status), _("<b>Welcome to Inkscape!</b> Use shape or freehand tools to create objects; use selector (arrow) to move or transform them."));
+
+ gtk_box_pack_start (GTK_BOX (dtw->statusbar), dtw->select_status, TRUE, TRUE, 0);
+
+
+ // Zoom status spinbutton
dtw->zoom_status = gtk_spin_button_new_with_range (log(SP_DESKTOP_ZOOM_MIN)/log(2), log(SP_DESKTOP_ZOOM_MAX)/log(2), 0.1);
+ gtk_widget_set_name(dtw->zoom_status, "ZoomStatus");
gtk_widget_set_tooltip_text (dtw->zoom_status, _("Zoom"));
gtk_widget_set_size_request (dtw->zoom_status, STATUS_ZOOM_WIDTH, -1);
gtk_entry_set_width_chars (GTK_ENTRY (dtw->zoom_status), 6);
@@ -669,12 +719,14 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
dtw->zoom_update = g_signal_connect (G_OBJECT (dtw->zoom_status), "value_changed", G_CALLBACK (sp_dtw_zoom_value_changed), dtw);
dtw->zoom_update = g_signal_connect (G_OBJECT (dtw->zoom_status), "populate_popup", G_CALLBACK (sp_dtw_zoom_populate_popup), dtw);
- // cursor coordinates
+ // Cursor coordinates
#if GTK_CHECK_VERSION(3,0,0)
dtw->coord_status = gtk_grid_new();
+ gtk_widget_set_name(dtw->coord_status, "CoordinateAndZStatus");
gtk_grid_set_row_spacing(GTK_GRID(dtw->coord_status), 0);
gtk_grid_set_column_spacing(GTK_GRID(dtw->coord_status), 2);
GtkWidget* sep = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
+ gtk_widget_set_name(sep, "CoordinateSeparator");
gtk_grid_attach(GTK_GRID(dtw->coord_status),
GTK_WIDGET(sep),
0, 0, 1, 2);
@@ -688,42 +740,40 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
GTK_FILL, GTK_FILL, 0, 0);
#endif
- eventbox = gtk_event_box_new ();
- gtk_container_add (GTK_CONTAINER (eventbox), dtw->coord_status);
- gtk_widget_set_tooltip_text (eventbox, _("Cursor coordinates"));
+ gtk_widget_set_tooltip_text (dtw->coord_status, _("Cursor coordinates"));
GtkWidget *label_x = gtk_label_new(_("X:"));
- gtk_misc_set_alignment (GTK_MISC(label_x), 0.0, 0.5);
-
-#if GTK_CHECK_VERSION(3,0,0)
- gtk_grid_attach(GTK_GRID(dtw->coord_status),
- label_x, 1, 0, 1, 1);
-#else
- gtk_table_attach(GTK_TABLE(dtw->coord_status), label_x, 1,2, 0,1, GTK_FILL, GTK_FILL, 0, 0);
-#endif
-
GtkWidget *label_y = gtk_label_new(_("Y:"));
- gtk_misc_set_alignment (GTK_MISC(label_y), 0.0, 0.5);
#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_halign(label_x, GTK_ALIGN_START);
+ gtk_widget_set_halign(label_y, GTK_ALIGN_START);
+ gtk_grid_attach(GTK_GRID(dtw->coord_status), label_x, 1, 0, 1, 1);
gtk_grid_attach(GTK_GRID(dtw->coord_status), label_y, 1, 1, 1, 1);
#else
+ gtk_misc_set_alignment (GTK_MISC(label_x), 0.0, 0.5);
+ gtk_misc_set_alignment (GTK_MISC(label_y), 0.0, 0.5);
+ gtk_table_attach(GTK_TABLE(dtw->coord_status), label_x, 1,2, 0,1, GTK_FILL, GTK_FILL, 0, 0);
gtk_table_attach(GTK_TABLE(dtw->coord_status), label_y, 1,2, 1,2, GTK_FILL, GTK_FILL, 0, 0);
#endif
dtw->coord_status_x = gtk_label_new(NULL);
- gtk_label_set_markup( GTK_LABEL(dtw->coord_status_x), "<tt> 0.00 </tt>" );
- gtk_misc_set_alignment (GTK_MISC(dtw->coord_status_x), 1.0, 0.5);
dtw->coord_status_y = gtk_label_new(NULL);
+ gtk_label_set_markup( GTK_LABEL(dtw->coord_status_x), "<tt> 0.00 </tt>" );
gtk_label_set_markup( GTK_LABEL(dtw->coord_status_y), "<tt> 0.00 </tt>" );
- gtk_misc_set_alignment (GTK_MISC(dtw->coord_status_y), 1.0, 0.5);
+
GtkWidget* label_z = gtk_label_new(_("Z:"));
+ gtk_widget_set_name(label_z, "ZLabel");
#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_halign(dtw->coord_status_x, GTK_ALIGN_END);
+ gtk_widget_set_halign(dtw->coord_status_y, GTK_ALIGN_END);
gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->coord_status_x, 2, 0, 1, 1);
gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->coord_status_y, 2, 1, 1, 1);
gtk_grid_attach(GTK_GRID(dtw->coord_status), label_z, 3, 0, 1, 2);
gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->zoom_status, 4, 0, 1, 2);
#else
+ gtk_misc_set_alignment (GTK_MISC(dtw->coord_status_x), 1.0, 0.5);
+ gtk_misc_set_alignment (GTK_MISC(dtw->coord_status_y), 1.0, 0.5);
gtk_table_attach(GTK_TABLE(dtw->coord_status), dtw->coord_status_x, 2,3, 0,1, GTK_FILL, GTK_FILL, 0, 0);
gtk_table_attach(GTK_TABLE(dtw->coord_status), dtw->coord_status_y, 2,3, 1,2, GTK_FILL, GTK_FILL, 0, 0);
gtk_table_attach(GTK_TABLE(dtw->coord_status), label_z, 3,4, 0,2, GTK_FILL, GTK_FILL, 0, 0);
@@ -731,14 +781,10 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
#endif
sp_set_font_size_smaller (dtw->coord_status);
- gtk_box_pack_end (GTK_BOX (statusbar_tail), eventbox, FALSE, FALSE, 1);
- dtw->layer_selector = new Inkscape::Widgets::LayerSelector(NULL);
- // FIXME: need to unreference on container destruction to avoid leak
- dtw->layer_selector->reference();
- //dtw->layer_selector->set_size_request(-1, SP_ICON_SIZE_BUTTON);
- gtk_box_pack_start(GTK_BOX(dtw->statusbar), GTK_WIDGET(dtw->layer_selector->gobj()), FALSE, FALSE, 1);
+ gtk_box_pack_end (GTK_BOX (dtw->statusbar), dtw->coord_status, FALSE, FALSE, 0);
+ // --------------- Color Management ---------------- //
dtw->_tracker = ege_color_prof_tracker_new(GTK_WIDGET(dtw->layer_selector->gobj()));
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
bool fromDisplay = prefs->getBool( "/options/displayprofile/from_display");
@@ -746,31 +792,14 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
Glib::ustring id = Inkscape::CMSSystem::getDisplayId( 0, 0 );
bool enabled = false;
- dtw->canvas->cms_key = id;
- enabled = !dtw->canvas->cms_key.empty();
+ dtw->canvas->_cms_key = id;
+ enabled = !dtw->canvas->_cms_key.empty();
cms_adjust_set_sensitive( dtw, enabled );
}
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
g_signal_connect( G_OBJECT(dtw->_tracker), "changed", G_CALLBACK(sp_dtw_color_profile_event), dtw );
- dtw->select_status_eventbox = gtk_event_box_new ();
- dtw->select_status = gtk_label_new (NULL);
- gtk_label_set_ellipsize (GTK_LABEL(dtw->select_status), PANGO_ELLIPSIZE_END);
- gtk_misc_set_alignment (GTK_MISC (dtw->select_status), 0.0, 0.5);
- gtk_widget_set_size_request (dtw->select_status, 1, -1);
- // display the initial welcome message in the statusbar
- gtk_label_set_markup (GTK_LABEL (dtw->select_status), _("<b>Welcome to Inkscape!</b> Use shape or freehand tools to create objects; use selector (arrow) to move or transform them."));
- // space label 2 pixels from left edge
- gtk_container_add (GTK_CONTAINER (dtw->select_status_eventbox), dtw->select_status);
-#if GTK_CHECK_VERSION(3,0,0)
- gtk_box_pack_start(GTK_BOX(dtw->statusbar),
- gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0),
- FALSE, FALSE, 2);
-#else
- gtk_box_pack_start (GTK_BOX (dtw->statusbar), gtk_hbox_new(FALSE, 0), FALSE, FALSE, 2);
-#endif
- gtk_box_pack_start (GTK_BOX (dtw->statusbar), dtw->select_status_eventbox, TRUE, TRUE, 0);
-
+ // ------------------ Finish Up -------------------- //
gtk_widget_show_all (dtw->vbox);
gtk_widget_grab_focus (GTK_WIDGET(dtw->canvas));
@@ -1035,7 +1064,7 @@ sp_desktop_widget_event (GtkWidget *widget, GdkEvent *event, SPDesktopWidget *dt
// current item on the canvas, because item events and all mouse events are caught
// and passed on by the canvas acetate (I think). --bb
if ((event->type == GDK_KEY_PRESS || event->type == GDK_KEY_RELEASE)
- && !dtw->canvas->current_item) {
+ && !dtw->canvas->_current_item) {
return sp_desktop_root_handler (NULL, event, dtw->desktop);
}
}
@@ -1054,9 +1083,9 @@ void sp_dtw_color_profile_event(EgeColorProfTracker */*tracker*/, SPDesktopWidge
gint monitor = gdk_screen_get_monitor_at_window(screen, window);
Glib::ustring id = Inkscape::CMSSystem::getDisplayId( screenNum, monitor );
bool enabled = false;
- dtw->canvas->cms_key = id;
+ dtw->canvas->_cms_key = id;
dtw->requestCanvasUpdate();
- enabled = !dtw->canvas->cms_key.empty();
+ enabled = !dtw->canvas->_cms_key.empty();
cms_adjust_set_sensitive( dtw, enabled );
}
#else
@@ -1092,8 +1121,8 @@ void cms_adjust_toggled( GtkWidget */*button*/, gpointer data )
SPDesktopWidget *dtw = SP_DESKTOP_WIDGET(data);
bool down = SP_BUTTON_IS_DOWN(dtw->cms_adjust);
- if ( down != dtw->canvas->enable_cms_display_adj ) {
- dtw->canvas->enable_cms_display_adj = down;
+ if ( down != dtw->canvas->_enable_cms_display_adj ) {
+ dtw->canvas->_enable_cms_display_adj = down;
dtw->requestCanvasUpdate();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setBool("/options/displayprofile/enable", down);
@@ -1439,6 +1468,7 @@ bool SPDesktopWidget::showInfoDialog( Glib::ustring const &message )
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
"%s", message.c_str());
+ gtk_widget_set_name(dialog, "InfoDialog");
gtk_window_set_title( GTK_WINDOW(dialog), _("Note:")); // probably want to take this as a parameter.
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
@@ -1685,7 +1715,11 @@ void SPDesktopWidget::setToolboxPosition(Glib::ustring const& id, GtkPositionTyp
case GTK_POS_TOP:
case GTK_POS_BOTTOM:
if ( gtk_widget_is_ancestor(toolbox, hbox) ) {
- gtk_widget_reparent( toolbox, vbox );
+ // Removing a widget can reduce ref count to zero
+ g_object_ref(G_OBJECT(toolbox));
+ gtk_container_remove(GTK_CONTAINER(hbox), toolbox);
+ gtk_container_add(GTK_CONTAINER(vbox), toolbox);
+ g_object_unref(G_OBJECT(toolbox));
gtk_box_set_child_packing(GTK_BOX(vbox), toolbox, FALSE, TRUE, 0, GTK_PACK_START);
}
ToolboxFactory::setOrientation(toolbox, GTK_ORIENTATION_HORIZONTAL);
@@ -1693,7 +1727,10 @@ void SPDesktopWidget::setToolboxPosition(Glib::ustring const& id, GtkPositionTyp
case GTK_POS_LEFT:
case GTK_POS_RIGHT:
if ( !gtk_widget_is_ancestor(toolbox, hbox) ) {
- gtk_widget_reparent( toolbox, hbox );
+ g_object_ref(G_OBJECT(toolbox));
+ gtk_container_remove(GTK_CONTAINER(vbox), toolbox);
+ gtk_container_add(GTK_CONTAINER(hbox), toolbox);
+ g_object_unref(G_OBJECT(toolbox));
gtk_box_set_child_packing(GTK_BOX(hbox), toolbox, FALSE, TRUE, 0, GTK_PACK_START);
if (pos == GTK_POS_LEFT) {
gtk_box_reorder_child( GTK_BOX(hbox), toolbox, 0 );
@@ -1744,6 +1781,7 @@ SPDesktopWidget* SPDesktopWidget::createInstance(SPNamedView *namedview)
dtw->layer_selector->setDesktop(dtw->desktop);
dtw->menubar = sp_ui_main_menubar (dtw->desktop);
+ gtk_widget_set_name(dtw->menubar, "MenuBar");
gtk_widget_show_all (dtw->menubar);
gtk_box_pack_start (GTK_BOX (dtw->vbox), dtw->menubar, FALSE, FALSE, 0);
diff --git a/src/widgets/eek-preview.cpp b/src/widgets/eek-preview.cpp
index 19dbb04ab..9951a8957 100644
--- a/src/widgets/eek-preview.cpp
+++ b/src/widgets/eek-preview.cpp
@@ -239,7 +239,7 @@ static
gboolean eek_preview_draw(GtkWidget *widget,
cairo_t *cr)
{
- GtkStyle *style = gtk_widget_get_style(widget);
+
EekPreview *preview = EEK_PREVIEW(widget);
EekPreviewPrivate *priv = EEK_PREVIEW_GET_PRIVATE(preview);
@@ -284,7 +284,8 @@ gboolean eek_preview_draw(GtkWidget *widget,
0, 0,
allocation.width, allocation.height);
#else
- GdkWindow* window = gtk_widget_get_window(widget);
+ GtkStyle *style = gtk_widget_get_style(widget);
+ GdkWindow *window = gtk_widget_get_window(widget);
gtk_paint_flat_box( style,
window,
@@ -495,14 +496,11 @@ gboolean eek_preview_draw(GtkWidget *widget,
otherArea.y = possible.y + (possible.height - otherArea.height) / 2;
}
#if GTK_CHECK_VERSION(3,0,0)
- gtk_paint_diamond( style,
- cr,
- gtk_widget_get_state (widget),
- GTK_SHADOW_ETCHED_OUT,
- widget,
- NULL,
- otherArea.x, otherArea.y,
- otherArea.width, otherArea.height );
+ // This should be a diamond too?
+ gtk_render_check(context,
+ cr,
+ otherArea.x, otherArea.y,
+ otherArea.width, otherArea.height );
#else
gtk_paint_diamond( style,
window,
@@ -549,7 +547,11 @@ static gboolean eek_preview_enter_cb( GtkWidget* widget, GdkEventCrossing* event
EekPreviewPrivate *priv = EEK_PREVIEW_GET_PRIVATE(preview);
priv->within = TRUE;
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_state_flags( widget, priv->hot ? GTK_STATE_FLAG_ACTIVE : GTK_STATE_FLAG_PRELIGHT, false );
+#else
gtk_widget_set_state( widget, priv->hot ? GTK_STATE_ACTIVE : GTK_STATE_PRELIGHT );
+#endif
}
return FALSE;
@@ -562,7 +564,11 @@ static gboolean eek_preview_leave_cb( GtkWidget* widget, GdkEventCrossing* event
EekPreviewPrivate *priv = EEK_PREVIEW_GET_PRIVATE(preview);
priv->within = FALSE;
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_state_flags( widget, GTK_STATE_FLAG_NORMAL, false );
+#else
gtk_widget_set_state( widget, GTK_STATE_NORMAL );
+#endif
}
return FALSE;
@@ -587,7 +593,11 @@ static gboolean eek_preview_button_press_cb( GtkWidget* widget, GdkEventButton*
if ( priv->within )
{
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_state_flags( widget, GTK_STATE_FLAG_ACTIVE, false );
+#else
gtk_widget_set_state( widget, GTK_STATE_ACTIVE );
+#endif
}
}
}
@@ -602,7 +612,11 @@ static gboolean eek_preview_button_release_cb( GtkWidget* widget, GdkEventButton
EekPreviewPrivate *priv = EEK_PREVIEW_GET_PRIVATE(preview);
priv->hot = FALSE;
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_state_flags( widget, GTK_STATE_FLAG_NORMAL, false );
+#else
gtk_widget_set_state( widget, GTK_STATE_NORMAL );
+#endif
if ( priv->within &&
(event->button == PRIME_BUTTON_MAGIC_NUMBER ||
diff --git a/src/widgets/ege-adjustment-action.cpp b/src/widgets/ege-adjustment-action.cpp
index a91149f4c..272217aa4 100644
--- a/src/widgets/ege-adjustment-action.cpp
+++ b/src/widgets/ege-adjustment-action.cpp
@@ -865,7 +865,13 @@ static GtkWidget* create_tool_item( GtkAction* action )
gtk_box_pack_start( GTK_BOX(hb), icon, FALSE, FALSE, 0 );
} else {
GtkWidget* lbl = gtk_label_new( g_value_get_string( &value ) ? g_value_get_string( &value ) : "wwww" );
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_halign(lbl, GTK_ALIGN_END);
+#else
gtk_misc_set_alignment( GTK_MISC(lbl), 1.0, 0.5 );
+#endif
+
gtk_box_pack_start( GTK_BOX(hb), lbl, FALSE, FALSE, 0 );
}
}
diff --git a/src/widgets/ege-select-one-action.cpp b/src/widgets/ege-select-one-action.cpp
index ab86c49f8..2e106154e 100644
--- a/src/widgets/ege-select-one-action.cpp
+++ b/src/widgets/ege-select-one-action.cpp
@@ -818,9 +818,14 @@ GtkWidget* create_tool_item( GtkAction* action )
gtk_box_pack_start( GTK_BOX(holder), normal, FALSE, FALSE, 0 );
{
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_halign(holder, GTK_ALIGN_START);
+ gtk_container_add(GTK_CONTAINER(item), holder);
+#else
GtkWidget *align = gtk_alignment_new(0, 0.5, 0, 0);
gtk_container_add( GTK_CONTAINER(align), holder);
gtk_container_add( GTK_CONTAINER(item), align );
+#endif
}
}
@@ -855,10 +860,14 @@ void resync_active( EgeSelectOneAction* act, gint active, gboolean override )
GList* children = gtk_container_get_children( GTK_CONTAINER(proxies->data) );
if ( children && children->data ) {
gpointer combodata = g_object_get_data( G_OBJECT(children->data), "ege-combo-box" );
+
+#if !GTK_CHECK_VERSION(3,0,0)
if (!combodata && GTK_IS_ALIGNMENT(children->data)) {
GList *other = gtk_container_get_children( GTK_CONTAINER(children->data) );
combodata = g_object_get_data( G_OBJECT(other->data), "ege-combo-box" );
}
+#endif
+
if ( GTK_IS_COMBO_BOX(combodata) ) {
GtkComboBox* combo = GTK_COMBO_BOX(combodata);
if ((active == -1) && (gtk_combo_box_get_has_entry(combo))) {
@@ -915,10 +924,14 @@ void resync_sensitive( EgeSelectOneAction* act )
GList* children = gtk_container_get_children( GTK_CONTAINER(proxies->data) );
if ( children && children->data ) {
gpointer combodata = g_object_get_data( G_OBJECT(children->data), "ege-combo-box" );
+
+#if !GTK_CHECK_VERSION(3,0,0)
if (!combodata && GTK_IS_ALIGNMENT(children->data)) {
GList *other = gtk_container_get_children( GTK_CONTAINER(children->data) );
combodata = g_object_get_data( G_OBJECT(other->data), "ege-combo-box" );
}
+#endif
+
if ( GTK_IS_COMBO_BOX(combodata) ) {
/* Not implemented */
} else if ( GTK_IS_BOX(children->data) ) {
diff --git a/src/widgets/eraser-toolbar.cpp b/src/widgets/eraser-toolbar.cpp
index 1f79b50f2..bb553f4e6 100644
--- a/src/widgets/eraser-toolbar.cpp
+++ b/src/widgets/eraser-toolbar.cpp
@@ -57,6 +57,13 @@ static void sp_erc_width_value_changed( GtkAdjustment *adj, GObject *tbl )
update_presets_list(tbl);
}
+static void sp_erc_mass_value_changed( GtkAdjustment *adj, GObject* tbl )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble( "/tools/eraser/mass", gtk_adjustment_get_value(adj) );
+ update_presets_list(tbl);
+}
+
static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl )
{
SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
@@ -65,7 +72,18 @@ static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl )
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setBool( "/tools/eraser/mode", eraserMode );
}
-
+ GtkAction *split = GTK_ACTION( g_object_get_data(tbl, "split") );
+ GtkAction *mass = GTK_ACTION( g_object_get_data(tbl, "mass") );
+ GtkAction *width = GTK_ACTION( g_object_get_data(tbl, "width") );
+ if(eraserMode == TRUE){
+ gtk_action_set_visible( split, TRUE );
+ gtk_action_set_visible( mass, TRUE );
+ gtk_action_set_visible( width, TRUE );
+ } else {
+ gtk_action_set_visible( split, FALSE );
+ gtk_action_set_visible( mass, FALSE );
+ gtk_action_set_visible( width, FALSE );
+ }
// only take action if run by the attr_changed listener
if (!g_object_get_data( tbl, "freeze" )) {
// in turn, prevent listener from responding
@@ -82,11 +100,20 @@ static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl )
}
}
+static void sp_toogle_break_apart( GtkToggleAction* act, gpointer data )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gboolean active = gtk_toggle_action_get_active(act);
+ prefs->setBool("/tools/eraser/break_apart", active);
+}
+
void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
+ Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gint eraserMode = FALSE;
{
GtkListStore* model = gtk_list_store_new( 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING );
-
GtkTreeIter iter;
gtk_list_store_append( model, &iter );
gtk_list_store_set( model, &iter,
@@ -113,29 +140,70 @@ void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
ege_select_one_action_set_icon_column( act, 2 );
ege_select_one_action_set_tooltip_column( act, 1 );
- /// @todo Convert to boolean?
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0;
+ eraserMode = prefs->getBool("/tools/eraser/mode") ? TRUE : FALSE;
ege_select_one_action_set_active( act, eraserMode );
g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_erasertb_mode_changed), holder );
}
{
/* Width */
- gchar const* labels[] = {_("(hairline)"), 0, 0, 0, _("(default)"), 0, 0, 0, 0, _("(broad stroke)")};
- gdouble values[] = {1, 3, 5, 10, 15, 20, 30, 50, 75, 100};
+ gchar const* labels[] = {_("(no width)"),_("(hairline)"), 0, 0, 0, _("(default)"), 0, 0, 0, 0, _("(broad stroke)")};
+ gdouble values[] = {0, 1, 3, 5, 10, 15, 20, 30, 50, 75, 100};
EgeAdjustmentAction *eact = create_adjustment_action( "EraserWidthAction",
_("Pen Width"), _("Width:"),
_("The width of the eraser pen (relative to the visible canvas area)"),
"/tools/eraser/width", 15,
GTK_WIDGET(desktop->canvas), holder, TRUE, "altx-eraser",
- 1, 100, 1.0, 10.0,
+ 0, 100, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
sp_erc_width_value_changed, NULL /*unit tracker*/, 1, 0);
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
+ g_object_set_data( holder, "width", eact );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
}
+ {
+ /* Mass */
+ gchar const* labels[] = {_("(no inertia)"), _("(slight smoothing, default)"), _("(noticeable lagging)"), 0, 0, _("(maximum inertia)")};
+ gdouble values[] = {0.0, 2, 10, 20, 50, 100};
+ EgeAdjustmentAction* eact = create_adjustment_action( "EraserMassAction",
+ _("Eraser Mass"), _("Mass:"),
+ _("Increase to make the eraser drag behind, as if slowed by inertia"),
+ "/tools/eraser/mass", 10.0,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
+ 0.0, 100, 1, 10.0,
+ labels, values, G_N_ELEMENTS(labels),
+ sp_erc_mass_value_changed, NULL /*unit tracker*/, 1, 0);
+ ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
+ g_object_set_data( holder, "mass", eact );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
+ gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
+ }
+ /* Overlap */
+ {
+ InkToggleAction* act = ink_toggle_action_new( "EraserBreakAppart",
+ _("Break apart cut items"),
+ _("Break apart cut items"),
+ INKSCAPE_ICON("distribute-randomize"),
+ secondarySize );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/eraser/break_apart", false) );
+ g_object_set_data( holder, "split", act );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toogle_break_apart), holder) ;
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ }
+ GtkAction *split = GTK_ACTION( g_object_get_data(holder, "split") );
+ GtkAction *mass = GTK_ACTION( g_object_get_data(holder, "mass") );
+ GtkAction *width = GTK_ACTION( g_object_get_data(holder, "width") );
+ if(eraserMode == TRUE){
+ gtk_action_set_visible( split, TRUE );
+ gtk_action_set_visible( mass, TRUE );
+ gtk_action_set_visible( width, TRUE );
+ } else {
+ gtk_action_set_visible( split, FALSE );
+ gtk_action_set_visible( mass, FALSE );
+ gtk_action_set_visible( width, FALSE );
+ }
}
diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp
index 943434868..aefcb2e81 100644
--- a/src/widgets/font-selector.cpp
+++ b/src/widgets/font-selector.cpp
@@ -159,9 +159,24 @@ static void sp_font_selector_init(SPFontSelector *fsel)
/* Muck with style, see text-toolbar.cpp */
gtk_widget_set_name( GTK_WIDGET(fsel->family_treeview), "font_selector_family" );
+
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkCssProvider *css_provider = gtk_css_provider_new();
+ gtk_css_provider_load_from_data(css_provider,
+ "#font_selector_family {\n"
+ " -GtkWidget-wide-separators: true;\n"
+ " -GtkWidget-separator-height: 6;\n"
+ "}\n",
+ -1, NULL);
+
+ GdkScreen *screen = gdk_screen_get_default();
+ gtk_style_context_add_provider_for_screen(screen,
+ GTK_STYLE_PROVIDER(css_provider),
+ GTK_STYLE_PROVIDER_PRIORITY_USER);
+#else
gtk_rc_parse_string (
"widget \"*font_selector_family\" style \"fontfamily-separator-style\"");
-
+#endif
Inkscape::FontLister* fontlister = Inkscape::FontLister::get_instance();
Glib::RefPtr<Gtk::ListStore> store = fontlister->get_font_list();
diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp
index 35c1e4a8d..3aa44c90a 100644
--- a/src/widgets/gradient-vector.cpp
+++ b/src/widgets/gradient-vector.cpp
@@ -914,7 +914,13 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s
/* Label */
GtkWidget *l = gtk_label_new(C_("Gradient","Offset:"));
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_halign(l, GTK_ALIGN_END);
+#else
gtk_misc_set_alignment(GTK_MISC(l), 1.0, 0.5);
+#endif
+
gtk_box_pack_start(GTK_BOX(hb),l, FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS);
gtk_widget_show(l);
diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp
index 542d16797..f2031fe51 100644
--- a/src/widgets/icon.cpp
+++ b/src/widgets/icon.cpp
@@ -232,6 +232,7 @@ void IconImpl::sizeAllocate(GtkWidget *widget, GtkAllocation *allocation)
}
}
+// GTK3 Only, Doesn't actually seem to be used.
gboolean IconImpl::draw(GtkWidget *widget, cairo_t* cr)
{
SPIcon *icon = SP_ICON(widget);
@@ -247,24 +248,34 @@ gboolean IconImpl::draw(GtkWidget *widget, cairo_t* cr)
if (gtk_widget_get_state_flags (GTK_WIDGET(icon)) != GTK_STATE_FLAG_NORMAL && image) {
#else
if (gtk_widget_get_state (GTK_WIDGET(icon)) != GTK_STATE_NORMAL && image) {
+ std::cerr << "IconImpl::draw: Ooops! It is called in GTK2" << std::endl;
#endif
+ std::cerr << "IconImpl::draw: No image, creating fallback" << std::endl;
+
+#if GTK_CHECK_VERSION(3,0,0)
+ // image = gtk_render_icon_pixbuf(gtk_widget_get_style_context(widget),
+ // source,
+ // (GtkIconSize)-1);
+
+ // gtk_render_icon_pixbuf deprecated, replaced by:
+ GtkIconTheme *icon_theme = gtk_icon_theme_get_default();
+ image = gtk_icon_theme_load_icon (icon_theme,
+ "gtk-image",
+ 32,
+ (GtkIconLookupFlags)0,
+ NULL);
+#else
GtkIconSource *source = gtk_icon_source_new();
gtk_icon_source_set_pixbuf(source, icon->pb);
gtk_icon_source_set_size(source, GTK_ICON_SIZE_SMALL_TOOLBAR); // note: this is boilerplate and not used
gtk_icon_source_set_size_wildcarded(source, FALSE);
-
-#if GTK_CHECK_VERSION(3,0,0)
- image = gtk_render_icon_pixbuf(gtk_widget_get_style_context(widget),
- source,
- (GtkIconSize)-1);
-#else
image = gtk_style_render_icon(gtk_widget_get_style(widget), source,
gtk_widget_get_direction(widget),
(GtkStateType) gtk_widget_get_state(widget),
(GtkIconSize)-1, widget, "gtk-image");
+ gtk_icon_source_free(source);
#endif
- gtk_icon_source_free(source);
unref_image = true;
}
@@ -272,7 +283,13 @@ gboolean IconImpl::draw(GtkWidget *widget, cairo_t* cr)
GtkAllocation allocation;
GtkRequisition requisition;
gtk_widget_get_allocation(widget, &allocation);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_get_preferred_size(widget, &requisition, NULL);
+#else
gtk_widget_get_requisition(widget, &requisition);
+#endif
+
int x = floor(allocation.x + ((allocation.width - requisition.width) * 0.5));
int y = floor(allocation.y + ((allocation.height - requisition.height) * 0.5));
int width = gdk_pixbuf_get_width(image);
@@ -787,6 +804,10 @@ GtkWidget *IconImpl::newFull( Inkscape::IconSize lsize, gchar const *name )
GtkWidget *widget = NULL;
gint trySize = CLAMP( static_cast<gint>(lsize), 0, static_cast<gint>(G_N_ELEMENTS(iconSizeLookup) - 1) );
+ if (trySize != lsize ) {
+ std::cerr << "GtkWidget *IconImple::newFull(): lsize != trySize: lsize: " << lsize
+ << " try Size: " << trySize << " " << (name?name:"NULL") << std::endl;
+ }
if ( !sizeMapDone ) {
injectCustomSize();
}
@@ -814,6 +835,7 @@ GtkWidget *IconImpl::newFull( Inkscape::IconSize lsize, gchar const *name )
if ( Inkscape::Preferences::get()->getBool("/options/iconrender/named_nodelay") ) {
int psize = getPhysSize(lsize);
+ // std::cout << " name: " << name << " size: " << psize << std::endl;
prerenderIcon(name, mappedSize, psize);
} else {
addPreRender( mappedSize, name );
@@ -986,8 +1008,6 @@ int IconImpl::getPhysSize(int size)
"inkscape-decoration"
};
- GtkWidget *icon = GTK_WIDGET(g_object_new(SP_TYPE_ICON, NULL));
-
for (unsigned i = 0; i < G_N_ELEMENTS(gtkSizes); ++i) {
guint const val_ix = (gtkSizes[i] <= GTK_ICON_SIZE_DIALOG) ? (guint)gtkSizes[i] : (guint)Inkscape::ICON_SIZE_DECORATION;
@@ -1012,7 +1032,12 @@ int IconImpl::getPhysSize(int size)
// gtk_icon_size_lookup(), because themes are free to render the pixbuf however
// they like, including changing the usual size."
gchar const *id = INKSCAPE_ICON("document-open");
- GdkPixbuf *pb = gtk_widget_render_icon( icon, id, gtkSizes[i], NULL);
+ GtkIconTheme *icon_theme = gtk_icon_theme_get_default();
+ GdkPixbuf *pb = gtk_icon_theme_load_icon (icon_theme,
+ id,
+ vals[val_ix],
+ (GtkIconLookupFlags)0,
+ NULL);
if (pb) {
width = gdk_pixbuf_get_width(pb);
height = gdk_pixbuf_get_height(pb);
@@ -1028,7 +1053,6 @@ int IconImpl::getPhysSize(int size)
g_object_unref(G_OBJECT(pb));
}
}
- //g_object_unref(icon);
init = true;
}
diff --git a/src/widgets/image-menu-item.c b/src/widgets/image-menu-item.c
new file mode 100644
index 000000000..2b9500ba0
--- /dev/null
+++ b/src/widgets/image-menu-item.c
@@ -0,0 +1,1071 @@
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2001 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-2000.
+ * Forked by . Icons in menus are important to us.
+ */
+
+#include "config.h"
+
+#include <glib/gi18n-lib.h>
+#include <gtk/gtk.h>
+
+#include "widgets/image-menu-item.h"
+
+/**
+ * SECTION:gtkimagemenuitem
+ * @Short_description: A menu item with an icon
+ * @Title: ImageMenuItem
+ *
+ * A ImageMenuItem is a menu item which has an icon next to the text label.
+ *
+ * Note that the user can disable display of menu icons, so make sure to still
+ * fill in the text label.
+ */
+
+
+struct _ImageMenuItemPrivate
+{
+ GtkWidget *image;
+
+ gchar *label;
+ guint use_stock : 1;
+ guint toggle_size;
+};
+
+enum {
+ PROP_0,
+ PROP_IMAGE,
+ PROP_USE_STOCK,
+ PROP_ACCEL_GROUP,
+};
+
+static GtkActivatableIface *parent_activatable_iface;
+
+static void image_menu_item_destroy (GtkWidget *widget);
+static void image_menu_item_get_preferred_width (GtkWidget *widget,
+ gint *minimum,
+ gint *natural);
+static void image_menu_item_get_preferred_height (GtkWidget *widget,
+ gint *minimum,
+ gint *natural);
+static void image_menu_item_get_preferred_height_for_width (GtkWidget *widget,
+ gint width,
+ gint *minimum,
+ gint *natural);
+static void image_menu_item_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation);
+static void image_menu_item_map (GtkWidget *widget);
+static void image_menu_item_remove (GtkContainer *container,
+ GtkWidget *child);
+static void image_menu_item_toggle_size_request (GtkMenuItem *menu_item,
+ gint *requisition);
+static void image_menu_item_set_label (GtkMenuItem *menu_item,
+ const gchar *label);
+static const gchar * image_menu_item_get_label (GtkMenuItem *menu_item);
+
+static void image_menu_item_forall (GtkContainer *container,
+ gboolean include_internals,
+ GtkCallback callback,
+ gpointer callback_data);
+
+static void image_menu_item_finalize (GObject *object);
+static void image_menu_item_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void image_menu_item_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void image_menu_item_screen_changed (GtkWidget *widget,
+ GdkScreen *previous_screen);
+
+static void image_menu_item_recalculate (ImageMenuItem *image_menu_item);
+
+static void image_menu_item_activatable_interface_init (GtkActivatableIface *iface);
+static void image_menu_item_update (GtkActivatable *activatable,
+ GtkAction *action,
+ const gchar *property_name);
+static void image_menu_item_sync_action_properties (GtkActivatable *activatable,
+ GtkAction *action);
+
+
+G_DEFINE_TYPE_WITH_CODE (ImageMenuItem, image_menu_item, GTK_TYPE_MENU_ITEM,
+ G_ADD_PRIVATE (ImageMenuItem)
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE,
+ image_menu_item_activatable_interface_init))
+
+
+static void
+image_menu_item_class_init (ImageMenuItemClass *klass)
+{
+ GObjectClass *gobject_class = (GObjectClass*) klass;
+ GtkWidgetClass *widget_class = (GtkWidgetClass*) klass;
+ GtkMenuItemClass *menu_item_class = (GtkMenuItemClass*) klass;
+ GtkContainerClass *container_class = (GtkContainerClass*) klass;
+
+ widget_class->destroy = image_menu_item_destroy;
+ widget_class->screen_changed = image_menu_item_screen_changed;
+ widget_class->get_preferred_width = image_menu_item_get_preferred_width;
+ widget_class->get_preferred_height = image_menu_item_get_preferred_height;
+ widget_class->get_preferred_height_for_width = image_menu_item_get_preferred_height_for_width;
+ widget_class->size_allocate = image_menu_item_size_allocate;
+ widget_class->map = image_menu_item_map;
+
+ container_class->forall = image_menu_item_forall;
+ container_class->remove = image_menu_item_remove;
+
+ menu_item_class->toggle_size_request = image_menu_item_toggle_size_request;
+ menu_item_class->set_label = image_menu_item_set_label;
+ menu_item_class->get_label = image_menu_item_get_label;
+
+ gobject_class->finalize = image_menu_item_finalize;
+ gobject_class->set_property = image_menu_item_set_property;
+ gobject_class->get_property = image_menu_item_get_property;
+
+ /**
+ * ImageMenuItem:image:
+ *
+ * Child widget to appear next to the menu text.
+ *
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_IMAGE,
+ g_param_spec_object ("image",
+ _("Image widget"),
+ _("Child widget to appear next to the menu text"),
+ GTK_TYPE_WIDGET,
+ GTK_PARAM_READWRITE | G_PARAM_DEPRECATED));
+ /**
+ * ImageMenuItem:use-stock:
+ *
+ * If %TRUE, the label set in the menuitem is used as a
+ * stock id to select the stock item for the item.
+ *
+ * Since: 2.16
+ *
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_USE_STOCK,
+ g_param_spec_boolean ("use-stock",
+ _("Use stock"),
+ _("Whether to use the label text to create a stock menu item"),
+ FALSE,
+ GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_DEPRECATED));
+
+ /**
+ * ImageMenuItem:accel-group:
+ *
+ * The Accel Group to use for stock accelerator keys
+ *
+ * Since: 2.16
+ *
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_ACCEL_GROUP,
+ g_param_spec_object ("accel-group",
+ _("Accel Group"),
+ _("The Accel Group to use for stock accelerator keys"),
+ GTK_TYPE_ACCEL_GROUP,
+ GTK_PARAM_WRITABLE | G_PARAM_DEPRECATED));
+
+}
+
+static void
+image_menu_item_init (ImageMenuItem *image_menu_item)
+{
+ ImageMenuItemPrivate *priv;
+
+ image_menu_item->priv = image_menu_item_get_instance_private (image_menu_item);
+ priv = image_menu_item->priv;
+
+ priv->image = NULL;
+ priv->use_stock = FALSE;
+ priv->label = NULL;
+}
+
+static void
+image_menu_item_finalize (GObject *object)
+{
+ ImageMenuItemPrivate *priv = IMAGE_MENU_ITEM (object)->priv;
+
+ g_free (priv->label);
+ priv->label = NULL;
+
+ G_OBJECT_CLASS (image_menu_item_parent_class)->finalize (object);
+}
+
+static void
+image_menu_item_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ ImageMenuItem *image_menu_item = IMAGE_MENU_ITEM (object);
+
+ switch (prop_id)
+ {
+ case PROP_IMAGE:
+ image_menu_item_set_image (image_menu_item, (GtkWidget *) g_value_get_object (value));
+ break;
+ case PROP_USE_STOCK:
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+ image_menu_item_set_use_stock (image_menu_item, g_value_get_boolean (value));
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+ break;
+ case PROP_ACCEL_GROUP:
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+ image_menu_item_set_accel_group (image_menu_item, g_value_get_object (value));
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+image_menu_item_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ ImageMenuItem *image_menu_item = IMAGE_MENU_ITEM (object);
+
+ switch (prop_id)
+ {
+ case PROP_IMAGE:
+ g_value_set_object (value, image_menu_item_get_image (image_menu_item));
+ break;
+ case PROP_USE_STOCK:
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+ g_value_set_boolean (value, image_menu_item_get_use_stock (image_menu_item));
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+image_menu_item_map (GtkWidget *widget)
+{
+ ImageMenuItem *image_menu_item = IMAGE_MENU_ITEM (widget);
+ ImageMenuItemPrivate *priv = image_menu_item->priv;
+
+ GTK_WIDGET_CLASS (image_menu_item_parent_class)->map (widget);
+
+ if (priv->image)
+ g_object_set (priv->image, "visible", TRUE, NULL);
+}
+
+static void
+image_menu_item_destroy (GtkWidget *widget)
+{
+ ImageMenuItem *image_menu_item = IMAGE_MENU_ITEM (widget);
+ ImageMenuItemPrivate *priv = image_menu_item->priv;
+
+ if (priv->image)
+ gtk_container_remove (GTK_CONTAINER (image_menu_item),
+ priv->image);
+
+ GTK_WIDGET_CLASS (image_menu_item_parent_class)->destroy (widget);
+}
+
+static void
+image_menu_item_toggle_size_request (GtkMenuItem *menu_item,
+ gint *requisition)
+{
+ ImageMenuItem *image_menu_item = IMAGE_MENU_ITEM (menu_item);
+ ImageMenuItemPrivate *priv = image_menu_item->priv;
+ GtkPackDirection pack_dir;
+ GtkWidget *parent;
+ GtkWidget *widget = GTK_WIDGET (menu_item);
+
+ parent = gtk_widget_get_parent (widget);
+
+ if (GTK_IS_MENU_BAR (parent))
+ pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
+ else
+ pack_dir = GTK_PACK_DIRECTION_LTR;
+
+ *requisition = 0;
+
+ if (priv->image && gtk_widget_get_visible (priv->image))
+ {
+ GtkRequisition image_requisition;
+ guint toggle_spacing;
+
+ gtk_widget_get_preferred_size (priv->image, &image_requisition, NULL);
+
+ gtk_widget_style_get (GTK_WIDGET (menu_item),
+ "toggle-spacing", &toggle_spacing,
+ NULL);
+
+ if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL)
+ {
+ if (image_requisition.width > 0)
+ *requisition = image_requisition.width + toggle_spacing;
+ }
+ else
+ {
+ if (image_requisition.height > 0)
+ *requisition = image_requisition.height + toggle_spacing;
+ }
+ }
+}
+
+static void
+image_menu_item_recalculate (ImageMenuItem *image_menu_item)
+{
+ ImageMenuItemPrivate *priv = image_menu_item->priv;
+ GtkStockItem stock_item;
+ GtkWidget *image;
+ const gchar *resolved_label = priv->label;
+
+ if (priv->use_stock && priv->label)
+ {
+
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+
+ if (!priv->image)
+ {
+ image = gtk_image_new_from_stock (priv->label, GTK_ICON_SIZE_MENU);
+ image_menu_item_set_image (image_menu_item, image);
+ }
+
+ if (gtk_stock_lookup (priv->label, &stock_item))
+ resolved_label = stock_item.label;
+
+ gtk_menu_item_set_use_underline (GTK_MENU_ITEM (image_menu_item), TRUE);
+
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+ }
+
+ GTK_MENU_ITEM_CLASS
+ (image_menu_item_parent_class)->set_label (GTK_MENU_ITEM (image_menu_item), resolved_label);
+
+}
+
+static void
+image_menu_item_set_label (GtkMenuItem *menu_item,
+ const gchar *label)
+{
+ ImageMenuItemPrivate *priv = IMAGE_MENU_ITEM (menu_item)->priv;
+
+ if (priv->label != label)
+ {
+ g_free (priv->label);
+ priv->label = g_strdup (label);
+
+ image_menu_item_recalculate (IMAGE_MENU_ITEM (menu_item));
+
+ g_object_notify (G_OBJECT (menu_item), "label");
+
+ }
+}
+
+static const gchar *
+image_menu_item_get_label (GtkMenuItem *menu_item)
+{
+ ImageMenuItemPrivate *priv = IMAGE_MENU_ITEM (menu_item)->priv;
+
+ return priv->label;
+}
+
+static void
+image_menu_item_get_preferred_width (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
+{
+ ImageMenuItem *image_menu_item = IMAGE_MENU_ITEM (widget);
+ ImageMenuItemPrivate *priv = image_menu_item->priv;
+ GtkPackDirection pack_dir;
+ GtkWidget *parent;
+
+ parent = gtk_widget_get_parent (widget);
+
+ if (GTK_IS_MENU_BAR (parent))
+ pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
+ else
+ pack_dir = GTK_PACK_DIRECTION_LTR;
+
+ GTK_WIDGET_CLASS (image_menu_item_parent_class)->get_preferred_width (widget, minimum, natural);
+
+ if ((pack_dir == GTK_PACK_DIRECTION_TTB || pack_dir == GTK_PACK_DIRECTION_BTT) &&
+ priv->image &&
+ gtk_widget_get_visible (priv->image))
+ {
+ gint child_minimum, child_natural;
+
+ gtk_widget_get_preferred_width (priv->image, &child_minimum, &child_natural);
+
+ *minimum = MAX (*minimum, child_minimum);
+ *natural = MAX (*natural, child_natural);
+ }
+}
+
+static void
+image_menu_item_get_preferred_height (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
+{
+ ImageMenuItem *image_menu_item = IMAGE_MENU_ITEM (widget);
+ ImageMenuItemPrivate *priv = image_menu_item->priv;
+ gint child_height = 0;
+ GtkPackDirection pack_dir;
+ GtkWidget *parent;
+
+ parent = gtk_widget_get_parent (widget);
+
+ if (GTK_IS_MENU_BAR (parent))
+ pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
+ else
+ pack_dir = GTK_PACK_DIRECTION_LTR;
+
+ if (priv->image && gtk_widget_get_visible (priv->image))
+ {
+ GtkRequisition child_requisition;
+
+ gtk_widget_get_preferred_size (priv->image, &child_requisition, NULL);
+
+ child_height = child_requisition.height;
+ }
+
+ GTK_WIDGET_CLASS (image_menu_item_parent_class)->get_preferred_height (widget, minimum, natural);
+
+ if (pack_dir == GTK_PACK_DIRECTION_RTL || pack_dir == GTK_PACK_DIRECTION_LTR)
+ {
+ *minimum = MAX (*minimum, child_height);
+ *natural = MAX (*natural, child_height);
+ }
+}
+
+static void
+image_menu_item_get_preferred_height_for_width (GtkWidget *widget,
+ gint width,
+ gint *minimum,
+ gint *natural)
+{
+ ImageMenuItem *image_menu_item = IMAGE_MENU_ITEM (widget);
+ ImageMenuItemPrivate *priv = image_menu_item->priv;
+ gint child_height = 0;
+ GtkPackDirection pack_dir;
+ GtkWidget *parent;
+
+ parent = gtk_widget_get_parent (widget);
+
+ if (GTK_IS_MENU_BAR (parent))
+ pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
+ else
+ pack_dir = GTK_PACK_DIRECTION_LTR;
+
+ if (priv->image && gtk_widget_get_visible (priv->image))
+ {
+ GtkRequisition child_requisition;
+
+ gtk_widget_get_preferred_size (priv->image, &child_requisition, NULL);
+
+ child_height = child_requisition.height;
+ }
+
+ GTK_WIDGET_CLASS
+ (image_menu_item_parent_class)->get_preferred_height_for_width (widget, width, minimum, natural);
+
+ if (pack_dir == GTK_PACK_DIRECTION_RTL || pack_dir == GTK_PACK_DIRECTION_LTR)
+ {
+ *minimum = MAX (*minimum, child_height);
+ *natural = MAX (*natural, child_height);
+ }
+}
+
+
+static void
+image_menu_item_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ ImageMenuItem *image_menu_item = IMAGE_MENU_ITEM (widget);
+ ImageMenuItemPrivate *priv = image_menu_item->priv;
+ GtkAllocation widget_allocation;
+ GtkPackDirection pack_dir;
+ GtkWidget *parent;
+
+ parent = gtk_widget_get_parent (widget);
+
+ if (GTK_IS_MENU_BAR (parent))
+ pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
+ else
+ pack_dir = GTK_PACK_DIRECTION_LTR;
+
+ GTK_WIDGET_CLASS (image_menu_item_parent_class)->size_allocate (widget, allocation);
+
+ if (priv->image && gtk_widget_get_visible (priv->image))
+ {
+ gint x, y, offset;
+ GtkStyleContext *context;
+ GtkStateFlags state;
+ GtkBorder padding;
+ GtkRequisition child_requisition;
+ GtkAllocation child_allocation;
+ guint horizontal_padding, toggle_spacing;
+ gint toggle_size;
+
+ toggle_size = image_menu_item->priv->toggle_size;
+ gtk_widget_style_get (widget,
+ "horizontal-padding", &horizontal_padding,
+ "toggle-spacing", &toggle_spacing,
+ NULL);
+
+ /* Man this is lame hardcoding action, but I can't
+ * come up with a solution that's really better.
+ */
+
+ gtk_widget_get_preferred_size (priv->image, &child_requisition, NULL);
+
+ gtk_widget_get_allocation (widget, &widget_allocation);
+
+ context = gtk_widget_get_style_context (widget);
+ state = gtk_widget_get_state_flags (widget);
+ gtk_style_context_get_padding (context, state, &padding);
+ offset = gtk_container_get_border_width (GTK_CONTAINER (image_menu_item));
+
+ if (pack_dir == GTK_PACK_DIRECTION_LTR ||
+ pack_dir == GTK_PACK_DIRECTION_RTL)
+ {
+ if ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) ==
+ (pack_dir == GTK_PACK_DIRECTION_LTR))
+ x = offset + horizontal_padding + padding.left +
+ (toggle_size - toggle_spacing - child_requisition.width) / 2;
+ else
+ x = widget_allocation.width - offset - horizontal_padding - padding.right -
+ toggle_size + toggle_spacing +
+ (toggle_size - toggle_spacing - child_requisition.width) / 2;
+
+ y = (widget_allocation.height - child_requisition.height) / 2;
+ }
+ else
+ {
+ if ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) ==
+ (pack_dir == GTK_PACK_DIRECTION_TTB))
+ y = offset + horizontal_padding + padding.top +
+ (toggle_size - toggle_spacing - child_requisition.height) / 2;
+ else
+ y = widget_allocation.height - offset - horizontal_padding - padding.bottom -
+ toggle_size + toggle_spacing +
+ (toggle_size - toggle_spacing - child_requisition.height) / 2;
+
+ x = (widget_allocation.width - child_requisition.width) / 2;
+ }
+
+ child_allocation.width = child_requisition.width;
+ child_allocation.height = child_requisition.height;
+ child_allocation.x = widget_allocation.x + MAX (x, 0);
+ child_allocation.y = widget_allocation.y + MAX (y, 0);
+
+ gtk_widget_size_allocate (priv->image, &child_allocation);
+ }
+}
+
+static void
+image_menu_item_forall (GtkContainer *container,
+ gboolean include_internals,
+ GtkCallback callback,
+ gpointer callback_data)
+{
+ ImageMenuItem *image_menu_item = IMAGE_MENU_ITEM (container);
+ ImageMenuItemPrivate *priv = image_menu_item->priv;
+
+ GTK_CONTAINER_CLASS (image_menu_item_parent_class)->forall (container,
+ include_internals,
+ callback,
+ callback_data);
+
+ if (include_internals && priv->image)
+ (* callback) (priv->image, callback_data);
+}
+
+
+static void
+image_menu_item_activatable_interface_init (GtkActivatableIface *iface)
+{
+ parent_activatable_iface = g_type_interface_peek_parent (iface);
+ iface->update = image_menu_item_update;
+ iface->sync_action_properties = image_menu_item_sync_action_properties;
+}
+
+static gboolean
+activatable_update_stock_id (ImageMenuItem *image_menu_item, GtkAction *action)
+{
+ GtkWidget *image;
+ const gchar *stock_id = gtk_action_get_stock_id (action);
+
+ image = image_menu_item_get_image (image_menu_item);
+
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+
+ if (GTK_IS_IMAGE (image) &&
+ stock_id && gtk_icon_factory_lookup_default (stock_id))
+ {
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+ gtk_image_set_from_stock (GTK_IMAGE (image), stock_id, GTK_ICON_SIZE_MENU);
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+ return TRUE;
+ }
+
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+
+ return FALSE;
+}
+
+static gboolean
+activatable_update_gicon (ImageMenuItem *image_menu_item, GtkAction *action)
+{
+ GtkWidget *image;
+ GIcon *icon = gtk_action_get_gicon (action);
+ const gchar *stock_id;
+ gboolean ret = FALSE;
+
+ stock_id = gtk_action_get_stock_id (action);
+
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+
+ image = image_menu_item_get_image (image_menu_item);
+
+ if (icon && GTK_IS_IMAGE (image) &&
+ !(stock_id && gtk_icon_factory_lookup_default (stock_id)))
+ {
+ gtk_image_set_from_gicon (GTK_IMAGE (image), icon, GTK_ICON_SIZE_MENU);
+ ret = TRUE;
+ }
+
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+
+ return ret;
+}
+
+static void
+activatable_update_icon_name (ImageMenuItem *image_menu_item, GtkAction *action)
+{
+ GtkWidget *image;
+ const gchar *icon_name = gtk_action_get_icon_name (action);
+
+ image = image_menu_item_get_image (image_menu_item);
+
+ if (GTK_IS_IMAGE (image) &&
+ (gtk_image_get_storage_type (GTK_IMAGE (image)) == GTK_IMAGE_EMPTY ||
+ gtk_image_get_storage_type (GTK_IMAGE (image)) == GTK_IMAGE_ICON_NAME))
+ {
+ gtk_image_set_from_icon_name (GTK_IMAGE (image), icon_name, GTK_ICON_SIZE_MENU);
+ }
+}
+
+static void
+image_menu_item_update (GtkActivatable *activatable,
+ GtkAction *action,
+ const gchar *property_name)
+{
+ ImageMenuItem *image_menu_item;
+ gboolean use_appearance;
+
+ image_menu_item = IMAGE_MENU_ITEM (activatable);
+
+ parent_activatable_iface->update (activatable, action, property_name);
+
+ use_appearance = gtk_activatable_get_use_action_appearance (activatable);
+ if (!use_appearance)
+ return;
+
+ if (strcmp (property_name, "stock-id") == 0)
+ activatable_update_stock_id (image_menu_item, action);
+ else if (strcmp (property_name, "gicon") == 0)
+ activatable_update_gicon (image_menu_item, action);
+ else if (strcmp (property_name, "icon-name") == 0)
+ activatable_update_icon_name (image_menu_item, action);
+}
+
+static void
+image_menu_item_sync_action_properties (GtkActivatable *activatable,
+ GtkAction *action)
+{
+ ImageMenuItem *image_menu_item;
+ GtkWidget *image;
+ gboolean use_appearance;
+
+ image_menu_item = IMAGE_MENU_ITEM (activatable);
+
+ parent_activatable_iface->sync_action_properties (activatable, action);
+
+ if (!action)
+ return;
+
+ use_appearance = gtk_activatable_get_use_action_appearance (activatable);
+ if (!use_appearance)
+ return;
+
+ image = image_menu_item_get_image (image_menu_item);
+ if (image && !GTK_IS_IMAGE (image))
+ {
+ image_menu_item_set_image (image_menu_item, NULL);
+ image = NULL;
+ }
+
+ if (!image)
+ {
+ image = gtk_image_new ();
+ gtk_widget_show (image);
+ image_menu_item_set_image (IMAGE_MENU_ITEM (activatable),
+ image);
+ }
+
+ if (!activatable_update_stock_id (image_menu_item, action) &&
+ !activatable_update_gicon (image_menu_item, action))
+ activatable_update_icon_name (image_menu_item, action);
+
+}
+
+
+/**
+ * image_menu_item_new:
+ *
+ * Creates a new #ImageMenuItem with an empty label.
+ *
+ * Returns: a new #ImageMenuItem
+ *
+ */
+GtkWidget*
+image_menu_item_new (void)
+{
+ return g_object_new (TYPE_IMAGE_MENU_ITEM, NULL);
+}
+
+/**
+ * image_menu_item_new_with_label:
+ * @label: the text of the menu item.
+ *
+ * Creates a new #ImageMenuItem containing a label.
+ *
+ * Returns: a new #ImageMenuItem.
+ *
+ */
+GtkWidget*
+image_menu_item_new_with_label (const gchar *label)
+{
+ return g_object_new (TYPE_IMAGE_MENU_ITEM,
+ "label", label,
+ NULL);
+}
+
+/**
+ * image_menu_item_new_with_mnemonic:
+ * @label: the text of the menu item, with an underscore in front of the
+ * mnemonic character
+ *
+ * Creates a new #ImageMenuItem containing a label. The label
+ * will be created using gtk_label_new_with_mnemonic(), so underscores
+ * in @label indicate the mnemonic for the menu item.
+ *
+ * Returns: a new #ImageMenuItem
+ *
+ */
+GtkWidget*
+image_menu_item_new_with_mnemonic (const gchar *label)
+{
+ return g_object_new (TYPE_IMAGE_MENU_ITEM,
+ "use-underline", TRUE,
+ "label", label,
+ NULL);
+}
+
+/**
+ * image_menu_item_new_from_stock:
+ * @stock_id: the name of the stock item.
+ * @accel_group: (allow-none): the #GtkAccelGroup to add the menu items
+ * accelerator to, or %NULL.
+ *
+ * Creates a new #ImageMenuItem containing the image and text from a
+ * stock item. Some stock ids have preprocessor macros like #STOCK_OK
+ * and #STOCK_APPLY.
+ *
+ * If you want this menu item to have changeable accelerators, then pass in
+ * %NULL for accel_group. Next call gtk_menu_item_set_accel_path() with an
+ * appropriate path for the menu item, use gtk_stock_lookup() to look up the
+ * standard accelerator for the stock item, and if one is found, call
+ * gtk_accel_map_add_entry() to register it.
+ *
+ * Returns: a new #ImageMenuItem.
+ *
+ */
+GtkWidget*
+image_menu_item_new_from_stock (const gchar *stock_id,
+ GtkAccelGroup *accel_group)
+{
+ return g_object_new (TYPE_IMAGE_MENU_ITEM,
+ "label", stock_id,
+ "use-stock", TRUE,
+ "accel-group", accel_group,
+ NULL);
+}
+
+/**
+ * image_menu_item_set_use_stock:
+ * @image_menu_item: a #ImageMenuItem
+ * @use_stock: %TRUE if the menuitem should use a stock item
+ *
+ * If %TRUE, the label set in the menuitem is used as a
+ * stock id to select the stock item for the item.
+ *
+ * Since: 2.16
+ *
+ */
+void
+image_menu_item_set_use_stock (ImageMenuItem *image_menu_item,
+ gboolean use_stock)
+{
+ ImageMenuItemPrivate *priv;
+
+ g_return_if_fail (IS_IMAGE_MENU_ITEM (image_menu_item));
+
+ priv = image_menu_item->priv;
+
+ if (priv->use_stock != use_stock)
+ {
+ priv->use_stock = use_stock;
+
+ image_menu_item_recalculate (image_menu_item);
+
+ g_object_notify (G_OBJECT (image_menu_item), "use-stock");
+ }
+}
+
+/**
+ * image_menu_item_get_use_stock:
+ * @image_menu_item: a #ImageMenuItem
+ *
+ * Checks whether the label set in the menuitem is used as a
+ * stock id to select the stock item for the item.
+ *
+ * Returns: %TRUE if the label set in the menuitem is used as a
+ * stock id to select the stock item for the item
+ *
+ * Since: 2.16
+ *
+ */
+gboolean
+image_menu_item_get_use_stock (ImageMenuItem *image_menu_item)
+{
+ g_return_val_if_fail (IS_IMAGE_MENU_ITEM (image_menu_item), FALSE);
+
+ return image_menu_item->priv->use_stock;
+}
+
+/**
+ * image_menu_item_set_accel_group:
+ * @image_menu_item: a #ImageMenuItem
+ * @accel_group: the #GtkAccelGroup
+ *
+ * Specifies an @accel_group to add the menu items accelerator to
+ * (this only applies to stock items so a stock item must already
+ * be set, make sure to call image_menu_item_set_use_stock()
+ * and gtk_menu_item_set_label() with a valid stock item first).
+ *
+ * If you want this menu item to have changeable accelerators then
+ * you shouldnt need this (see image_menu_item_new_from_stock()).
+ *
+ * Since: 2.16
+ *
+ */
+void
+image_menu_item_set_accel_group (ImageMenuItem *image_menu_item,
+ GtkAccelGroup *accel_group)
+{
+ ImageMenuItemPrivate *priv;
+ GtkStockItem stock_item;
+
+ /* Silent return for the constructor */
+ if (!accel_group)
+ return;
+
+ g_return_if_fail (IS_IMAGE_MENU_ITEM (image_menu_item));
+ g_return_if_fail (GTK_IS_ACCEL_GROUP (accel_group));
+
+ priv = image_menu_item->priv;
+
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+
+ if (priv->use_stock && priv->label && gtk_stock_lookup (priv->label, &stock_item))
+ if (stock_item.keyval)
+ {
+ gtk_widget_add_accelerator (GTK_WIDGET (image_menu_item),
+ "activate",
+ accel_group,
+ stock_item.keyval,
+ stock_item.modifier,
+ GTK_ACCEL_VISIBLE);
+
+ g_object_notify (G_OBJECT (image_menu_item), "accel-group");
+ }
+
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+
+}
+
+/**
+ * image_menu_item_set_image:
+ * @image_menu_item: a #ImageMenuItem.
+ * @image: (allow-none): a widget to set as the image for the menu item.
+ *
+ * Sets the image of @image_menu_item to the given widget.
+ * Note that it depends on the show-menu-images setting whether
+ * the image will be displayed or not.
+ *
+ */
+void
+image_menu_item_set_image (ImageMenuItem *image_menu_item,
+ GtkWidget *image)
+{
+ ImageMenuItemPrivate *priv;
+
+ g_return_if_fail (IS_IMAGE_MENU_ITEM (image_menu_item));
+
+ priv = image_menu_item->priv;
+
+ if (image == priv->image)
+ return;
+
+ if (priv->image)
+ gtk_container_remove (GTK_CONTAINER (image_menu_item),
+ priv->image);
+
+ priv->image = image;
+
+ if (image == NULL)
+ return;
+
+ gtk_widget_set_parent (image, GTK_WIDGET (image_menu_item));
+ g_object_set (image, "visible", TRUE, "no-show-all", TRUE, NULL);
+
+ g_object_notify (G_OBJECT (image_menu_item), "image");
+}
+
+/**
+ * image_menu_item_get_image:
+ * @image_menu_item: a #ImageMenuItem
+ *
+ * Gets the widget that is currently set as the image of @image_menu_item.
+ * See image_menu_item_set_image().
+ *
+ * Return value: (transfer none): the widget set as image of @image_menu_item
+ *
+ **/
+GtkWidget*
+image_menu_item_get_image (ImageMenuItem *image_menu_item)
+{
+ g_return_val_if_fail (IS_IMAGE_MENU_ITEM (image_menu_item), NULL);
+
+ return image_menu_item->priv->image;
+}
+
+static void
+image_menu_item_remove (GtkContainer *container,
+ GtkWidget *child)
+{
+ ImageMenuItem *image_menu_item = IMAGE_MENU_ITEM (container);
+ ImageMenuItemPrivate *priv = image_menu_item->priv;
+
+ if (child == priv->image)
+ {
+ gboolean widget_was_visible;
+
+ widget_was_visible = gtk_widget_get_visible (child);
+
+ gtk_widget_unparent (child);
+ priv->image = NULL;
+
+ if (widget_was_visible &&
+ gtk_widget_get_visible (GTK_WIDGET (container)))
+ gtk_widget_queue_resize (GTK_WIDGET (container));
+
+ g_object_notify (G_OBJECT (image_menu_item), "image");
+ }
+ else
+ {
+ GTK_CONTAINER_CLASS (image_menu_item_parent_class)->remove (container, child);
+ }
+}
+
+static void
+show_image_change_notify (ImageMenuItem *image_menu_item)
+{
+ ImageMenuItemPrivate *priv = image_menu_item->priv;
+
+ if (priv->image)
+ {
+ gtk_widget_show (priv->image);
+ }
+}
+
+static void
+traverse_container (GtkWidget *widget,
+ gpointer data)
+{
+ if (IS_IMAGE_MENU_ITEM (widget))
+ show_image_change_notify (IMAGE_MENU_ITEM (widget));
+ else if (GTK_IS_CONTAINER (widget))
+ gtk_container_forall (GTK_CONTAINER (widget), traverse_container, NULL);
+}
+
+static void
+image_menu_item_setting_changed (GtkSettings *settings)
+{
+ GList *list, *l;
+
+ list = gtk_window_list_toplevels ();
+
+ for (l = list; l; l = l->next)
+ gtk_container_forall (GTK_CONTAINER (l->data),
+ traverse_container, NULL);
+
+ g_list_free (list);
+}
+
+static void
+image_menu_item_screen_changed (GtkWidget *widget,
+ GdkScreen *previous_screen)
+{
+ GtkSettings *settings;
+ gulong show_image_connection;
+
+ if (!gtk_widget_has_screen (widget))
+ return;
+
+ settings = gtk_widget_get_settings (widget);
+
+ show_image_connection =
+ g_signal_handler_find (settings, G_SIGNAL_MATCH_FUNC, 0, 0,
+ NULL, image_menu_item_setting_changed, NULL);
+
+ if (show_image_connection)
+ return;
+
+ g_signal_connect (settings, "notify::gtk-menu-images",
+ G_CALLBACK (image_menu_item_setting_changed), NULL);
+
+ show_image_change_notify (IMAGE_MENU_ITEM (widget));
+}
diff --git a/src/widgets/image-menu-item.h b/src/widgets/image-menu-item.h
new file mode 100644
index 000000000..61cc48f3a
--- /dev/null
+++ b/src/widgets/image-menu-item.h
@@ -0,0 +1,81 @@
+/* GTK - The GIMP Toolkit
+ * Copyright (C) Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-2000.
+ * Forked for , icons in menus are important to us.
+ */
+
+#ifndef __IMAGE_MENU_ITEM_H__
+#define __IMAGE_MENU_ITEM_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GTK_PARAM_READABLE G_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
+#define GTK_PARAM_WRITABLE G_PARAM_WRITABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
+#define GTK_PARAM_READWRITE G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
+
+#define TYPE_IMAGE_MENU_ITEM (image_menu_item_get_type ())
+#define IMAGE_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_IMAGE_MENU_ITEM, ImageMenuItem))
+#define IMAGE_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_IMAGE_MENU_ITEM, ImageMenuItemClass))
+#define IS_IMAGE_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_IMAGE_MENU_ITEM))
+#define IS_IMAGE_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_IMAGE_MENU_ITEM))
+#define IMAGE_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_IMAGE_MENU_ITEM, ImageMenuItemClass))
+
+typedef struct _ImageMenuItem ImageMenuItem;
+typedef struct _ImageMenuItemPrivate ImageMenuItemPrivate;
+typedef struct _ImageMenuItemClass ImageMenuItemClass;
+
+struct _ImageMenuItem
+{
+ GtkMenuItem menu_item;
+
+ /*< private >*/
+ ImageMenuItemPrivate *priv;
+};
+
+struct _ImageMenuItemClass
+{
+ GtkMenuItemClass parent_class;
+
+ /* Padding for future expansion */
+ void (*_gtk_reserved1) (void);
+ void (*_gtk_reserved2) (void);
+ void (*_gtk_reserved3) (void);
+ void (*_gtk_reserved4) (void);
+};
+
+GType image_menu_item_get_type (void) G_GNUC_CONST;
+GtkWidget* image_menu_item_new (void);
+GtkWidget* image_menu_item_new_with_label (const gchar *label);
+GtkWidget* image_menu_item_new_with_mnemonic (const gchar *label);
+GtkWidget* image_menu_item_new_from_stock (const gchar *stock_id,
+ GtkAccelGroup *accel_group);
+void image_menu_item_set_image (ImageMenuItem *image_menu_item,
+ GtkWidget *image);
+GtkWidget* image_menu_item_get_image (ImageMenuItem *image_menu_item);
+void image_menu_item_set_use_stock (ImageMenuItem *image_menu_item,
+ gboolean use_stock);
+gboolean image_menu_item_get_use_stock (ImageMenuItem *image_menu_item);
+void image_menu_item_set_accel_group (ImageMenuItem *image_menu_item,
+ GtkAccelGroup *accel_group);
+
+G_END_DECLS
+
+#endif /* __IMAGE_MENU_ITEM_H__ */
diff --git a/src/widgets/ink-action.cpp b/src/widgets/ink-action.cpp
index 5941c31e4..ace99d9aa 100644
--- a/src/widgets/ink-action.cpp
+++ b/src/widgets/ink-action.cpp
@@ -1,12 +1,20 @@
#include "widgets/icon.h"
#include "icon-size.h"
#include <glib/gi18n.h>
-#include <gtk/gtk.h>
+
#include "widgets/ink-action.h"
#include "widgets/button.h"
+#include <gtk/gtk.h>
+
+#if GTK_CHECK_VERSION(3,0,0)
+ // Fork of gtk-imagemenuitem to continue support
+ #include "widgets/image-menu-item.h"
+
+#endif
+
static void ink_action_finalize( GObject* obj );
static void ink_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec );
static void ink_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec );
@@ -158,7 +166,12 @@ static GtkWidget* ink_action_create_menu_item( GtkAction* action )
gchar* label = 0;
g_object_get( G_OBJECT(act), "label", &label, NULL );
+#if GTK_CHECK_VERSION(3,0,0)
+ item = image_menu_item_new_with_mnemonic( label );
+#else
item = gtk_image_menu_item_new_with_mnemonic( label );
+#endif
+
GtkWidget* child = sp_icon_new( Inkscape::ICON_SIZE_MENU, act->private_data->iconId );
// TODO this work-around is until SPIcon will live properly inside of a popup menu
if ( SP_IS_ICON(child) ) {
@@ -172,7 +185,12 @@ static GtkWidget* ink_action_create_menu_item( GtkAction* action )
}
}
gtk_widget_show_all( child );
+
+#if GTK_CHECK_VERSION(3,0,0)
+ image_menu_item_set_image( IMAGE_MENU_ITEM(item), child );
+#else
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(item), child );
+#endif
g_free( label );
label = 0;
@@ -374,9 +392,16 @@ static GtkWidget* ink_toggle_action_create_tool_item( GtkAction* action )
GtkToolButton* button = GTK_TOOL_BUTTON(item);
if ( act->private_data->iconId ) {
GtkWidget* child = sp_icon_new( act->private_data->iconSize, act->private_data->iconId );
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_hexpand(child, FALSE);
+ gtk_widget_set_vexpand(child, FALSE);
+ gtk_tool_button_set_icon_widget(button, child);
+#else
GtkWidget* align = gtk_alignment_new( 0.5, 0.5, 0.0, 0.0 );
gtk_container_add( GTK_CONTAINER(align), child );
gtk_tool_button_set_icon_widget( button, align );
+#endif
} else {
gchar *label = 0;
g_object_get( G_OBJECT(action), "short_label", &label, NULL );
@@ -405,10 +430,18 @@ static void ink_toggle_action_update_icon( InkToggleAction* action )
GtkToolButton* button = GTK_TOOL_BUTTON(proxies->data);
GtkWidget* child = sp_icon_new( action->private_data->iconSize, action->private_data->iconId );
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_hexpand(child, FALSE);
+ gtk_widget_set_vexpand(child, FALSE);
+ gtk_widget_show_all(child);
+ gtk_tool_button_set_icon_widget(button, child);
+#else
GtkWidget* align = gtk_alignment_new( 0.5, 0.5, 0.0, 0.0 );
gtk_container_add( GTK_CONTAINER(align), child );
gtk_widget_show_all( align );
gtk_tool_button_set_icon_widget( button, align );
+#endif
}
}
@@ -577,9 +610,16 @@ static GtkWidget* ink_radio_action_create_tool_item( GtkAction* action )
GtkToolButton* button = GTK_TOOL_BUTTON(item);
GtkWidget* child = sp_icon_new( act->private_data->iconSize, act->private_data->iconId );
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_hexpand(child, FALSE);
+ gtk_widget_set_vexpand(child, FALSE);
+ gtk_tool_button_set_icon_widget(button, child);
+#else
GtkWidget* align = gtk_alignment_new( 0.5, 0.5, 0.0, 0.0 );
gtk_container_add( GTK_CONTAINER(align), child );
gtk_tool_button_set_icon_widget( button, align );
+#endif
} else {
// For now trigger a warning but don't do anything else
GtkToolButton* button = GTK_TOOL_BUTTON(item);
diff --git a/src/widgets/ink-comboboxentry-action.cpp b/src/widgets/ink-comboboxentry-action.cpp
index 1114d2cdb..ec5e26cf5 100644
--- a/src/widgets/ink-comboboxentry-action.cpp
+++ b/src/widgets/ink-comboboxentry-action.cpp
@@ -371,9 +371,16 @@ GtkWidget* create_tool_item( GtkAction* action )
g_free( combobox_name );
{
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_halign(comboBoxEntry, GTK_ALIGN_START);
+ gtk_widget_set_hexpand(comboBoxEntry, FALSE);
+ gtk_widget_set_vexpand(comboBoxEntry, FALSE);
+ gtk_container_add(GTK_CONTAINER(item), comboBoxEntry);
+#else
GtkWidget *align = gtk_alignment_new(0, 0.5, 0, 0);
gtk_container_add( GTK_CONTAINER(align), comboBoxEntry );
gtk_container_add( GTK_CONTAINER(item), align );
+#endif
}
ink_comboboxentry_action->combobox = GTK_COMBO_BOX (comboBoxEntry);
@@ -956,3 +963,14 @@ gboolean keypress_cb( GtkWidget * /*widget*/, GdkEventKey *event, gpointer data
return wasConsumed;
}
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/widgets/ruler.cpp b/src/widgets/ruler.cpp
index ab486eeeb..deffd384a 100644
--- a/src/widgets/ruler.cpp
+++ b/src/widgets/ruler.cpp
@@ -41,8 +41,9 @@
#define GTK_PARAM_READWRITE G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
-#define DEFAULT_RULER_FONT_SCALE PANGO_SCALE_X_SMALL
-#define MINIMUM_INCR 5
+#define DEFAULT_RULER_FONT_SCALE PANGO_SCALE_X_SMALL
+#define MINIMUM_INCR 5
+#define IMMEDIATE_REDRAW_THRESHOLD 20
using Inkscape::Util::unit_table;
@@ -71,11 +72,11 @@ typedef struct
GdkWindow *input_window;
cairo_surface_t *backing_store;
+ gboolean backing_store_valid;
+ GdkRectangle last_pos_rect;
+ guint pos_redraw_idle_id;
PangoLayout *layout;
gdouble font_scale;
-
- gint xsrc;
- gint ysrc;
GList *track_widgets;
} SPRulerPrivate;
@@ -132,18 +133,22 @@ static void sp_ruler_style_updated (GtkWidget *widget);
static void sp_ruler_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void sp_ruler_style_set (GtkWidget *widget,
- GtkStyle *prev_style);
+ GtkStyle *prev_style);
#endif
static gboolean sp_ruler_motion_notify (GtkWidget *widget,
GdkEventMotion *event);
static gboolean sp_ruler_draw (GtkWidget *widget,
- cairo_t *cr);
+ cairo_t *cr);
#if !GTK_CHECK_VERSION(3,0,0)
static gboolean sp_ruler_expose (GtkWidget *widget,
GdkEventExpose *event);
#endif
static void sp_ruler_draw_ticks (SPRuler *ruler);
+static GdkRectangle sp_ruler_get_pos_rect (SPRuler *ruler,
+ gdouble position);
+static gboolean sp_ruler_idle_queue_pos_redraw(gpointer data);
+static void sp_ruler_queue_pos_redraw (SPRuler *ruler);
static void sp_ruler_draw_pos (SPRuler *ruler,
cairo_t *cr);
static void sp_ruler_make_pixmap (SPRuler *ruler);
@@ -163,6 +168,10 @@ sp_ruler_class_init (SPRulerClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+#if GTK_CHECK_VERSION(3,20,0)
+ gtk_widget_class_set_css_name (widget_class, "ruler-widget");
+#endif
+
object_class->dispose = sp_ruler_dispose;
object_class->set_property = sp_ruler_set_property;
object_class->get_property = sp_ruler_get_property;
@@ -260,34 +269,23 @@ sp_ruler_init (SPRuler *ruler)
gtk_widget_set_has_window (GTK_WIDGET (ruler), FALSE);
- priv->orientation = GTK_ORIENTATION_HORIZONTAL;
- priv->unit = unit_table.getUnit("px");
- priv->lower = 0;
- priv->upper = 0;
- priv->position = 0;
- priv->max_size = 0;
- priv->backing_store = NULL;
- priv->font_scale = DEFAULT_RULER_FONT_SCALE;
+ priv->orientation = GTK_ORIENTATION_HORIZONTAL;
+ priv->unit = unit_table.getUnit("px");
+ priv->lower = 0;
+ priv->upper = 0;
+ priv->position = 0;
+ priv->max_size = 0;
-#if GTK_CHECK_VERSION(3,0,0)
- #if GTK_CHECK_VERSION(3,8,0)
- const gchar *str =
- "SPRuler {\n"
- " background-color: @theme_bg_color;\n"
- "}\n";
- #else
- const gchar *str =
- "SPRuler {\n"
- " background-color: @bg_color;\n"
- "}\n";
- #endif
- GtkCssProvider *css = gtk_css_provider_new ();
- gtk_css_provider_load_from_data (css, str, -1, NULL);
- gtk_style_context_add_provider (gtk_widget_get_style_context (GTK_WIDGET (ruler)),
- GTK_STYLE_PROVIDER (css),
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
- g_object_unref (css);
-#endif
+ priv->backing_store = NULL;
+ priv->backing_store_valid = FALSE;
+
+ priv->last_pos_rect.x = 0;
+ priv->last_pos_rect.y = 0;
+ priv->last_pos_rect.width = 0;
+ priv->last_pos_rect.height = 0;
+ priv->pos_redraw_idle_id = 0;
+
+ priv->font_scale = DEFAULT_RULER_FONT_SCALE;
}
static void
@@ -299,6 +297,12 @@ sp_ruler_dispose (GObject *object)
while (priv->track_widgets)
sp_ruler_remove_track_widget (ruler, GTK_WIDGET(priv->track_widgets->data));
+ if (priv->pos_redraw_idle_id)
+ {
+ g_source_remove (priv->pos_redraw_idle_id);
+ priv->pos_redraw_idle_id = 0;
+ }
+
G_OBJECT_CLASS (parent_class)->dispose (object);
}
@@ -343,6 +347,7 @@ sp_ruler_set_range (SPRuler *ruler,
}
g_object_thaw_notify (G_OBJECT (ruler));
+ priv->backing_store_valid = FALSE;
gtk_widget_queue_draw (GTK_WIDGET (ruler));
}
@@ -513,7 +518,9 @@ sp_ruler_unrealize(GtkWidget *widget)
cairo_surface_destroy (priv->backing_store);
priv->backing_store = NULL;
}
-
+
+ priv->backing_store_valid = FALSE;
+
if (priv->layout)
{
g_object_unref (priv->layout);
@@ -689,7 +696,6 @@ sp_ruler_expose (GtkWidget *widget,
cairo_clip (cr);
gtk_widget_get_allocation (widget, &allocation);
- cairo_translate (cr, allocation.x, allocation.y);
gboolean result = sp_ruler_draw (widget, cr);
@@ -733,6 +739,8 @@ sp_ruler_make_pixmap (SPRuler *ruler)
CAIRO_CONTENT_COLOR,
allocation.width,
allocation.height);
+
+ priv->backing_store_valid = FALSE;
}
static void
@@ -743,118 +751,22 @@ sp_ruler_draw_pos (SPRuler *ruler,
#if GTK_CHECK_VERSION(3,0,0)
GtkStyleContext *context = gtk_widget_get_style_context (widget);
- GtkBorder border;
GdkRGBA color;
#else
GtkStyle *style = gtk_widget_get_style (widget);
GtkStateType state = gtk_widget_get_state (widget);
- gint xthickness;
- gint ythickness;
#endif
SPRulerPrivate *priv = SP_RULER_GET_PRIVATE (ruler);
- GtkAllocation allocation;
- gint x, y;
- gint width, height;
- gint bs_width, bs_height;
+ GdkRectangle pos_rect;
if (! gtk_widget_is_drawable (widget))
return;
- gtk_widget_get_allocation(widget, &allocation);
-
-#if GTK_CHECK_VERSION(3,0,0)
- gtk_style_context_get_border (context, static_cast<GtkStateFlags>(0), &border);
-#else
- xthickness = style->xthickness;
- ythickness = style->ythickness;
-#endif
-
- if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
- {
- width = allocation.width;
-#if GTK_CHECK_VERSION(3,0,0)
- height = allocation.height - (border.top + border.bottom);
-#else
- height = allocation.height - ythickness * 2;
-#endif
-
- bs_width = height / 2 + 2;
- bs_width |= 1; /* make sure it's odd */
- bs_height = bs_width / 2 + 1;
- }
- else
- {
-#if GTK_CHECK_VERSION(3,0,0)
- width = allocation.width - (border.left + border.right);
-#else
- width = allocation.width - xthickness * 2;
-#endif
- height = allocation.height;
-
- bs_height = width / 2 + 2;
- bs_height |= 1; /* make sure it's odd */
- bs_width = bs_height / 2 + 1;
- }
+ pos_rect = sp_ruler_get_pos_rect (ruler, sp_ruler_get_position (ruler));
- if ((bs_width > 0) && (bs_height > 0))
+ if ((pos_rect.width > 0) && (pos_rect.height > 0))
{
- gdouble lower;
- gdouble upper;
- gdouble position;
- gdouble increment;
-
- if (! cr)
- {
- cr = gdk_cairo_create (gtk_widget_get_window (widget));
- cairo_translate (cr, allocation.x, allocation.y);
- cairo_rectangle (cr, allocation.x, allocation.y, allocation.width, allocation.height);
- cairo_clip (cr);
-
- cairo_translate (cr, allocation.x, allocation.y);
-
- /* If a backing store exists, restore the ruler */
- if (priv->backing_store)
- {
- cairo_set_source_surface (cr, priv->backing_store, 0, 0);
- cairo_rectangle (cr, priv->xsrc, priv->ysrc, bs_width, bs_height);
- cairo_fill (cr);
- }
- }
- else
- {
- cairo_reference (cr);
- }
-
- position = sp_ruler_get_position (ruler);
-
- sp_ruler_get_range (ruler, &lower, &upper, NULL);
-
- if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
- {
- increment = (gdouble) width / (upper - lower);
-
-#if GTK_CHECK_VERSION(3,0,0)
- x = ROUND ((position - lower) * increment) + (border.left - bs_width) / 2 - 1;
- y = (height + bs_height) / 2 + border.top;
-#else
- x = ROUND ((position - lower) * increment) + (xthickness - bs_width) / 2 - 1;
- y = (height + bs_height) / 2 + ythickness;
-#endif
- }
- else
- {
- increment = (gdouble) height / (upper - lower);
-
-#if GTK_CHECK_VERSION(3,0,0)
- x = (width + bs_width) / 2 + border.left;
- y = ROUND ((position - lower) * increment) + (border.top - bs_height) / 2 - 1;
-#else
- x = (width + bs_width) / 2 + xthickness;
- y = ROUND ((position - lower) * increment) + (ythickness - bs_height) / 2 - 1;
-#endif
- }
-
#if GTK_CHECK_VERSION(3,0,0)
gtk_style_context_get_color (context, gtk_widget_get_state_flags (widget),
&color);
@@ -863,26 +775,28 @@ sp_ruler_draw_pos (SPRuler *ruler,
gdk_cairo_set_source_color (cr, &style->fg[state]);
#endif
- cairo_move_to (cr, x, y);
+ cairo_move_to (cr, pos_rect.x, pos_rect.y);
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
{
- cairo_line_to (cr, x + bs_width / 2.0, y + bs_height);
- cairo_line_to (cr, x + bs_width, y);
+ cairo_line_to (cr, pos_rect.x + pos_rect.width / 2.0,
+ pos_rect.y + pos_rect.height);
+ cairo_line_to (cr, pos_rect.x + pos_rect.width,
+ pos_rect.y);
}
else
{
- cairo_line_to (cr, x + bs_width, y + bs_height / 2.0);
- cairo_line_to (cr, x, y + bs_height);
+ cairo_line_to (cr, pos_rect.x + pos_rect.width,
+
+ pos_rect.y + pos_rect.height / 2.0);
+ cairo_line_to (cr, pos_rect.x,
+ pos_rect.y + pos_rect.height);
}
cairo_fill (cr);
-
- cairo_destroy (cr);
-
- priv->xsrc = x;
- priv->ysrc = y;
}
+
+ priv->last_pos_rect = pos_rect;
}
/**
@@ -1096,6 +1010,7 @@ sp_ruler_set_unit (SPRuler *ruler,
priv->unit = unit;
g_object_notify(G_OBJECT(ruler), "unit");
+ priv->backing_store_valid = FALSE;
gtk_widget_queue_draw (GTK_WIDGET (ruler));
}
}
@@ -1131,10 +1046,39 @@ sp_ruler_set_position (SPRuler *ruler,
if (priv->position != position)
{
- priv->position = position;
- g_object_notify (G_OBJECT (ruler), "position");
-
- sp_ruler_draw_pos (ruler, NULL);
+ GdkRectangle rect;
+ gint xdiff, ydiff;
+
+ priv->position = position;
+ g_object_notify (G_OBJECT (ruler), "position");
+
+ rect = sp_ruler_get_pos_rect (ruler, priv->position);
+
+ xdiff = rect.x - priv->last_pos_rect.x;
+ ydiff = rect.y - priv->last_pos_rect.y;
+
+ /*
+ * If the position has changed far enough, queue a redraw immediately.
+ * Otherwise, we only queue a redraw in a low priority idle handler, to
+ * allow for other things (like updating the canvas) to run.
+ *
+ * TODO: This might not be necessary any more in GTK3 with the frame
+ * clock. Investigate this more after the port to GTK3.
+ */
+ if (priv->last_pos_rect.width != 0 &&
+ priv->last_pos_rect.height != 0 &&
+ (ABS (xdiff) > IMMEDIATE_REDRAW_THRESHOLD ||
+ ABS (ydiff) > IMMEDIATE_REDRAW_THRESHOLD))
+ {
+ sp_ruler_queue_pos_redraw (ruler);
+ }
+ else if (! priv->pos_redraw_idle_id)
+ {
+ priv->pos_redraw_idle_id =
+ g_idle_add_full (G_PRIORITY_LOW,
+ sp_ruler_idle_queue_pos_redraw,
+ ruler, NULL);
+ }
}
}
@@ -1154,7 +1098,7 @@ sp_ruler_get_position (SPRuler *ruler)
static gboolean
sp_ruler_motion_notify (GtkWidget *widget,
- GdkEventMotion *event)
+ GdkEventMotion *event)
{
SPRuler *ruler = SP_RULER(widget);
@@ -1347,7 +1291,7 @@ sp_ruler_draw_ticks (SPRuler *ruler)
if (ideal_length > ++length)
length = ideal_length;
- if (lower < upper)
+ if (lower < upper)
{
start = floor (lower / subd_incr) * subd_incr;
end = ceil (upper / subd_incr) * subd_incr;
@@ -1413,16 +1357,16 @@ sp_ruler_draw_ticks (SPRuler *ruler)
pango_layout_get_extents (layout, &logical_rect, NULL);
#if GTK_CHECK_VERSION(3,0,0)
- cairo_move_to (cr,
+ cairo_move_to (cr,
pos + 2,
border.top + PANGO_PIXELS (logical_rect.y - digit_offset));
#else
- cairo_move_to (cr,
+ cairo_move_to (cr,
pos + 2,
ythickness + PANGO_PIXELS (logical_rect.y - digit_offset));
#endif
- pango_cairo_show_layout(cr, layout);
+ pango_cairo_show_layout(cr, layout);
}
else
{
@@ -1435,15 +1379,15 @@ sp_ruler_draw_ticks (SPRuler *ruler)
pango_layout_get_extents (layout, NULL, &logical_rect);
#if GTK_CHECK_VERSION(3,0,0)
- cairo_move_to (cr,
+ cairo_move_to (cr,
border.left + 1,
pos + digit_height * j + 2 + PANGO_PIXELS (logical_rect.y - digit_offset));
#else
- cairo_move_to (cr,
+ cairo_move_to (cr,
xthickness + 1,
pos + digit_height * j + 2 + PANGO_PIXELS (logical_rect.y - digit_offset));
#endif
- pango_cairo_show_layout (cr, layout);
+ pango_cairo_show_layout (cr, layout);
}
}
}
@@ -1454,10 +1398,128 @@ sp_ruler_draw_ticks (SPRuler *ruler)
cairo_fill (cr);
+ priv->backing_store_valid = TRUE;
+
out:
cairo_destroy (cr);
}
+static GdkRectangle
+sp_ruler_get_pos_rect (SPRuler *ruler,
+ gdouble position)
+{
+ GtkWidget *widget = GTK_WIDGET (ruler);
+ SPRulerPrivate *priv = SP_RULER_GET_PRIVATE (ruler);
+ GtkAllocation allocation;
+ gint width, height;
+ gint xthickness;
+ gint ythickness;
+ gdouble upper, lower;
+ gdouble increment;
+ GdkRectangle rect = { 0, 0, 0, 0 };
+
+ if (! gtk_widget_is_drawable (widget))
+ return rect;
+
+ gtk_widget_get_allocation (widget, &allocation);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkStyleContext *context = gtk_widget_get_style_context (widget);
+ GtkBorder padding;
+
+ gtk_style_context_get_border(context, static_cast<GtkStateFlags>(0), &padding);
+
+ xthickness = padding.left + padding.right;
+ ythickness = padding.top + padding.bottom;
+#else
+ GtkStyle *style = gtk_widget_get_style (widget);
+ xthickness = style->xthickness;
+ ythickness = style->ythickness;
+#endif
+
+ if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ width = allocation.width;
+ height = allocation.height - ythickness * 2;
+
+ rect.width = height / 2 + 2;
+ rect.width |= 1; /* make sure it's odd */
+ rect.height = rect.width / 2 + 1;
+ }
+ else
+ {
+ width = allocation.width - xthickness * 2;
+ height = allocation.height;
+
+ rect.height = width / 2 + 2;
+ rect.height |= 1; /* make sure it's odd */
+ rect.width = rect.height / 2 + 1;
+ }
+
+ sp_ruler_get_range (ruler, &lower, &upper, NULL);
+
+ if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ increment = (gdouble) width / (upper - lower);
+
+ rect.x = ROUND ((position - lower) * increment) + (xthickness - rect.width) / 2 - 1;
+ rect.y = (height + rect.height) / 2 + ythickness;
+ }
+ else
+ {
+ increment = (gdouble) height / (upper - lower);
+
+ rect.x = (width + rect.width) / 2 + xthickness;
+ rect.y = ROUND ((position - lower) * increment) + (ythickness - rect.height) / 2 - 1;
+ }
+
+ rect.x += allocation.x;
+ rect.y += allocation.y;
+
+ return rect;
+}
+
+static gboolean
+sp_ruler_idle_queue_pos_redraw (gpointer data)
+{
+ SPRuler *ruler = (SPRuler *)data;
+ SPRulerPrivate *priv = SP_RULER_GET_PRIVATE (ruler);
+
+ sp_ruler_queue_pos_redraw (ruler);
+
+ gboolean ret = g_source_remove(priv->pos_redraw_idle_id);
+ priv->pos_redraw_idle_id = 0;
+
+ return ret;
+}
+
+static void
+sp_ruler_queue_pos_redraw (SPRuler *ruler)
+{
+ SPRulerPrivate *priv = SP_RULER_GET_PRIVATE (ruler);
+ const GdkRectangle rect = sp_ruler_get_pos_rect (ruler, priv->position);
+
+ gtk_widget_queue_draw_area (GTK_WIDGET(ruler),
+ rect.x,
+ rect.y,
+ rect.width,
+ rect.height);
+
+ if (priv->last_pos_rect.width != 0 || priv->last_pos_rect.height != 0)
+ {
+ gtk_widget_queue_draw_area (GTK_WIDGET(ruler),
+ priv->last_pos_rect.x,
+ priv->last_pos_rect.y,
+ priv->last_pos_rect.width,
+ priv->last_pos_rect.height);
+
+ priv->last_pos_rect.x = 0;
+ priv->last_pos_rect.y = 0;
+ priv->last_pos_rect.width = 0;
+ priv->last_pos_rect.height = 0;
+ }
+}
+
static PangoLayout*
sp_ruler_create_layout (GtkWidget *widget,
const gchar *text)
diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp
index e49c4c00a..9851b0606 100644
--- a/src/widgets/select-toolbar.cpp
+++ b/src/widgets/select-toolbar.cpp
@@ -136,13 +136,13 @@ sp_selection_layout_widget_change_selection(SPWidget *spw, Inkscape::Selection *
}
static void
-sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
+sp_object_layout_any_value_changed(GtkAdjustment *adj, GObject *tbl)
{
- if (g_object_get_data(G_OBJECT(spw), "update")) {
+ if (g_object_get_data(tbl, "update")) {
return;
}
- UnitTracker *tracker = reinterpret_cast<UnitTracker*>(g_object_get_data(G_OBJECT(spw), "tracker"));
+ UnitTracker *tracker = reinterpret_cast<UnitTracker*>(g_object_get_data(tbl, "tracker"));
if ( !tracker || tracker->isUpdating() ) {
/*
* When only units are being changed, don't treat changes
@@ -150,7 +150,7 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
*/
return;
}
- g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(TRUE));
+ g_object_set_data(tbl, "update", GINT_TO_POINTER(TRUE));
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
Inkscape::Selection *selection = desktop->getSelection();
@@ -168,7 +168,7 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
Geom::OptRect bbox_user = selection->bounds(bbox_type);
if ( !bbox_user ) {
- g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(FALSE));
+ g_object_set_data(tbl, "update", GINT_TO_POINTER(FALSE));
return;
}
@@ -181,10 +181,10 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
Unit const *unit = tracker->getActiveUnit();
g_return_if_fail(unit != NULL);
- GtkAdjustment* a_x = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "X" ) );
- GtkAdjustment* a_y = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "Y" ) );
- GtkAdjustment* a_w = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "width" ) );
- GtkAdjustment* a_h = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "height" ) );
+ GtkAdjustment* a_x = GTK_ADJUSTMENT( g_object_get_data( tbl, "X" ) );
+ GtkAdjustment* a_y = GTK_ADJUSTMENT( g_object_get_data( tbl, "Y" ) );
+ GtkAdjustment* a_w = GTK_ADJUSTMENT( g_object_get_data( tbl, "width" ) );
+ GtkAdjustment* a_h = GTK_ADJUSTMENT( g_object_get_data( tbl, "height" ) );
if (unit->type == Inkscape::Util::UNIT_TYPE_LINEAR) {
x0 = Quantity::convert(gtk_adjustment_get_value(a_x), unit, "px");
@@ -205,7 +205,7 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
}
// Keep proportions if lock is on
- GtkToggleAction *lock = GTK_TOGGLE_ACTION( g_object_get_data(G_OBJECT(spw), "lock") );
+ GtkToggleAction *lock = GTK_TOGGLE_ACTION( g_object_get_data(tbl, "lock") );
if ( gtk_toggle_action_get_active(lock) ) {
if (adj == a_h) {
x1 = x0 + yrel * bbox_user->dimensions()[Geom::X];
@@ -265,68 +265,7 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
desktop->getCanvas()->endForcedFullRedraws();
}
- g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(FALSE));
-}
-
-static GtkWidget* createCustomSlider( GtkAdjustment *adjustment, gdouble climbRate, guint digits, Inkscape::UI::Widget::UnitTracker *unit_tracker )
-{
-#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::Adjustment> adj = Glib::wrap(adjustment, true);
- Inkscape::UI::Widget::SpinButton *inkSpinner = new Inkscape::UI::Widget::SpinButton(adj, climbRate, digits);
-#else
- Inkscape::UI::Widget::SpinButton *inkSpinner = new Inkscape::UI::Widget::SpinButton(*Glib::wrap(adjustment, true), climbRate, digits);
-#endif
- inkSpinner->addUnitTracker(unit_tracker);
- inkSpinner = Gtk::manage( inkSpinner );
- GtkWidget *widget = GTK_WIDGET( inkSpinner->gobj() );
- return widget;
-}
-
-// TODO create_adjustment_action appears to be a rogue tile copy from toolbox.cpp. Resolve it to be unified:
-
-static EgeAdjustmentAction * create_adjustment_action( gchar const *name,
- gchar const *label,
- gchar const *shortLabel,
- gchar const *data,
- gdouble lower,
- GtkWidget* focusTarget,
- UnitTracker* tracker,
- GtkWidget* spw,
- gchar const *tooltip,
- gboolean altx )
-{
- static bool init = false;
- if ( !init ) {
- init = true;
- ege_adjustment_action_set_compact_tool_factory( createCustomSlider );
- }
-
- GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0.0, lower, 1e6, SPIN_STEP, SPIN_PAGE_STEP, 0 ) );
- if (tracker) {
- tracker->addAdjustment(adj);
- }
- if ( spw ) {
- g_object_set_data( G_OBJECT(spw), data, adj );
- }
-
- EgeAdjustmentAction* act = ege_adjustment_action_new( adj, name, Q_(label), tooltip, 0, SPIN_STEP, 3, tracker );
- if ( shortLabel ) {
- g_object_set( act, "short_label", Q_(shortLabel), NULL );
- }
-
- g_signal_connect( G_OBJECT(adj), "value_changed", G_CALLBACK(sp_object_layout_any_value_changed), spw );
- if ( focusTarget ) {
- ege_adjustment_action_set_focuswidget( act, focusTarget );
- }
-
- if ( altx ) { // this spinbutton will be activated by alt-x
- g_object_set( G_OBJECT(act), "self-id", "altx", NULL );
- }
-
- // Using a cast just to make sure we pass in the right kind of function pointer
- g_object_set( G_OBJECT(act), "tool-post", static_cast<EgeWidgetFixup>(sp_set_font_size_smaller), NULL );
-
- return act;
+ g_object_set_data(tbl, "update", GINT_TO_POINTER(FALSE));
}
// toggle button callbacks and updaters
@@ -497,21 +436,60 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
// four spinbuttons
- eact = create_adjustment_action( "XAction", C_("Select toolbar", "X position"), C_("Select toolbar", "X:"), "X",
- -1e6, GTK_WIDGET(desktop->canvas), tracker, spw,
- _("Horizontal coordinate of selection"), TRUE );
+ eact = create_adjustment_action(
+ "XAction", /* name */
+ C_("Select toolbar", "X position"), /* label */
+ C_("Select toolbar", "X:"), /* shortLabel */
+ C_("Select toolbar", "Horizontal coordinate of selection"), /* tooltip */
+ "/tools/select/X", /* path */
+ 0.0, /* def(default) */
+ GTK_WIDGET(desktop->canvas), /* focusTarget */
+ G_OBJECT(spw), /* dataKludge */
+ TRUE, "altx", /* altx, altx_mark */
+ -1e6, 1e6, SPIN_STEP, SPIN_PAGE_STEP, /* lower, uppper, step, page */
+ 0, 0, 0, /* descrLabels, descrValues, descrCount */
+ sp_object_layout_any_value_changed, /* callback */
+ tracker, /* unit_tracker */
+ SPIN_STEP, 3, 1); /* climb, digits, factor */
+
gtk_action_group_add_action( selectionActions, GTK_ACTION(eact) );
contextActions->push_back( GTK_ACTION(eact) );
- eact = create_adjustment_action( "YAction", C_("Select toolbar", "Y position"), C_("Select toolbar", "Y:"), "Y",
- -1e6, GTK_WIDGET(desktop->canvas), tracker, spw,
- _("Vertical coordinate of selection"), FALSE );
+ eact = create_adjustment_action(
+ "YAction", /* name */
+ C_("Select toolbar", "Y position"), /* label */
+ C_("Select toolbar", "Y:"), /* shortLabel */
+ C_("Select toolbar", "Vertical coordinate of selection"), /* tooltip */
+ "/tools/select/Y", /* path */
+ 0.0, /* def(default) */
+ GTK_WIDGET(desktop->canvas), /* focusTarget */
+ G_OBJECT(spw), /* dataKludge */
+ TRUE, "altx", /* altx, altx_mark */
+ -1e6, 1e6, SPIN_STEP, SPIN_PAGE_STEP, /* lower, uppper, step, page */
+ 0, 0, 0, /* descrLabels, descrValues, descrCount */
+ sp_object_layout_any_value_changed, /* callback */
+ tracker, /* unit_tracker */
+ SPIN_STEP, 3, 1); /* climb, digits, factor */
+
gtk_action_group_add_action( selectionActions, GTK_ACTION(eact) );
contextActions->push_back( GTK_ACTION(eact) );
- eact = create_adjustment_action( "WidthAction", C_("Select toolbar", "Width"), C_("Select toolbar", "W:"), "width",
- 0.0, GTK_WIDGET(desktop->canvas), tracker, spw,
- _("Width of selection"), FALSE );
+ eact = create_adjustment_action(
+ "WidthAction", /* name */
+ C_("Select toolbar", "Width"), /* label */
+ C_("Select toolbar", "W:"), /* shortLabel */
+ C_("Select toolbar", "Width of selection"), /* tooltip */
+ "/tools/select/width", /* path */
+ 0.0, /* def(default) */
+ GTK_WIDGET(desktop->canvas), /* focusTarget */
+ G_OBJECT(spw), /* dataKludge */
+ TRUE, "altx", /* altx, altx_mark */
+ 0.0, 1e6, SPIN_STEP, SPIN_PAGE_STEP, /* lower, uppper, step, page */
+ 0, 0, 0, /* descrLabels, descrValues, descrCount */
+ sp_object_layout_any_value_changed, /* callback */
+ tracker, /* unit_tracker */
+ SPIN_STEP, 3, 1); /* climb, digits, factor */
+
gtk_action_group_add_action( selectionActions, GTK_ACTION(eact) );
contextActions->push_back( GTK_ACTION(eact) );
@@ -528,9 +506,23 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
gtk_action_group_add_action( mainActions, GTK_ACTION(itact) );
}
- eact = create_adjustment_action( "HeightAction", C_("Select toolbar", "Height"), C_("Select toolbar", "H:"), "height",
- 0.0, GTK_WIDGET(desktop->canvas), tracker, spw,
- _("Height of selection"), FALSE );
+ eact = create_adjustment_action(
+ "HeightAction", /* name */
+ C_("Select toolbar", "Height"), /* label */
+ C_("Select toolbar", "H:"), /* shortLabel */
+ C_("Select toolbar", "Height of selection"), /* tooltip */
+ "/tools/select/height", /* path */
+ 0.0, /* def(default) */
+ GTK_WIDGET(desktop->canvas), /* focusTarget */
+ G_OBJECT(spw), /* dataKludge */
+ TRUE, "altx", /* altx, altx_mark */
+ 0.0, 1e6, SPIN_STEP, SPIN_PAGE_STEP, /* lower, uppper, step, page */
+ 0, 0, 0, /* descrLabels, descrValues, descrCount */
+ sp_object_layout_any_value_changed, /* callback */
+ tracker, /* unit_tracker */
+ SPIN_STEP, 3, 1); /* climb, digits, factor */
+
+
gtk_action_group_add_action( selectionActions, GTK_ACTION(eact) );
contextActions->push_back( GTK_ACTION(eact) );
diff --git a/src/widgets/shrink-wrap-button.cpp b/src/widgets/shrink-wrap-button.cpp
deleted file mode 100644
index 941a0466c..000000000
--- a/src/widgets/shrink-wrap-button.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Inkscape::Widgets::shrink_wrap_button - shrink a button to minimum size
- *
- * Authors:
- * MenTaLguY <mental@rydia.net>
- *
- * Copyright (C) 2004 MenTaLguY
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gtkmm/button.h>
-#include <gtk/gtk.h>
-
-#include "shrink-wrap-button.h"
-
-namespace Inkscape {
-namespace Widgets {
-
-void shrink_wrap_button(Gtk::Button &button) {
- button.set_border_width(0);
- button.set_can_focus(false);
- button.set_can_default(false);
-
- Gtk::Widget* child = button.get_child();
- Gtk::Requisition req_min;
-
- if (child) {
-#if WITH_GTKMM_3_0
- Gtk::Requisition req_nat;
- child->get_preferred_size(req_min, req_nat);
-#else
- req_min = child->size_request();
-#endif
- } else {
- req_min.width = 0;
- req_min.height = 0;
- }
-
- // TODO: Use Gtk::StyleContext instead
- GtkStyle* style = gtk_widget_get_style(GTK_WIDGET(button.gobj()));
-
- req_min.width += 2 + 2 * std::max(2, style->xthickness);
- req_min.height += 2 + 2 * std::max(2, style->ythickness);
-
- button.set_size_request(req_min.width, req_min.height);
-}
-
-}
-}
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/widgets/shrink-wrap-button.h b/src/widgets/shrink-wrap-button.h
deleted file mode 100644
index ca9153aea..000000000
--- a/src/widgets/shrink-wrap-button.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Inkscape::Widgets::shrink_wrap_button - shrink a button to minimum size
- *
- * Authors:
- * MenTaLguY <mental@rydia.net>
- *
- * Copyright (C) 2004 MenTaLguY
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#ifndef SEEN_INKSCAPE_WIDGETS_SHRINK_WRAP_BUTTON_H
-#define SEEN_INKSCAPE_WIDGETS_SHRINK_WRAP_BUTTON_H
-
-namespace Gtk { class Button; }
-
-namespace Inkscape {
-namespace Widgets {
-
-void shrink_wrap_button(Gtk::Button &button);
-
-}
-}
-
-#endif
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/widgets/spw-utilities.cpp b/src/widgets/spw-utilities.cpp
index 7030753a5..5500e1068 100644
--- a/src/widgets/spw-utilities.cpp
+++ b/src/widgets/spw-utilities.cpp
@@ -84,12 +84,23 @@ spw_label_old(GtkWidget *table, const gchar *label_text, int col, int row)
label_widget = gtk_label_new (label_text);
g_assert(label_widget != NULL);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_halign(label_widget, GTK_ALIGN_END);
+#else
gtk_misc_set_alignment (GTK_MISC (label_widget), 1.0, 0.5);
+#endif
+
gtk_widget_show (label_widget);
#if GTK_CHECK_VERSION(3,0,0)
+#if GTK_CHECK_VERSION(3,12,0)
+ gtk_widget_set_margin_start(label_widget, 4);
+ gtk_widget_set_margin_end(label_widget, 4);
+#else
gtk_widget_set_margin_left(label_widget, 4);
gtk_widget_set_margin_right(label_widget, 4);
+#endif
gtk_widget_set_hexpand(label_widget, TRUE);
gtk_widget_set_halign(label_widget, GTK_ALIGN_FILL);
gtk_widget_set_valign(label_widget, GTK_ALIGN_CENTER);
@@ -166,7 +177,13 @@ spw_checkbutton(GtkWidget * dialog, GtkWidget * table,
g_assert(table != NULL);
GtkWidget *l = gtk_label_new (label);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_halign(l, GTK_ALIGN_END);
+#else
gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5);
+#endif
+
gtk_widget_show (l);
#if GTK_CHECK_VERSION(3,0,0)
@@ -238,12 +255,26 @@ sp_set_font_size_recursive (GtkWidget *w, gpointer font)
{
guint size = GPOINTER_TO_UINT (font);
- PangoFontDescription* pan = pango_font_description_new ();
- pango_font_description_set_size (pan, size);
-
#if GTK_CHECK_VERSION(3,0,0)
- gtk_widget_override_font (w, pan);
+ GtkCssProvider *css_provider = gtk_css_provider_new();
+
+ const double pt_size = size / static_cast<double>(PANGO_SCALE);
+ std::ostringstream css_data;
+ css_data << "GtkWidget {\n"
+ << " font-size: " << pt_size << "pt;\n"
+ << "}\n";
+
+ gtk_css_provider_load_from_data(css_provider,
+ css_data.str().c_str(),
+ -1, NULL);
+
+ GtkStyleContext *style_context = gtk_widget_get_style_context(w);
+ gtk_style_context_add_provider(style_context,
+ GTK_STYLE_PROVIDER(css_provider),
+ GTK_STYLE_PROVIDER_PRIORITY_USER);
#else
+ PangoFontDescription* pan = pango_font_description_new ();
+ pango_font_description_set_size (pan, size);
gtk_widget_modify_font (w, pan);
#endif
@@ -251,7 +282,11 @@ sp_set_font_size_recursive (GtkWidget *w, gpointer font)
gtk_container_foreach (GTK_CONTAINER(w), (GtkCallback) sp_set_font_size_recursive, font);
}
+#if GTK_CHECK_VERSION(3,0,0)
+ g_object_unref(css_provider);
+#else
pango_font_description_free (pan);
+#endif
}
void
diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp
index 43dffec56..84a6e77ad 100644
--- a/src/widgets/stroke-style.cpp
+++ b/src/widgets/stroke-style.cpp
@@ -221,6 +221,67 @@ StrokeStyle::StrokeStyle() :
#endif
i++;
+ /* Dash */
+ spw_label(table, _("Dashes:"), 0, i, NULL); //no mnemonic for now
+ //decide what to do:
+ // implement a set_mnemonic_source function in the
+ // SPDashSelector class, so that we do not have to
+ // expose any of the underlying widgets?
+ dashSelector = Gtk::manage(new SPDashSelector);
+
+ dashSelector->show();
+
+#if WITH_GTKMM_3_0
+ dashSelector->set_hexpand();
+ dashSelector->set_halign(Gtk::ALIGN_FILL);
+ dashSelector->set_valign(Gtk::ALIGN_CENTER);
+ table->attach(*dashSelector, 1, i, 3, 1);
+#else
+ table->attach(*dashSelector, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 0, 0);
+#endif
+
+ dashSelector->changed_signal.connect(sigc::mem_fun(*this, &StrokeStyle::lineDashChangedCB));
+
+ i++;
+
+ /* Drop down marker selectors*/
+ // TRANSLATORS: Path markers are an SVG feature that allows you to attach arbitrary shapes
+ // (arrowheads, bullets, faces, whatever) to the start, end, or middle nodes of a path.
+
+ spw_label(table, _("Markers:"), 0, i, NULL);
+
+ hb = spw_hbox(table, 1, 1, i);
+ i++;
+
+ startMarkerCombo = Gtk::manage(new MarkerComboBox("marker-start", SP_MARKER_LOC_START));
+ startMarkerCombo->set_tooltip_text(_("Start Markers are drawn on the first node of a path or shape"));
+ startMarkerConn = startMarkerCombo->signal_changed().connect(
+ sigc::bind<MarkerComboBox *, StrokeStyle *, SPMarkerLoc>(
+ sigc::ptr_fun(&StrokeStyle::markerSelectCB), startMarkerCombo, this, SP_MARKER_LOC_START));
+ startMarkerCombo->show();
+
+ hb->pack_start(*startMarkerCombo, true, true, 0);
+
+ midMarkerCombo = Gtk::manage(new MarkerComboBox("marker-mid", SP_MARKER_LOC_MID));
+ midMarkerCombo->set_tooltip_text(_("Mid Markers are drawn on every node of a path or shape except the first and last nodes"));
+ midMarkerConn = midMarkerCombo->signal_changed().connect(
+ sigc::bind<MarkerComboBox *, StrokeStyle *, SPMarkerLoc>(
+ sigc::ptr_fun(&StrokeStyle::markerSelectCB), midMarkerCombo, this, SP_MARKER_LOC_MID));
+ midMarkerCombo->show();
+
+ hb->pack_start(*midMarkerCombo, true, true, 0);
+
+ endMarkerCombo = Gtk::manage(new MarkerComboBox("marker-end", SP_MARKER_LOC_END));
+ endMarkerCombo->set_tooltip_text(_("End Markers are drawn on the last node of a path or shape"));
+ endMarkerConn = endMarkerCombo->signal_changed().connect(
+ sigc::bind<MarkerComboBox *, StrokeStyle *, SPMarkerLoc>(
+ sigc::ptr_fun(&StrokeStyle::markerSelectCB), endMarkerCombo, this, SP_MARKER_LOC_END));
+ endMarkerCombo->show();
+
+ hb->pack_start(*endMarkerCombo, true, true, 0);
+
+ i++;
+
/* Join type */
// TRANSLATORS: The line join style specifies the shape to be used at the
// corners of paths. It can be "miter", "round" or "bevel".
@@ -230,14 +291,6 @@ StrokeStyle::StrokeStyle() :
Gtk::RadioButtonGroup joinGrp;
- joinMiter = makeRadioButton(joinGrp, INKSCAPE_ICON("stroke-join-miter"),
- hb, STROKE_STYLE_BUTTON_JOIN, "miter");
-
- // TRANSLATORS: Miter join: joining lines with a sharp (pointed) corner.
- // For an example, draw a triangle with a large stroke width and modify the
- // "Join" option (in the Fill and Stroke dialog).
- joinMiter->set_tooltip_text(_("Miter join"));
-
joinRound = makeRadioButton(joinGrp, INKSCAPE_ICON("stroke-join-round"),
hb, STROKE_STYLE_BUTTON_JOIN, "round");
@@ -254,7 +307,13 @@ StrokeStyle::StrokeStyle() :
// "Join" option (in the Fill and Stroke dialog).
joinBevel->set_tooltip_text(_("Bevel join"));
- i++;
+ joinMiter = makeRadioButton(joinGrp, INKSCAPE_ICON("stroke-join-miter"),
+ hb, STROKE_STYLE_BUTTON_JOIN, "miter");
+
+ // TRANSLATORS: Miter join: joining lines with a sharp (pointed) corner.
+ // For an example, draw a triangle with a large stroke width and modify the
+ // "Join" option (in the Fill and Stroke dialog).
+ joinMiter->set_tooltip_text(_("Miter join"));
/* Miterlimit */
// TRANSLATORS: Miter limit: only for "miter join", this limits the length
@@ -265,8 +324,6 @@ StrokeStyle::StrokeStyle() :
// when they become too long.
//spw_label(t, _("Miter _limit:"), 0, i);
- hb = spw_hbox(table, 3, 1, i);
-
#if WITH_GTKMM_3_0
miterLimitAdj = new Glib::RefPtr<Gtk::Adjustment>(Gtk::Adjustment::create(4.0, 0.0, 100.0, 0.1, 10.0, 0.0));
miterLimitSpin = new Inkscape::UI::Widget::SpinButton(*miterLimitAdj, 0.1, 2);
@@ -277,7 +334,6 @@ StrokeStyle::StrokeStyle() :
miterLimitSpin->set_tooltip_text(_("Maximum length of the miter (in units of stroke width)"));
miterLimitSpin->show();
- spw_label(table, _("Miter _limit:"), 0, i, miterLimitSpin);
sp_dialog_defocus_on_enter_cpp(miterLimitSpin);
hb->pack_start(*miterLimitSpin, false, false, 0);
@@ -288,6 +344,7 @@ StrokeStyle::StrokeStyle() :
#else
miterLimitAdj->signal_value_changed().connect(sigc::mem_fun(*this, &StrokeStyle::miterLimitChangedCB));
#endif
+
i++;
/* Cap type */
@@ -322,64 +379,43 @@ StrokeStyle::StrokeStyle() :
i++;
- /* Dash */
- spw_label(table, _("Dashes:"), 0, i, NULL); //no mnemonic for now
- //decide what to do:
- // implement a set_mnemonic_source function in the
- // SPDashSelector class, so that we do not have to
- // expose any of the underlying widgets?
- dashSelector = Gtk::manage(new SPDashSelector);
-
- dashSelector->show();
+ /* Paint order */
+ // TRANSLATORS: Paint order determines the order the 'fill', 'stroke', and 'markers are painted.
+ spw_label(table, _("Order:"), 0, i, NULL);
-#if WITH_GTKMM_3_0
- dashSelector->set_hexpand();
- dashSelector->set_halign(Gtk::ALIGN_FILL);
- dashSelector->set_valign(Gtk::ALIGN_CENTER);
- table->attach(*dashSelector, 1, i, 3, 1);
-#else
- table->attach(*dashSelector, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 0, 0);
-#endif
+ hb = spw_hbox(table, 4, 1, i);
- dashSelector->changed_signal.connect(sigc::mem_fun(*this, &StrokeStyle::lineDashChangedCB));
+ Gtk::RadioButtonGroup paintOrderGrp;
- i++;
+ paintOrderFSM = makeRadioButton(paintOrderGrp, INKSCAPE_ICON("paint-order-fsm"),
+ hb, STROKE_STYLE_BUTTON_ORDER, "normal");
+ paintOrderFSM->set_tooltip_text(_("Fill, Stroke, Markers"));
- /* Drop down marker selectors*/
- // TRANSLATORS: Path markers are an SVG feature that allows you to attach arbitrary shapes
- // (arrowheads, bullets, faces, whatever) to the start, end, or middle nodes of a path.
+ paintOrderSFM = makeRadioButton(paintOrderGrp, INKSCAPE_ICON("paint-order-sfm"),
+ hb, STROKE_STYLE_BUTTON_ORDER, "stroke fill markers");
+ paintOrderSFM->set_tooltip_text(_("Stroke, Fill, Markers"));
- spw_label(table, _("Markers:"), 0, i, NULL);
+ paintOrderFMS = makeRadioButton(paintOrderGrp, INKSCAPE_ICON("paint-order-fms"),
+ hb, STROKE_STYLE_BUTTON_ORDER, "fill markers stroke");
+ paintOrderFMS->set_tooltip_text(_("Fill, Markers, Stroke"));
- hb = spw_hbox(table, 1, 1, i);
i++;
- startMarkerCombo = Gtk::manage(new MarkerComboBox("marker-start", SP_MARKER_LOC_START));
- startMarkerCombo->set_tooltip_text(_("Start Markers are drawn on the first node of a path or shape"));
- startMarkerConn = startMarkerCombo->signal_changed().connect(
- sigc::bind<MarkerComboBox *, StrokeStyle *, SPMarkerLoc>(
- sigc::ptr_fun(&StrokeStyle::markerSelectCB), startMarkerCombo, this, SP_MARKER_LOC_START));
- startMarkerCombo->show();
+ hb = spw_hbox(table, 4, 1, i);
- hb->pack_start(*startMarkerCombo, true, true, 0);
+ paintOrderMFS = makeRadioButton(paintOrderGrp, INKSCAPE_ICON("paint-order-mfs"),
+ hb, STROKE_STYLE_BUTTON_ORDER, "markers fill stroke");
+ paintOrderMFS->set_tooltip_text(_("Markers, Fill, Stroke"));
- midMarkerCombo = Gtk::manage(new MarkerComboBox("marker-mid", SP_MARKER_LOC_MID));
- midMarkerCombo->set_tooltip_text(_("Mid Markers are drawn on every node of a path or shape except the first and last nodes"));
- midMarkerConn = midMarkerCombo->signal_changed().connect(
- sigc::bind<MarkerComboBox *, StrokeStyle *, SPMarkerLoc>(
- sigc::ptr_fun(&StrokeStyle::markerSelectCB), midMarkerCombo, this, SP_MARKER_LOC_MID));
- midMarkerCombo->show();
+ paintOrderSMF = makeRadioButton(paintOrderGrp, INKSCAPE_ICON("paint-order-smf"),
+ hb, STROKE_STYLE_BUTTON_ORDER, "stroke markers fill");
+ paintOrderSMF->set_tooltip_text(_("Stroke, Markers, Fill"));
- hb->pack_start(*midMarkerCombo, true, true, 0);
+ paintOrderMSF = makeRadioButton(paintOrderGrp, INKSCAPE_ICON("paint-order-msf"),
+ hb, STROKE_STYLE_BUTTON_ORDER, "markers stroke fill");
+ paintOrderMSF->set_tooltip_text(_("Markers, Stroke, Fill"));
- endMarkerCombo = Gtk::manage(new MarkerComboBox("marker-end", SP_MARKER_LOC_END));
- endMarkerCombo->set_tooltip_text(_("End Markers are drawn on the last node of a path or shape"));
- endMarkerConn = endMarkerCombo->signal_changed().connect(
- sigc::bind<MarkerComboBox *, StrokeStyle *, SPMarkerLoc>(
- sigc::ptr_fun(&StrokeStyle::markerSelectCB), endMarkerCombo, this, SP_MARKER_LOC_END));
- endMarkerCombo->show();
-
- hb->pack_start(*endMarkerCombo, true, true, 0);
+ i++;
setDesktop(desktop);
updateLine();
@@ -802,6 +838,43 @@ StrokeStyle::setCapType (unsigned const captype)
}
/**
+ * Sets the cap type for a line, and updates the stroke style widget's buttons
+ */
+void
+StrokeStyle::setPaintOrder (gchar const *paint_order)
+{
+ Gtk::RadioButton *tb = paintOrderFSM;
+
+ SPIPaintOrder temp;
+ temp.read( paint_order );
+
+ if (temp.layer[0] != SP_CSS_PAINT_ORDER_NORMAL) {
+
+ if (temp.layer[0] == SP_CSS_PAINT_ORDER_FILL) {
+ if (temp.layer[1] == SP_CSS_PAINT_ORDER_STROKE) {
+ tb = paintOrderFSM;
+ } else {
+ tb = paintOrderFMS;
+ }
+ } else if (temp.layer[0] == SP_CSS_PAINT_ORDER_STROKE) {
+ if (temp.layer[1] == SP_CSS_PAINT_ORDER_FILL) {
+ tb = paintOrderSFM;
+ } else {
+ tb = paintOrderSMF;
+ }
+ } else {
+ if (temp.layer[1] == SP_CSS_PAINT_ORDER_STROKE) {
+ tb = paintOrderMSF;
+ } else {
+ tb = paintOrderMFS;
+ }
+ }
+
+ }
+ setPaintOrderButtons(tb);
+}
+
+/**
* Callback for when stroke style widget is updated, including markers, cap type,
* join type, etc.
*/
@@ -825,6 +898,9 @@ StrokeStyle::updateLine()
int result_ml = sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_STROKEMITERLIMIT);
int result_cap = sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_STROKECAP);
int result_join = sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_STROKEJOIN);
+
+ int result_order = sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_PAINTORDER);
+
SPIPaint &targPaint = (kind == FILL) ? query.fill : query.stroke;
if (!sel || sel->isEmpty()) {
@@ -902,6 +978,13 @@ StrokeStyle::updateLine()
setCapButtons(NULL);
}
+ if (result_order != QUERY_STYLE_MULTIPLE_DIFFERENT &&
+ result_order != QUERY_STYLE_NOTHING ) {
+ setPaintOrder (query.paint_order.value);
+ } else {
+ setPaintOrder (NULL);
+ }
+
if (!sel || sel->isEmpty())
return;
@@ -1109,6 +1192,11 @@ void StrokeStyle::buttonToggledCB(StrokeStyleButton *tb, StrokeStyle *spw)
sp_repr_css_set_property(css, "stroke-linecap", tb->get_stroke_style());
sp_desktop_set_style (spw->desktop, css);
spw->setCapButtons(tb);
+ break;
+ case STROKE_STYLE_BUTTON_ORDER:
+ sp_repr_css_set_property(css, "paint-order", tb->get_stroke_style());
+ sp_desktop_set_style (spw->desktop, css);
+ //spw->setPaintButtons(tb);
}
sp_repr_css_attr_unref(css);
@@ -1143,6 +1231,21 @@ StrokeStyle::setCapButtons(Gtk::ToggleButton *active)
/**
+ * Updates the paint order style toggle buttons
+ */
+void
+StrokeStyle::setPaintOrderButtons(Gtk::ToggleButton *active)
+{
+ paintOrderFSM->set_active(active == paintOrderFSM);
+ paintOrderSFM->set_active(active == paintOrderSFM);
+ paintOrderFMS->set_active(active == paintOrderFMS);
+ paintOrderMFS->set_active(active == paintOrderMFS);
+ paintOrderSMF->set_active(active == paintOrderSMF);
+ paintOrderMSF->set_active(active == paintOrderMSF);
+}
+
+
+/**
* Updates the marker combobox to highlight the appropriate marker and scroll to
* that marker.
*/
diff --git a/src/widgets/stroke-style.h b/src/widgets/stroke-style.h
index 2605e1acf..d83067a4a 100644
--- a/src/widgets/stroke-style.h
+++ b/src/widgets/stroke-style.h
@@ -127,7 +127,8 @@ private:
/** List of valid types for the stroke-style radio-button widget */
enum StrokeStyleButtonType {
STROKE_STYLE_BUTTON_JOIN, ///< A button to set the line-join style
- STROKE_STYLE_BUTTON_CAP ///< A button to set the line-cap style
+ STROKE_STYLE_BUTTON_CAP, ///< A button to set the line-cap style
+ STROKE_STYLE_BUTTON_ORDER ///< A button to set the paint-order style
};
/**
@@ -158,8 +159,10 @@ private:
void setDashSelectorFromStyle(SPDashSelector *dsel, SPStyle *style);
void setJoinType (unsigned const jointype);
void setCapType (unsigned const captype);
+ void setPaintOrder (gchar const *paint_order);
void setJoinButtons(Gtk::ToggleButton *active);
void setCapButtons(Gtk::ToggleButton *active);
+ void setPaintOrderButtons(Gtk::ToggleButton *active);
void scaleLine();
void setScaledDash(SPCSSAttr *css, int ndash, double *dash, double offset, double scale);
void setMarkerColor(SPObject *marker, int loc, SPItem *item);
@@ -204,6 +207,12 @@ private:
StrokeStyleButton *capButt;
StrokeStyleButton *capRound;
StrokeStyleButton *capSquare;
+ StrokeStyleButton *paintOrderFSM;
+ StrokeStyleButton *paintOrderSFM;
+ StrokeStyleButton *paintOrderFMS;
+ StrokeStyleButton *paintOrderMFS;
+ StrokeStyleButton *paintOrderSMF;
+ StrokeStyleButton *paintOrderMSF;
SPDashSelector *dashSelector;
gboolean update;
diff --git a/src/widgets/swatch-selector.cpp b/src/widgets/swatch-selector.cpp
index 6f2807255..b9cce1d19 100644
--- a/src/widgets/swatch-selector.cpp
+++ b/src/widgets/swatch-selector.cpp
@@ -37,10 +37,11 @@ SwatchSelector::SwatchSelector() :
color_selector->show();
pack_start(*color_selector);
- _selected_color.signal_grabbed.connect(sigc::mem_fun(this, &SwatchSelector::_grabbedCb));
- _selected_color.signal_dragged.connect(sigc::mem_fun(this, &SwatchSelector::_draggedCb));
- _selected_color.signal_released.connect(sigc::mem_fun(this, &SwatchSelector::_releasedCb));
- _selected_color.signal_changed.connect(sigc::mem_fun(this, &SwatchSelector::_changedCb));
+ //_selected_color.signal_grabbed.connect(sigc::mem_fun(this, &SwatchSelector::_grabbedCb));
+ _selected_color.signal_dragged.connect(sigc::mem_fun(this, &SwatchSelector::_changedCb));
+ _selected_color.signal_released.connect(sigc::mem_fun(this, &SwatchSelector::_changedCb));
+ // signal_changed doesn't get called if updating shape with colour.
+ //_selected_color.signal_changed.connect(sigc::mem_fun(this, &SwatchSelector::_changedCb));
}
SwatchSelector::~SwatchSelector()
@@ -53,45 +54,6 @@ SPGradientSelector *SwatchSelector::getGradientSelector()
return _gsel;
}
-void SwatchSelector::_grabbedCb()
-{
-}
-
-void SwatchSelector::_draggedCb()
-{
- // if (data) {
- //SwatchSelector *swsel = reinterpret_cast<SwatchSelector*>(data);
-
- // TODO might have to block cycles
-
- // Copied from gradient-vector.cpp, but does not appear to cause visible changes:
- /*
- if (swsel->_gsel) {
- SPGradient *gradient = swsel->_gsel->getVector();
- SPGradient *ngr = sp_gradient_ensure_vector_normalized(gradient);
- if (ngr != gradient) {
- // Our master gradient has changed
- // TODO replace with proper - sp_gradient_vector_widget_load_gradient(GTK_WIDGET(swsel->_gsel), ngr);
- }
-
- sp_gradient_ensure_vector(ngr);
-
-
- SPStop* stop = ngr->getFirstStop();
- if (stop) {
- swsel->_csel->base->getColorAlpha(stop->specified_color, &stop->opacity);
- stop->currentColor = false;
- // TODO push refresh
- }
- }
- */
- // }
-}
-
-void SwatchSelector::_releasedCb()
-{
-}
-
void SwatchSelector::_changedCb()
{
if (_updating_color) {
diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp
index 5ca92b4c0..23acb74af 100644
--- a/src/widgets/text-toolbar.cpp
+++ b/src/widgets/text-toolbar.cpp
@@ -54,12 +54,18 @@
#include "ui/icon-names.h"
#include "ui/tools/text-tool.h"
#include "ui/tools/tool-base.h"
+#include "ui/widget/unit-tracker.h"
+#include "util/units.h"
#include "verbs.h"
#include "xml/repr.h"
using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
using Inkscape::UI::PrefPusher;
+using Inkscape::Util::Unit;
+using Inkscape::Util::Quantity;
+using Inkscape::Util::unit_table;
+using Inkscape::UI::Widget::UnitTracker;
//#define DEBUG_TEXT
@@ -502,6 +508,10 @@ static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl )
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
+static bool is_relative( Unit const *unit ) {
+ return (unit->abbr == "" || unit->abbr == "em" || unit->abbr == "ex" || unit->abbr == "%");
+}
+
static void sp_text_lineheight_value_changed( GtkAdjustment *adj, GObject *tbl )
{
// quit if run by the _changed callbacks
@@ -510,25 +520,49 @@ static void sp_text_lineheight_value_changed( GtkAdjustment *adj, GObject *tbl )
}
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
- // At the moment this handles only numerical values (i.e. no percent).
+
+ // Get user selected unit and save as preference
+ UnitTracker *tracker = reinterpret_cast<UnitTracker*>(g_object_get_data(tbl, "tracker"));
+ Unit const *unit = tracker->getActiveUnit();
+ g_return_if_fail(unit != NULL);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
+
+ // Only save if not relative unit
+ if ( !is_relative(unit) ) {
+ // This nonsense is to get SP_CSS_UNIT_xx value corresponding to unit so
+ // we can save it (allows us to adjust line height value when unit changes).
+ SPILength temp_length;
+ Inkscape::CSSOStringStream temp_stream;
+ temp_stream << 1 << unit->abbr;
+ temp_length.read(temp_stream.str().c_str());
+ prefs->setInt("/tools/text/lineheight/display_unit", temp_length.unit);
+ g_object_set_data( tbl, "lineheight_unit", GINT_TO_POINTER(temp_length.unit));
+ }
+
// Set css line height.
SPCSSAttr *css = sp_repr_css_attr_new ();
Inkscape::CSSOStringStream osfs;
- osfs << gtk_adjustment_get_value(adj)*100 << "%";
+ if ( is_relative(unit) ) {
+ osfs << gtk_adjustment_get_value(adj) << unit->abbr;
+ } else {
+ // Inside SVG file, always use "px" for absolute units.
+ osfs << Quantity::convert(gtk_adjustment_get_value(adj), unit, "px") << "px";
+ }
sp_repr_css_set_property (css, "line-height", osfs.str().c_str());
+
// Apply line-height to selected objects.
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
sp_desktop_set_style (desktop, css, true, false);
- // Until deprecated sodipodi:linespacing purged:
+ // Only need to save for undo if a text item has been changed.
Inkscape::Selection *selection = desktop->getSelection();
bool modmade = false;
std::vector<SPItem*> itemlist=selection->itemList();
for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){
if (SP_IS_TEXT (*i)) {
- (*i)->getRepr()->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL));
modmade = true;
}
}
@@ -554,6 +588,162 @@ static void sp_text_lineheight_value_changed( GtkAdjustment *adj, GObject *tbl )
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
+
+static void sp_text_lineheight_unit_changed( gpointer /* */, GObject *tbl )
+{
+ // quit if run by the _changed callbacks
+ if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
+ return;
+ }
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
+
+ // Get old saved unit
+ int old_unit = GPOINTER_TO_INT( g_object_get_data(tbl, "lineheight_unit"));
+
+ // Get user selected unit and save as preference
+ UnitTracker *tracker = reinterpret_cast<UnitTracker*>(g_object_get_data(tbl, "tracker"));
+ Unit const *unit = tracker->getActiveUnit();
+ g_return_if_fail(unit != NULL);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
+ // Only save if not relative unit
+ if ( !is_relative(unit) ) {
+ // This nonsense is to get SP_CSS_UNIT_xx value corresponding to unit.
+ SPILength temp_length;
+ Inkscape::CSSOStringStream temp_stream;
+ temp_stream << 1 << unit->abbr;
+ temp_length.read(temp_stream.str().c_str());
+ prefs->setInt("/tools/text/lineheight/display_unit", temp_length.unit);
+ g_object_set_data( tbl, "lineheight_unit", GINT_TO_POINTER(temp_length.unit));
+ }
+
+ // Read current line height value
+ EgeAdjustmentAction *line_height_act =
+ reinterpret_cast<EgeAdjustmentAction *>(g_object_get_data(tbl, "TextLineHeightAction"));
+ GtkAdjustment *line_height_adj = ege_adjustment_action_get_adjustment( line_height_act );
+ double line_height = gtk_adjustment_get_value(line_height_adj);
+
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ Inkscape::Selection *selection = desktop->getSelection();
+ std::vector<SPItem*> itemlist=selection->itemList();
+
+ // Convert between units
+ if ((unit->abbr == "" || unit->abbr == "em") && old_unit == SP_CSS_UNIT_EX) {
+ line_height *= 0.5;
+ } else if ((unit->abbr) == "ex" && (old_unit == SP_CSS_UNIT_EM || old_unit == SP_CSS_UNIT_NONE) ) {
+ line_height *= 2.0;
+ } else if ((unit->abbr == "" || unit->abbr == "em") && old_unit == SP_CSS_UNIT_PERCENT) {
+ line_height /= 100.0;
+ } else if ((unit->abbr) == "%" && (old_unit == SP_CSS_UNIT_EM || old_unit == SP_CSS_UNIT_NONE) ) {
+ line_height *= 100;
+ } else if ((unit->abbr) == "ex" && old_unit == SP_CSS_UNIT_PERCENT) {
+ line_height /= 50.0;
+ } else if ((unit->abbr) == "%" && old_unit == SP_CSS_UNIT_EX) {
+ line_height *= 50;
+ } else if (is_relative(unit)) {
+ // Convert absolute to relative... for the moment use average font-size
+ double font_size = 0;
+ int count = 0;
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){
+ if (SP_IS_TEXT (*i)) {
+ double doc_scale = Geom::Affine((*i)->i2dt_affine()).descrim();
+ font_size += (*i)->style->font_size.computed * doc_scale;
+ ++count;
+ }
+ }
+ if (count > 0) {
+ font_size /= count;
+ } else {
+ font_size = 20;
+ }
+
+ if (old_unit == SP_CSS_UNIT_NONE) old_unit = SP_CSS_UNIT_EM;
+ line_height = Quantity::convert(line_height, sp_style_get_css_unit_string(old_unit), "px");
+
+ if (font_size > 0) {
+ line_height /= font_size;
+ }
+ if ((unit->abbr) == "%") {
+ line_height *= 100;
+ } else if ((unit->abbr) == "ex") {
+ line_height *= 2;
+ }
+ } else if (old_unit==SP_CSS_UNIT_NONE || old_unit==SP_CSS_UNIT_PERCENT ||
+ old_unit==SP_CSS_UNIT_EM || old_unit==SP_CSS_UNIT_EX) {
+ // Convert relative to absolute... for the moment use average font-size
+ double font_size = 0;
+ int count = 0;
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){
+ if (SP_IS_TEXT (*i)) {
+ double doc_scale = Geom::Affine((*i)->i2dt_affine()).descrim();
+ font_size += (*i)->style->font_size.computed * doc_scale;
+ ++count;
+ }
+ }
+ if (count > 0) {
+ font_size /= count;
+ } else {
+ font_size = 20;
+ }
+
+ if (old_unit == SP_CSS_UNIT_PERCENT) {
+ line_height /= 100.0;
+ } else if (old_unit == SP_CSS_UNIT_EX) {
+ line_height /= 2.0;
+ }
+ line_height *= font_size;
+ line_height = Quantity::convert(line_height, "px", unit);
+ } else {
+ // Convert between different absolute units (only used in GUI)
+ line_height = Quantity::convert(line_height, sp_style_get_css_unit_string(old_unit), unit);
+ }
+
+ // Set css line height.
+ SPCSSAttr *css = sp_repr_css_attr_new ();
+ Inkscape::CSSOStringStream osfs;
+ if ( is_relative(unit) ) {
+ osfs << line_height << unit->abbr;
+ } else {
+ osfs << Quantity::convert(line_height, unit, "px") << "px";
+ }
+ sp_repr_css_set_property (css, "line-height", osfs.str().c_str());
+
+ // Update GUI with line_height value.
+ gtk_adjustment_set_value(line_height_adj, line_height);
+
+ // Apply line-height to selected objects.
+ sp_desktop_set_style (desktop, css, true, false);
+
+ // Only need to save for undo if a text item has been changed.
+ bool modmade = false;
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){
+ if (SP_IS_TEXT (*i)) {
+ modmade = true;
+ }
+ }
+
+ // Save for undo
+ if(modmade) {
+ DocumentUndo::maybeDone(SP_ACTIVE_DESKTOP->getDocument(), "ttb:line-height", SP_VERB_NONE,
+ _("Text: Change line-height unit"));
+ }
+
+ // If no selected objects, set default.
+ SPStyle query(SP_ACTIVE_DOCUMENT);
+ int result_numbers =
+ sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
+ if (result_numbers == QUERY_STYLE_NOTHING)
+ {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->mergeStyle("/tools/text/style", css);
+ }
+
+ sp_repr_css_attr_unref (css);
+
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
+}
+
+
static void sp_text_wordspacing_value_changed( GtkAdjustment *adj, GObject *tbl )
{
// quit if run by the _changed callbacks
@@ -1064,6 +1254,7 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/
{
activeButton = 3;
} else {
+ // This should take 'direction' into account
if (query.text_anchor.computed == SP_CSS_TEXT_ANCHOR_START) activeButton = 0;
if (query.text_anchor.computed == SP_CSS_TEXT_ANCHOR_MIDDLE) activeButton = 1;
if (query.text_anchor.computed == SP_CSS_TEXT_ANCHOR_END) activeButton = 2;
@@ -1071,16 +1262,46 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/
ege_select_one_action_set_active( textAlignAction, activeButton );
- // Line height (spacing)
+ // Line height (spacing) and line height unit
double height;
+ int line_height_unit = -1;
if (query.line_height.normal) {
height = Inkscape::Text::Layout::LINE_HEIGHT_NORMAL;
+ line_height_unit = SP_CSS_UNIT_NONE;
} else {
- if (query.line_height.unit == SP_CSS_UNIT_PERCENT) {
- height = query.line_height.value;
- } else {
- height = query.line_height.computed;
- }
+ height = query.line_height.value;
+ line_height_unit = query.line_height.unit;
+ }
+
+ switch (line_height_unit) {
+ case SP_CSS_UNIT_NONE:
+ case SP_CSS_UNIT_EM:
+ case SP_CSS_UNIT_EX:
+ break;
+ case SP_CSS_UNIT_PERCENT:
+ height *= 100.0; // Inkscape store % as fraction in .value
+ break;
+ case SP_CSS_UNIT_PX:
+ // If unit is set to 'px', use the preferred display unit (if absolute).
+ line_height_unit =
+ prefs->getInt("/tools/text/lineheight/display_unit", SP_CSS_UNIT_PT);
+ // But not if prefered unit is relative
+ if (line_height_unit != SP_CSS_UNIT_NONE &&
+ line_height_unit != SP_CSS_UNIT_EM &&
+ line_height_unit != SP_CSS_UNIT_EX &&
+ line_height_unit != SP_CSS_UNIT_PERCENT) {
+ height =
+ Quantity::convert(height, "px", sp_style_get_css_unit_string(line_height_unit));
+ } else {
+ line_height_unit = SP_CSS_UNIT_PX;
+ }
+ break;
+ default:
+ // If unit has been set by an external program to something other than 'px', use
+ // that unit. But height is average of computed values (px) so we need to convert
+ // back.
+ height =
+ Quantity::convert(height, "px", sp_style_get_css_unit_string(line_height_unit));
}
GtkAction* lineHeightAction = GTK_ACTION( g_object_get_data( tbl, "TextLineHeightAction" ) );
@@ -1088,7 +1309,17 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/
ege_adjustment_action_get_adjustment(EGE_ADJUSTMENT_ACTION( lineHeightAction ));
gtk_adjustment_set_value( lineHeightAdjustment, height );
-
+ UnitTracker* tracker = reinterpret_cast<UnitTracker*>( g_object_get_data( tbl, "tracker" ) );
+ if( line_height_unit == SP_CSS_UNIT_NONE ) {
+ // Function 'sp_style_get_css_unit_string' returns 'px' for unit none.
+ // We need to avoid this.
+ tracker->setActiveUnitByAbbr("");
+ } else {
+ tracker->setActiveUnitByAbbr(sp_style_get_css_unit_string(line_height_unit));
+ }
+ // Save unit so we can do convertions between new/old units.
+ g_object_set_data( tbl, "lineheight_unit", GINT_TO_POINTER(line_height_unit));
+
// Word spacing
double wordSpacing;
if (query.word_spacing.normal) wordSpacing = 0.0;
@@ -1231,7 +1462,6 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/
#endif
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
-
}
static void sp_text_toolbox_selection_modified(Inkscape::Selection *selection, guint /*flags*/, GObject *tbl)
@@ -1332,6 +1562,23 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
g_object_set_data( holder, "TextFontFamilyAction", act );
// Change style of drop-down from menu to list
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkCssProvider *css_provider = gtk_css_provider_new();
+ gtk_css_provider_load_from_data(css_provider,
+ "#TextFontFamilyAction_combobox {\n"
+ " -GtkComboBox-appears-as-list: true;\n"
+ "}\n"
+ "combobox window.popup scrolledwindow treeview separator {\n"
+ " -GtkWidget-wide-separators: true;\n"
+ " -GtkWidget-separator-height: 6;\n"
+ "}\n",
+ -1, NULL);
+
+ GdkScreen *screen = gdk_screen_get_default();
+ gtk_style_context_add_provider_for_screen(screen,
+ GTK_STYLE_PROVIDER(css_provider),
+ GTK_STYLE_PROVIDER_PRIORITY_USER);
+#else
gtk_rc_parse_string (
"style \"dropdown-as-list-style\"\n"
"{\n"
@@ -1344,6 +1591,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
" GtkWidget::separator-height = 6\n"
"}\n"
"widget \"*gtk-combobox-popup-window.GtkScrolledWindow.GtkTreeView\" style \"fontfamily-separator-style\"");
+#endif
}
/* Font size */
@@ -1582,6 +1830,15 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_text_orientation_changed), holder );
}
+ /* Line height unit tracker */
+ UnitTracker* tracker = new UnitTracker(Inkscape::Util::UNIT_TYPE_LINEAR);
+ tracker->prependUnit(unit_table.getUnit("")); // No unit
+ tracker->addUnit(unit_table.getUnit("%"));
+ tracker->addUnit(unit_table.getUnit("em"));
+ tracker->addUnit(unit_table.getUnit("ex"));
+ tracker->setActiveUnit(unit_table.getUnit("%"));
+ g_object_set_data( holder, "tracker", tracker );
+
/* Line height */
{
// Drop down menu
@@ -1599,20 +1856,28 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
holder, /* dataKludge */
FALSE, /* set alt-x keyboard shortcut? */
NULL, /* altx_mark */
- 0.0, 10.0, 0.01, 0.10, /* lower, upper, step (arrow up/down), page up/down */
+ 0.0, 1000.0, 1.0, 10.0, /* lower, upper, step (arrow up/down), page up/down */
labels, values, G_N_ELEMENTS(labels), /* drop down menu */
sp_text_lineheight_value_changed, /* callback */
- NULL, /* unit tracker */
+ NULL, // tracker, /* unit tracker */
0.1, /* step (used?) */
2, /* digits to show */
1.0 /* factor (multiplies default) */
);
+ //tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
g_object_set_data( holder, "TextLineHeightAction", eact );
g_object_set( G_OBJECT(eact), "iconId", "text_line_spacing", NULL );
}
+ /* Line height units */
+ {
+ GtkAction* act = tracker->createAction( "TextLineHeightUnitsAction", _("Units"), ("") );
+ gtk_action_group_add_action( mainActions, act );
+ g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_text_lineheight_unit_changed), holder );
+ }
+
/* Word spacing */
{
// Drop down menu
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index 6787ef6cc..f7b5e585f 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -55,6 +55,7 @@
#include "ui/tools-switch.h"
#include "../ui/icon-names.h"
#include "../ui/widget/style-swatch.h"
+#include "../ui/widget/unit-tracker.h"
#include "../verbs.h"
#include "../widgets/button.h"
#include "../widgets/spinbutton-events.h"
@@ -126,7 +127,8 @@ Inkscape::IconSize ToolboxFactory::prefToSize( Glib::ustring const &path, int ba
static Inkscape::IconSize sizeChoices[] = {
Inkscape::ICON_SIZE_LARGE_TOOLBAR,
Inkscape::ICON_SIZE_SMALL_TOOLBAR,
- Inkscape::ICON_SIZE_MENU
+ Inkscape::ICON_SIZE_MENU,
+ Inkscape::ICON_SIZE_DIALOG
};
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int index = prefs->getIntLimited( path, base, 0, G_N_ELEMENTS(sizeChoices) );
@@ -497,6 +499,9 @@ static gchar const * ui_descr =
" <toolitem action='EraserModeAction' />"
" <separator />"
" <toolitem action='EraserWidthAction' />"
+ " <toolitem action='EraserBreakAppart' />"
+ " <separator />"
+ " <toolitem action='EraserMassAction' />"
" </toolbar>"
" <toolbar name='TextToolbar'>"
@@ -512,6 +517,7 @@ static gchar const * ui_descr =
" <toolitem action='TextSubscriptAction' />"
" <separator />"
" <toolitem action='TextLineHeightAction' />"
+ " <toolitem action='TextLineHeightUnitsAction' />"
" <toolitem action='TextLetterSpacingAction' />"
" <toolitem action='TextWordSpacingAction' />"
" <toolitem action='TextDxAction' />"
@@ -993,6 +999,7 @@ static GtkWidget* toolboxNewCommon( GtkWidget* tb, BarId id, GtkPositionType /*h
gtk_widget_set_sensitive(tb, FALSE);
GtkWidget *hb = gtk_event_box_new(); // A simple, neutral container.
+ gtk_widget_set_name(hb, "ToolboxCommon");
gtk_container_add(GTK_CONTAINER(hb), tb);
gtk_widget_show(GTK_WIDGET(tb));
@@ -1010,6 +1017,7 @@ GtkWidget *ToolboxFactory::createToolToolbox()
{
#if GTK_CHECK_VERSION(3,0,0)
GtkWidget *tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+ gtk_widget_set_name(tb, "ToolToolbox");
gtk_box_set_homogeneous(GTK_BOX(tb), FALSE);
#else
GtkWidget *tb = gtk_vbox_new(FALSE, 0);
@@ -1022,6 +1030,7 @@ GtkWidget *ToolboxFactory::createAuxToolbox()
{
#if GTK_CHECK_VERSION(3,0,0)
GtkWidget *tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+ gtk_widget_set_name(tb, "AuxToolbox");
gtk_box_set_homogeneous(GTK_BOX(tb), FALSE);
#else
GtkWidget *tb = gtk_vbox_new(FALSE, 0);
@@ -1038,6 +1047,7 @@ GtkWidget *ToolboxFactory::createCommandsToolbox()
{
#if GTK_CHECK_VERSION(3,0,0)
GtkWidget *tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+ gtk_widget_set_name(tb, "CommandsToolbox");
gtk_box_set_homogeneous(GTK_BOX(tb), FALSE);
#else
GtkWidget *tb = gtk_vbox_new(FALSE, 0);
@@ -1050,6 +1060,7 @@ GtkWidget *ToolboxFactory::createSnapToolbox()
{
#if GTK_CHECK_VERSION(3,0,0)
GtkWidget *tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+ gtk_widget_set_name(tb, "SnapToolbox");
gtk_box_set_homogeneous(GTK_BOX(tb), FALSE);
#else
GtkWidget *tb = gtk_vbox_new(FALSE, 0);
@@ -1119,6 +1130,10 @@ EgeAdjustmentAction * create_adjustment_action( gchar const *name,
g_object_set_data( dataKludge, prefs->getEntry(path).getEntryName().data(), adj );
}
+ if (unit_tracker) {
+ unit_tracker->addAdjustment(adj);
+ }
+
// Using a cast just to make sure we pass in the right kind of function pointer
g_object_set( G_OBJECT(act), "tool-post", static_cast<EgeWidgetFixup>(sp_set_font_size_smaller), NULL );
@@ -1396,6 +1411,7 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
// converted to GtkActions and UIManager
GtkWidget* kludge = gtk_toolbar_new();
+ gtk_widget_set_name( kludge, "Kludge" );
g_object_set_data( G_OBJECT(kludge), "dtw", desktop->canvas);
g_object_set_data( G_OBJECT(kludge), "desktop", desktop);
dataHolders[aux_toolboxes[i].type_name] = kludge;
@@ -1408,7 +1424,7 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
} else {
sub_toolbox = aux_toolboxes[i].create_func(desktop);
}
-
+ gtk_widget_set_name( sub_toolbox, "SubToolBox" );
gtk_size_group_add_widget( grouper, sub_toolbox );
gtk_container_add(GTK_CONTAINER(toolbox), sub_toolbox);
@@ -1426,6 +1442,7 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
#if GTK_CHECK_VERSION(3,0,0)
GtkWidget* holder = gtk_grid_new();
+ gtk_widget_set_name( holder, "ToolbarHolder" );
gtk_grid_attach( GTK_GRID(holder), kludge, 2, 0, 1, 1);
#else
GtkWidget* holder = gtk_table_new( 1, 3, FALSE );