diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2018-12-03 14:12:58 +0000 |
|---|---|---|
| committer | Tavmjong Bah <tavmjong@free.fr> | 2018-12-03 14:12:58 +0000 |
| commit | d0a70cf731c5d3e2698f62876a4acade0361bb8e (patch) | |
| tree | ff8e35ffe8c44db6b28b8c29c108513307f057c7 /src | |
| parent | Use std::unique_ptr for all MessageContext (diff) | |
| download | inkscape-d0a70cf731c5d3e2698f62876a4acade0361bb8e.tar.gz inkscape-d0a70cf731c5d3e2698f62876a4acade0361bb8e.zip | |
Remove dependance of SVGViewWidget on SVGView and View. Remove SVGView.
Another step in making View not dependent on GUI.
Diffstat (limited to 'src')
| -rw-r--r-- | src/desktop.h | 14 | ||||
| -rw-r--r-- | src/display/canvas-arena.cpp | 4 | ||||
| -rw-r--r-- | src/inkview-window.cpp | 5 | ||||
| -rw-r--r-- | src/object/sp-anchor.cpp | 18 | ||||
| -rw-r--r-- | src/object/sp-item.h | 5 | ||||
| -rw-r--r-- | src/ui/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/ui/view/README | 7 | ||||
| -rw-r--r-- | src/ui/view/svg-view-widget.cpp | 206 | ||||
| -rw-r--r-- | src/ui/view/svg-view-widget.h | 35 | ||||
| -rw-r--r-- | src/ui/view/svg-view.cpp | 240 | ||||
| -rw-r--r-- | src/ui/view/svg-view.h | 101 | ||||
| -rw-r--r-- | src/ui/view/view.h | 17 |
12 files changed, 254 insertions, 400 deletions
diff --git a/src/desktop.h b/src/desktop.h index 81c837921..ddac3fb67 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -436,12 +436,12 @@ public: void setDocument (SPDocument* doc) override; bool shutdown() override; - void mouseover() override {} - void mouseout() override {} + guint get_hruler_thickness(); guint get_vruler_thickness(); guint get_vscroll_thickness(); guint get_hscroll_thickness(); + virtual bool onDeleteUI (GdkEventAny*); virtual bool onWindowStateEvent (GdkEventWindowState* event); @@ -581,11 +581,11 @@ private: sigc::connection _commit_connection; sigc::connection _modified_connection; - void onResized (double, double) override; - void onRedrawRequested() override; - void onStatusMessage (Inkscape::MessageType type, gchar const *message) override; - void onDocumentURISet (gchar const* uri) override; - void onDocumentResized (double, double) override; + void onResized (double, double); + void onRedrawRequested(); + void onStatusMessage (Inkscape::MessageType type, gchar const *message); + void onDocumentURISet (gchar const* uri); + void onDocumentResized (double, double); static void _onActivate (SPDesktop* dt); static void _onDeactivate (SPDesktop* dt); diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index 734cbf910..fb20ccfe3 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -229,6 +229,9 @@ sp_canvas_arena_viewbox_changed (SPCanvasItem *item, Geom::IntRect const &new_ar arena->drawing.setCacheLimit(expanded); } +// What is this used for? It appears to allow one to get signals on entering/leaving elements which +// is intend to be used by Inkview to change the cursor when over an anchor. However arena->active +// appears to only be set to root. static gint sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event) { @@ -236,7 +239,6 @@ sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event) /* fixme: This sucks, we have to handle enter/leave notifiers */ SPCanvasArena *arena = SP_CANVAS_ARENA (item); - gint ret = FALSE; switch (event->type) { diff --git a/src/inkview-window.cpp b/src/inkview-window.cpp index 44dce62aa..d69734131 100644 --- a/src/inkview-window.cpp +++ b/src/inkview-window.cpp @@ -20,7 +20,6 @@ #include <iostream> #include "document.h" -#include "inkscape.h" // INKSCAPE macro #include "ui/monitor.h" #include "ui/view/svg-view-widget.h" @@ -149,10 +148,6 @@ InkviewWindow::show_document(SPDocument* document) int height = MIN((int)document->getHeight().value("px") * _scale, monitor_geometry.get_height()); resize (width, height); - // setDocument() reduces the document count... bump it up so document won't be deleted. - // ToDo: view should not be handling document lifetime. - INKSCAPE.add_document(document); - if (_view) { _view->setDocument(document); } else { diff --git a/src/object/sp-anchor.cpp b/src/object/sp-anchor.cpp index d4361a4ef..544e2d3e9 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/svg-view.h" +#include "ui/view/svg-view-widget.h" #include "document.h" SPAnchor::SPAnchor() : SPGroup() { @@ -154,11 +154,13 @@ 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) { + * which hasn't worked since at least 0.48). GUI code should not be here. */ +int SPAnchor::event(SPEvent* event) { + switch (event->type) { case SPEvent::ACTIVATE: if (this->href) { + // If this actually worked, it could be useful to open a webpage with the link. g_print("Activated xlink:href=\"%s\"\n", this->href); return TRUE; } @@ -166,18 +168,16 @@ gint SPAnchor::event(SPEvent* event) { case SPEvent::MOUSEOVER: { - auto view = dynamic_cast<Inkscape::UI::View::SVGView*>(event->view); - if (view) { - view->mouseover(); + if (event->view) { + event->view->mouseover(); } break; } case SPEvent::MOUSEOUT: { - auto view = dynamic_cast<Inkscape::UI::View::SVGView*>(event->view); - if (view) { - view->mouseout(); + if (event->view) { + event->view->mouseout(); } break; } diff --git a/src/object/sp-item.h b/src/object/sp-item.h index 068571d85..7d9ecd44f 100644 --- a/src/object/sp-item.h +++ b/src/object/sp-item.h @@ -48,7 +48,7 @@ class URIReference; namespace UI { namespace View { -class View; +class SVGViewWidget; } } } @@ -70,6 +70,7 @@ enum PatternTransform { * to process correct ones in meaningful way. * Also, this probably goes to SPObject base class. * + * GUI Code should not be here! */ class SPEvent { @@ -83,7 +84,7 @@ public: }; Type type; - Inkscape::UI::View::View* view; + Inkscape::UI::View::SVGViewWidget* view; }; class SPItemView { diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 96658b2a1..f0c0b2fe3 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -202,7 +202,6 @@ set(ui_SRC widget/unit-menu.cpp widget/unit-tracker.cpp - view/svg-view.cpp view/svg-view-widget.cpp view/view.cpp view/view-widget.cpp @@ -429,7 +428,6 @@ set(ui_SRC widget/unit-tracker.h view/edit-widget-interface.h - view/svg-view.h view/svg-view-widget.h view/view.h view/view-widget.h diff --git a/src/ui/view/README b/src/ui/view/README index cab0bf6f3..b8092910a 100644 --- a/src/ui/view/README +++ b/src/ui/view/README @@ -8,7 +8,7 @@ can be displayed by more than one window, each having its own view View is the base class for: * SPDesktop -* SVGView +* SVGView REMOVED SPViewWidget is the base for: @@ -28,10 +28,9 @@ SPDesktopWidget contains a SPCanvas Plus lots of other junk. -SVGViewWidget is derived from Gtk::Scrollbar. It contains: +SVGViewWidget is derived from Gtk::Scrollbar. It no longer is dependent +on View (and really doesn't belong here anymore). It contains: SPCanvas - SVGView - To do: diff --git a/src/ui/view/svg-view-widget.cpp b/src/ui/view/svg-view-widget.cpp index c696a3ad2..c349b5aca 100644 --- a/src/ui/view/svg-view-widget.cpp +++ b/src/ui/view/svg-view-widget.cpp @@ -1,12 +1,17 @@ // SPDX-License-Identifier: GPL-2.0-or-later /** * @file - * A light-weight widget containing an SPCanvas with a View for rendering an SVG. + * A light-weight widget containing an SPCanvas for rendering an SVG. */ /* * Authors: * Tavmjong Bah <tavmjong@free.fr> * + * Includes code moved from svg-view.cpp authored by: + * MenTaLGuy + * Ralf Stephan <ralf@ark.in-berlin.de> + * Jon A. Cruz <jon@joncruz.org> + * * Copyright (C) 2018 Authors * * The contents of this file may be used under the GNU General Public License Version 2 or later. @@ -14,52 +19,158 @@ * */ +#include <iostream> + #include "svg-view-widget.h" -#include "svg-view.h" #include "document.h" +#include "2geom/transforms.h" + #include "display/sp-canvas.h" #include "display/sp-canvas-group.h" #include "display/sp-canvas-item.h" +#include "display/canvas-arena.h" +#include "object/sp-item.h" +#include "object/sp-root.h" + +#include "util/units.h" namespace Inkscape { namespace UI { namespace View { /** - * A light-weight widget containing an SPCanvas with a View for rendering an SVG. + * Callback connected with arena_event. + */ +// This hasn't worked since at least 0.48. It should result in a cursor change over <a></a> links. +// There should be a better way of doing this. See note in canvas-arena.cpp. +static gint arena_handler(SPCanvasArena */*arena*/, Inkscape::DrawingItem *ai, + GdkEvent *event, SVGViewWidget *svgview) +{ + static gdouble x, y; + static gboolean active = FALSE; + SPEvent spev; + + SPItem *spitem = (ai) ? ai->getItem() : 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 = SPEvent::ACTIVATE; + if ( spitem != nullptr ) + { + spitem->emitEvent (spev); + } + } + } + active = FALSE; + break; + case GDK_MOTION_NOTIFY: + active = FALSE; + break; + case GDK_ENTER_NOTIFY: + spev.type = SPEvent::MOUSEOVER; + spev.view = svgview; + if ( spitem != nullptr ) + { + spitem->emitEvent (spev); + } + break; + case GDK_LEAVE_NOTIFY: + spev.type = SPEvent::MOUSEOUT; + spev.view = svgview; + if ( spitem != nullptr ) + { + spitem->emitEvent (spev); + } + break; + default: + break; + } + + return TRUE; +} + + +/** + * A light-weight widget containing an SPCanvas for rendering an SVG. * It's derived from a Gtk::ScrolledWindow like the previous C version, but that doesn't seem to be * too useful. */ SVGViewWidget::SVGViewWidget(SPDocument* document) + : _document(nullptr) + , _dkey(0) + , _parent(nullptr) + , _drawing(nullptr) + , _hscale(1.0) + , _vscale(1.0) + , _rescale(false) + , _keepaspect(false) + , _width(0.0) + , _height(0.0) { - _canvas = SPCanvas::createAA(); - add(*Glib::wrap(_canvas)); + _canvas = SPCanvas::createAA(); + add(*Glib::wrap(_canvas)); + + SPCanvasItem* item = + sp_canvas_item_new(SP_CANVAS(_canvas)->getRoot(), SP_TYPE_CANVAS_GROUP, nullptr); + _parent = SP_CANVAS_GROUP(item); + + _drawing = sp_canvas_item_new (_parent, SP_TYPE_CANVAS_ARENA, nullptr); + g_signal_connect (G_OBJECT (_drawing), "arena_event", G_CALLBACK (arena_handler), this); - SPCanvasItem* parent = - sp_canvas_item_new(SP_CANVAS(_canvas)->getRoot(), SP_TYPE_CANVAS_GROUP, nullptr); - _view = new SVGView(SP_CANVAS_GROUP(parent)); - _view->setDocument(document); + setDocument(document); - signal_size_allocate().connect(sigc::mem_fun(*this, &SVGViewWidget::size_allocate)); + signal_size_allocate().connect(sigc::mem_fun(*this, &SVGViewWidget::size_allocate)); } SVGViewWidget::~SVGViewWidget() { - delete _view; + if (_document) { + _document = nullptr; + } } void SVGViewWidget::setDocument(SPDocument* document) { - _view->setDocument(document); + // Clear old document + if (_document) { + _document->getRoot()->invoke_hide(_dkey); // Removed from display tree + } + + // Add new document + if (document) { + _document = document; + + Inkscape::DrawingItem *ai = document->getRoot()->invoke_show( + SP_CANVAS_ARENA (_drawing)->drawing, + _dkey, + SP_ITEM_SHOW_DISPLAY); + + if (ai) { + SP_CANVAS_ARENA (_drawing)->drawing.root()->prependChild(ai); + } + + doRescale (); + } } void SVGViewWidget::setResize(int width, int height) { + // Triggers size_allocation which calls SVGViewWidget::size_allocate. set_size_request(width, height); queue_resize(); } @@ -67,7 +178,76 @@ SVGViewWidget::setResize(int width, int height) void SVGViewWidget::size_allocate(Gtk::Allocation& allocation) { - _view->setRescale(true, true, allocation.get_width(), allocation.get_height()); + double width = allocation.get_width(); + double height = allocation.get_height(); + + if (width < 0.0 || height < 0.0) { + std::cerr << "SVGViewWidget::size_allocate: negative dimensions!" << std::endl; + return; + } + + _rescale = true; + _keepaspect = true; + _width = width; + _height = height; + + doRescale (); +} + +void +SVGViewWidget::doRescale() +{ + if (!_document) { + std::cerr << "SVGViewWidget::doRescale: No document!" << std::endl; + return; + } + + if (_document->getWidth().value("px") < 1e-9) { + std::cerr << "SVGViewWidget::doRescale: Width too small!" << std::endl; + return; + } + + if (_document->getHeight().value("px") < 1e-9) { + std::cerr << "SVGViewWidget::doRescale: Height too small!" << std::endl; + return; + } + + double x_offset = 0.0; + double y_offset = 0.0; + if (_rescale) { + _hscale = _width / _document->getWidth().value("px"); + _vscale = _height / _document->getHeight().value("px"); + if (_keepaspect) { + if (_hscale > _vscale) { + _hscale = _vscale; + x_offset = (_width - _document->getWidth().value("px") * _vscale)/2.0; + } else { + _vscale = _hscale; + y_offset = (_height - _document->getHeight().value("px") * _hscale)/2.0; + } + } + } + + if (_drawing) { + sp_canvas_item_affine_absolute (_drawing, Geom::Scale(_hscale, _vscale) * Geom::Translate(x_offset, y_offset)); + } +} + +void +SVGViewWidget::mouseover() +{ + 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); + g_object_unref(cursor); +} + +void +SVGViewWidget::mouseout() +{ + GdkWindow *window = gtk_widget_get_window (GTK_WIDGET(SP_CANVAS_ITEM(_drawing)->canvas)); + gdk_window_set_cursor(window, nullptr); } } // Namespace View diff --git a/src/ui/view/svg-view-widget.h b/src/ui/view/svg-view-widget.h index 718e164cd..6d1fe9f1a 100644 --- a/src/ui/view/svg-view-widget.h +++ b/src/ui/view/svg-view-widget.h @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later /** * @file - * A light-weight widget containing an SPCanvas with a View for rendering an SVG. + * A light-weight widget containing an SPCanvas with for rendering an SVG. */ /* * Authors: @@ -21,15 +21,15 @@ #include <gtkmm.h> class SPDocument; +class SPCanvasGroup; +class SPCanvasItem; namespace Inkscape { namespace UI { namespace View { -class SVGView; - /** - * A light-weight widget containing an SPCanvas with an SVGView for rendering an SVG. + * A light-weight widget containing an SPCanvas for rendering an SVG. */ class SVGViewWidget : public Gtk::ScrolledWindow { @@ -42,8 +42,33 @@ public: private: void size_allocate(Gtk::Allocation& allocation); - SVGView* _view; GtkWidget* _canvas; + +// From SVGView --------------------------------- + +public: + SPDocument* _document; + unsigned int _dkey; + SPCanvasGroup *_parent; + SPCanvasItem *_drawing; + double _hscale; ///< horizontal scale + double _vscale; ///< vertical scale + bool _rescale; ///< whether to rescale automatically + bool _keepaspect; + double _width; + double _height; + + /** + * Helper function that sets rescale ratio. + */ + void doRescale(); + + /** + * Change cursor (used for links). + */ + void mouseover(); + void mouseout(); + }; } // Namespace View diff --git a/src/ui/view/svg-view.cpp b/src/ui/view/svg-view.cpp deleted file mode 100644 index 14ced7fac..000000000 --- a/src/ui/view/svg-view.cpp +++ /dev/null @@ -1,240 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * Functions and callbacks for generic SVG view and widget. - * - * Authors: - * Lauris Kaplinski <lauris@kaplinski.com> - * Ralf Stephan <ralf@ark.in-berlin.de> - * Jon A. Cruz <jon@joncruz.org> - * Abhishek Sharma - * - * Copyright (C) 2001-2002 Lauris Kaplinski - * Copyright (C) 2001 Ximian, Inc. - * - * Released under GNU GPL v2+, read the file 'COPYING' for more information. - */ - -#include <2geom/transforms.h> - -#include "ui/view/svg-view.h" - -#include "document.h" - -#include "display/canvas-arena.h" -#include "display/drawing-group.h" - -#include "object/sp-item.h" -#include "object/sp-root.h" - -#include "util/units.h" - -namespace Inkscape { -namespace UI { -namespace View { - -SVGView::SVGView(SPCanvasGroup *parent) -{ - _hscale = 1.0; - _vscale = 1.0; - _rescale = FALSE; - _keepaspect = FALSE; - _width = 0.0; - _height = 0.0; - - _dkey = 0; - _drawing = nullptr; - _parent = parent; -} - -SVGView::~SVGView() -{ - if (doc() && _drawing) - { - doc()->getRoot()->invoke_hide(_dkey); - _drawing = nullptr; - } -} - -void SVGView::setScale(gdouble hscale, gdouble vscale) -{ - if (!_rescale && ((hscale != _hscale) || (vscale != _vscale))) { - _hscale = hscale; - _vscale = vscale; - doRescale (true); - } -} - -void SVGView::setRescale(bool rescale, bool keepaspect, gdouble width, gdouble height) -{ - g_return_if_fail (!rescale || (width >= 0.0)); - g_return_if_fail (!rescale || (height >= 0.0)); - - _rescale = rescale; - _keepaspect = keepaspect; - _width = width; - _height = height; - - doRescale (true); -} - -void SVGView::doRescale(bool event) -{ - if (!doc()) { - return; - } - if (doc()->getWidth().value("px") < 1e-9) { - return; - } - if (doc()->getHeight().value("px") < 1e-9) { - return; - } - - double x_offset = 0.0; - double y_offset = 0.0; - if (_rescale) { - _hscale = _width / doc()->getWidth().value("px"); - _vscale = _height / doc()->getHeight().value("px"); - if (_keepaspect) { - if (_hscale > _vscale) { - _hscale = _vscale; - x_offset = (_width - doc()->getWidth().value("px") * _vscale)/2.0; - } else { - _vscale = _hscale; - y_offset = (_height - doc()->getHeight().value("px") * _hscale)/2.0; - } - } - } - - if (_drawing) { - sp_canvas_item_affine_absolute (_drawing, Geom::Scale(_hscale, _vscale) * Geom::Translate(x_offset, y_offset)); - } - - if (event) { - emitResized (doc()->getWidth().value("px") * _hscale, - doc()->getHeight().value("px") * _vscale); - } -} - -void SVGView::mouseover() -{ - 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); - g_object_unref(cursor); -} - -void SVGView::mouseout() -{ - GdkWindow *window = gtk_widget_get_window (GTK_WIDGET(SP_CANVAS_ITEM(_drawing)->canvas)); - gdk_window_set_cursor(window, nullptr); -} - - -//---------------------------------------------------------------- -/** - * Callback connected with arena_event. - */ -/// \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; - static gboolean active = FALSE; - SPEvent spev; - - SPItem *spitem = (ai) ? ai->getItem() : 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 = SPEvent::ACTIVATE; - if ( spitem != nullptr ) - { - spitem->emitEvent (spev); - } - } - } - active = FALSE; - break; - case GDK_MOTION_NOTIFY: - active = FALSE; - break; - case GDK_ENTER_NOTIFY: - spev.type = SPEvent::MOUSEOVER; - spev.view = svgview; - if ( spitem != nullptr ) - { - spitem->emitEvent (spev); - } - break; - case GDK_LEAVE_NOTIFY: - spev.type = SPEvent::MOUSEOUT; - spev.view = svgview; - if ( spitem != nullptr ) - { - spitem->emitEvent (spev); - } - break; - default: - break; - } - - return TRUE; -} - -void SVGView::setDocument(SPDocument *document) -{ - if (doc()) { - doc()->getRoot()->invoke_hide(_dkey); - } - - if (!_drawing) { - _drawing = sp_canvas_item_new (_parent, SP_TYPE_CANVAS_ARENA, nullptr); - g_signal_connect (G_OBJECT (_drawing), "arena_event", G_CALLBACK (arena_handler), this); - } - - View::setDocument (document); - - if (document) { - Inkscape::DrawingItem *ai = document->getRoot()->invoke_show( - SP_CANVAS_ARENA (_drawing)->drawing, - _dkey, - SP_ITEM_SHOW_DISPLAY); - - if (ai) { - SP_CANVAS_ARENA (_drawing)->drawing.root()->prependChild(ai); - } - - doRescale (!_rescale); - } -} - -void SVGView::onDocumentResized(gdouble width, gdouble height) -{ - setScale (width, height); - doRescale (!_rescale); -} - -} -} -} - -/* - 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/ui/view/svg-view.h b/src/ui/view/svg-view.h deleted file mode 100644 index 8ec452ede..000000000 --- a/src/ui/view/svg-view.h +++ /dev/null @@ -1,101 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -#ifndef SEEN_SVG_VIEW_H -#define SEEN_SVG_VIEW_H -/* - * Authors: - * Lauris Kaplinski <lauris@kaplinski.com> - * Ralf Stephan <ralf@ark.in-berlin.de> - * - * Copyright (C) 2001-2002 Lauris Kaplinski - * Copyright (C) 2001 Ximian, Inc. - * - * Released under GNU GPL v2+, read the file 'COPYING' for more information. - */ - -#include "ui/view/view.h" - -struct SPCanvasGroup; -struct SPCanvasItem; - -namespace Inkscape { -namespace UI { -namespace View { - -/** - * Generic SVG view. - */ -class SVGView : public View { -public: - unsigned int _dkey; - SPCanvasGroup *_parent; - SPCanvasItem *_drawing; - double _hscale; ///< horizontal scale - double _vscale; ///< vertical scale - bool _rescale; ///< whether to rescale automatically - bool _keepaspect; - double _width; - double _height; - - - /** - * Constructs new SPSVGView object and returns pointer to it. - */ - SVGView(SPCanvasGroup* parent); - - ~SVGView() override; - - /** - * Rescales SPSVGView to given proportions. - */ - void setScale(double hscale, double vscale); - - /** - * Rescales SPSVGView and keeps aspect ratio. - */ - void setRescale(bool rescale, bool keepaspect, double width, double height); - - /** - * Helper function that sets rescale ratio and emits resize event. - */ - void doRescale(bool event); - - /** - * Callback connected with set_document signal. - */ - void setDocument(SPDocument *document) override; - - void mouseover() override; - - void mouseout() override; - - bool shutdown() override { return true; } - -private: - virtual void onPositionSet(double, double) {} - void onResized(double, double) override {} - void onRedrawRequested() override {} - void onStatusMessage(Inkscape::MessageType /*type*/, gchar const */*message*/) override {} - void onDocumentURISet(gchar const* /*uri*/) override {} - - /** - * Callback connected with document_resized signal. - */ - void onDocumentResized(double, double) override; -}; - -} -} -} - -#endif // SEEN_SVG_VIEW_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 : diff --git a/src/ui/view/view.h b/src/ui/view/view.h index d3afc73c3..3acfd2c1c 100644 --- a/src/ui/view/view.h +++ b/src/ui/view/view.h @@ -95,17 +95,12 @@ public: void emitResized(gdouble width, gdouble height); void requestRedraw(); - // view subclasses must give implementations of these methods - - virtual bool shutdown() = 0; - virtual void mouseover() = 0; - virtual void mouseout() = 0; - - virtual void onResized (double, double) = 0; - virtual void onRedrawRequested() = 0; - virtual void onStatusMessage (Inkscape::MessageType type, gchar const *message) = 0; - virtual void onDocumentURISet (gchar const* uri) = 0; - virtual void onDocumentResized (double, double) = 0; + virtual void onResized (double, double) {}; + virtual void onRedrawRequested() {}; + virtual void onStatusMessage (Inkscape::MessageType type, gchar const *message) {}; + virtual void onDocumentURISet (gchar const* uri) {}; + virtual void onDocumentResized (double, double) {}; + virtual bool shutdown() { return false; }; protected: SPDocument *_doc; |
