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

Refactor/concept text support #78

Merged
merged 15 commits into from
Sep 7, 2017
Merged

Conversation

fespinoza
Copy link
Owner

@fespinoza fespinoza commented Aug 23, 2017

  • showTextView(inRect:text:)
  • showTextView(atPoint:text:)
  • dismissTextView()

so now they work with a textView instead of a textField.

TODO

  • fix bug when editing a concept (with big font)
  • change styling when editing
  • remove padding from text
  • maxSize logic for text view and conceptText

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.
@fespinoza
Copy link
Owner Author

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.
@fespinoza fespinoza changed the title [WIP] Refactor/concept text support Refactor/concept text support Sep 4, 2017
conceptMode = .textBased
}

dismissTextView()
Copy link
Owner Author

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?
Copy link
Owner Author

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))
Copy link
Owner Author

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?

@@ -209,4 +238,13 @@ class StateManager {
)
}
}

// TODO: remove this function
Copy link
Owner Author

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.
@fespinoza fespinoza merged commit dde4b3f into master Sep 7, 2017
@fespinoza fespinoza deleted the refactor/concept-text-support branch September 7, 2017 18:57
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

Successfully merging this pull request may close these issues.

1 participant