From: Charles G. <ch...@qu...> - 2019-06-10 14:04:52
|
Pretty sure this functionality already exists in the codebase (can't comment initially on whether it works or not though). Admittedly it could all do with cleaning up as it perhaps shouldn't be Box specific but Frame/Window specific. Perhaps Box.frame or Box.window should return a screen object or similar. That's a copy/pasta from the 3.0 branch. /* <p>The value true is put to this property on the root box when the surface is maximized, * and false when the surface is un-maximized. Reading from this value will return true if * the surface is maximized and false if it is not. Putting true to this property will * maximize the window, and putting false to this property will unmaximize the window. Note * that not all platforms support maximization.</p> * * @type(true) * */ // FIXME: the call to setMaximized() will trigger another call of this // code in the course of triggering write traps case "Maximized": if (parent == null && getSurface() != null) { getSurface().setMaximized(JSU.toBoolean(value)); } /* <p>The value true is put to this property on the root box when the surface is minimized, * and false when the surface is unminimized. Reading from this value will return true if * the surface is minimized and false if it is not. Putting true to this property will * minimize the window, and putting false will unminimize it.</p> * * @type(true) * */ // FIXME: the call to setMinimized() will trigger another call of this // code in the course of triggering write traps case "Minimized": if (parent == null && getSurface() != null) { getSurface().setMinimized(JSU.toBoolean(value)); } - Charles Goodwin QuickShift Software Ltd www.quick-shift.co.uk m: +44 777 301 3221 On Mon, Jun 10, 2019 at 2:23 PM <svn...@we...> wrote: > -------------------- SVN Commit Notification -------------------- > Repository: *vexi* > Revision: *5197* > Author: *remie* > Date: Mon Jun 10 15:23:18 CEST 2019 > > ----------------------------------------------------------------- > Log Message: > -----------------------------------------------------------------*Add vexi.ui.screen. maximise(box, optional bool), minimise(box, optional bool), isMaximised(box), isMinimised(box)* > > ----------------------------------------------------------------- > Changes: > ----------------------------------------------------------------- > U branches/vexi3/org.vexi-core.main/src/main/java/org/vexi/core/Vexi.java > > ----------------------------------------------------------------- > Diff: (only first 500 lines shown) > ----------------------------------------------------------------- > Modified: branches/vexi3/org.vexi-core.main/src/main/java/org/vexi/core/Vexi.java > =================================================================== > --- branches/vexi3/org.vexi-core.main/src/main/java/org/vexi/core/Vexi.java 2019-06-10 09:52:47 UTC (rev 5196) > +++ branches/vexi3/org.vexi-core.main/src/main/java/org/vexi/core/Vexi.java 2019-06-10 13:23:18 UTC (rev 5197) > @@ -647,6 +647,38 @@ > * @type(Number) */ > case "ui.screen.height": return JSU.N(Platform.getScreenBounds().height); > > + /* > + * Set the maximised state of the screen of the surface of the provided box > + * to the bool provided, if omitted it maximises > + * @method > + * @param(box) > + * @param(Boolean) > + */ > + case "ui.screen.maximise": return METHOD; > + /* > + * Set the minimised state of the screen of the surface of the provided box > + * to the bool provided, if omitted it minimises > + * @method > + * @param(box) > + * @param(Boolean) > + */ > + case "ui.screen.minimise": return METHOD; > + > + /* > + * Returns whether the screen of the surface of the provided box is maximised > + * @method > + * @param(Box) > + * @return(Boolean) > + */ > + case "ui.screen.isMaximised": return METHOD; > + /* > + * Returns whether the screen of the surface of the provided box is minimised > + * @method > + * @param(Box) > + * @return(Boolean) > + */ > + case "ui.screen.isMinimised": return METHOD; > + > /* <p>Returns the original object that the clonee is a clone of</p> > * > * @method > @@ -776,7 +808,45 @@ > case "file.save": return accessFile(args,true); > case "file.temp": return Resources.createTempFile(args); > case "js.eval": return Methods.eval(args); > + case "ui.screen.maximise": { > + if (args[0] == null) { > + throw new JSExn("can't maximise a null frame"); > + } > + Box b = null; > + try { > + b = (Box)args[0]; > + } catch (ClassCastException cce) { > + throw new JSExn("can't maximise screen for non-box '"+args[0]+"'"); > + } > + Surface s = null; > + try { > + s = b.getSurface(); > + } catch (ClassCastException cce) { > + throw new JSExn("can't maximise screen for box not attached to a surface"); > + } > + s._setMaximized(args.length>1 ? JSU.toBoolean(args[1]) : true); > + return null; > } > + case "ui.screen.minimise": { > + if (args[0] == null) { > + throw new JSExn("can't minimise a null frame"); > + } > + Box b = null; > + try { > + b = (Box)args[0]; > + } catch (ClassCastException cce) { > + throw new JSExn("can't minimise screen for non-box '"+args[0]+"'"); > + } > + Surface s = null; > + try { > + s = b.getSurface(); > + } catch (ClassCastException cce) { > + throw new JSExn("can't minimise screen for box not attached to a surface"); > + } > + s.setMinimized(args.length>1 ? JSU.toBoolean(args[1]) : true); > + return null; > + } > + } > > switch (args.length) { > case 0: > @@ -826,7 +896,7 @@ > case "thread.sleep": Main.SCHEDULER.sleep(JSU.toInt(args[0])); return null; > case "ui.browser": Platform.newBrowserWindow(JSU.toString(args[0])); return null; > case "ui.font.install": Resources.installFont(args[0]); return null; > - case "ui.insets": > + case "ui.insets": { > if (args[0] == null) { > throw new JSExn("can't discern insets for a null frame"); > } > @@ -848,9 +918,46 @@ > ret.put(JSU.S("bottom"), JSU.N(s.bottomInset)); > ret.put(JSU.S("right"), JSU.N(s.rightInset)); > return ret; > + } > case "ui.loadImage": > LoadableImage.load(args); > return null; > + case "ui.screen.isMaximised": { > + if (args[0] == null) { > + throw new JSExn("can't determine maximised screen state for a null frame"); > + } > + Box b = null; > + try { > + b = (Box)args[0]; > + } catch (ClassCastException cce) { > + throw new JSExn("can't determine maximised screen state for non-box '"+args[0]+"'"); > + } > + Surface s = null; > + try { > + s = b.getSurface(); > + } catch (ClassCastException cce) { > + throw new JSExn("can't determine maximised screen state for box not attached to a surface"); > + } > + return JSU.B(s.maximized); > + } > + case "ui.screen.isMinimised": { > + if (args[0] == null) { > + throw new JSExn("can't determine minimised screen state for a null frame"); > + } > + Box b = null; > + try { > + b = (Box)args[0]; > + } catch (ClassCastException cce) { > + throw new JSExn("can't determine minimised screen state for non-box '"+args[0]+"'"); > + } > + Surface s = null; > + try { > + s = b.getSurface(); > + } catch (ClassCastException cce) { > + throw new JSExn("can't determine minimised screen state for box not attached to a surface"); > + } > + return JSU.B(s.minimized); > + } > case "ui.colorAsHex": > return JSU.S(Color.colorToString(Color.stringToColor(JSU.toString(args[0])))); > case "unclone": return args[0].unclone(); > > |