Move gaphas.view.model to gaphas.model
Now more of Gaphas can be used without depending on Gtk. This is useful for, for example, the Sphinx extension in Gaphor.
This commit is contained in:
parent
b3e737219f
commit
a51f017179
@ -7,7 +7,7 @@ Protocols
|
||||
|
||||
Although ``gaphas.Canvas`` can be used as a default model, any class that adhere's to the Model protocol can be used as a model.
|
||||
|
||||
.. autoclass:: gaphas.view.model.Model
|
||||
.. autoclass:: gaphas.model.Model
|
||||
:members:
|
||||
|
||||
An item should implement these methods, so it can be rendered by the View. Not that painters or tools can require additional methods.
|
||||
|
@ -28,17 +28,15 @@ To get connecting items (i.e. all lines connected to a class)::
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import TYPE_CHECKING, Iterable, Protocol
|
||||
from typing import Iterable, Protocol
|
||||
|
||||
import cairo
|
||||
|
||||
from gaphas import matrix, tree
|
||||
from gaphas.connections import Connection, Connections
|
||||
from gaphas.decorators import nonrecursive
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from gaphas.item import Item
|
||||
from gaphas.view.model import View
|
||||
from gaphas.item import Item
|
||||
from gaphas.model import View
|
||||
|
||||
|
||||
def instant_cairo_context():
|
||||
|
@ -6,10 +6,10 @@ from gi.repository import Gtk
|
||||
from gaphas.connector import Handle, LinePort
|
||||
from gaphas.geometry import distance_point_point_fast
|
||||
from gaphas.item import Line, matrix_i2i
|
||||
from gaphas.model import Model
|
||||
from gaphas.selection import Selection
|
||||
from gaphas.solver import WEAK
|
||||
from gaphas.tool.itemtool import Segment
|
||||
from gaphas.view.model import Model
|
||||
|
||||
|
||||
@Segment.register(Line) # type: ignore
|
||||
|
@ -1,4 +1,5 @@
|
||||
"""This package contains everything to display a Canvas on a screen."""
|
||||
|
||||
from gaphas import model
|
||||
from gaphas.selection import Selection
|
||||
from gaphas.view.gtkview import DEFAULT_CURSOR, GtkView
|
||||
|
@ -10,11 +10,11 @@ from gaphas.decorators import g_async
|
||||
from gaphas.geometry import Rect, Rectangle
|
||||
from gaphas.item import Item
|
||||
from gaphas.matrix import Matrix
|
||||
from gaphas.model import Model
|
||||
from gaphas.painter import DefaultPainter, ItemPainter
|
||||
from gaphas.painter.painter import ItemPainterType, Painter
|
||||
from gaphas.quadtree import Quadtree, QuadtreeBucket
|
||||
from gaphas.selection import Selection
|
||||
from gaphas.view.model import Model
|
||||
from gaphas.view.scrolling import Scrolling
|
||||
|
||||
# Handy debug flag for drawing bounding boxes around the items.
|
||||
@ -35,9 +35,8 @@ BOUNDING_BOX_TOLERANCE = 1.0
|
||||
|
||||
|
||||
class GtkView(Gtk.DrawingArea, Gtk.Scrollable):
|
||||
"""GTK+ widget for rendering a gaphas.view.model.Model to a screen. The
|
||||
view uses Tools to handle events and Painters to draw. Both are
|
||||
configurable.
|
||||
"""GTK+ widget for rendering a gaphas.model.Model to a screen. The view
|
||||
uses Tools to handle events and Painters to draw. Both are configurable.
|
||||
|
||||
The widget already contains adjustment objects (`hadjustment`,
|
||||
`vadjustment`) to be used for scrollbars.
|
||||
|
@ -6,7 +6,7 @@ from gaphas.connector import ConnectionSink, Connector
|
||||
from gaphas.item import Element as Box
|
||||
from gaphas.item import Line
|
||||
from gaphas.matrix import Matrix
|
||||
from gaphas.view.model import Model
|
||||
from gaphas.model import Model
|
||||
|
||||
|
||||
def test_canvas_is_a_view_model(canvas):
|
||||
|
Loading…
x
Reference in New Issue
Block a user