summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/object/sp-anchor.cpp24
-rw-r--r--src/object/sp-item.h26
-rw-r--r--src/ui/view/README19
-rw-r--r--src/ui/view/svg-view.cpp57
4 files changed, 75 insertions, 51 deletions
diff --git a/src/object/sp-anchor.cpp b/src/object/sp-anchor.cpp
index 9fd556945..d4361a4ef 100644
--- a/src/object/sp-anchor.cpp
+++ b/src/object/sp-anchor.cpp
@@ -20,7 +20,7 @@
#include "xml/repr.h"
#include "attributes.h"
#include "sp-anchor.h"
-#include "ui/view/view.h"
+#include "ui/view/svg-view.h"
#include "document.h"
SPAnchor::SPAnchor() : SPGroup() {
@@ -153,22 +153,34 @@ gchar* SPAnchor::description() const {
}
/* fixme: We should forward event to appropriate container/view */
+/* The only use of SPEvent appears to be here, to change the cursor in Inkview when over a link (and
+ * which hasn't worked since at least 0.48). */
gint SPAnchor::event(SPEvent* event) {
switch (event->type) {
- case SP_EVENT_ACTIVATE:
+ case SPEvent::ACTIVATE:
if (this->href) {
g_print("Activated xlink:href=\"%s\"\n", this->href);
return TRUE;
}
break;
- case SP_EVENT_MOUSEOVER:
- (static_cast<Inkscape::UI::View::View*>(event->data))->mouseover();
+ case SPEvent::MOUSEOVER:
+ {
+ auto view = dynamic_cast<Inkscape::UI::View::SVGView*>(event->view);
+ if (view) {
+ view->mouseover();
+ }
break;
+ }
- case SP_EVENT_MOUSEOUT:
- (static_cast<Inkscape::UI::View::View*>(event->data))->mouseout();
+ case SPEvent::MOUSEOUT:
+ {
+ auto view = dynamic_cast<Inkscape::UI::View::SVGView*>(event->view);
+ if (view) {
+ view->mouseout();
+ }
break;
+ }
default:
break;
diff --git a/src/object/sp-item.h b/src/object/sp-item.h
index 2bd8f2215..068571d85 100644
--- a/src/object/sp-item.h
+++ b/src/object/sp-item.h
@@ -46,15 +46,12 @@ class Drawing;
class DrawingItem;
class URIReference;
+namespace UI {
+namespace View {
+class View;
+}
+}
}
-
-enum {
- SP_EVENT_INVALID,
- SP_EVENT_NONE,
- SP_EVENT_ACTIVATE,
- SP_EVENT_MOUSEOVER,
- SP_EVENT_MOUSEOUT
-};
// TODO make a completely new function that transforms either the fill or
// stroke of any SPItem without adding an extra parameter to adjust_pattern.
@@ -75,9 +72,18 @@ enum PatternTransform {
*
*/
class SPEvent {
+
public:
- unsigned int type;
- void* data;
+ enum Type {
+ INVALID,
+ NONE,
+ ACTIVATE,
+ MOUSEOVER,
+ MOUSEOUT
+ };
+
+ Type type;
+ Inkscape::UI::View::View* view;
};
class SPItemView {
diff --git a/src/ui/view/README b/src/ui/view/README
index dad4e7242..cab0bf6f3 100644
--- a/src/ui/view/README
+++ b/src/ui/view/README
@@ -5,16 +5,16 @@ View is an abstract base class for all UI document views. Documents
can be displayed by more than one window, each having its own view
(e.g. zoom level, selection, etc.).
-View is the parent class for:
+View is the base class for:
-* SPDocument
+* SPDesktop
* SVGView
-SPViewWidget is the "parent" for:
+SPViewWidget is the base for:
* SPDocumentWidget
-(It was also parent for SPSVGViewWidget but that has been replaced by
+(It was also base for SPSVGViewWidget but that has been replaced by
SVGViewWidget which is derived, rather uselessly, from Gtk::Scrollbar).
SPViewWidget contains a GtkEventBox and holds a View.
@@ -28,9 +28,10 @@ SPDesktopWidget contains a
SPCanvas
Plus lots of other junk.
-SVGViewWidget contains a
- GtkScrolledWindow
- SPCanvas.
+SVGViewWidget is derived from Gtk::Scrollbar. It contains:
+ SPCanvas
+ SVGView
+
To do:
@@ -39,3 +40,7 @@ To do:
It doesn't use the EventBox of SPViewWidget!
* Get rid of SPViewWidget, integrating it directly into a
new C++ Desktop widget.
+
+A DesktopViewWidget should contain:
+ DesktopView (aka SPDesktop)
+ SPCanvas
diff --git a/src/ui/view/svg-view.cpp b/src/ui/view/svg-view.cpp
index 6db3fa2a4..e86228322 100644
--- a/src/ui/view/svg-view.cpp
+++ b/src/ui/view/svg-view.cpp
@@ -130,11 +130,12 @@ void SVGView::mouseout()
gdk_window_set_cursor(window, nullptr);
}
+
//----------------------------------------------------------------
/**
* Callback connected with arena_event.
*/
-/// \todo fixme.
+/// \todo fixme. This hasn't worked since at least 0.48. It should result in a cursor change over <a></a> links.
static gint arena_handler(SPCanvasArena */*arena*/, Inkscape::DrawingItem *ai, GdkEvent *event, SVGView *svgview)
{
static gdouble x, y;
@@ -144,46 +145,46 @@ static gint arena_handler(SPCanvasArena */*arena*/, Inkscape::DrawingItem *ai, G
SPItem *spitem = (ai) ? (static_cast<SPItem*>(ai->data())) : nullptr;
switch (event->type) {
- case GDK_BUTTON_PRESS:
- if (event->button.button == 1) {
- active = TRUE;
- x = event->button.x;
- y = event->button.y;
- }
- break;
- case GDK_BUTTON_RELEASE:
- if (event->button.button == 1) {
- if (active && (event->button.x == x) &&
- (event->button.y == y)) {
- spev.type = SP_EVENT_ACTIVATE;
- if ( spitem != nullptr )
- {
- spitem->emitEvent (spev);
- }
- }
+ case GDK_BUTTON_PRESS:
+ if (event->button.button == 1) {
+ active = TRUE;
+ x = event->button.x;
+ y = event->button.y;
+ }
+ break;
+ case GDK_BUTTON_RELEASE:
+ if (event->button.button == 1) {
+ if (active && (event->button.x == x) &&
+ (event->button.y == y)) {
+ spev.type = SPEvent::ACTIVATE;
+ if ( spitem != nullptr )
+ {
+ spitem->emitEvent (spev);
+ }
+ }
}
active = FALSE;
break;
- case GDK_MOTION_NOTIFY:
+ case GDK_MOTION_NOTIFY:
active = FALSE;
break;
- case GDK_ENTER_NOTIFY:
- spev.type = SP_EVENT_MOUSEOVER;
- spev.data = svgview;
+ case GDK_ENTER_NOTIFY:
+ spev.type = SPEvent::MOUSEOVER;
+ spev.view = svgview;
if ( spitem != nullptr )
{
- spitem->emitEvent (spev);
+ spitem->emitEvent (spev);
}
break;
- case GDK_LEAVE_NOTIFY:
- spev.type = SP_EVENT_MOUSEOUT;
- spev.data = svgview;
+ case GDK_LEAVE_NOTIFY:
+ spev.type = SPEvent::MOUSEOUT;
+ spev.view = svgview;
if ( spitem != nullptr )
{
- spitem->emitEvent (spev);
+ spitem->emitEvent (spev);
}
break;
- default:
+ default:
break;
}