dazscript-framework 0.1.14 → 0.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dazscript-framework",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "author": "Freddy Diaz",
5
5
  "license": "MPL-2.0",
6
6
  "description": "",
package/src/common/log.ts CHANGED
@@ -43,7 +43,6 @@ export const dump = (obj: any) => {
43
43
  App.flushLogBuffer()
44
44
  }
45
45
 
46
-
47
46
  const format = (message: string, level?: 'ERROR' | 'TRACE' | 'DUMP' | 'INFO') => {
48
47
  if (message == null) {
49
48
  return ''
@@ -0,0 +1,36 @@
1
+ import { WidgetBuilderBase, createWidget } from './widget-builder';
2
+ import { WidgetBuilderContext } from './widgets-builder';
3
+
4
+ export default class ColorPickerBuilder extends WidgetBuilderBase<DzColorWgt> {
5
+ private _value?: Color
6
+ private _minWidth: number
7
+ private _parent: DzWidget | DzLayout | null = null;
8
+
9
+ constructor(private readonly context: WidgetBuilderContext) {
10
+ super(null)
11
+ }
12
+
13
+ value(color: Color): this {
14
+ this._value = color
15
+ return this
16
+ }
17
+
18
+ minWidth(width: number): this {
19
+ this._minWidth = width
20
+ return this
21
+ }
22
+
23
+ parent(parent: DzWidget | DzLayout): this {
24
+ this._parent = parent
25
+ return this
26
+ }
27
+
28
+ override build(): DzColorWgt {
29
+ let widget = createWidget(this.context).parent(this._parent ?? this.context.parent).build(DzColorWgt)
30
+
31
+ if (this._value) widget.value = this._value
32
+ widget.minWidth = this._minWidth
33
+
34
+ return widget;
35
+ }
36
+ }
@@ -9,6 +9,7 @@ export default class GroupBoxBuilder implements IWidgetBuilder<DzGroupBox> {
9
9
  private _direction: Direction = 'vertical'
10
10
  private _style: { flat?: boolean }
11
11
  private _visible: Observable<boolean>
12
+ private _columns: number = 1
12
13
 
13
14
  constructor(private context: WidgetBuilderContext) {
14
15
  }
@@ -42,11 +43,17 @@ export default class GroupBoxBuilder implements IWidgetBuilder<DzGroupBox> {
42
43
  return this
43
44
  }
44
45
 
45
- build(then?: (layout: DzVBoxLayout | DzHBoxLayout) => void): DzGroupBox {
46
+ columns(value: number): this {
47
+ this._columns = value
48
+ return this
49
+ }
50
+
51
+ build(then?: (layout: DzVBoxLayout | DzHBoxLayout, groupBox: DzGroupBox) => void): DzGroupBox {
46
52
  let groupBox = createWidget(this.context).build(DzGroupBox)
47
53
 
48
54
  groupBox.title = this._title?.value
49
55
  groupBox.flat = this._style?.flat
56
+ groupBox.columns = this._columns
50
57
 
51
58
  this._title?.connect((text) => {
52
59
  groupBox.title = text
@@ -55,7 +62,9 @@ export default class GroupBoxBuilder implements IWidgetBuilder<DzGroupBox> {
55
62
  new LayoutBuilder(this.context)
56
63
  .parent(groupBox)
57
64
  .direction(this._direction)
58
- .build(then)
65
+ .build((layout) => {
66
+ then?.(layout, groupBox)
67
+ })
59
68
 
60
69
  if (this._visible) {
61
70
  if (this._visible.value === false)
@@ -1,4 +1,3 @@
1
- import { AlignmentFlags } from '@dst/common/alignmentFlags';
2
1
  import { WidgetBuilderBase, createWidget } from './widget-builder';
3
2
  import { WidgetBuilderContext } from './widgets-builder';
4
3
 
@@ -14,7 +14,7 @@ export class PopupMenuBuilder extends WidgetBuilderBase<DzPopupMenu> {
14
14
  }
15
15
 
16
16
  parent(parent: DzWidget): this {
17
- this.widget.reparent(parent, new Point(0, 0))
17
+ this.widget.reparent(parent)
18
18
  return this
19
19
  }
20
20
 
@@ -0,0 +1,23 @@
1
+ import { WidgetBuilderBase, createWidget } from './widget-builder'
2
+ import { WidgetBuilderContext } from './widgets-builder'
3
+
4
+ export default class SliderBuilder extends WidgetBuilderBase<DzFloatSlider> {
5
+ constructor(context: WidgetBuilderContext) {
6
+ super(createWidget(context).build(DzFloatSlider))
7
+ }
8
+
9
+ value(value: number): this {
10
+ this.widget.value = value
11
+ return this
12
+ }
13
+
14
+ min(min: number): this {
15
+ this.widget.min = min
16
+ return this
17
+ }
18
+
19
+ max(max: number): this {
20
+ this.widget.max = max
21
+ return this
22
+ }
23
+ }
@@ -24,17 +24,17 @@ export abstract class WidgetBuilderBase<T extends DzWidget> implements IWidgetBu
24
24
  }
25
25
 
26
26
  clickFocus(): this {
27
- this.widget.getWidget().focusPolicy = DzWidget.ClickFocus
27
+ this.widget.getWidget().focusPolicy = QtFocusPolicy.ClickFocus
28
28
  return this
29
29
  }
30
30
 
31
31
  tabFocus(): this {
32
- this.widget.getWidget().focusPolicy = DzWidget.TabFocus
32
+ this.widget.getWidget().focusPolicy = QtFocusPolicy.TabFocus
33
33
  return this
34
34
  }
35
35
 
36
36
  noFocus(): this {
37
- this.widget.getWidget().focusPolicy = DzWidget.NoFocus
37
+ this.widget.getWidget().focusPolicy = QtFocusPolicy.NoFocus
38
38
  return this
39
39
  }
40
40
 
@@ -1,6 +1,7 @@
1
1
  import { Observable } from '@dsf/lib/observable'
2
2
  import { ButtonBuilder } from './button-builder'
3
3
  import CheckBoxBuilder from './checkbox-builder'
4
+ import ColorPickerBuilder from './color-picker-builder'
4
5
  import { ComboBoxBuilder } from './combo-box-builder'
5
6
  import { ComboEditBuilder } from './combo-edit-builder'
6
7
  import GroupBoxBuilder from './groupbox-builder'
@@ -11,6 +12,7 @@ import { ListViewBuilder } from './list-view-builder'
11
12
  import { NodeSelectionComboBoxBuilder } from './node-selection-builder'
12
13
  import { PopupMenuBuilder } from './popup-menu-builder'
13
14
  import RadioButtonBuilder from './radio-builder'
15
+ import SliderBuilder from './slider-builder'
14
16
  import { SplitterBuilder, SplitterBuilderContext } from './splitter-builder'
15
17
  import { TabBuilder, TabBuilderContext } from './tab-builder'
16
18
  import { createWidget } from './widget-builder'
@@ -104,6 +106,14 @@ export class WidgetsBuilder {
104
106
  // return new PathComboBoxBuilder(this.context, checkBoxes)
105
107
  // }
106
108
 
109
+ slider(): SliderBuilder {
110
+ return new SliderBuilder(this.context)
111
+ }
112
+
113
+ color(): ColorPickerBuilder {
114
+ return new ColorPickerBuilder(this.context)
115
+ }
116
+
107
117
  /**
108
118
  *
109
119
  * @returns
@@ -42,13 +42,12 @@ export const getSelectedFigure = (): DzSkeleton | null => {
42
42
  * Given the selected nodes in the scene, return the figures they are part of
43
43
  * @returns the selected figures
44
44
  */
45
- export const getSelectedFigures = (callback: (figure: DzSkeleton) => void | boolean = () => true): DzSkeleton[] => {
45
+ export const getSelectedFigures = (): DzSkeleton[] => {
46
46
  let nodes: DzSkeleton[] = []
47
47
  for (let node of scene.getSelectedNodeList()) {
48
48
  let skeleton = node.getSkeleton?.()
49
49
  if (!skeleton || contains(nodes, node)) continue
50
50
  nodes.push(skeleton)
51
- if (!!callback?.(skeleton)) break
52
51
  }
53
52
  return nodes
54
53
  }
@@ -5,3 +5,4 @@ const acceptUndoFor = (caption: string, callback: () => void) => {
5
5
  }
6
6
 
7
7
  export { acceptUndoFor as acceptUndo }
8
+