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

add setPosition to Quicksettings interface #6

Open
phivk opened this issue Jun 3, 2017 · 3 comments
Open

add setPosition to Quicksettings interface #6

phivk opened this issue Jun 3, 2017 · 3 comments

Comments

@phivk
Copy link

phivk commented Jun 3, 2017

It would be nice to have methods to set the position of GUI panels. I checked quicksettings.js and it has such a method available.

Would you agree this would make a nice addition?
If so I could try to find some time to implement and create a PR.

@craftoid
Copy link
Member

Hey @phillchill! Thanks for your interest in p5.gui + suggestion for improvement!
You can currently set the absolute position of the panel in the constructor like so:

createGui(label, x, y);

But I agree, something like setPosition would make sense in dynamic interfaces, or if the size of the window is not known on construction. It might be nice to add relative positioning though, maybe by using negative values for x and y ...

@phivk
Copy link
Author

phivk commented Jul 18, 2017

ah, that's good to know. For the moment I was using a jQuery solution like this (here positioning something bottom right of screen):

$( "div.qs_title_bar:contains([title])" ).parent().css({"left": "initial", "right":"20px", "top":"initial", "bottom":"20px"});

As a first step I'd simply build directly on the setPosition() method from quicksettings.js

Relative positioning (relative to what btw?) can also be added on top of this...

@craftoid
Copy link
Member

Definitely trying to do without jQuery :)

I was thinking relative to the window, p5.js canvas, or some other dedicated parent element...

  • setPosition(100, 100) would place the gui relative to the top left corner.
  • setPosition(-100, 100) would place the gui relative to the top right corner.
  • setPosition(100, -100) would place the gui relative to the bottom left corner.
  • setPosition(-100, -100) would place the gui relative to the bottom right corner.

Not sure if bottom placement really is a thing.
But half of the time I think it's nicer to move the GUI over to the right ...

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