Skip to content

Commit

Permalink
Move gaphas.view.model to gaphas.model
Browse files Browse the repository at this point in the history
Now more of Gaphas can be used without depending on Gtk. This is useful for,
for example, the Sphinx extension in Gaphor.
  • Loading branch information
amolenaar committed Dec 8, 2021
1 parent b3e7372 commit a51f017
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/api/model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 3 additions & 5 deletions gaphas/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,15 @@
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():
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion gaphas/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
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
Expand Down
1 change: 1 addition & 0 deletions gaphas/view/__init__.py
Original file line number Diff line number Diff line change
@@ -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
7 changes: 3 additions & 4 deletions gaphas/view/gtkview.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
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.
Expand All @@ -35,9 +35,8 @@


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.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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):
Expand Down

0 comments on commit a51f017

Please sign in to comment.