diff --git a/CHANGELOG.md b/CHANGELOG.md index 61c5f97..300dbe6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ ## Unreleased +- Remove the need to wrap widget values with `asOneOf` (#7) +Any of the input record fields can now be either `a` or `Binding a`, as long as props of the widget have that field as `ValueOrBinding a`. + +- Move all widgets into a single module (#7) +Modules for individual widgets like `AGS.Widget.Button` are removed. +Now widgets should only be imported from `AGS.widget`. + - Make `Applications.matchAppName` return `Boolean` rather than `Effect Boolean` ## v0.1.0 diff --git a/src/AGS/Widget.purs b/src/AGS/Widget.purs index 836980c..14aa12c 100644 --- a/src/AGS/Widget.purs +++ b/src/AGS/Widget.purs @@ -13,72 +13,73 @@ import AGS.Binding , overBoth , overValue ) as Exports -import AGS.Widget.Box (BoxProps, UpdateBoxProps, box, box') as Exports -import AGS.Widget.Button (ButtonProps, UpdateButtonProps, button, button') as Exports -import AGS.Widget.CenterBox - ( CenterBoxProps - , UpdateCenterBoxProps +import AGS.Widget.Internal + ( class ToValueOrBindingC + , AGSWidgetProps + , Any + , AnyF + , BoxProps + , ButtonProps + , CenterBoxProps + , CircularProgressProps + , EntryProps + , EventBoxProps + , IconProps + , LabelProps + , Mark + , MarkPosition + , MenuItemProps + , MenuProps + , MkWidget + , MkWidgetWithUpdates + , OverlayProps + , ProgressBarProps + , RevealerProps + , ScrollableProps + , SliderProps + , StackProps + , ToValueOrBinding + , box + , box' + , button + , button' , centerBox , centerBox' - ) as Exports -import AGS.Widget.CircularProgress - ( CircularProgressProps - , UpdateCircularProgressProps , circularProgress , circularProgress' - ) as Exports -import AGS.Widget.Entry (EntryProps, UpdateEntryProps, entry, entry') as Exports -import AGS.Widget.EventBox - ( EventBoxProps - , UpdateEventBoxProps + , entry + , entry' , eventBox , eventBox' - ) as Exports -import AGS.Widget.Icon (IconProps, UpdateIconProps, icon, icon') as Exports -import AGS.Widget.Internal - ( AGSWidgetProps - , Any - , AnyF + , icon + , icon' + , label + , label' + , markPositionBottom + , markPositionLeft + , markPositionRight + , markPositionTop + , menu + , menu' + , menuItem + , menuItem' , mkAny - , unsafeWidgetUpdate - ) as Exports -import AGS.Widget.Label (LabelProps, label, label') as Exports -import AGS.Widget.Menu (MenuProps, UpdateMenuProps, menu, menu') as Exports -import AGS.Widget.Menu.Item (MenuItem, MenuItemProps, menuItem, menuItemImpl) as Exports -import AGS.Widget.Overlay (OverlayProps, UpdateOverlayProps, overlay, overlay') as Exports -import AGS.Widget.ProgressBar - ( ProgressBarProps - , UpdateProgressBarProps + , overlay + , overlay' , progressBar , progressBar' - ) as Exports -import AGS.Widget.Revealer - ( GtkRevealerTransitionType - , RevealerProps - , UpdateRevealerProps + , propsToValueOrBindings , revealer , revealer' - , transitions - ) as Exports -import AGS.Widget.Scrollable - ( ScrollableProps - , UpdateScrollableProps , scrollable , scrollable' - ) as Exports -import AGS.Widget.Slider - ( Mark - , MarkPosition - , SliderProps - , UpdateSliderProps - , markPositionBottom - , markPositionLeft - , markPositionRight - , markPositionTop , slider , slider' + , stack + , stack' + , toValueOrBinding + , withUpdates ) as Exports -import AGS.Widget.Stack (StackProps, stack, stack') as Exports import AGS.Widget.Window (Window, WindowProps, window) as Exports import Effect (Effect) import Effect.Uncurried diff --git a/src/AGS/Widget/Box.js b/src/AGS/Widget/Box.js deleted file mode 100644 index 3751711..0000000 --- a/src/AGS/Widget/Box.js +++ /dev/null @@ -1,3 +0,0 @@ -export const boxImpl = - props => Widget.Box(props) - diff --git a/src/AGS/Widget/Box.purs b/src/AGS/Widget/Box.purs deleted file mode 100644 index 541ee2d..0000000 --- a/src/AGS/Widget/Box.purs +++ /dev/null @@ -1,54 +0,0 @@ -module AGS.Widget.Box - ( BoxProps - , UpdateBoxProps - , box - , box' - ) where - -import Prelude - -import AGS.Binding (ValueOrBinding) -import AGS.Widget.Internal - ( AGSWidgetProps - , unsafeWidgetUpdate - ) -import Data.Tuple.Nested (type (/\), (/\)) -import Effect (Effect) -import Gtk.Box (GtkBoxProps) -import Gtk.Container (GtkContainerProps) -import Gtk.Orientable (GtkOrientableProps) -import Gtk.Widget (Widget) -import Prim.Row (class Union) -import Type.Row (type (+)) -import Unsafe.Coerce (unsafeCoerce) - -type BoxProps r = - AGSWidgetProps - + GtkContainerProps - + GtkOrientableProps - + GtkBoxProps - + - ( vertical ∷ Boolean - , children ∷ ValueOrBinding (Array Widget) - | r - ) - -box ∷ ∀ r r'. Union r r' (BoxProps ()) ⇒ Record r → Widget -box = boxImpl <<< unsafeCoerce - -foreign import boxImpl ∷ Record (BoxProps ()) → Widget - -type UpdateBoxProps = Record (BoxProps ()) → Record (BoxProps ()) - -box' - ∷ ∀ r r' - . Union r r' (BoxProps ()) - ⇒ Record r - → Widget /\ (UpdateBoxProps → Effect Unit) -box' props = - let - widget = box props - update = unsafeWidgetUpdate @(BoxProps ()) widget - in - widget /\ update - diff --git a/src/AGS/Widget/Button.js b/src/AGS/Widget/Button.js deleted file mode 100644 index 1102c18..0000000 --- a/src/AGS/Widget/Button.js +++ /dev/null @@ -1,3 +0,0 @@ -export const buttonImpl = - props => Widget.Button(props) - diff --git a/src/AGS/Widget/Button.purs b/src/AGS/Widget/Button.purs deleted file mode 100644 index cd12c49..0000000 --- a/src/AGS/Widget/Button.purs +++ /dev/null @@ -1,59 +0,0 @@ -module AGS.Widget.Button - ( ButtonProps - , UpdateButtonProps - , button - , button' - ) where - -import Prelude - -import AGS.Binding (ValueOrBinding) -import AGS.Widget.Internal (AGSWidgetProps, unsafeWidgetUpdate) -import Data.Tuple.Nested (type (/\), (/\)) -import Effect (Effect) -import Gtk.Button (GtkButtonProps) -import Gtk.Container (GtkContainerProps) -import Gtk.Widget (Widget) -import Prim.Row (class Union) -import Type.Row (type (+)) -import Unsafe.Coerce (unsafeCoerce) - -type ButtonProps r = - AGSWidgetProps - + GtkContainerProps - + GtkButtonProps - + - ( child ∷ ValueOrBinding Widget - , onClicked ∷ Effect Unit - , onPrimaryClick ∷ Effect Unit - , onSecondaryClick ∷ Effect Unit - , onMiddleClick ∷ Effect Unit - , onPrimaryClickRelease ∷ Effect Unit - , onSecondaryClickRelease ∷ Effect Unit - , onMiddleClickRelease ∷ Effect Unit - , onHover ∷ Effect Unit - , onHoverLost ∷ Effect Unit - , onScrollUp ∷ Effect Unit - , onScrollDown ∷ Effect Unit - | r - ) - -button ∷ ∀ r r'. Union r r' (ButtonProps ()) ⇒ Record r → Widget -button = buttonImpl <<< unsafeCoerce - -foreign import buttonImpl ∷ Record (ButtonProps ()) → Widget - -type UpdateButtonProps = Record (ButtonProps ()) → Record (ButtonProps ()) - -button' - ∷ ∀ r r' - . Union r r' (ButtonProps ()) - ⇒ Record r - → Widget /\ (UpdateButtonProps → Effect Unit) -button' props = - let - widget = button props - update = unsafeWidgetUpdate @(ButtonProps ()) widget - in - widget /\ update - diff --git a/src/AGS/Widget/CenterBox.js b/src/AGS/Widget/CenterBox.js deleted file mode 100644 index 2c6a75f..0000000 --- a/src/AGS/Widget/CenterBox.js +++ /dev/null @@ -1 +0,0 @@ -export const centerBoxImpl = Widget.CenterBox diff --git a/src/AGS/Widget/CenterBox.purs b/src/AGS/Widget/CenterBox.purs deleted file mode 100644 index e2aa72f..0000000 --- a/src/AGS/Widget/CenterBox.purs +++ /dev/null @@ -1,50 +0,0 @@ -module AGS.Widget.CenterBox - ( CenterBoxProps - , UpdateCenterBoxProps - , centerBox - , centerBox' - ) where - -import Prelude - -import AGS.Binding (ValueOrBinding) -import AGS.Widget.Box (BoxProps) -import AGS.Widget.Internal (unsafeWidgetUpdate) -import Data.Tuple.Nested (type (/\), (/\)) -import Effect (Effect) -import Gtk.Widget (Widget) -import Prim.Row (class Union) -import Unsafe.Coerce (unsafeCoerce) - -type CenterBoxProps r = - BoxProps - ( startWidget ∷ ValueOrBinding Widget - , centerWidget ∷ ValueOrBinding Widget - , endWidget ∷ ValueOrBinding Widget - | r - ) - -centerBox - ∷ ∀ r r' - . Union r r' (CenterBoxProps ()) - ⇒ Record r - → Widget -centerBox = centerBoxImpl <<< unsafeCoerce - -foreign import centerBoxImpl ∷ Record (CenterBoxProps ()) → Widget - -type UpdateCenterBoxProps = - Record (CenterBoxProps ()) → Record (CenterBoxProps ()) - -centerBox' - ∷ ∀ r r' - . Union r r' (CenterBoxProps ()) - ⇒ Record r - → Widget /\ (UpdateCenterBoxProps → Effect Unit) -centerBox' props = - let - widget = centerBox props - update = unsafeWidgetUpdate @(CenterBoxProps ()) widget - in - widget /\ update - diff --git a/src/AGS/Widget/CircularProgress.js b/src/AGS/Widget/CircularProgress.js deleted file mode 100644 index 1f22722..0000000 --- a/src/AGS/Widget/CircularProgress.js +++ /dev/null @@ -1,4 +0,0 @@ -export const circularProgressImpl = - props => - Widget.CircularProgress(props) - diff --git a/src/AGS/Widget/CircularProgress.purs b/src/AGS/Widget/CircularProgress.purs deleted file mode 100644 index e3542f2..0000000 --- a/src/AGS/Widget/CircularProgress.purs +++ /dev/null @@ -1,51 +0,0 @@ -module AGS.Widget.CircularProgress - ( CircularProgressProps - , UpdateCircularProgressProps - , circularProgress - , circularProgress' - ) where - -import Prelude - -import AGS.Widget.Internal (AGSWidgetProps, unsafeWidgetUpdate) -import Data.Tuple.Nested (type (/\), (/\)) -import Effect (Effect) -import Gtk.Container (GtkContainerProps) -import Gtk.Widget (Widget) -import Prim.Row (class Union) -import Type.Row (type (+)) -import Unsafe.Coerce (unsafeCoerce) - -type CircularProgressProps r = - AGSWidgetProps - + GtkContainerProps - + - ( startAt ∷ Number - , endAt ∷ Number - , inverted ∷ Boolean - , rounded ∷ Boolean - , value ∷ Number - | r - ) - -circularProgress - ∷ ∀ r r'. Union r r' (CircularProgressProps ()) ⇒ Record r → Widget -circularProgress = circularProgressImpl <<< unsafeCoerce - -foreign import circularProgressImpl ∷ Record (CircularProgressProps ()) → Widget - -type UpdateCircularProgressProps = - Record (CircularProgressProps ()) → Record (CircularProgressProps ()) - -circularProgress' - ∷ ∀ r r' - . Union r r' (CircularProgressProps ()) - ⇒ Record r - → Widget /\ (UpdateCircularProgressProps → Effect Unit) -circularProgress' props = - let - widget = circularProgress props - update = unsafeWidgetUpdate @(CircularProgressProps ()) widget - in - widget /\ update - diff --git a/src/AGS/Widget/Entry.js b/src/AGS/Widget/Entry.js deleted file mode 100644 index 4553309..0000000 --- a/src/AGS/Widget/Entry.js +++ /dev/null @@ -1,4 +0,0 @@ -export const entryImpl = - props => - Widget.Entry(props) - diff --git a/src/AGS/Widget/Entry.purs b/src/AGS/Widget/Entry.purs deleted file mode 100644 index 365a5fe..0000000 --- a/src/AGS/Widget/Entry.purs +++ /dev/null @@ -1,47 +0,0 @@ -module AGS.Widget.Entry - ( EntryProps - , UpdateEntryProps - , entry - , entry' - ) where - -import Prelude - -import AGS.Widget.Internal (AGSWidgetProps, unsafeWidgetUpdate) -import Data.Tuple.Nested (type (/\), (/\)) -import Effect (Effect) -import Effect.Uncurried (EffectFn1) -import Gtk.Entry (GtkEntryProps) -import Gtk.Widget (Widget) -import Prim.Row (class Union) -import Type.Row (type (+)) -import Unsafe.Coerce (unsafeCoerce) - -type EntryProps r = - AGSWidgetProps - + GtkEntryProps - + - ( onChange ∷ EffectFn1 Widget Unit - , onAccept ∷ EffectFn1 Widget Unit - | r - ) - -entry ∷ ∀ r r'. Union r r' (EntryProps ()) ⇒ Record r → Widget -entry = entryImpl <<< unsafeCoerce - -foreign import entryImpl ∷ Record (EntryProps ()) → Widget - -type UpdateEntryProps = Record (EntryProps ()) → Record (EntryProps ()) - -entry' - ∷ ∀ r r' - . Union r r' (EntryProps ()) - ⇒ Record r - → Widget /\ (UpdateEntryProps → Effect Unit) -entry' props = - let - widget = entry props - update = unsafeWidgetUpdate @(EntryProps ()) widget - in - widget /\ update - diff --git a/src/AGS/Widget/EventBox.js b/src/AGS/Widget/EventBox.js deleted file mode 100644 index 0591928..0000000 --- a/src/AGS/Widget/EventBox.js +++ /dev/null @@ -1,3 +0,0 @@ -export const eventBoxImpl = - props => Widget.EventBox(props) - diff --git a/src/AGS/Widget/EventBox.purs b/src/AGS/Widget/EventBox.purs deleted file mode 100644 index b6e9b59..0000000 --- a/src/AGS/Widget/EventBox.purs +++ /dev/null @@ -1,58 +0,0 @@ -module AGS.Widget.EventBox - ( EventBoxProps - , UpdateEventBoxProps - , eventBox - , eventBox' - ) where - -import Prelude - -import AGS.Widget.Internal (AGSWidgetProps, unsafeWidgetUpdate) -import Data.Tuple.Nested (type (/\), (/\)) -import Effect (Effect) -import Gtk.Container (GtkContainerProps) -import Gtk.Widget (Widget) -import Prim.Row (class Union) -import Type.Row (type (+)) -import Unsafe.Coerce (unsafeCoerce) - -type EventBoxProps r = - AGSWidgetProps - + GtkContainerProps - + - ( onPrimaryClick ∷ Effect Unit - , onSecondaryClick ∷ Effect Unit - , onMiddleClick ∷ Effect Unit - , onPrimaryClickRelease ∷ Effect Unit - , onSecondaryClickRelease ∷ Effect Unit - , onMiddleClickRelease ∷ Effect Unit - , onHover ∷ Effect Unit - , onHoverLost ∷ Effect Unit - , onScrollUp ∷ Effect Unit - , onScrollDown ∷ Effect Unit - | r - ) - -eventBox - ∷ ∀ r r' - . Union r r' (EventBoxProps ()) - ⇒ Record r - → Widget -eventBox = eventBoxImpl <<< unsafeCoerce - -foreign import eventBoxImpl ∷ Record (EventBoxProps ()) → Widget - -type UpdateEventBoxProps = Record (EventBoxProps ()) → Record (EventBoxProps ()) - -eventBox' - ∷ ∀ r r' - . Union r r' (EventBoxProps ()) - ⇒ Record r - → Widget /\ (UpdateEventBoxProps → Effect Unit) -eventBox' props = - let - widget = eventBox props - update = unsafeWidgetUpdate @(EventBoxProps ()) widget - in - widget /\ update - diff --git a/src/AGS/Widget/Icon.js b/src/AGS/Widget/Icon.js deleted file mode 100644 index f5112b8..0000000 --- a/src/AGS/Widget/Icon.js +++ /dev/null @@ -1,3 +0,0 @@ -export const iconImpl = - props => - Widget.Icon(props) diff --git a/src/AGS/Widget/Icon.purs b/src/AGS/Widget/Icon.purs deleted file mode 100644 index 48bf408..0000000 --- a/src/AGS/Widget/Icon.purs +++ /dev/null @@ -1,48 +0,0 @@ -module AGS.Widget.Icon - ( IconProps - , UpdateIconProps - , icon - , icon' - ) where - -import Prelude - -import AGS.Widget.Internal (AGSWidgetProps, unsafeWidgetUpdate) -import Data.Tuple.Nested (type (/\), (/\)) -import Effect (Effect) -import Gtk.Image (GtkImageProps) -import Gtk.Misc (GtkMiscProps) -import Gtk.Widget (Widget) -import Prim.Row (class Union) -import Type.Row (type (+)) -import Unsafe.Coerce (unsafeCoerce) - -type IconProps r = - AGSWidgetProps - + GtkMiscProps - + GtkImageProps - + - ( icon ∷ String - , size ∷ Number - | r - ) - -icon ∷ ∀ r r'. Union r r' (IconProps ()) ⇒ Record r → Widget -icon = iconImpl <<< unsafeCoerce - -foreign import iconImpl ∷ Record (IconProps ()) → Widget - -type UpdateIconProps = Record (IconProps ()) → Record (IconProps ()) - -icon' - ∷ ∀ r r' - . Union r r' (IconProps ()) - ⇒ Record r - → Widget /\ (UpdateIconProps → Effect Unit) -icon' props = - let - widget = icon props - update = unsafeWidgetUpdate @(IconProps ()) widget - in - widget /\ update - diff --git a/src/AGS/Widget/Internal.js b/src/AGS/Widget/Internal.js index 25cceb9..b3eb8be 100644 --- a/src/AGS/Widget/Internal.js +++ b/src/AGS/Widget/Internal.js @@ -1,3 +1,5 @@ +import { Binding } from 'resource:///com/github/Aylur/ags/service.js' + export const unsafeGetwidgetPropsImpl = ks => widget => Object.fromEntries(ks.map(k => [k, widget[k]])) @@ -9,3 +11,26 @@ export const unsafeUpdateWidgetProps = widget[k] = v }) +export const isBinding = + v => + v instanceof Binding + +// Widgets + +export const boxImpl = Widget.Box +export const buttonImpl = Widget.Button +export const centerBoxImpl = Widget.CenterBox +export const circularProgressImpl = Widget.CircularProgress +export const entryImpl = Widget.Entry +export const eventBoxImpl = Widget.EventBox +export const iconImpl = Widget.Icon +export const labelImpl = Widget.Label +export const menuImpl = Widget.Menu +export const menuItemImpl = Widget.MenuItem +export const overlayImpl = Widget.Overlay +export const progressBarImpl = Widget.ProgressBar +export const revealerImpl = Widget.Revealer +export const scrollableImpl = Widget.Scrollable +export const sliderImpl = Widget.Slider +export const stackImpl = Widget.Stack + diff --git a/src/AGS/Widget/Internal.purs b/src/AGS/Widget/Internal.purs index 45c23b4..90962fe 100644 --- a/src/AGS/Widget/Internal.purs +++ b/src/AGS/Widget/Internal.purs @@ -1,21 +1,112 @@ module AGS.Widget.Internal - ( AGSWidgetProps + ( -- Widget utils + AGSWidgetProps , AnyF , Any , mkAny - , unsafeWidgetUpdate + , propsToValueOrBindings + , ToValueOrBinding + , class ToValueOrBindingC + , toValueOrBinding + , MkWidget + , MkWidgetWithUpdates + , withUpdates + + -- Widgets + , box + , box' + , BoxProps + , button + , button' + , ButtonProps + , centerBox + , centerBox' + , CenterBoxProps + , circularProgress + , circularProgress' + , CircularProgressProps + , entry + , entry' + , EntryProps + , eventBox + , eventBox' + , EventBoxProps + , icon + , icon' + , IconProps + , label + , label' + , LabelProps + , menu + , menu' + , MenuProps + , menuItem + , menuItem' + , MenuItemProps + , overlay + , overlay' + , OverlayProps + , progressBar + , progressBar' + , ProgressBarProps + , revealer + , revealer' + , RevealerProps + , scrollable + , scrollable' + , ScrollableProps + , slider + , slider' + , SliderProps + , Mark + , MarkPosition + , markPositionTop + , markPositionLeft + , markPositionRight + , markPositionBottom + , stack + , stack' + , StackProps ) where import Prelude -import AGS.Binding (ValueOrBinding) +import AGS.Binding (Binding, ValueOrBinding) import Data.Exists (Exists, mkExists) +import Data.Maybe (Maybe, maybe) +import Data.Tuple.Nested (type (/\), (/\)) import Effect (Effect) -import Effect.Uncurried (EffectFn1) +import Effect.Uncurried (EffectFn1, mkEffectFn1) +import Foreign.Object (Object) +import Gtk.Actionable (GtkActionableProps) +import Gtk.Activatable (GtkActivatableProps) +import Gtk.Box (GtkBoxProps) +import Gtk.Button (GtkButtonProps) +import Gtk.Container (GtkContainerProps) +import Gtk.Entry (GtkEntryProps) +import Gtk.Image (GtkImageProps) +import Gtk.Label (GtkLabelProps) +import Gtk.Menu (GtkMenuProps) +import Gtk.MenuItem (GtkMenuItemProps) +import Gtk.MenuShell (GtkMenuShellProps) +import Gtk.Misc (GtkMiscProps) +import Gtk.Orientable (GtkOrientableProps) +import Gtk.ProgressBar (GtkProgressBarProps) +import Gtk.Range (GtkRangeProps) +import Gtk.Revealer (GtkRevealerProps) +import Gtk.Scale (GtkScaleProps) +import Gtk.ScrollType (GtkScrollType) +import Gtk.ScrolledWindow (GtkScrolledWindowProps) +import Gtk.Stack (GtkStackProps) import Gtk.Widget (GtkWidgetProps, Widget) +import Heterogeneous.Mapping (class HMap, class Mapping, hmap) +import Prim.Row (class Union) import Record.Studio.Keys (class Keys, keys) +import Record.Unsafe as RU import Type.Proxy (Proxy(..)) import Type.Row (type (+)) +import Unsafe.Coerce (unsafeCoerce) +import Untagged.Union (asOneOf) type AGSWidgetProps r = GtkWidgetProps @@ -23,11 +114,11 @@ type AGSWidgetProps r = ( setup ∷ EffectFn1 Widget Unit , className ∷ ValueOrBinding String , classNames ∷ Array String - , css ∷ String - , hpack ∷ String {- TODO make it a proper type -} - , vpack ∷ String {- TODO make it a proper type -} - , cursor ∷ String {- TODO make it a proper type -} - , attribute ∷ Any + , css ∷ ValueOrBinding String + , hpack ∷ ValueOrBinding String {- TODO make it a proper type -} + , vpack ∷ ValueOrBinding String {- TODO make it a proper type -} + , cursor ∷ ValueOrBinding String {- TODO make it a proper type -} + , attribute ∷ ValueOrBinding Any | r ) @@ -35,11 +126,81 @@ newtype AnyF a = AnyF a type Any = Exists AnyF --- TODO move out of the internal module mkAny ∷ ∀ a. a → Any mkAny = mkExists <<< AnyF --- * Utils for widgets updates +-- *** Utils for widget construction + +class ToValueOrBindingC a b | a → b where + toValueOrBinding ∷ a → ValueOrBinding b + +instance ToValueOrBindingC (Binding a) a where + toValueOrBinding = asOneOf + +else instance ToValueOrBindingC a a where + toValueOrBinding = asOneOf + +instance + ToValueOrBindingC a b ⇒ + Mapping ToValueOrBinding a (ValueOrBinding b) where + mapping _ = toValueOrBinding + +-- Helper datatype for HMap +data ToValueOrBinding = ToValueOrBinding + +-- Map any record with `toValueOrBinding` as long as the resultant row type `rout` is in union with `@props`. +-- Every field of `@props` needs to be of type `ValueOrBinding _`. +propsToValueOrBindings + ∷ ∀ _rt rin rout @props + . HMap ToValueOrBinding (Record rin) (Record rout) + ⇒ Union rout _rt props + ⇒ Record rin + → Record rout +propsToValueOrBindings = hmap ToValueOrBinding + +-- | Alias for a function creating a widget out of a record with any number of this widget's props. +-- | Types of the record's fields have to align with the `props` row such that for every `ValueOrBinding a` +-- | in the `props` row, every input record's field has to be either `a` or `Binding a`. +type MkWidget props = + ( ∀ _rt _rin _rout + . HMap ToValueOrBinding (Record _rin) (Record _rout) + ⇒ Union _rout _rt props + ⇒ Record _rin + → Widget + ) + +-- | Same as `MkWidget`, but with an update function, which accepts a function `{ | props } → { | props }` +-- | and returns `Effect Unit`. +type MkWidgetWithUpdates props = + ( ∀ _rt _rin _rout + . HMap ToValueOrBinding (Record _rin) (Record _rout) + ⇒ Union _rout _rt props + ⇒ Record _rin + → Widget /\ ((Record props → Record props) → Effect Unit) + ) + +-- | Construct a widget with a function which, when applied to a function +-- | from widget properties to widget properties, would update that widget. +-- | +-- | ```purescript +-- | do +-- | let box /\ updateBox = Widget.withUpdates Widget.box {} +-- | updateBox (\w -> w { css = w.css <> " color: red;" }) +-- | pure box +-- | ``` +-- | +-- | Note: type inference may be weak here, use visible type application to aid the compiler. +-- | For example `withUpdates @(LabelProps ()) label { label: "my label" }` +withUpdates ∷ ∀ @props. Keys props ⇒ MkWidget props → MkWidgetWithUpdates props +withUpdates ctor props = widget /\ update + + where + widget = ctor props + update = unsafeWidgetUpdate @props widget + +foreign import isBinding ∷ ∀ a. a → Boolean + +-- *** Utils for widgets updates unsafeWidgetUpdate ∷ ∀ @r @@ -59,3 +220,407 @@ unsafeGetWidgetProps = unsafeGetwidgetPropsImpl (keys (Proxy @r)) foreign import unsafeGetwidgetPropsImpl ∷ ∀ r. Array String → Widget → Record r foreign import unsafeUpdateWidgetProps ∷ ∀ r. Record r → Widget → Effect Unit +-- *** Widgets + +foreign import boxImpl ∷ Record (BoxProps ()) → Widget +foreign import buttonImpl ∷ Record (ButtonProps ()) → Widget +foreign import centerBoxImpl ∷ Record (CenterBoxProps ()) → Widget +foreign import circularProgressImpl ∷ Record (CircularProgressProps ()) → Widget +foreign import entryImpl ∷ Record (EntryProps ()) → Widget +foreign import eventBoxImpl ∷ Record (EventBoxProps ()) → Widget +foreign import iconImpl ∷ Record (IconProps ()) → Widget +foreign import labelImpl ∷ Record (LabelProps ()) → Widget +foreign import menuImpl ∷ Record (MenuProps ()) → Widget +foreign import menuItemImpl ∷ Record (MenuItemProps ()) → Widget +foreign import overlayImpl ∷ Record (OverlayProps ()) → Widget +foreign import progressBarImpl ∷ Record (ProgressBarProps ()) → Widget +foreign import revealerImpl ∷ Record (RevealerProps ()) → Widget +foreign import scrollableImpl ∷ Record (ScrollableProps ()) → Widget +foreign import sliderImpl ∷ Record (SliderProps ()) → Widget +foreign import stackImpl ∷ Record (StackProps ()) → Widget + +-- * Box + +type BoxProps r = + AGSWidgetProps + + GtkContainerProps + + GtkOrientableProps + + GtkBoxProps + + + ( vertical ∷ ValueOrBinding Boolean + , children ∷ ValueOrBinding (Array Widget) + | r + ) + +box ∷ MkWidget (BoxProps ()) +box = boxImpl <<< unsafeCoerce <<< propsToValueOrBindings @(BoxProps ()) + +box' ∷ MkWidgetWithUpdates (BoxProps ()) +box' = withUpdates box + +-- * Button + +type ButtonProps r = + AGSWidgetProps + + GtkContainerProps + + GtkButtonProps + + + ( child ∷ ValueOrBinding Widget + , onClicked ∷ ValueOrBinding (Effect Unit) + , onPrimaryClick ∷ ValueOrBinding (Effect Unit) + , onSecondaryClick ∷ ValueOrBinding (Effect Unit) + , onMiddleClick ∷ ValueOrBinding (Effect Unit) + , onPrimaryClickRelease ∷ ValueOrBinding (Effect Unit) + , onSecondaryClickRelease ∷ ValueOrBinding (Effect Unit) + , onMiddleClickRelease ∷ ValueOrBinding (Effect Unit) + , onHover ∷ ValueOrBinding (Effect Unit) + , onHoverLost ∷ ValueOrBinding (Effect Unit) + , onScrollUp ∷ ValueOrBinding (Effect Unit) + , onScrollDown ∷ ValueOrBinding (Effect Unit) + | r + ) + +button ∷ MkWidget (ButtonProps ()) +button = buttonImpl + <<< unsafeCoerce + <<< propsToValueOrBindings @(ButtonProps ()) + +button' ∷ MkWidgetWithUpdates (ButtonProps ()) +button' = withUpdates button + +-- * CenterBox + +type CenterBoxProps r = + BoxProps + ( startWidget ∷ ValueOrBinding Widget + , centerWidget ∷ ValueOrBinding Widget + , endWidget ∷ ValueOrBinding Widget + | r + ) + +centerBox ∷ MkWidget (CenterBoxProps ()) +centerBox = centerBoxImpl + <<< unsafeCoerce + <<< propsToValueOrBindings @(CenterBoxProps ()) + +centerBox' ∷ MkWidgetWithUpdates (CenterBoxProps ()) +centerBox' = withUpdates centerBox + +-- * CircularProgress + +type CircularProgressProps r = + AGSWidgetProps + + GtkContainerProps + + + ( startAt ∷ ValueOrBinding Number + , endAt ∷ ValueOrBinding Number + , inverted ∷ ValueOrBinding Boolean + , rounded ∷ ValueOrBinding Boolean + , value ∷ ValueOrBinding Number + | r + ) + +circularProgress ∷ MkWidget (CircularProgressProps ()) +circularProgress = circularProgressImpl + <<< unsafeCoerce + <<< propsToValueOrBindings @(CircularProgressProps ()) + +circularProgress' ∷ MkWidgetWithUpdates (CircularProgressProps ()) +circularProgress' = withUpdates circularProgress + +-- * Entry + +type EntryProps r = + AGSWidgetProps + + GtkEntryProps + + + ( onChange ∷ ValueOrBinding (EffectFn1 Widget Unit) + , onAccept ∷ ValueOrBinding (EffectFn1 Widget Unit) + | r + ) + +entry ∷ MkWidget (EntryProps ()) +entry = entryImpl <<< unsafeCoerce <<< propsToValueOrBindings @(EntryProps ()) + +entry' ∷ MkWidgetWithUpdates (EntryProps ()) +entry' = withUpdates entry + +-- * EventBox + +type EventBoxProps r = + AGSWidgetProps + + GtkContainerProps + + + ( onPrimaryClick ∷ ValueOrBinding (Effect Unit) + , onSecondaryClick ∷ ValueOrBinding (Effect Unit) + , onMiddleClick ∷ ValueOrBinding (Effect Unit) + , onPrimaryClickRelease ∷ ValueOrBinding (Effect Unit) + , onSecondaryClickRelease ∷ ValueOrBinding (Effect Unit) + , onMiddleClickRelease ∷ ValueOrBinding (Effect Unit) + , onHover ∷ ValueOrBinding (Effect Unit) + , onHoverLost ∷ ValueOrBinding (Effect Unit) + , onScrollUp ∷ ValueOrBinding (Effect Unit) + , onScrollDown ∷ ValueOrBinding (Effect Unit) + | r + ) + +eventBox ∷ MkWidget (EventBoxProps ()) +eventBox = eventBoxImpl + <<< unsafeCoerce + <<< propsToValueOrBindings @(EventBoxProps ()) + +eventBox' ∷ MkWidgetWithUpdates (EventBoxProps ()) +eventBox' = withUpdates eventBox + +-- * Icon + +type IconProps r = + AGSWidgetProps + + GtkMiscProps + + GtkImageProps + + + ( icon ∷ ValueOrBinding String + , size ∷ ValueOrBinding Number + | r + ) + +icon ∷ MkWidget (IconProps ()) +icon = iconImpl <<< unsafeCoerce <<< propsToValueOrBindings @(IconProps ()) + +icon' ∷ MkWidgetWithUpdates (IconProps ()) +icon' = withUpdates icon + +-- * Label + +type LabelProps r = + AGSWidgetProps + + GtkLabelProps + + + ( justification ∷ ValueOrBinding String {- TODO make it a proper type -} + , truncate ∷ ValueOrBinding String {- TODO make it a proper type -} + | r + ) + +label ∷ MkWidget (LabelProps ()) +label = labelImpl <<< unsafeCoerce <<< propsToValueOrBindings @(LabelProps ()) + +label' ∷ MkWidgetWithUpdates (LabelProps ()) +label' = withUpdates label + +-- * Menu + +type MenuProps r = + AGSWidgetProps + + GtkContainerProps + + GtkMenuProps Widget + + GtkMenuShellProps + + + ( children ∷ ValueOrBinding (Array Widget) + , onPopup ∷ ValueOrBinding (Effect Unit) + , onMoveScroll ∷ ValueOrBinding (EffectFn1 GtkScrollType Unit) + | r + ) + +menu ∷ MkWidget (MenuProps ()) +menu = menuImpl <<< unsafeCoerce <<< propsToValueOrBindings @(MenuProps ()) + +menu' ∷ MkWidgetWithUpdates (MenuProps ()) +menu' = withUpdates menu + +-- * MenuItem + +type MenuItemProps r = + AGSWidgetProps + + GtkActionableProps + + GtkActivatableProps + + GtkContainerProps + -- should be somehow constrained to `Menu` rather than all widgets + + GtkMenuItemProps Widget + + + ( child ∷ ValueOrBinding Widget + , onActivate ∷ ValueOrBinding (Effect Boolean) + , onSelect ∷ ValueOrBinding (Effect Boolean) + , onDeselect ∷ ValueOrBinding (Effect Boolean) + | r + ) + +menuItem ∷ MkWidget (MenuItemProps ()) +menuItem = menuItemImpl + <<< unsafeCoerce + <<< propsToValueOrBindings @(MenuItemProps ()) + +menuItem' ∷ MkWidgetWithUpdates (MenuItemProps ()) +menuItem' = withUpdates menuItem + +-- * Overlay + +type OverlayProps r = + AGSWidgetProps + + + ( child ∷ ValueOrBinding Widget + , overlays ∷ ValueOrBinding (Array Widget) + , passThrough ∷ ValueOrBinding Boolean + | r + ) + +overlay ∷ MkWidget (OverlayProps ()) +overlay = overlayImpl + <<< unsafeCoerce + <<< propsToValueOrBindings @(OverlayProps ()) + +overlay' ∷ MkWidgetWithUpdates (OverlayProps ()) +overlay' = withUpdates overlay + +-- * ProgressBar + +type ProgressBarProps r = + AGSWidgetProps + + GtkOrientableProps + + GtkProgressBarProps + + + ( vertical ∷ ValueOrBinding Boolean + , value ∷ ValueOrBinding Number + | r + ) + +progressBar ∷ MkWidget (ProgressBarProps ()) +progressBar = progressBarImpl + <<< unsafeCoerce + <<< propsToValueOrBindings @(ProgressBarProps ()) + +progressBar' ∷ MkWidgetWithUpdates (ProgressBarProps ()) +progressBar' = withUpdates progressBar + +-- * Revealer + +type RevealerProps r = + AGSWidgetProps + + GtkContainerProps + + GtkRevealerProps + + r + +revealer ∷ MkWidget (RevealerProps ()) +revealer = revealerImpl <<< unsafeCoerce + +revealer' ∷ MkWidgetWithUpdates (RevealerProps ()) +revealer' = withUpdates revealer + +-- * Scrollable + +type ScrollableProps r = + AGSWidgetProps + + GtkScrolledWindowProps + + GtkContainerProps + + + ( hscroll ∷ ValueOrBinding String {- TODO make it a proper type -} + , vscroll ∷ ValueOrBinding String {- TODO make it a proper type -} + | r + ) + +scrollable ∷ MkWidget (ScrollableProps ()) +scrollable = scrollableImpl + <<< unsafeCoerce + <<< propsToValueOrBindings @(ScrollableProps ()) + +scrollable' ∷ MkWidgetWithUpdates (ScrollableProps ()) +scrollable' = withUpdates scrollable + +-- * Slider + +foreign import data MarkPosition ∷ Type + +markPositionTop = unsafeCoerce "top" ∷ MarkPosition +markPositionLeft = unsafeCoerce "left" ∷ MarkPosition +markPositionRight = unsafeCoerce "right" ∷ MarkPosition +markPositionBottom = unsafeCoerce "bottom" ∷ MarkPosition + +type Mark = + { at ∷ Number + , label ∷ Maybe String + , position ∷ Maybe MarkPosition + } + +type SliderProps r = + AGSWidgetProps + + GtkOrientableProps + + GtkScaleProps + + GtkRangeProps + + + ( vertical ∷ ValueOrBinding Boolean + , value ∷ ValueOrBinding Number + , min ∷ ValueOrBinding Number + , max ∷ ValueOrBinding Number + , marks ∷ ValueOrBinding (Array Mark) + , onChange ∷ ValueOrBinding (Number → Effect Unit) + | r + ) + +slider ∷ MkWidget (SliderProps ()) +slider = sliderImpl + <<< unsafeCoerce + <<< propsToValueOrBindings @(SliderProps ()) + <<< prepare + + where + prepare r = + r + # + ( if RU.unsafeHas "marks" r then + RU.unsafeSet "marks" + (prepareMarks $ RU.unsafeGet "marks" r) + else + identity + ) + # + ( if RU.unsafeHas "onChange" r then + RU.unsafeSet "onChange" + (prepareOnChangeCb $ RU.unsafeGet "onChange" r) + else + identity + ) + + prepareOnChangeCb + ∷ (Number → Effect Unit) {- or Binding -} + → EffectFn1 { value ∷ Number } Unit {- or Binding -} + prepareOnChangeCb fn = + if isBinding fn then + unsafeCoerce $ map (\f → mkEffectFn1 \{ value } → f value) + (unsafeCoerce fn ∷ Binding (Number → Effect Unit)) + else + mkEffectFn1 \{ value } → fn value + + prepareMarks + ∷ Array Mark {- or Binding (Array Mark) -} + → Array (Array Number) {- or Binding (Array (Array Number)) -} + prepareMarks ms = + if isBinding ms then + unsafeCoerce $ map (map prepareMark) + (unsafeCoerce ms ∷ Binding (Array Mark)) + else + map prepareMark ms + + prepareMark ∷ Mark → Array (Number {- or String -} ) + prepareMark { at, label: markLabel, position } = + [ at ] <> maybe [] unsafeCoerce markLabel <> maybe [] unsafeCoerce position + +slider' ∷ MkWidgetWithUpdates (SliderProps ()) +slider' = withUpdates slider + +-- * Stack + +type StackProps r = + AGSWidgetProps + + GtkContainerProps + + GtkStackProps Widget + + + ( children ∷ ValueOrBinding (Object Widget) + , shown ∷ ValueOrBinding String + | r + ) + +stack ∷ MkWidget (StackProps ()) +stack = stackImpl <<< unsafeCoerce <<< propsToValueOrBindings @(StackProps ()) + +stack' ∷ MkWidgetWithUpdates (StackProps ()) +stack' = withUpdates stack + diff --git a/src/AGS/Widget/Label.js b/src/AGS/Widget/Label.js deleted file mode 100644 index de45771..0000000 --- a/src/AGS/Widget/Label.js +++ /dev/null @@ -1,3 +0,0 @@ - -export const labelImpl = Widget.Label - diff --git a/src/AGS/Widget/Label.purs b/src/AGS/Widget/Label.purs deleted file mode 100644 index f5a85bf..0000000 --- a/src/AGS/Widget/Label.purs +++ /dev/null @@ -1,48 +0,0 @@ -module AGS.Widget.Label - ( LabelProps - , label - , label' - ) where - -import Prelude - -import AGS.Widget.Internal (AGSWidgetProps, unsafeWidgetUpdate) -import Data.Tuple.Nested (type (/\), (/\)) -import Effect (Effect) -import Gtk.Label (GtkLabelProps) -import Gtk.Widget (Widget) -import Prim.Row (class Union) -import Type.Row (type (+)) -import Unsafe.Coerce (unsafeCoerce) - -type LabelProps r = - AGSWidgetProps - + GtkLabelProps - + - ( justification ∷ String {- TODO make it a proper type -} - , truncate ∷ String {- TODO make it a proper type -} - | r - ) - -label ∷ ∀ r r'. Union r r' (LabelProps ()) ⇒ Record r → Widget -label = labelImpl <<< unsafeCoerce - -foreign import labelImpl - ∷ ∀ (r ∷ Row Type) - . Record r - → Widget - -type UpdateLabelProps = Record (LabelProps ()) → Record (LabelProps ()) - -label' - ∷ ∀ r r' - . Union r r' (LabelProps ()) - ⇒ Record r - → Widget /\ (UpdateLabelProps → Effect Unit) -label' props = - let - widget = label props - update = unsafeWidgetUpdate @(LabelProps ()) widget - in - widget /\ update - diff --git a/src/AGS/Widget/Menu.js b/src/AGS/Widget/Menu.js deleted file mode 100644 index e4dadd0..0000000 --- a/src/AGS/Widget/Menu.js +++ /dev/null @@ -1,4 +0,0 @@ -export const menuImpl = - props => - Widget.Menu(props) - diff --git a/src/AGS/Widget/Menu.purs b/src/AGS/Widget/Menu.purs deleted file mode 100644 index f0d5169..0000000 --- a/src/AGS/Widget/Menu.purs +++ /dev/null @@ -1,54 +0,0 @@ -module AGS.Widget.Menu - ( MenuProps - , UpdateMenuProps - , menu - , menu' - , module AGS.Widget.Menu.Item - ) where - -import AGS.Widget.Internal (AGSWidgetProps, unsafeWidgetUpdate) -import AGS.Widget.Menu.Item (MenuItem, MenuItemProps, menuItem, menuItemImpl) -import Data.Tuple.Nested (type (/\), (/\)) -import Effect (Effect) -import Effect.Uncurried (EffectFn1) -import Gtk.Container (GtkContainerProps) -import Gtk.Menu (GtkMenuProps) -import Gtk.MenuShell (GtkMenuShellProps) -import Gtk.ScrollType (GtkScrollType) -import Gtk.Widget (Widget) -import Prelude (Unit, (<<<)) -import Prim.Row (class Union) -import Type.Row (type (+)) -import Unsafe.Coerce (unsafeCoerce) - -type MenuProps r = - AGSWidgetProps - + GtkContainerProps - + GtkMenuProps Widget - + GtkMenuShellProps - + - ( children ∷ Array MenuItem - , onPopup ∷ Effect Unit - , onMoveScroll ∷ EffectFn1 GtkScrollType Unit - | r - ) - -menu ∷ ∀ r r'. Union r r' (MenuProps ()) ⇒ Record r → Widget -menu = menuImpl <<< unsafeCoerce - -foreign import menuImpl ∷ Record (MenuProps ()) → Widget - -type UpdateMenuProps = Record (MenuProps ()) → Record (MenuProps ()) - -menu' - ∷ ∀ r r' - . Union r r' (MenuProps ()) - ⇒ Record r - → Widget /\ (UpdateMenuProps → Effect Unit) -menu' props = - let - widget = menu props - update = unsafeWidgetUpdate @(MenuProps ()) widget - in - widget /\ update - diff --git a/src/AGS/Widget/Menu/Item.js b/src/AGS/Widget/Menu/Item.js deleted file mode 100644 index 07488a6..0000000 --- a/src/AGS/Widget/Menu/Item.js +++ /dev/null @@ -1,4 +0,0 @@ -export const menuItemImpl = - props => - Widget.MenuItem(props) - diff --git a/src/AGS/Widget/Menu/Item.purs b/src/AGS/Widget/Menu/Item.purs deleted file mode 100644 index 96ac25e..0000000 --- a/src/AGS/Widget/Menu/Item.purs +++ /dev/null @@ -1,36 +0,0 @@ -module AGS.Widget.Menu.Item where - -import AGS.Widget.Internal (AGSWidgetProps) -import Effect (Effect) -import Gtk.Actionable (GtkActionableProps) -import Gtk.Activatable (GtkActivatableProps) -import Gtk.Container (GtkContainerProps) -import Gtk.MenuItem (GtkMenuItemProps) -import Gtk.Widget (Widget) -import Prelude ((<<<)) -import Prim.Row (class Union) -import Type.Row (type (+)) -import Unsafe.Coerce (unsafeCoerce) - -foreign import data MenuItem ∷ Type - -type MenuItemProps r = - AGSWidgetProps - + GtkActionableProps - + GtkActivatableProps - + GtkContainerProps - -- should be somehow constrained to `Menu` rather than all widgets - + GtkMenuItemProps Widget - + - ( child ∷ Widget - , onActivate ∷ Effect Boolean - , onSelect ∷ Effect Boolean - , onDeselect ∷ Effect Boolean - | r - ) - -menuItem ∷ ∀ r r'. Union r r' (MenuItemProps ()) ⇒ Record r → MenuItem -menuItem = menuItemImpl <<< unsafeCoerce - -foreign import menuItemImpl ∷ Record (MenuItemProps ()) → MenuItem - diff --git a/src/AGS/Widget/Overlay.js b/src/AGS/Widget/Overlay.js deleted file mode 100644 index c3d3235..0000000 --- a/src/AGS/Widget/Overlay.js +++ /dev/null @@ -1,4 +0,0 @@ -export const overlayImpl = - props => - Widget.Overlay(props) - diff --git a/src/AGS/Widget/Overlay.purs b/src/AGS/Widget/Overlay.purs deleted file mode 100644 index 65e49cf..0000000 --- a/src/AGS/Widget/Overlay.purs +++ /dev/null @@ -1,45 +0,0 @@ -module AGS.Widget.Overlay - ( OverlayProps - , UpdateOverlayProps - , overlay - , overlay' - ) where - -import Prelude - -import AGS.Widget.Internal (AGSWidgetProps, unsafeWidgetUpdate) -import Data.Tuple.Nested (type (/\), (/\)) -import Effect (Effect) -import Gtk.Widget (Widget) -import Prim.Row (class Union) -import Type.Row (type (+)) -import Unsafe.Coerce (unsafeCoerce) - -type OverlayProps r = - AGSWidgetProps - + - ( child ∷ Widget - , overlays ∷ Array Widget - , passThrough ∷ Boolean - | r - ) - -overlay ∷ ∀ r r'. Union r r' (OverlayProps ()) ⇒ Record r → Widget -overlay = overlayImpl <<< unsafeCoerce - -foreign import overlayImpl ∷ Record (OverlayProps ()) → Widget - -type UpdateOverlayProps = Record (OverlayProps ()) → Record (OverlayProps ()) - -overlay' - ∷ ∀ r r' - . Union r r' (OverlayProps ()) - ⇒ Record r - → Widget /\ (UpdateOverlayProps → Effect Unit) -overlay' props = - let - widget = overlay props - update = unsafeWidgetUpdate @(OverlayProps ()) widget - in - widget /\ update - diff --git a/src/AGS/Widget/ProgressBar.js b/src/AGS/Widget/ProgressBar.js deleted file mode 100644 index 05a832d..0000000 --- a/src/AGS/Widget/ProgressBar.js +++ /dev/null @@ -1,3 +0,0 @@ -export const progressBarImpl = - props => - Widget.ProgressBar(props) diff --git a/src/AGS/Widget/ProgressBar.purs b/src/AGS/Widget/ProgressBar.purs deleted file mode 100644 index 947c679..0000000 --- a/src/AGS/Widget/ProgressBar.purs +++ /dev/null @@ -1,49 +0,0 @@ -module AGS.Widget.ProgressBar - ( ProgressBarProps - , UpdateProgressBarProps - , progressBar - , progressBar' - ) where - -import Prelude - -import AGS.Widget.Internal (AGSWidgetProps, unsafeWidgetUpdate) -import Data.Tuple.Nested (type (/\), (/\)) -import Effect (Effect) -import Gtk.Orientable (GtkOrientableProps) -import Gtk.ProgressBar (GtkProgressBarProps) -import Gtk.Widget (Widget) -import Prim.Row (class Union) -import Type.Row (type (+)) -import Unsafe.Coerce (unsafeCoerce) - -type ProgressBarProps r = - AGSWidgetProps - + GtkOrientableProps - + GtkProgressBarProps - + - ( vertical ∷ Boolean - , value ∷ Number - | r - ) - -progressBar ∷ ∀ r r'. Union r r' (ProgressBarProps ()) ⇒ Record r → Widget -progressBar = progressBarImpl <<< unsafeCoerce - -foreign import progressBarImpl ∷ Record (ProgressBarProps ()) → Widget - -type UpdateProgressBarProps = - Record (ProgressBarProps ()) → Record (ProgressBarProps ()) - -progressBar' - ∷ ∀ r r' - . Union r r' (ProgressBarProps ()) - ⇒ Record r - → Widget /\ (UpdateProgressBarProps → Effect Unit) -progressBar' props = - let - widget = progressBar props - update = unsafeWidgetUpdate @(ProgressBarProps ()) widget - in - widget /\ update - diff --git a/src/AGS/Widget/Revealer.js b/src/AGS/Widget/Revealer.js deleted file mode 100644 index d01b214..0000000 --- a/src/AGS/Widget/Revealer.js +++ /dev/null @@ -1,4 +0,0 @@ -export const revealerImpl = - props => - Widget.Revealer(props) - diff --git a/src/AGS/Widget/Revealer.purs b/src/AGS/Widget/Revealer.purs deleted file mode 100644 index 9886516..0000000 --- a/src/AGS/Widget/Revealer.purs +++ /dev/null @@ -1,46 +0,0 @@ -module AGS.Widget.Revealer - ( RevealerProps - , UpdateRevealerProps - , revealer - , revealer' - , module Gtk.RevealerTransition - ) where - -import Prelude - -import AGS.Widget.Internal (AGSWidgetProps, unsafeWidgetUpdate) -import Data.Tuple.Nested (type (/\), (/\)) -import Effect (Effect) -import Gtk.Container (GtkContainerProps) -import Gtk.Revealer (GtkRevealerProps) -import Gtk.RevealerTransition (GtkRevealerTransitionType, transitions) -import Gtk.Widget (Widget) -import Prim.Row (class Union) -import Type.Row (type (+)) -import Unsafe.Coerce (unsafeCoerce) - -type RevealerProps r = - AGSWidgetProps - + GtkContainerProps - + GtkRevealerProps - + r - -revealer ∷ ∀ r r'. Union r r' (RevealerProps ()) ⇒ Record r → Widget -revealer = revealerImpl <<< unsafeCoerce - -foreign import revealerImpl ∷ ∀ r. Record r → Widget - -type UpdateRevealerProps = Record (RevealerProps ()) → Record (RevealerProps ()) - -revealer' - ∷ ∀ r r' - . Union r r' (RevealerProps ()) - ⇒ Record r - → Widget /\ (UpdateRevealerProps → Effect Unit) -revealer' props = - let - widget = revealer props - update = unsafeWidgetUpdate @(RevealerProps ()) widget - in - widget /\ update - diff --git a/src/AGS/Widget/Scrollable.js b/src/AGS/Widget/Scrollable.js deleted file mode 100644 index f9982e0..0000000 --- a/src/AGS/Widget/Scrollable.js +++ /dev/null @@ -1,4 +0,0 @@ -export const scrollableImpl = - props => - Widget.Scrollable(props) - diff --git a/src/AGS/Widget/Scrollable.purs b/src/AGS/Widget/Scrollable.purs deleted file mode 100644 index ab27d46..0000000 --- a/src/AGS/Widget/Scrollable.purs +++ /dev/null @@ -1,49 +0,0 @@ -module AGS.Widget.Scrollable - ( ScrollableProps - , UpdateScrollableProps - , scrollable - , scrollable' - ) where - -import Prelude - -import AGS.Widget.Internal (AGSWidgetProps, unsafeWidgetUpdate) -import Data.Tuple.Nested (type (/\), (/\)) -import Effect (Effect) -import Gtk.Container (GtkContainerProps) -import Gtk.ScrolledWindow (GtkScrolledWindowProps) -import Gtk.Widget (Widget) -import Prim.Row (class Union) -import Type.Row (type (+)) -import Unsafe.Coerce (unsafeCoerce) - -type ScrollableProps r = - AGSWidgetProps - + GtkScrolledWindowProps - + GtkContainerProps - + - ( hscroll ∷ String {- TODO make it a proper type -} - , vscroll ∷ String {- TODO make it a proper type -} - | r - ) - -scrollable ∷ ∀ r r'. Union r r' (ScrollableProps ()) ⇒ Record r → Widget -scrollable = scrollableImpl <<< unsafeCoerce - -foreign import scrollableImpl ∷ Record (ScrollableProps ()) → Widget - -type UpdateScrollableProps = - Record (ScrollableProps ()) → Record (ScrollableProps ()) - -scrollable' - ∷ ∀ r r' - . Union r r' (ScrollableProps ()) - ⇒ Record r - → Widget /\ (UpdateScrollableProps → Effect Unit) -scrollable' props = - let - widget = scrollable props - update = unsafeWidgetUpdate @(ScrollableProps ()) widget - in - widget /\ update - diff --git a/src/AGS/Widget/Slider.js b/src/AGS/Widget/Slider.js deleted file mode 100644 index 66057d8..0000000 --- a/src/AGS/Widget/Slider.js +++ /dev/null @@ -1,4 +0,0 @@ -export const sliderImpl = - props => - Widget.Slider(props) - diff --git a/src/AGS/Widget/Slider.purs b/src/AGS/Widget/Slider.purs deleted file mode 100644 index 64cc4c6..0000000 --- a/src/AGS/Widget/Slider.purs +++ /dev/null @@ -1,96 +0,0 @@ -module AGS.Widget.Slider - ( SliderProps - , UpdateSliderProps - , Mark - , MarkPosition - , slider - , slider' - , markPositionTop - , markPositionLeft - , markPositionRight - , markPositionBottom - ) where - -import Prelude - -import AGS.Widget.Internal (AGSWidgetProps, unsafeWidgetUpdate) -import Data.Maybe (Maybe, maybe) -import Data.Tuple.Nested (type (/\), (/\)) -import Effect (Effect) -import Effect.Uncurried (mkEffectFn1) -import Gtk.Orientable (GtkOrientableProps) -import Gtk.Range (GtkRangeProps) -import Gtk.Scale (GtkScaleProps) -import Gtk.Widget (Widget) -import Prim.Row (class Union) -import Record.Unsafe as RU -import Type.Row (type (+)) -import Unsafe.Coerce (unsafeCoerce) - -foreign import data MarkPosition ∷ Type - -markPositionTop = unsafeCoerce "top" ∷ MarkPosition -markPositionLeft = unsafeCoerce "left" ∷ MarkPosition -markPositionRight = unsafeCoerce "right" ∷ MarkPosition -markPositionBottom = unsafeCoerce "bottom" ∷ MarkPosition - -type Mark = - { at ∷ Number - , label ∷ Maybe String - , position ∷ Maybe MarkPosition - } - -type SliderProps r = - AGSWidgetProps - + GtkOrientableProps - + GtkScaleProps - + GtkRangeProps - + - ( vertical ∷ Boolean - , value ∷ Number - , min ∷ Number - , max ∷ Number - , marks ∷ Array Mark - , onChange ∷ Number → Effect Unit - | r - ) - -slider ∷ ∀ r r'. Union r r' (SliderProps ()) ⇒ Record r → Widget -slider = sliderImpl <<< prepare - where - prepare r = - r - # - ( if RU.unsafeHas "marks" r then - RU.unsafeSet "marks" - (prepareMark `map @Array` RU.unsafeGet "marks" r) - else - identity - ) - # - ( if RU.unsafeHas "onChange" r then - RU.unsafeSet "onChange" - (mkEffectFn1 \{ value } → RU.unsafeGet "onChange" r value) - else - identity - ) - - prepareMark { at, label, position } = - [ at ] <> maybe [] unsafeCoerce label <> maybe [] unsafeCoerce position - -foreign import sliderImpl ∷ ∀ r. Record r → Widget - -type UpdateSliderProps = Record (SliderProps ()) → Record (SliderProps ()) - -slider' - ∷ ∀ r r' - . Union r r' (SliderProps ()) - ⇒ Record r - → Widget /\ (UpdateSliderProps → Effect Unit) -slider' props = - let - widget = slider props - update = unsafeWidgetUpdate @(SliderProps ()) widget - in - widget /\ update - diff --git a/src/AGS/Widget/Stack.js b/src/AGS/Widget/Stack.js deleted file mode 100644 index 6ab3158..0000000 --- a/src/AGS/Widget/Stack.js +++ /dev/null @@ -1,3 +0,0 @@ -export const stackImpl = - props => - Widget.Stack(props) diff --git a/src/AGS/Widget/Stack.purs b/src/AGS/Widget/Stack.purs deleted file mode 100644 index 8fcd5fc..0000000 --- a/src/AGS/Widget/Stack.purs +++ /dev/null @@ -1,48 +0,0 @@ -module AGS.Widget.Stack - ( StackProps - , stack - , stack' - ) where - -import Prelude - -import AGS.Widget.Internal (AGSWidgetProps, unsafeWidgetUpdate) -import Data.Tuple.Nested (type (/\), (/\)) -import Effect (Effect) -import Foreign.Object (Object) -import Gtk.Container (GtkContainerProps) -import Gtk.Stack (GtkStackProps) -import Gtk.Widget (Widget) -import Prim.Row (class Union) -import Type.Row (type (+)) -import Unsafe.Coerce (unsafeCoerce) - -type StackProps r = - AGSWidgetProps - + GtkContainerProps - + GtkStackProps Widget - + - ( children ∷ Object Widget - , shown ∷ String - | r - ) - -stack ∷ ∀ r r'. Union r r' (StackProps ()) ⇒ Record r → Widget -stack = stackImpl <<< unsafeCoerce - -foreign import stackImpl ∷ Record (StackProps ()) → Widget - -type UpdateStackProps = Record (StackProps ()) → Record (StackProps ()) - -stack' - ∷ ∀ r r' - . Union r r' (StackProps ()) - ⇒ Record r - → Widget /\ (UpdateStackProps → Effect Unit) -stack' props = - let - widget = stack props - update = unsafeWidgetUpdate @(StackProps ()) widget - in - widget /\ update - diff --git a/src/Gtk/Actionable.purs b/src/Gtk/Actionable.purs index a8fc8d1..48e3fed 100644 --- a/src/Gtk/Actionable.purs +++ b/src/Gtk/Actionable.purs @@ -1,7 +1,9 @@ module Gtk.Actionable where +import AGS.Binding (ValueOrBinding) + type GtkActionableProps r = - ( actionName ∷ String + ( actionName ∷ ValueOrBinding String -- , actionTarget ∷ GLib.Variant | r ) diff --git a/src/Gtk/Activatable.purs b/src/Gtk/Activatable.purs index 4c39bd7..d0cee49 100644 --- a/src/Gtk/Activatable.purs +++ b/src/Gtk/Activatable.purs @@ -1,8 +1,10 @@ module Gtk.Activatable where +import AGS.Binding (ValueOrBinding) + type GtkActivatableProps r = ( -- relatedAction ∷ Gtk.Action - useActionAppearance ∷ Boolean + useActionAppearance ∷ ValueOrBinding Boolean | r ) diff --git a/src/Gtk/Box.purs b/src/Gtk/Box.purs index 78af065..1675f1f 100644 --- a/src/Gtk/Box.purs +++ b/src/Gtk/Box.purs @@ -1,11 +1,13 @@ module Gtk.Box where +import AGS.Binding (ValueOrBinding) + -- https://gjs-docs.gnome.org/gtk30~3.0/gtk.box -- Inherited: Gtk.Orientable (1), Gtk.Widget (39), Gtk.Container (3) type GtkBoxProps r = ( -- baselinePosition ∷ Gtk.BaselinePosition - homogeneous ∷ Boolean - , spacing ∷ Number + homogeneous ∷ ValueOrBinding Boolean + , spacing ∷ ValueOrBinding Number | r ) diff --git a/src/Gtk/Button.purs b/src/Gtk/Button.purs index b947b9a..a26bce0 100644 --- a/src/Gtk/Button.purs +++ b/src/Gtk/Button.purs @@ -6,15 +6,15 @@ import Gtk.Widget (Widget) -- https://gjs-docs.gnome.org/gtk30~3.0/gtk.button -- Inherited: GObject.Object (1), Gtk.Widget (69), Gtk.Container (4) type GtkButtonProps r = - ( alwaysShowImage ∷ Boolean + ( alwaysShowImage ∷ ValueOrBinding Boolean , image ∷ ValueOrBinding Widget -- , imagePosition ∷ Gtk.PositionType - , label ∷ String - -- , relief ∷ Gtk.ReliefStyle - , useStock ∷ Boolean - , useUnderline ∷ Boolean - , xalign ∷ Number - , yalign ∷ Number + , label ∷ ValueOrBinding String + -- , relief ∷ ValueOrBinding Gtk.ReliefStyle + , useStock ∷ ValueOrBinding Boolean + , useUnderline ∷ ValueOrBinding Boolean + , xalign ∷ ValueOrBinding Number + , yalign ∷ ValueOrBinding Number | r ) diff --git a/src/Gtk/Container.purs b/src/Gtk/Container.purs index a4c897b..4c17299 100644 --- a/src/Gtk/Container.purs +++ b/src/Gtk/Container.purs @@ -6,7 +6,7 @@ import Gtk.Widget (Widget) -- https://gjs-docs.gnome.org/gtk30~3.0/gtk.container -- Inherited: Gtk.Widget (39) type GtkContainerProps r = - ( borderWidth ∷ Number + ( borderWidth ∷ ValueOrBinding Number , child ∷ ValueOrBinding Widget -- , resizeMode ∷ Gtk.ResizeMode | r diff --git a/src/Gtk/Image.purs b/src/Gtk/Image.purs index e6c6828..43fb3a7 100644 --- a/src/Gtk/Image.purs +++ b/src/Gtk/Image.purs @@ -1,19 +1,21 @@ module Gtk.Image where +import AGS.Binding (ValueOrBinding) + type GtkImageProps r = - ( file ∷ String - -- , gicon ∷ Gio.Icon - , iconName ∷ String - -- , iconSet ∷ Gtk.IconSet - , iconSize ∷ Number - -- , pixbuf ∷ GdkPixbuf.Pixbuf - -- , pixbufAnimation ∷ GdkPixbuf.PixbufAnimation - , pixelSize ∷ Number - , resource ∷ String - , stock ∷ String - -- , storageType ∷ Gtk.ImageType - -- , surface ∷ Cairo.Surface - , useFallback ∷ Boolean + ( file ∷ ValueOrBinding String + -- , gicon ∷ ValueOrBinding Gio.Icon + , iconName ∷ ValueOrBinding String + -- , iconSet ∷ ValueOrBinding Gtk.IconSet + , iconSize ∷ ValueOrBinding Number + -- , pixbuf ∷ ValueOrBinding GdkPixbuf.Pixbuf + -- , pixbufAnimation ∷ ValueOrBinding GdkPixbuf.PixbufAnimation + , pixelSize ∷ ValueOrBinding Number + , resource ∷ ValueOrBinding String + , stock ∷ ValueOrBinding String + -- , storageType ∷ ValueOrBinding Gtk.ImageType + -- , surface ∷ ValueOrBinding Cairo.Surface + , useFallback ∷ ValueOrBinding Boolean | r ) diff --git a/src/Gtk/Label.purs b/src/Gtk/Label.purs index f1dbf68..743224d 100644 --- a/src/Gtk/Label.purs +++ b/src/Gtk/Label.purs @@ -6,28 +6,28 @@ import Gtk.Widget (Widget) -- https://gjs-docs.gnome.org/gtk30~3.0/gtk.label -- Inherited: Gtk.Widget (39), Gtk.Misc (4) type GtkLabelProps r = - ( angle ∷ Number - -- , attributes ∷ Pango.AttrList - , cursorPosition ∷ Number - -- , ellipsize ∷ Pango.EllipsizeMode - -- , justify ∷ Gtk.Justification + ( angle ∷ ValueOrBinding Number + -- , attributes ∷ ValueOrBinding Pango.AttrList + , cursorPosition ∷ ValueOrBinding Number + -- , ellipsize ∷ ValueOrBinding Pango.EllipsizeMode + -- , justify ∷ ValueOrBinding Gtk.Justification , label ∷ ValueOrBinding String - , lines ∷ Number - , maxWidthChars ∷ Number - , mnemonicKeyval ∷ Number + , lines ∷ ValueOrBinding Number + , maxWidthChars ∷ ValueOrBinding Number + , mnemonicKeyval ∷ ValueOrBinding Number , mnemonicWidget ∷ ValueOrBinding Widget - , pattern ∷ String - , selectable ∷ Boolean - , selectionBound ∷ Number - , singleLineMode ∷ Boolean - , trackVisitedLinks ∷ Boolean - , useMarkup ∷ Boolean - , useUnderline ∷ Boolean - , widthChars ∷ Number - , wrap ∷ Boolean - -- , wrapMode ∷ Pango.WrapMode - , xalign ∷ Number - , yalign ∷ Number + , pattern ∷ ValueOrBinding String + , selectable ∷ ValueOrBinding Boolean + , selectionBound ∷ ValueOrBinding Number + , singleLineMode ∷ ValueOrBinding Boolean + , trackVisitedLinks ∷ ValueOrBinding Boolean + , useMarkup ∷ ValueOrBinding Boolean + , useUnderline ∷ ValueOrBinding Boolean + , widthChars ∷ ValueOrBinding Number + , wrap ∷ ValueOrBinding Boolean + -- , wrapMode ∷ ValueOrBinding Pango.WrapMode + , xalign ∷ ValueOrBinding Number + , yalign ∷ ValueOrBinding Number | r ) diff --git a/src/Gtk/Menu.purs b/src/Gtk/Menu.purs index 4db96ba..6ebd52a 100644 --- a/src/Gtk/Menu.purs +++ b/src/Gtk/Menu.purs @@ -1,19 +1,21 @@ module Gtk.Menu where +import AGS.Binding (ValueOrBinding) + -- Type parameter `a` is implied to be `Gtk.Widget` or anything that extends it type GtkMenuProps a r = - ( -- accelGroup ∷ Gtk.AccelGroup - accelPath ∷ String - , active ∷ Number - --, anchorHints ∷ Gdk.AnchorHints - , attachWidget ∷ a - --, menuTypeHint ∷ Gdk.WindowTypeHint - , monitor ∷ Number - , rectAnchorDx ∷ Number - , rectAnchorDy ∷ Number - , reserveToggleSize ∷ Boolean - , tearoffSAte ∷ Boolean - , tearoffTTle ∷ String + ( -- accelGroup ∷ ValueOrBinding Gtk.AccelGroup + accelPath ∷ ValueOrBinding String + , active ∷ ValueOrBinding Number + --, anchorHints ∷ ValueOrBinding Gdk.AnchorHints + , attachWidget ∷ ValueOrBinding a + --, menuTypeHint ∷ ValueOrBinding Gdk.WindowTypeHint + , monitor ∷ ValueOrBinding Number + , rectAnchorDx ∷ ValueOrBinding Number + , rectAnchorDy ∷ ValueOrBinding Number + , reserveToggleSize ∷ ValueOrBinding Boolean + , tearoffSAte ∷ ValueOrBinding Boolean + , tearoffTTle ∷ ValueOrBinding String | r ) diff --git a/src/Gtk/MenuItem.purs b/src/Gtk/MenuItem.purs index 7269f45..9096f2b 100644 --- a/src/Gtk/MenuItem.purs +++ b/src/Gtk/MenuItem.purs @@ -1,12 +1,14 @@ module Gtk.MenuItem where +import AGS.Binding (ValueOrBinding) + -- The type parameter `a` is implied to be `Gtk.Menu` or anything that extends it type GtkMenuItemProps a r = - ( accelPath ∷ String - , label ∷ String - , rightJustified ∷ Boolean - , submenu ∷ a - , useUnderline ∷ Boolean + ( accelPath ∷ ValueOrBinding String + , label ∷ ValueOrBinding String + , rightJustified ∷ ValueOrBinding Boolean + , submenu ∷ ValueOrBinding a + , useUnderline ∷ ValueOrBinding Boolean | r ) diff --git a/src/Gtk/MenuShell.purs b/src/Gtk/MenuShell.purs index 0e4a9e0..c8d932a 100644 --- a/src/Gtk/MenuShell.purs +++ b/src/Gtk/MenuShell.purs @@ -1,7 +1,9 @@ module Gtk.MenuShell where +import AGS.Binding (ValueOrBinding) + type GtkMenuShellProps r = - ( takeFocus ∷ Boolean + ( takeFocus ∷ ValueOrBinding Boolean | r ) diff --git a/src/Gtk/Misc.purs b/src/Gtk/Misc.purs index 33457c1..be0a1b5 100644 --- a/src/Gtk/Misc.purs +++ b/src/Gtk/Misc.purs @@ -1,10 +1,12 @@ module Gtk.Misc where +import AGS.Binding (ValueOrBinding) + type GtkMiscProps r = - ( xalign ∷ Number - , xpad ∷ Number - , yalign ∷ Number - , ypad ∷ Number + ( xalign ∷ ValueOrBinding Number + , xpad ∷ ValueOrBinding Number + , yalign ∷ ValueOrBinding Number + , ypad ∷ ValueOrBinding Number | r ) diff --git a/src/Gtk/Orientable.purs b/src/Gtk/Orientable.purs index d0e5a4e..60e5524 100644 --- a/src/Gtk/Orientable.purs +++ b/src/Gtk/Orientable.purs @@ -3,7 +3,7 @@ module Gtk.Orientable where -- https://gjs-docs.gnome.org/gtk30~3.0/gtk.orientable type GtkOrientableProps ∷ ∀ k. k → k type GtkOrientableProps r = - ( -- orientation ∷ Gtk.Orientation + ( -- orientation ∷ ValueOrBinding Gtk.Orientation | r ) diff --git a/src/Gtk/ProgressBar.purs b/src/Gtk/ProgressBar.purs index 3c03c05..35641eb 100644 --- a/src/Gtk/ProgressBar.purs +++ b/src/Gtk/ProgressBar.purs @@ -1,12 +1,14 @@ module Gtk.ProgressBar where +import AGS.Binding (ValueOrBinding) + type GtkProgressBarProps r = ( -- ellipsize ∷ Pango.EllipsizeMode - fraction ∷ Number - , inverted ∷ Boolean - , pulseStep ∷ Number - , showText ∷ Boolean - , text ∷ String + fraction ∷ ValueOrBinding Number + , inverted ∷ ValueOrBinding Boolean + , pulseStep ∷ ValueOrBinding Number + , showText ∷ ValueOrBinding Boolean + , text ∷ ValueOrBinding String | r ) diff --git a/src/Gtk/Range.purs b/src/Gtk/Range.purs index e448450..6daf595 100644 --- a/src/Gtk/Range.purs +++ b/src/Gtk/Range.purs @@ -1,14 +1,16 @@ module Gtk.Range where +import AGS.Binding (ValueOrBinding) + type GtkRangeProps r = - ( -- adjustment ∷ Gtk.Adjustment - fillLevel ∷ Number - , inverted ∷ Boolean - -- , lowerStepperSensitivity ∷ Gtk.SensitivityType - , restrictToFillLevel ∷ Boolean - , roundDigits ∷ Number - , showFillLevel ∷ Boolean - -- , upperStepperSensitivity ∷ Gtk.SensitivityType + ( -- adjustment ∷ ValueOrBinding Gtk.Adjustment + fillLevel ∷ ValueOrBinding Number + , inverted ∷ ValueOrBinding Boolean + -- , lowerStepperSensitivity ∷ ValueOrBinding Gtk.SensitivityType + , restrictToFillLevel ∷ ValueOrBinding Boolean + , roundDigits ∷ ValueOrBinding Number + , showFillLevel ∷ ValueOrBinding Boolean + -- , upperStepperSensitivity ∷ ValueOrBinding Gtk.SensitivityType | r ) diff --git a/src/Gtk/Revealer.purs b/src/Gtk/Revealer.purs index 806f66d..e50150a 100644 --- a/src/Gtk/Revealer.purs +++ b/src/Gtk/Revealer.purs @@ -3,13 +3,14 @@ module Gtk.Revealer , module Gtk.RevealerTransition ) where +import AGS.Binding (ValueOrBinding) import Gtk.RevealerTransition (GtkRevealerTransitionType, transitions) type GtkRevealerProps r = - ( childRevealed ∷ Boolean - , revealChild ∷ Boolean - , transitionDuration ∷ Number - , transitionType ∷ GtkRevealerTransitionType + ( childRevealed ∷ ValueOrBinding Boolean + , revealChild ∷ ValueOrBinding Boolean + , transitionDuration ∷ ValueOrBinding Number + , transitionType ∷ ValueOrBinding GtkRevealerTransitionType | r ) diff --git a/src/Gtk/Scale.purs b/src/Gtk/Scale.purs index 2879e1f..3b12d31 100644 --- a/src/Gtk/Scale.purs +++ b/src/Gtk/Scale.purs @@ -1,10 +1,12 @@ module Gtk.Scale where +import AGS.Binding (ValueOrBinding) + type GtkScaleProps r = - ( digits ∷ Number - , drawValue ∷ Boolean - , hasOrigin ∷ Boolean - -- , valuePos ∷ Gtk.PositionType + ( digits ∷ ValueOrBinding Number + , drawValue ∷ ValueOrBinding Boolean + , hasOrigin ∷ ValueOrBinding Boolean + -- , valuePos ∷ ValueOrBinding Gtk.PositionType | r ) diff --git a/src/Gtk/ScrolledWindow.purs b/src/Gtk/ScrolledWindow.purs index 9934e59..e7477c2 100644 --- a/src/Gtk/ScrolledWindow.purs +++ b/src/Gtk/ScrolledWindow.purs @@ -1,23 +1,25 @@ module Gtk.ScrolledWindow where +import AGS.Binding (ValueOrBinding) + -- https://gjs-docs.gnome.org/gtk30~3.0/gtk.scrolledwindow -- Inherited: Gtk.Widget (39), Gtk.Container (3) type GtkScrolledWindowProps r = - ( -- hadjustment ∷ Gtk.Adjustment - -- hscrollbarPolicy ∷ Gtk.PolicyType - kineticScrolling ∷ Boolean - , maxContentHeight ∷ Number - , maxContentWidth ∷ Number - , minContentHeight ∷ Number - , minContentWidth ∷ Number - , overlayScrolling ∷ Boolean - , propagateNaturalHeight ∷ Boolean - , propagateNaturalWidth ∷ Boolean - -- , shadowType ∷ Gtk.ShadowType - -- , vadjustment ∷ Gtk.Adjustment - -- , vscrollbarPolicy ∷ Gtk.PolicyType - -- , windowPlacement ∷ Gtk.CornerType - , windowPlacementSet ∷ Boolean + ( -- hadjustment ∷ ValueOrBinding Gtk.Adjustment + -- hscrollbarPolicy ∷ ValueOrBinding Gtk.PolicyType + kineticScrolling ∷ ValueOrBinding Boolean + , maxContentHeight ∷ ValueOrBinding Number + , maxContentWidth ∷ ValueOrBinding Number + , minContentHeight ∷ ValueOrBinding Number + , minContentWidth ∷ ValueOrBinding Number + , overlayScrolling ∷ ValueOrBinding Boolean + , propagateNaturalHeight ∷ ValueOrBinding Boolean + , propagateNaturalWidth ∷ ValueOrBinding Boolean + -- , shadowType ∷ ValueOrBinding Gtk.ShadowType + -- , vadjustment ∷ ValueOrBinding Gtk.Adjustment + -- , vscrollbarPolicy ∷ ValueOrBinding Gtk.PolicyType + -- , windowPlacement ∷ ValueOrBinding Gtk.CornerType + , windowPlacementSet ∷ ValueOrBinding Boolean | r ) diff --git a/src/Gtk/Stack.purs b/src/Gtk/Stack.purs index cefa3f2..ebf010f 100644 --- a/src/Gtk/Stack.purs +++ b/src/Gtk/Stack.purs @@ -1,5 +1,7 @@ module Gtk.Stack where +import AGS.Binding (ValueOrBinding) + foreign import data GtkStackTransitionType ∷ Type foreign import transitions @@ -27,14 +29,14 @@ foreign import transitions -- Type parameter `a` is implied to be `Gtk.Widget` or anything that extends it type GtkStackProps a r = - ( hhomogeneous ∷ Boolean - , homogeneous ∷ Boolean - , interpolateSize ∷ Boolean - , transitionDuration ∷ Number - , transitionRunning ∷ Boolean - , transitionType ∷ GtkStackTransitionType - , vhomogeneous ∷ Boolean - , visibleChild ∷ a - , visibleChildName ∷ String + ( hhomogeneous ∷ ValueOrBinding Boolean + , homogeneous ∷ ValueOrBinding Boolean + , interpolateSize ∷ ValueOrBinding Boolean + , transitionDuration ∷ ValueOrBinding Number + , transitionRunning ∷ ValueOrBinding Boolean + , transitionType ∷ ValueOrBinding GtkStackTransitionType + , vhomogeneous ∷ ValueOrBinding Boolean + , visibleChild ∷ ValueOrBinding a + , visibleChildName ∷ ValueOrBinding String | r )