G4P V4 GWindow setResizable()?

edited December 2015 in Library Questions

Hi Quark,

I know you've had your hands full with updates to the new G4P since Processing 3 came out. I presume that you just haven't gotten around to adding the resizing ability for GWindows in the new release of G4P?

If it's there, please point me to the correct method to use, I'm not seeing one. :) Otherwise, take this as a friendly/patient up-vote for the feature.

Thanks! Rudnik

Answers

  • Just spotted this discussion.

    I presume that you just haven't gotten around to adding the resizing ability for GWindows in the new release of G4P?

    I don't remember being asked to add this feature and there are no tickets on Sourceforge asking for this either.

    Resizing a GWindow probably won't be straight forward especially with Processing 3 but I will investigate the possibility.

  • Answer ✓

    If you have a GWindow called window then you can use

    window.getSurface().setResizable(true);

    According the the Processing 3 docs this is not enabled by default because "'because most sketches won't behave well when resized"

    So this is not a feature I am likely to implement in G4P

  • edited December 2015

    An interesting point is we can't directly access field surface from another class outside the main sketch.
    B/c they've decided outta the blue that surface should be protected.
    Even though the old frame was public. 8-|
    Dunno what exactly we're being protected from.
    But now only the "getter" getSurface() is guaranteed to work at all times.

  • Dunno what exactly we're being protected from.

    It is protected from being changed directly with

    surface = null;
    // or with G4P
    window.surface = null;
    // or even something that is not null :)
    

    But you can still access surface with getSurface() and you can access it directly by inheriting from the PSurface class. This is good OO design

    Even though the old frame was public

    This was poor OO design

    So things are improving ;)

  • It is protected from being changed directly with.

    How does that work? Since sketches are subclasses of PApplet, surface can be directly accessed! >:)
    It's only when dealing w/ "foreign" classes that annoying protected access level kicks in! ~X(
    So for 99% of times, it doesn't protect anything. Only gets in the way for more complex sketches! 8-}

  • edited December 2015

    How does that work? Since sketches are subclasses of PApplet, surface can be directly accessed!

    You are right I forgot that because I had been thinking of how I access it in G4P. The answer is to make it private or final (if practical) and keep the public getSurface() method. This will protect the surface variable being changed and the getSurface() method is likely to be inlined by the JVM.

  • edited December 2015

    Apart from assigning null to surface, I got no idea how to create a PSurface for it! :))
    No 1 reassigns surface ever. We don't need that kinda "protection"! [-X

  • edited January 2016

    Thanks for looking into Quark-- I hadn't realized I had to go through the getSurface method to access it. SetResizable was one of those things I used with P2. I think this actually answers several other questions I had in regard to GWindow and PApplet in P3. Your hint has already helped me figure out why frame.setAlwaysOnTop(true) wasn't working anymore ;)

    Also, Happy New Year

Sign In or Register to comment.