Top | ![]() |
![]() |
![]() |
![]() |
Applet.PopupResizeHandlerApplet.PopupResizeHandler — Class that allows an applet to be resized using the mouse. |
Parameters - actor: The actor to be resized get_orientation: Function that returns the current orientation of the applet. (St.Side) resized_callback: Function that is called while resizing is in progress with the new width and height as parameters. This function should actually change the applet size. This is also called once when resizing has ended (resizingInProgress == false) so that the applet can store the final size instead of doing so continuously whilst resizing is in progress. get_user_width: Function that returns the current applet width. This is called only when resizing begins so does not have to return the correct width while resizing is in progress. Note: This value does not necessarily have to be the applet width. It could be the width of a container inside the applet used for sizing the applet. get_user_height: As get_user_width but for height
Example - this.menu = new Applet.AppletPopupMenu(this, this.orientation); this.settings.bind("popup-width", "popup_width"); this.settings.bind("popup-height", "popup_height");
this._resizer = new Applet.PopupResizeHandler( this.menu.actor, () => this.orientation, (w,h) => this._onBoxResized(w,h), () => this.popup_width global.ui_scale, () => this.popup_height global.ui_scale);
...
_onBoxResized(width, height) { this.popup_width = Math.max(width / global.ui_scale, 300); this.popup_height = Math.max(height / global.ui_scale, 400); this.menu.actor.set_width(this.popup_width global.ui_scale); this.menu.actor.set_height(this.popup_height global.ui_scale); }