diff --git a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/CheckBoxDsl.kt b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/CheckBoxDsl.kt index 4970fa5f3c..59240bf7ef 100644 --- a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/CheckBoxDsl.kt +++ b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/CheckBoxDsl.kt @@ -8,4 +8,4 @@ fun checkBox( labelAlignment: DefaultCheckBox.CheckBoxAlignment = DefaultCheckBox.CheckBoxAlignment.RIGHT, init: CheckBoxBuilder.() -> Unit ): CheckBox = - CheckBoxBuilder(labelAlignment = labelAlignment).apply(init).build() \ No newline at end of file + CheckBoxBuilder(labelAlignment = labelAlignment).apply(init).build() diff --git a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/ColorThemeDsl.kt b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/ColorThemeDsl.kt index 06c458693d..489d053e3f 100644 --- a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/ColorThemeDsl.kt +++ b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/ColorThemeDsl.kt @@ -4,4 +4,4 @@ import org.hexworks.zircon.api.builder.component.ColorThemeBuilder import org.hexworks.zircon.api.component.ColorTheme fun colorTheme(init: ColorThemeBuilder.() -> Unit): ColorTheme = - ColorThemeBuilder().apply(init).build() \ No newline at end of file + ColorThemeBuilder().apply(init).build() diff --git a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/ComponentScope.kt b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/ComponentScope.kt new file mode 100644 index 0000000000..e9db439f5e --- /dev/null +++ b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/ComponentScope.kt @@ -0,0 +1,127 @@ +package org.hexworks.zircon.api.dsl.component + +import org.hexworks.zircon.api.builder.component.* +import org.hexworks.zircon.api.component.* +import org.hexworks.zircon.api.component.modal.Modal +import org.hexworks.zircon.api.component.modal.ModalResult +import org.hexworks.zircon.api.data.Position +import org.hexworks.zircon.internal.component.impl.DefaultCheckBox +import org.hexworks.zircon.internal.dsl.ZirconDsl + +@ZirconDsl +class ComponentScope { + private lateinit var component: Component + + fun button(init: ButtonBuilder.() -> Unit) { + component = ButtonBuilder().apply(init).build() + } + + fun checkBox( + labelAlignment: DefaultCheckBox.CheckBoxAlignment = DefaultCheckBox.CheckBoxAlignment.RIGHT, + init: CheckBoxBuilder.() -> Unit + ) { + component = CheckBoxBuilder(labelAlignment = labelAlignment).apply(init).build() + } + + fun hBox(init: HBoxBuilder.() -> Unit) { + component = HBoxBuilder().apply(init).build() + } + + fun header(init: HeaderBuilder.() -> Unit) { + component = HeaderBuilder().apply(init).build() + } + + fun horizontalNumberInput( + width: Int, + init: HorizontalNumberInputBuilder.() -> Unit + ) { + component = HorizontalNumberInputBuilder(width).apply(init).build() + } + + fun horizontalScrollBar( + minValue: Int = 0, + maxValue: Int = 100, + init: HorizontalScrollBarBuilder.() -> Unit + ) { + component = HorizontalScrollBarBuilder(minValue, maxValue).apply(init).build() + } + + fun horizontalSlider(init: HorizontalSliderBuilder.() -> Unit) { + component = HorizontalSliderBuilder().apply(init).build() + } + + fun icon(init: IconBuilder.() -> Unit) { + component = IconBuilder().apply(init).build() + } + + fun label(init: LabelBuilder.() -> Unit) { + component = LabelBuilder().apply(init).build() + } + + fun listItem(init: ListItemBuilder.() -> Unit) { + component = ListItemBuilder().apply(init).build() + } + + fun logArea(init: LogAreaBuilder.() -> Unit) { + component = LogAreaBuilder().apply(init).build() + } + + fun modal(init: ModalBuilder.() -> Unit) { + component = ModalBuilder().apply(init).build() + } + + fun panel() { + PanelBuilder().build() + } + + fun paragraph(init: ParagraphBuilder.() -> Unit) { + component = ParagraphBuilder().apply(init).build() + } + + fun progressBar(init: ProgressBarBuilder.() -> Unit) { + component = ProgressBarBuilder().apply(init).build() + } + + fun radioButton(init: RadioButtonBuilder.() -> Unit) { + component = RadioButtonBuilder().apply(init).build() + } + + fun textArea(init: TextAreaBuilder.() -> Unit) { + TextAreaBuilder().apply(init).build() + } + + fun textBox( + initialContentWidth: Int, + nextPosition: Position = Position.defaultPosition(), + components: MutableList = mutableListOf(), + init: TextBoxBuilder.() -> Unit + ) { + component = TextBoxBuilder(initialContentWidth, nextPosition, components).apply(init).build() + } + + fun toggleButton(init: ToggleButtonBuilder.() -> Unit) { + ToggleButtonBuilder().apply(init).build() + } + + fun vBox(init: VBoxBuilder.() -> Unit) { + component = VBoxBuilder().apply(init).build() + } + + fun verticalNumberInput(height: Int, init: VerticalNumberInputBuilder.() -> Unit) { + component = VerticalNumberInputBuilder(height).apply(init).build() + } + + fun verticalScrollBar( + minValue: Int = 0, + maxValue: Int = 100, + init: VerticalScrollBarBuilder.() -> Unit + ) { + component = VerticalScrollBarBuilder(minValue, maxValue).apply(init).build() + } + + fun verticalSlider(init: VerticalSliderBuilder.() -> Unit) { + component = VerticalSliderBuilder().apply(init).build() + } + + fun build(): Component = component +} diff --git a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/HBoxDsl.kt b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/HBoxDsl.kt index ab5aba1f07..38b3914853 100644 --- a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/HBoxDsl.kt +++ b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/HBoxDsl.kt @@ -4,4 +4,4 @@ import org.hexworks.zircon.api.builder.component.HBoxBuilder import org.hexworks.zircon.api.component.HBox fun hBox(init: HBoxBuilder.() -> Unit): HBox = - HBoxBuilder().apply(init).build() \ No newline at end of file + HBoxBuilder().apply(init).build() diff --git a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/HeaderDsl.kt b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/HeaderDsl.kt index e449ec939e..7e53d556b0 100644 --- a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/HeaderDsl.kt +++ b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/HeaderDsl.kt @@ -4,4 +4,4 @@ import org.hexworks.zircon.api.builder.component.HeaderBuilder import org.hexworks.zircon.api.component.Header fun header(init: HeaderBuilder.() -> Unit): Header = - HeaderBuilder().apply(init).build() \ No newline at end of file + HeaderBuilder().apply(init).build() diff --git a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/HorizontalScrollBarDsl.kt b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/HorizontalScrollBarDsl.kt index b073925e5c..8ffe9a467d 100644 --- a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/HorizontalScrollBarDsl.kt +++ b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/HorizontalScrollBarDsl.kt @@ -8,4 +8,4 @@ fun horizontalScrollBar( maxValue: Int = 100, init: HorizontalScrollBarBuilder.() -> Unit ): ScrollBar = - HorizontalScrollBarBuilder(minValue, maxValue).apply(init).build() \ No newline at end of file + HorizontalScrollBarBuilder(minValue, maxValue).apply(init).build() diff --git a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/HorizontalSliderDsl.kt b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/HorizontalSliderDsl.kt index 861530757f..30ecff28ca 100644 --- a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/HorizontalSliderDsl.kt +++ b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/HorizontalSliderDsl.kt @@ -4,4 +4,4 @@ import org.hexworks.zircon.api.builder.component.HorizontalSliderBuilder import org.hexworks.zircon.api.component.Slider fun horizontalSlider(init: HorizontalSliderBuilder.() -> Unit): Slider = - HorizontalSliderBuilder().apply(init).build() \ No newline at end of file + HorizontalSliderBuilder().apply(init).build() diff --git a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/IconDsl.kt b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/IconDsl.kt index 369d77ccdb..7f9f4df90e 100644 --- a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/IconDsl.kt +++ b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/IconDsl.kt @@ -10,4 +10,4 @@ fun icon(init: IconBuilder.() -> Unit): Icon = fun IconBuilder.iconTile(init: TileBuilder.() -> Unit) = withIcon( TileBuilder().apply(init).build() - ) \ No newline at end of file + ) diff --git a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/LabelDsl.kt b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/LabelDsl.kt index be0dd837c5..9da54fa264 100644 --- a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/LabelDsl.kt +++ b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/LabelDsl.kt @@ -4,4 +4,4 @@ import org.hexworks.zircon.api.builder.component.LabelBuilder import org.hexworks.zircon.api.component.Label fun label(init: LabelBuilder.() -> Unit): Label = - LabelBuilder().apply(init).build() \ No newline at end of file + LabelBuilder().apply(init).build() diff --git a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/ListItemDsl.kt b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/ListItemDsl.kt index 918a00d5f1..e3670b6c07 100644 --- a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/ListItemDsl.kt +++ b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/ListItemDsl.kt @@ -4,4 +4,4 @@ import org.hexworks.zircon.api.builder.component.ListItemBuilder import org.hexworks.zircon.api.component.ListItem fun listItem(init: ListItemBuilder.() -> Unit): ListItem = - ListItemBuilder().apply(init).build() \ No newline at end of file + ListItemBuilder().apply(init).build() diff --git a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/LogAreaDsl.kt b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/LogAreaDsl.kt index a62bbb4e10..5650ab6c43 100644 --- a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/LogAreaDsl.kt +++ b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/LogAreaDsl.kt @@ -4,4 +4,4 @@ import org.hexworks.zircon.api.builder.component.LogAreaBuilder import org.hexworks.zircon.api.component.LogArea fun logArea(init: LogAreaBuilder.() -> Unit): LogArea = - LogAreaBuilder().apply(init).build() \ No newline at end of file + LogAreaBuilder().apply(init).build() diff --git a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/ModalDsl.kt b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/ModalDsl.kt index b58738a6b3..c7227eaa68 100644 --- a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/ModalDsl.kt +++ b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/ModalDsl.kt @@ -8,8 +8,8 @@ import org.hexworks.zircon.api.component.modal.ModalResult fun modal(init: ModalBuilder.() -> Unit): Modal = ModalBuilder().apply(init).build() -fun ModalBuilder.component(init: () -> Component) { +fun ModalBuilder.component(init: ComponentScope.() -> Unit) { withComponent( - init() + ComponentScope().apply(init).build() ) } \ No newline at end of file diff --git a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/PanelDsl.kt b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/PanelDsl.kt index e54be01216..ded244f37d 100644 --- a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/PanelDsl.kt +++ b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/PanelDsl.kt @@ -5,4 +5,3 @@ import org.hexworks.zircon.api.component.Panel fun panel(): Panel = PanelBuilder().build() - diff --git a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/ParagraphDsl.kt b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/ParagraphDsl.kt index 3f3813a3e8..05defc14c2 100644 --- a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/ParagraphDsl.kt +++ b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/ParagraphDsl.kt @@ -4,4 +4,4 @@ import org.hexworks.zircon.api.builder.component.ParagraphBuilder import org.hexworks.zircon.api.component.Paragraph fun paragraph(init: ParagraphBuilder.() -> Unit): Paragraph = - ParagraphBuilder().apply(init).build() \ No newline at end of file + ParagraphBuilder().apply(init).build() diff --git a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/RadioButtonDsl.kt b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/RadioButtonDsl.kt index a3239991d0..9a0efb2b3b 100644 --- a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/RadioButtonDsl.kt +++ b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/RadioButtonDsl.kt @@ -4,4 +4,4 @@ import org.hexworks.zircon.api.builder.component.RadioButtonBuilder import org.hexworks.zircon.api.component.RadioButton fun radioButton(init: RadioButtonBuilder.() -> Unit): RadioButton = - RadioButtonBuilder().apply(init).build() \ No newline at end of file + RadioButtonBuilder().apply(init).build() diff --git a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/RadioButtonGroupDsl.kt b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/RadioButtonGroupDsl.kt index 25e589d870..8ae2b1afdd 100644 --- a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/RadioButtonGroupDsl.kt +++ b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/RadioButtonGroupDsl.kt @@ -4,4 +4,4 @@ import org.hexworks.zircon.api.builder.component.RadioButtonGroupBuilder import org.hexworks.zircon.api.component.RadioButtonGroup fun radioButtonGroup(init: RadioButtonGroupBuilder.() -> Unit): RadioButtonGroup = - RadioButtonGroupBuilder().apply(init).build() \ No newline at end of file + RadioButtonGroupBuilder().apply(init).build() diff --git a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/TextAreaDsl.kt b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/TextAreaDsl.kt index c9971f4702..f03779ff34 100644 --- a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/TextAreaDsl.kt +++ b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/TextAreaDsl.kt @@ -4,4 +4,4 @@ import org.hexworks.zircon.api.builder.component.TextAreaBuilder import org.hexworks.zircon.api.component.TextArea fun textArea(init: TextAreaBuilder.() -> Unit): TextArea = - TextAreaBuilder().apply(init).build() \ No newline at end of file + TextAreaBuilder().apply(init).build() diff --git a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/TextBoxDsl.kt b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/TextBoxDsl.kt index 8b0fc36327..b5bac66742 100644 --- a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/TextBoxDsl.kt +++ b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/TextBoxDsl.kt @@ -17,5 +17,7 @@ fun textBox( fun TextBoxBuilder.paragraph(withNewLine: Boolean = true, init: ParagraphBuilder.() -> Unit) = addParagraph(ParagraphBuilder().apply(init).build(), withNewLine) -fun TextBoxBuilder.inlineComponent(init: () -> Component) = - addInlineComponent(init()) +fun TextBoxBuilder.inlineComponent(init: ComponentScope.() -> Unit) = + addInlineComponent( + ComponentScope().apply(init).build() + ) diff --git a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/ToggleButtonDsl.kt b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/ToggleButtonDsl.kt index 84f5c45296..fb5656de24 100644 --- a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/ToggleButtonDsl.kt +++ b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/ToggleButtonDsl.kt @@ -4,4 +4,4 @@ import org.hexworks.zircon.api.builder.component.ToggleButtonBuilder import org.hexworks.zircon.api.component.ToggleButton fun toggleButton(init: ToggleButtonBuilder.() -> Unit): ToggleButton = - ToggleButtonBuilder().apply(init).build() \ No newline at end of file + ToggleButtonBuilder().apply(init).build() diff --git a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/VBoxDsl.kt b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/VBoxDsl.kt index 6720a0da4a..c5025ce0b4 100644 --- a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/VBoxDsl.kt +++ b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/VBoxDsl.kt @@ -4,4 +4,4 @@ import org.hexworks.zircon.api.builder.component.VBoxBuilder import org.hexworks.zircon.api.component.VBox fun vBox(init: VBoxBuilder.() -> Unit): VBox = - VBoxBuilder().apply(init).build() \ No newline at end of file + VBoxBuilder().apply(init).build() diff --git a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/VerticalNumberInputDsl.kt b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/VerticalNumberInputDsl.kt index c186fd9194..23b85218b8 100644 --- a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/VerticalNumberInputDsl.kt +++ b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/VerticalNumberInputDsl.kt @@ -4,4 +4,4 @@ import org.hexworks.zircon.api.builder.component.VerticalNumberInputBuilder import org.hexworks.zircon.api.component.NumberInput fun verticalNumberInput(height: Int, init: VerticalNumberInputBuilder.() -> Unit): NumberInput = - VerticalNumberInputBuilder(height).apply(init).build() \ No newline at end of file + VerticalNumberInputBuilder(height).apply(init).build() diff --git a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/VerticalScrollBarDsl.kt b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/VerticalScrollBarDsl.kt index dd046ac1aa..076cdb6f29 100644 --- a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/VerticalScrollBarDsl.kt +++ b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/VerticalScrollBarDsl.kt @@ -8,4 +8,4 @@ fun verticalScrollBar( maxValue: Int = 100, init: VerticalScrollBarBuilder.() -> Unit ): ScrollBar = - VerticalScrollBarBuilder(minValue, maxValue).apply(init).build() \ No newline at end of file + VerticalScrollBarBuilder(minValue, maxValue).apply(init).build() diff --git a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/VerticalSliderDsl.kt b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/VerticalSliderDsl.kt index 1955c894d3..dbfd20098a 100644 --- a/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/VerticalSliderDsl.kt +++ b/zircon.core/src/commonMain/kotlin/org/hexworks/zircon/api/dsl/component/VerticalSliderDsl.kt @@ -4,4 +4,4 @@ import org.hexworks.zircon.api.builder.component.VerticalSliderBuilder import org.hexworks.zircon.api.component.Slider fun verticalSlider(init: VerticalSliderBuilder.() -> Unit): Slider = - VerticalSliderBuilder().apply(init).build() \ No newline at end of file + VerticalSliderBuilder().apply(init).build()