-
Notifications
You must be signed in to change notification settings - Fork 776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
View refactor #4051
Comments
I think there should be one PageControl for the whole document, as it's basically a state machine that updates the document state upon receiving user input (by the input handlers making method calls on the PageControl). However, we should be able to support multiple views of a document.
I agree with this proposal. The way I see it:
|
If we proceed as you suggest (if I understand correctly: a ToolHandler - owned by Control or the current gui/XournalView - handles the events and drawing of the elements under edition, the rest of the rendering goes into view/PageView), it is not clear to me what control/PageControl is used for then. It seems it'll end up being a 1-1 inerface to the model. Why not directly interact with the model then? The key point is possibly: who dispatches modification notifications (to the views)? I assume that in @Technius' plan, that's what control/PageControl is for. Right? This would be like the current control/layers/LayerController. On the other hand, @LittleHuba suggests in #3962 (comment) that the model itself would emit the notifications (like model/XojPage in the current base code). I'm okay with both versions, but we need to pick one and stick to it. Another thing bothers me: if and when we allow for a second view of the document, this second view should include the current edition (e.g. for a lecture, sharing the second view on a screen or online). This seems to imply that view/PageView should point to existing Toolhandler(s). I don't like that. |
The thought of having the model emit the notifications is that you can subscribe multiple views that will all show the same state. In this case the model would need to also reflect elements that are currently edited. So the tool handler does not draw anything itself but just updates the model. |
I've looked at this a bit more. It seems that before being actually able to split XojPageView into a view and a controller, a big amount of work on the tool handlers is required. For now, I failed to come up with a satisfactory scheme that handles the various behaviours listed below.
Ideal solution: Every tool handler is split into a model/view/controller. The model would every time be protected by a mutex, to fix #3579. Realistic short term solution: Add a The case of |
This ticket is for discussing View refactor related questions. See also #1795 and #1813 for a previous attempt.
The previous PR's #3503 #3985 #4001 #3969 and #3990 created view classes for each element, layer and background. The next step is the refactoring of the PageView class (for now, the class XojPageView in gui/PageView) and split it into a view/PageView and a control/PageControl.
The goal is to follow the general MVC scheme as layed down by @LittleHuba in
#3962 (comment).
This raises questions:
To be able to redistribute the functions properly, I need something clarified: in the event that we someday implement the possiblity to have several displays of the same document, should there be one PageControl instance per display, (say 2 PageView's and 2 PageControl), or a single PageControl?
How should the current tools be handled: for now, the function
XojPageView::paintPageSync
does two things:xournalpp/src/core/gui/PageView.cpp
Lines 893 to 897 in 498e6c1
I'm not sure how the second part should be handled. The tool handlers are definitely on the control side.
This probably means that the tool handlers themselves need to be split into a model-view-controller pattern, right?
The text was updated successfully, but these errors were encountered: