-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extra and alias Cursor, reorg package definitions
- Loading branch information
1 parent
e083c8a
commit cddf0d9
Showing
5 changed files
with
158 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
indigo/indigo-extras/src/main/scala/indigoextras/ui/components/datatypes/Cursor.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package indigoextras.ui.components.datatypes | ||
|
||
import indigo.* | ||
|
||
final case class Cursor( | ||
position: Int, | ||
blinkRate: Option[Seconds], | ||
lastModified: Seconds | ||
): | ||
|
||
def moveTo(position: Int): Cursor = | ||
this.copy(position = position) | ||
|
||
def noCursorBlink: Cursor = | ||
this.copy(blinkRate = None) | ||
def withCursorBlinkRate(interval: Seconds): Cursor = | ||
this.copy(blinkRate = Some(interval)) | ||
|
||
def withLastCursorMove(value: Seconds): Cursor = | ||
this.copy(lastModified = value) | ||
|
||
def cursorLeft: Cursor = | ||
this.copy(position = if (position - 1 >= 0) position - 1 else position) | ||
|
||
def cursorRight(maxLength: Int): Cursor = | ||
this.copy(position = if (position + 1 <= maxLength) position + 1 else maxLength) | ||
|
||
def cursorHome: Cursor = | ||
this.copy(position = 0) | ||
|
||
def moveCursorTo(newCursorPosition: Int, maxLength: Int): Cursor = | ||
if newCursorPosition >= 0 && newCursorPosition <= maxLength then this.copy(position = newCursorPosition) | ||
else if newCursorPosition < 0 then this.copy(position = 0) | ||
else this.copy(position = Math.max(0, maxLength)) | ||
|
||
def cursorEnd(maxLength: Int): Cursor = | ||
this.copy(position = maxLength) | ||
|
||
object Cursor: | ||
val default: Cursor = | ||
Cursor(0, Option(Seconds(0.5)), Seconds.zero) |
187 changes: 105 additions & 82 deletions
187
indigo/indigo-extras/src/main/scala/indigoextras/ui/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,124 +1,147 @@ | ||
package indigoextras | ||
package indigoextras.ui | ||
|
||
package object ui { | ||
import indigo.shared.Outcome | ||
import indigo.shared.events.GlobalEvent | ||
import indigo.shared.scenegraph.Layer | ||
import indigo.shared.shader.ShaderProgram | ||
|
||
// Component | ||
object syntax: | ||
|
||
type Component[A, ReferenceData] = indigoextras.ui.component.Component[A, ReferenceData] | ||
val Component: indigoextras.ui.component.Component.type = indigoextras.ui.component.Component | ||
extension [A, ReferenceData](component: A)(using c: Component[A, ReferenceData]) | ||
def update[StartupData, ContextData]( | ||
context: UIContext[ReferenceData] | ||
): GlobalEvent => Outcome[A] = | ||
c.updateModel(context, component) | ||
|
||
// Components | ||
def present[StartupData, ContextData]( | ||
context: UIContext[ReferenceData] | ||
): Outcome[Layer] = | ||
c.present(context, component) | ||
|
||
type Button[ReferenceData] = indigoextras.ui.components.Button[ReferenceData] | ||
val Button: indigoextras.ui.components.Button.type = indigoextras.ui.components.Button | ||
def refresh( | ||
reference: ReferenceData, | ||
parentDimensions: Dimensions | ||
): A = | ||
c.refresh(reference, component, parentDimensions) | ||
|
||
type ComponentGroup[ReferenceData] = indigoextras.ui.components.ComponentGroup[ReferenceData] | ||
val ComponentGroup: indigoextras.ui.components.ComponentGroup.type = indigoextras.ui.components.ComponentGroup | ||
// Component | ||
|
||
type ComponentList[ReferenceData] = indigoextras.ui.components.ComponentList[ReferenceData] | ||
val ComponentList: indigoextras.ui.components.ComponentList.type = indigoextras.ui.components.ComponentList | ||
type Component[A, ReferenceData] = indigoextras.ui.component.Component[A, ReferenceData] | ||
val Component: indigoextras.ui.component.Component.type = indigoextras.ui.component.Component | ||
|
||
type HitArea[ReferenceData] = indigoextras.ui.components.HitArea[ReferenceData] | ||
val HitArea: indigoextras.ui.components.HitArea.type = indigoextras.ui.components.HitArea | ||
// Components | ||
|
||
type Input = indigoextras.ui.components.Input | ||
val Input: indigoextras.ui.components.Input.type = indigoextras.ui.components.Input | ||
type Button[ReferenceData] = indigoextras.ui.components.Button[ReferenceData] | ||
val Button: indigoextras.ui.components.Button.type = indigoextras.ui.components.Button | ||
|
||
type Label[ReferenceData] = indigoextras.ui.components.Label[ReferenceData] | ||
val Label: indigoextras.ui.components.Label.type = indigoextras.ui.components.Label | ||
type ComponentGroup[ReferenceData] = indigoextras.ui.components.ComponentGroup[ReferenceData] | ||
val ComponentGroup: indigoextras.ui.components.ComponentGroup.type = indigoextras.ui.components.ComponentGroup | ||
|
||
type MaskedPane[A, ReferenceData] = indigoextras.ui.components.MaskedPane[A, ReferenceData] | ||
val MaskedPane: indigoextras.ui.components.MaskedPane.type = indigoextras.ui.components.MaskedPane | ||
type ComponentList[ReferenceData] = indigoextras.ui.components.ComponentList[ReferenceData] | ||
val ComponentList: indigoextras.ui.components.ComponentList.type = indigoextras.ui.components.ComponentList | ||
|
||
type ScrollPane[A, ReferenceData] = indigoextras.ui.components.ScrollPane[A, ReferenceData] | ||
val ScrollPane: indigoextras.ui.components.ScrollPane.type = indigoextras.ui.components.ScrollPane | ||
type HitArea[ReferenceData] = indigoextras.ui.components.HitArea[ReferenceData] | ||
val HitArea: indigoextras.ui.components.HitArea.type = indigoextras.ui.components.HitArea | ||
|
||
type Switch[ReferenceData] = indigoextras.ui.components.Switch[ReferenceData] | ||
val Switch: indigoextras.ui.components.Switch.type = indigoextras.ui.components.Switch | ||
type Input = indigoextras.ui.components.Input | ||
val Input: indigoextras.ui.components.Input.type = indigoextras.ui.components.Input | ||
|
||
type TextArea[ReferenceData] = indigoextras.ui.components.TextArea[ReferenceData] | ||
val TextArea: indigoextras.ui.components.TextArea.type = indigoextras.ui.components.TextArea | ||
type Label[ReferenceData] = indigoextras.ui.components.Label[ReferenceData] | ||
val Label: indigoextras.ui.components.Label.type = indigoextras.ui.components.Label | ||
|
||
// Component datatypes | ||
type MaskedPane[A, ReferenceData] = indigoextras.ui.components.MaskedPane[A, ReferenceData] | ||
val MaskedPane: indigoextras.ui.components.MaskedPane.type = indigoextras.ui.components.MaskedPane | ||
|
||
type Anchor = indigoextras.ui.components.datatypes.Anchor | ||
val Anchor: indigoextras.ui.components.datatypes.Anchor.type = indigoextras.ui.components.datatypes.Anchor | ||
type ScrollPane[A, ReferenceData] = indigoextras.ui.components.ScrollPane[A, ReferenceData] | ||
val ScrollPane: indigoextras.ui.components.ScrollPane.type = indigoextras.ui.components.ScrollPane | ||
|
||
type BoundsMode = indigoextras.ui.components.datatypes.BoundsMode | ||
val BoundsMode: indigoextras.ui.components.datatypes.BoundsMode.type = indigoextras.ui.components.datatypes.BoundsMode | ||
type Switch[ReferenceData] = indigoextras.ui.components.Switch[ReferenceData] | ||
val Switch: indigoextras.ui.components.Switch.type = indigoextras.ui.components.Switch | ||
|
||
type BoundsType[ReferenceData, A] = indigoextras.ui.components.datatypes.BoundsType[ReferenceData, A] | ||
val BoundsType: indigoextras.ui.components.datatypes.BoundsType.type = indigoextras.ui.components.datatypes.BoundsType | ||
type TextArea[ReferenceData] = indigoextras.ui.components.TextArea[ReferenceData] | ||
val TextArea: indigoextras.ui.components.TextArea.type = indigoextras.ui.components.TextArea | ||
|
||
type ComponentEntry[A, ReferenceData] = indigoextras.ui.components.datatypes.ComponentEntry[A, ReferenceData] | ||
val ComponentEntry: indigoextras.ui.components.datatypes.ComponentEntry.type = | ||
indigoextras.ui.components.datatypes.ComponentEntry | ||
// Component datatypes | ||
|
||
type ComponentId = indigoextras.ui.components.datatypes.ComponentId | ||
val ComponentId: indigoextras.ui.components.datatypes.ComponentId.type = | ||
indigoextras.ui.components.datatypes.ComponentId | ||
type Anchor = indigoextras.ui.components.datatypes.Anchor | ||
val Anchor: indigoextras.ui.components.datatypes.Anchor.type = indigoextras.ui.components.datatypes.Anchor | ||
|
||
type ComponentLayout = indigoextras.ui.components.datatypes.ComponentLayout | ||
val ComponentLayout: indigoextras.ui.components.datatypes.ComponentLayout.type = | ||
indigoextras.ui.components.datatypes.ComponentLayout | ||
type BoundsMode = indigoextras.ui.components.datatypes.BoundsMode | ||
val BoundsMode: indigoextras.ui.components.datatypes.BoundsMode.type = indigoextras.ui.components.datatypes.BoundsMode | ||
|
||
type FitMode = indigoextras.ui.components.datatypes.FitMode | ||
val FitMode: indigoextras.ui.components.datatypes.FitMode.type = indigoextras.ui.components.datatypes.FitMode | ||
type BoundsType[ReferenceData, A] = indigoextras.ui.components.datatypes.BoundsType[ReferenceData, A] | ||
val BoundsType: indigoextras.ui.components.datatypes.BoundsType.type = indigoextras.ui.components.datatypes.BoundsType | ||
|
||
type Overflow = indigoextras.ui.components.datatypes.Overflow | ||
val Overflow: indigoextras.ui.components.datatypes.Overflow.type = indigoextras.ui.components.datatypes.Overflow | ||
type ComponentEntry[A, ReferenceData] = indigoextras.ui.components.datatypes.ComponentEntry[A, ReferenceData] | ||
val ComponentEntry: indigoextras.ui.components.datatypes.ComponentEntry.type = | ||
indigoextras.ui.components.datatypes.ComponentEntry | ||
|
||
type Padding = indigoextras.ui.components.datatypes.Padding | ||
val Padding: indigoextras.ui.components.datatypes.Padding.type = indigoextras.ui.components.datatypes.Padding | ||
type ComponentId = indigoextras.ui.components.datatypes.ComponentId | ||
val ComponentId: indigoextras.ui.components.datatypes.ComponentId.type = | ||
indigoextras.ui.components.datatypes.ComponentId | ||
|
||
type ScrollOptions = indigoextras.ui.components.datatypes.ScrollOptions | ||
val ScrollOptions: indigoextras.ui.components.datatypes.ScrollOptions.type = | ||
indigoextras.ui.components.datatypes.ScrollOptions | ||
type ComponentLayout = indigoextras.ui.components.datatypes.ComponentLayout | ||
val ComponentLayout: indigoextras.ui.components.datatypes.ComponentLayout.type = | ||
indigoextras.ui.components.datatypes.ComponentLayout | ||
|
||
type SwitchState = indigoextras.ui.components.datatypes.SwitchState | ||
val SwitchState: indigoextras.ui.components.datatypes.SwitchState.type = | ||
indigoextras.ui.components.datatypes.SwitchState | ||
type Cursor = indigoextras.ui.components.datatypes.Cursor | ||
val Cursor: indigoextras.ui.components.datatypes.Cursor.type = indigoextras.ui.components.datatypes.Cursor | ||
|
||
// Datatypes | ||
type FitMode = indigoextras.ui.components.datatypes.FitMode | ||
val FitMode: indigoextras.ui.components.datatypes.FitMode.type = indigoextras.ui.components.datatypes.FitMode | ||
|
||
type Bounds = indigoextras.ui.datatypes.Bounds | ||
val Bounds: indigoextras.ui.datatypes.Bounds.type = indigoextras.ui.datatypes.Bounds | ||
type Overflow = indigoextras.ui.components.datatypes.Overflow | ||
val Overflow: indigoextras.ui.components.datatypes.Overflow.type = indigoextras.ui.components.datatypes.Overflow | ||
|
||
type Coords = indigoextras.ui.datatypes.Coords | ||
val Coords: indigoextras.ui.datatypes.Coords.type = indigoextras.ui.datatypes.Coords | ||
type Padding = indigoextras.ui.components.datatypes.Padding | ||
val Padding: indigoextras.ui.components.datatypes.Padding.type = indigoextras.ui.components.datatypes.Padding | ||
|
||
type Dimensions = indigoextras.ui.datatypes.Dimensions | ||
val Dimensions: indigoextras.ui.datatypes.Dimensions.type = indigoextras.ui.datatypes.Dimensions | ||
type ScrollOptions = indigoextras.ui.components.datatypes.ScrollOptions | ||
val ScrollOptions: indigoextras.ui.components.datatypes.ScrollOptions.type = | ||
indigoextras.ui.components.datatypes.ScrollOptions | ||
|
||
type UIContext[ReferenceData] = indigoextras.ui.datatypes.UIContext[ReferenceData] | ||
val UIContext: indigoextras.ui.datatypes.UIContext.type = indigoextras.ui.datatypes.UIContext | ||
type SwitchState = indigoextras.ui.components.datatypes.SwitchState | ||
val SwitchState: indigoextras.ui.components.datatypes.SwitchState.type = | ||
indigoextras.ui.components.datatypes.SwitchState | ||
|
||
// Shaders | ||
// Datatypes | ||
|
||
type LayerMask = indigoextras.ui.shaders.LayerMask | ||
val LayerMask: indigoextras.ui.shaders.LayerMask.type = indigoextras.ui.shaders.LayerMask | ||
type Bounds = indigoextras.ui.datatypes.Bounds | ||
val Bounds: indigoextras.ui.datatypes.Bounds.type = indigoextras.ui.datatypes.Bounds | ||
|
||
// Window | ||
type Coords = indigoextras.ui.datatypes.Coords | ||
val Coords: indigoextras.ui.datatypes.Coords.type = indigoextras.ui.datatypes.Coords | ||
|
||
type Window[A, ReferenceData] = indigoextras.ui.window.Window[A, ReferenceData] | ||
val Window: indigoextras.ui.window.Window.type = indigoextras.ui.window.Window | ||
type Dimensions = indigoextras.ui.datatypes.Dimensions | ||
val Dimensions: indigoextras.ui.datatypes.Dimensions.type = indigoextras.ui.datatypes.Dimensions | ||
|
||
type WindowContext = indigoextras.ui.window.WindowContext | ||
val WindowContext: indigoextras.ui.window.WindowContext.type = indigoextras.ui.window.WindowContext | ||
type UIContext[ReferenceData] = indigoextras.ui.datatypes.UIContext[ReferenceData] | ||
val UIContext: indigoextras.ui.datatypes.UIContext.type = indigoextras.ui.datatypes.UIContext | ||
|
||
type WindowEvent = indigoextras.ui.window.WindowEvent | ||
val WindowEvent: indigoextras.ui.window.WindowEvent.type = indigoextras.ui.window.WindowEvent | ||
// Shaders | ||
|
||
type WindowId = indigoextras.ui.window.WindowId | ||
val WindowId: indigoextras.ui.window.WindowId.type = indigoextras.ui.window.WindowId | ||
type LayerMask = indigoextras.ui.shaders.LayerMask | ||
val LayerMask: indigoextras.ui.shaders.LayerMask.type = indigoextras.ui.shaders.LayerMask | ||
|
||
type WindowManager[StartUpData, Model, RefData] = indigoextras.ui.window.WindowManager[StartUpData, Model, RefData] | ||
val WindowManager: indigoextras.ui.window.WindowManager.type = indigoextras.ui.window.WindowManager | ||
// Window | ||
|
||
type WindowMode = indigoextras.ui.window.WindowMode | ||
val WindowMode: indigoextras.ui.window.WindowMode.type = indigoextras.ui.window.WindowMode | ||
type Window[A, ReferenceData] = indigoextras.ui.window.Window[A, ReferenceData] | ||
val Window: indigoextras.ui.window.Window.type = indigoextras.ui.window.Window | ||
|
||
type Space = indigoextras.ui.window.Space | ||
val Space: indigoextras.ui.window.Space.type = indigoextras.ui.window.Space | ||
type WindowContext = indigoextras.ui.window.WindowContext | ||
val WindowContext: indigoextras.ui.window.WindowContext.type = indigoextras.ui.window.WindowContext | ||
|
||
} | ||
type WindowEvent = indigoextras.ui.window.WindowEvent | ||
val WindowEvent: indigoextras.ui.window.WindowEvent.type = indigoextras.ui.window.WindowEvent | ||
|
||
type WindowId = indigoextras.ui.window.WindowId | ||
val WindowId: indigoextras.ui.window.WindowId.type = indigoextras.ui.window.WindowId | ||
|
||
type WindowManager[StartUpData, Model, RefData] = indigoextras.ui.window.WindowManager[StartUpData, Model, RefData] | ||
val WindowManager: indigoextras.ui.window.WindowManager.type = indigoextras.ui.window.WindowManager | ||
|
||
type WindowMode = indigoextras.ui.window.WindowMode | ||
val WindowMode: indigoextras.ui.window.WindowMode.type = indigoextras.ui.window.WindowMode | ||
|
||
type Space = indigoextras.ui.window.Space | ||
val Space: indigoextras.ui.window.Space.type = indigoextras.ui.window.Space |
11 changes: 11 additions & 0 deletions
11
indigo/indigo-extras/src/main/scala/indigoextras/ui/shaders/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package indigoextras.ui.shaders | ||
|
||
import indigo.shared.shader.ShaderProgram | ||
|
||
val ui: Set[ShaderProgram] = | ||
Set( | ||
indigoextras.ui.shaders.LayerMask.shader | ||
) | ||
|
||
val all: Set[ShaderProgram] = | ||
ui |
24 changes: 0 additions & 24 deletions
24
indigo/indigo-extras/src/main/scala/indigoextras/ui/syntax.scala
This file was deleted.
Oops, something went wrong.