HeroEngine Forums

HeroEngine Support => GUI Creation => Topic started by: AWW_boss on Mar 24, 14, 10:38:22 AM

Title: resizable panel/window question
Post by: AWW_boss on Mar 24, 14, 10:38:22 AM
Hi!

I want to implement some logic which is very similar to the resizeable panel. I was trying to find where is this logic implemented but couldn't find it (basically i want to reuse the same code, without having to reinvent the wheel). Is this panel resizing done via hsl, or is it something in the underlaying engine?
Title: Re: resizable panel/window question
Post by: FI-ScottZ on Mar 24, 14, 04:01:59 PM
I am pretty sure that is done in the source code, not script.
Title: Re: resizable panel/window question
Post by: AWW_boss on Mar 24, 14, 04:14:47 PM
Blargh.
Title: Re: resizable panel/window question
Post by: Thazager on Mar 25, 14, 08:03:52 PM
I have written my own script code for something similar which resizes some of the panels we use. Here is a small section of it. It might help you get started. This is mostly working, with a small jitter on the resize.

Code: [Select]
// used to resize the panels and buttons to fit on window
method onMouseDrag(args references Class GUIMouseEvent)
  over as NodeRef of Class GUIControl = GetGUIControlUnderMouse()
  overPP as NodeRef of Class GUIControl

  if over <> None
    overPP = over.parent.parent
    if overPP <> None
      if overPP.name <> "PICwindow"
        return
      .
    .
  .

  if args.source is kindof GUIResizePanel
    if over <> None
      var win = FindGUIControlByName(None, "game.PICwindow" )
      screen as Vector3 = GetViewPortSize()
      type as NodeRef of Class GUIControl
      sizeX as Float
      sizeY as Float

      if over.name = "resizeTop" or over.name = "resizeBottom"
        win.size.x = win.size.y
      else
        win.size.y = win.size.x
      .
      if (win.size.x + win.position.x) > screen.x
        win.size.x = screen.x - win.position.x
        win.size.y = win.size.x
      .
      if (win.size.y + win.position.y) > screen.y
        win.size.y = screen.y - win.position.y
        win.size.x = win.size.y
      .
      if win.position.x < 0
        win.position.x = 0
      .
      if win.position.y < 0
        win.position.y = 0
      .
      size as NodeRef of Class GUILabel = FindGUIControlByName(win, "mysize")   // temp
      size.text = "("+win.size.x+"x"+win.size.y+")"

      win = FindGUIControlByName(None, "game.PICwindow.buttonPanel" )
      sizeX = (win.size.x - 12) / 5

      loop i from 1 to 5
        type = FindGUIControlByName(win, "Button"+i )    // buttons up top
        type.size.x = sizeX
      .
      setPanelSize()

      args.handled = true
    .
  .
.

// resize main panel
function setPanelSize()
  var win = FindGUIControlByName(None, "game.PICwindow" )
  type as NodeRef of Class GUIControl
  sizeX as Float = (win.size.x - 24) / 4
  sizeY as Float = (win.size.y - 64) / 4

  win = FindGUIControlByName(None, "game.PICwindow.mainPan2")
  loop i from 1 to 3
    type = FindGUIControlByName(win, "window"+i )   // power panel
    type.size.x = sizeX
  .
  type = FindGUIControlByName(win, "window5" )
  type.size.y = sizeY

  sizeX = (sizeX - 29) / 4
  loop i from 1 to 4
    type = FindGUIControlByName(win, "window1.butpanel.tab"+i )
    type.size.x = sizeX
  .
.

Title: Re: resizable panel/window question
Post by: AWW_boss on Mar 26, 14, 02:33:07 AM
thanks, i'll check it out
Title: Re: resizable panel/window question
Post by: Thazager on Apr 01, 14, 11:37:02 PM
I made an updated version. https://community.heroengine.com/forums/index.php/topic,5305.new.html#new