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

Classlib: QPenPrinter: Add 'bounds' method #1235

Merged
merged 1 commit into from
Nov 15, 2014
Merged

Classlib: QPenPrinter: Add 'bounds' method #1235

merged 1 commit into from
Nov 15, 2014

Conversation

jamshark70
Copy link
Contributor

This PR makes it simpler to use the same function as a UserView drawFunc and also with QPenPrinter.

Use case: Say I want to print vector graphics from a user view. I test the drawFunc in a user view (easier to see the results immediately). I want the function to adapt to the view size, so the function begins:

u.drawFunc = { |view|
    var b = view.bounds.moveTo(0, 0);
    ...
};

Now I've got it looking right, so I want to use it in QPenPrinter, but guess what? "Message 'bounds' not understood." So then I have to edit the function to call pageRect instead, or write something really silly like:

var b = if(view.isKindOf(QPenPrinter)) {
    view.pageRect
} {
    view.bounds
}.moveTo(0, 0);

Since the QPenPrinter is basically a stand-in for the user view, I think it should also respond to bounds.

A drawFunc may now simply ask the view for its bounds, and it will
work whether the view is a UserView or a QPenPrinter. Without this,
the function has to check the class of the view, which is poor OOP.
telephon added a commit that referenced this pull request Nov 15, 2014
Classlib: QPenPrinter: Add 'bounds' method
@telephon telephon merged commit 727927c into supercollider:master Nov 15, 2014
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.

2 participants