Skip to content

Commit

Permalink
[GoldenLayout] Add size-related config options
Browse files Browse the repository at this point in the history
  • Loading branch information
hyazinthh committed Feb 20, 2024
1 parent 5e2b6a5 commit 7d15ebb
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 19 deletions.
23 changes: 23 additions & 0 deletions src/Aardvark.UI.Primitives/Golden/GoldenLayout.fs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ module LayoutConfig =
DragToNewWindow = true
HeaderButtons = Buttons.All
SetPopoutTitle = true
MinItemWidth = 20
MinItemHeight = 20
DragProxyWidth = 300
DragProxyHeight = 200
LabelMinimize = "Minimize"
LabelMaximize = "Maximize"
LabelPopOut = "Open in new window"
Expand Down Expand Up @@ -67,6 +71,7 @@ module Builders =
Closable = true
Header = Some Header.Top
Buttons = None
MinSize = None
Size = Size.Weight 1
KeepAlive = true }

Expand Down Expand Up @@ -96,6 +101,11 @@ module Builders =
member inline x.Buttons(e : Element, buttons : Buttons) =
{ e with Buttons = Some buttons }

/// Minimum size (in pixels) of the element in any dimension.
[<CustomOperation("minSize")>]
member inline x.MinSize(e : Element, sizeInPixels : int) =
{ e with MinSize = Some sizeInPixels }

/// Size of the element in case the parent is a row or column container.
[<CustomOperation("size")>]
member inline x.Size(e : Element, size : Size) =
Expand Down Expand Up @@ -297,6 +307,10 @@ module GoldenLayoutApp =
o.["header"] <- ofHeader config e.Buttons e.Header
o.["size"] <- JToken.op_Implicit (string e.Size)

match e.MinSize with
| Some s -> o.["minSize"] <- JToken.op_Implicit $"%d{s}px"
| _ -> ()

let s = JObject()
s.["keepAlive"] <- JToken.op_Implicit e.KeepAlive
o.["componentState"] <- s
Expand Down Expand Up @@ -335,10 +349,19 @@ module GoldenLayoutApp =
o.["setPopoutTitle"] <- JToken.op_Implicit config.SetPopoutTitle
o

let ofConfigDimensions (config : LayoutConfig) =
let o = JObject()
o.["defaultMinItemWidth"] <- JToken.op_Implicit $"{config.MinItemWidth}px"
o.["defaultMinItemHeight"] <- JToken.op_Implicit $"{config.MinItemHeight}px"
o.["dragProxyWidth"] <- JToken.op_Implicit config.DragProxyWidth
o.["dragProxyHeight"] <- JToken.op_Implicit config.DragProxyHeight
o

let ofLayoutConfig (config : LayoutConfig) (layout : Layout) =
let o = JObject()
o.["root"] <- JObject.ofLayout config layout
o.["settings"] <- JObject.ofConfigSettings config
o.["dimensions"] <- JObject.ofConfigDimensions config
o.["header"] <- JObject.ofConfigLabels config
o.ToString Formatting.None

Expand Down
15 changes: 15 additions & 0 deletions src/Aardvark.UI.Primitives/Golden/GoldenLayoutModel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ type Element =
/// Buttons to display in the header.
Buttons : Buttons option

/// Minimum size (in pixels) of the element in any dimension.
MinSize : int option

/// Size of the element in case the parent is a row or column container.
Size : Size

Expand Down Expand Up @@ -113,6 +116,18 @@ type LayoutConfig =
/// Determines whether the document.title of popouts is set and updated automatically to the document.title of the main window.
SetPopoutTitle : bool

/// Default minimum width (in pixels) of any item. Default is 20.
MinItemWidth : int

/// Default minimum height (in pixels) of any item. Default is 20.
MinItemHeight : int

/// Width (in pixels) of drag proxy elements. Default is 300.
DragProxyWidth : int

/// Height (in pixels) of drag proxy elements. Default is 200.
DragProxyHeight : int

/// Tooltip label of minimize button.
LabelMinimize : string

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Scratch/25 - GoldenLayout/App.fs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ let defaultLayout =
element {
id "render"
title "3D View"
minSize 100
}

element {
Expand Down

0 comments on commit 7d15ebb

Please sign in to comment.