Skip to content
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

Better separation of Model from View. #241

Closed
TomasMikula opened this issue Jan 15, 2016 · 4 comments
Closed

Better separation of Model from View. #241

TomasMikula opened this issue Jan 15, 2016 · 4 comments

Comments

@TomasMikula
Copy link
Member

StyledTextArea is a Node and as such takes care of rendering the visual representation of a document. In other words, StyledTextArea is the view. A big part of the model is represented by EditableStyledDocument, which is independent of the view. However, some parts of the model currently leak into StyledTextArea; namely undo/redo, caret position and selection. As a result, for example, to test undo/redo, one needs to instantiate the view, even though undo/redo itself doesn't depend on the view.

I propose to introduce a class (StyledTextAreaModel) to encapsulate the model.

@JordanMartinez
Copy link
Contributor

So the proposed StyledTextAreaModel would have an EditableStyledDocument and it would move ESD's plain and rich text changes EventStreams to the model itself. Then StyledTextArea would be passed the model itself as Constructor param (and possibly some other things), right?

However, due to #152, and in providing the foundation for #222 to be implemented, if caret position and selection are stored in the Model, how would each View know what to display? Would the Model have a list that stores the caret positions and selection IndexRange of each StyledTextArea that displays the model, each of which is bound to its corresponding StyledTextArea property?

@TomasMikula
Copy link
Member Author

EditableStyledDocument would stay without change. StyledTextArea's plain and rich text changes would move into StyledTextAreaModel and StyledTextArea would just delegate the corresponding methods to model. Model would not be shared, each area would have its own. However, EditableStyledDocument could be shared by multiple models, as it is now.

@JordanMartinez
Copy link
Contributor

Ah, ok that clarifies a lot.

@JordanMartinez
Copy link
Contributor

See my PR (#242)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants