-
Notifications
You must be signed in to change notification settings - Fork 17
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
Refactor/concept text support #78
Conversation
the names are more descriptive. also commented out all the code related to the textField.
- `showTextView(inRect:text:)` - `showTextView(atPoint:text:)` - `dismissTextView()` so now they work with a textView instead of a textField.
closes #58 |
`textView.attributedString()` returns an object with reference semantics, that is assigned to the `concept`, then the same string gets set to `””` in `dismissTextView`, but for the reference semantics, then `concept.attributedStringValue` is also `””`. This commit fixes that.
Either to given `contrainedSize` or to the `maxSize` for the visible rect in the point of the rect.
if so, adjust the mode for the concept. so in this way, constrained text in the textView will keep being constrained on the concept.
conceptMode = .textBased | ||
} | ||
|
||
dismissTextView() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this logic is duplicated.
// if the concept mode is | ||
// constrained, then pass the constraint | ||
// if not don't pass anything and it will be contrained to max visible area | ||
var constrainedSize: NSSize? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can go in the model
textField.allowsEditingTextAttributes = true | ||
return textField | ||
// MARK: - Text Handling | ||
let textContainer = NSTextContainer(size: NSSize(width: 300, height: 300)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i can remove this size?
LinkedIdeas/StateManager.swift
Outdated
@@ -209,4 +238,13 @@ class StateManager { | |||
) | |||
} | |||
} | |||
|
|||
// TODO: remove this function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revisit the logic for possible states
the previous implementation relied in an array of `possibleStates` of type `[CanvasState]`, but that made me create instances of that enum, even with dummy associated values, becuase they are non optionals, and they shoudln't be. Now, each transition method has a internal `isValidTransition(CanvasState) -> Bool` function to dermine the valid transitions, which internally they rely on switch statements to return this boolean, then I get type safety and compiler help when introducing new states without having to do the tricks i did before.
the textView methods depend on the presence of the scrollView, which is a force unwrapped optional as it's an IBOutlet in the view controller.
showTextView(inRect:text:)
showTextView(atPoint:text:)
dismissTextView()
so now they work with a textView instead of a textField.
TODO