bitcraftlab / p5.gui

p5.gui magically generates a graphical user interface for your p5.js sketches
https://bitcraftlab.github.io/p5.gui
MIT License
357 stars 91 forks source link

add setPosition to Quicksettings interface #6

Open phivk opened 7 years ago

phivk commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

Definitely trying to do without jQuery :)

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

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 ...