Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
- Exported types
- Methods
- appendBorder
- appendCairo
- appendColor
- appendConicGradient
- appendInsetShadow
- appendLayout
- appendLinearGradient
- appendNode
- appendOutsetShadow
- appendRadialGradient
- appendRepeatingLinearGradient
- appendRepeatingRadialGradient
- appendTexture
- glShaderPopTexture
- new
- perspective
- pop
- pushBlend
- pushBlur
- pushClip
- pushColorMatrix
- pushCrossFade
- pushGlShader
- pushOpacity
- pushRepeat
- pushRoundedClip
- pushShadow
- renderBackground
- renderFocus
- renderFrame
- renderInsertionCursor
- renderLayout
- restore
- rotate
- rotate3d
- save
- scale
- scale3d
- toNode
- toPaintable
- transform
- transformMatrix
- translate
- translate3d
GtkSnapshot is an auxiliary object that assists in creating GskRenderNodes
in the PaintableInterface
.snapshot
() vfunc. It functions in a similar way to
a cairo context, and maintains a stack of render nodes and their associated
transformations.
The node at the top of the stack is the the one that gtk_snapshot_append_…
functions operate on. Use the gtk_snapshot_push_… functions and snapshotPop
to change the current node.
The typical way to obtain a GtkSnapshot object is as an argument to
the WidgetClass
.snapshot
() vfunc. If you need to create your own GtkSnapshot,
use snapshotNew
.
Synopsis
- newtype Snapshot = Snapshot (ManagedPtr Snapshot)
- class (GObject o, IsDescendantOf Snapshot o) => IsSnapshot o
- toSnapshot :: (MonadIO m, IsSnapshot o) => o -> m Snapshot
- snapshotAppendBorder :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> RoundedRect -> [Float] -> [RGBA] -> m ()
- snapshotAppendCairo :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> Rect -> m Context
- snapshotAppendColor :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> RGBA -> Rect -> m ()
- snapshotAppendConicGradient :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> Rect -> Point -> Float -> [ColorStop] -> m ()
- snapshotAppendInsetShadow :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> RoundedRect -> RGBA -> Float -> Float -> Float -> Float -> m ()
- snapshotAppendLayout :: (HasCallStack, MonadIO m, IsSnapshot a, IsLayout b) => a -> b -> RGBA -> m ()
- snapshotAppendLinearGradient :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> Rect -> Point -> Point -> [ColorStop] -> m ()
- snapshotAppendNode :: (HasCallStack, MonadIO m, IsSnapshot a, IsRenderNode b) => a -> b -> m ()
- snapshotAppendOutsetShadow :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> RoundedRect -> RGBA -> Float -> Float -> Float -> Float -> m ()
- snapshotAppendRadialGradient :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> Rect -> Point -> Float -> Float -> Float -> Float -> [ColorStop] -> m ()
- snapshotAppendRepeatingLinearGradient :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> Rect -> Point -> Point -> [ColorStop] -> m ()
- snapshotAppendRepeatingRadialGradient :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> Rect -> Point -> Float -> Float -> Float -> Float -> [ColorStop] -> m ()
- snapshotAppendTexture :: (HasCallStack, MonadIO m, IsSnapshot a, IsTexture b) => a -> b -> Rect -> m ()
- snapshotGlShaderPopTexture :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> m ()
- snapshotNew :: (HasCallStack, MonadIO m) => m Snapshot
- snapshotPerspective :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> Float -> m ()
- snapshotPop :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> m ()
- snapshotPushBlend :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> BlendMode -> m ()
- snapshotPushBlur :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> Double -> m ()
- snapshotPushClip :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> Rect -> m ()
- snapshotPushColorMatrix :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> Matrix -> Vec4 -> m ()
- snapshotPushCrossFade :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> Double -> m ()
- snapshotPushGlShader :: (HasCallStack, MonadIO m, IsSnapshot a, IsGLShader b) => a -> b -> Rect -> Bytes -> m ()
- snapshotPushOpacity :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> Double -> m ()
- snapshotPushRepeat :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> Rect -> Maybe Rect -> m ()
- snapshotPushRoundedClip :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> RoundedRect -> m ()
- snapshotPushShadow :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> Shadow -> Word64 -> m ()
- snapshotRenderBackground :: (HasCallStack, MonadIO m, IsSnapshot a, IsStyleContext b) => a -> b -> Double -> Double -> Double -> Double -> m ()
- snapshotRenderFocus :: (HasCallStack, MonadIO m, IsSnapshot a, IsStyleContext b) => a -> b -> Double -> Double -> Double -> Double -> m ()
- snapshotRenderFrame :: (HasCallStack, MonadIO m, IsSnapshot a, IsStyleContext b) => a -> b -> Double -> Double -> Double -> Double -> m ()
- snapshotRenderInsertionCursor :: (HasCallStack, MonadIO m, IsSnapshot a, IsStyleContext b, IsLayout c) => a -> b -> Double -> Double -> c -> Int32 -> Direction -> m ()
- snapshotRenderLayout :: (HasCallStack, MonadIO m, IsSnapshot a, IsStyleContext b, IsLayout c) => a -> b -> Double -> Double -> c -> m ()
- snapshotRestore :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> m ()
- snapshotRotate :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> Float -> m ()
- snapshotRotate3d :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> Float -> Vec3 -> m ()
- snapshotSave :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> m ()
- snapshotScale :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> Float -> Float -> m ()
- snapshotScale3d :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> Float -> Float -> Float -> m ()
- snapshotToNode :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> m RenderNode
- snapshotToPaintable :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> Maybe Size -> m Paintable
- snapshotTransform :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> Maybe Transform -> m ()
- snapshotTransformMatrix :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> Matrix -> m ()
- snapshotTranslate :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> Point -> m ()
- snapshotTranslate3d :: (HasCallStack, MonadIO m, IsSnapshot a) => a -> Point3D -> m ()
Exported types
Memory-managed wrapper type.
Instances
Eq Snapshot Source # | |
GObject Snapshot Source # | |
Defined in GI.Gtk.Objects.Snapshot | |
ManagedPtrNewtype Snapshot Source # | |
Defined in GI.Gtk.Objects.Snapshot toManagedPtr :: Snapshot -> ManagedPtr Snapshot | |
TypedObject Snapshot Source # | |
Defined in GI.Gtk.Objects.Snapshot | |
HasParentTypes Snapshot Source # | |
Defined in GI.Gtk.Objects.Snapshot | |
IsGValue (Maybe Snapshot) Source # | Convert |
Defined in GI.Gtk.Objects.Snapshot gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe Snapshot -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe Snapshot) | |
type ParentTypes Snapshot Source # | |
Defined in GI.Gtk.Objects.Snapshot |
class (GObject o, IsDescendantOf Snapshot o) => IsSnapshot o Source #
Type class for types which can be safely cast to Snapshot
, for instance with toSnapshot
.
Instances
(GObject o, IsDescendantOf Snapshot o) => IsSnapshot o Source # | |
Defined in GI.Gtk.Objects.Snapshot |
toSnapshot :: (MonadIO m, IsSnapshot o) => o -> m Snapshot Source #
Methods
Click to display all available methods, including inherited ones
Methods
appendBorder, appendCairo, appendColor, appendConicGradient, appendInsetShadow, appendLayout, appendLinearGradient, appendNode, appendOutsetShadow, appendRadialGradient, appendRepeatingLinearGradient, appendRepeatingRadialGradient, appendTexture, bindProperty, bindPropertyFull, forceFloating, freezeNotify, getv, glShaderPopTexture, isFloating, notify, notifyByPspec, perspective, pop, pushBlend, pushBlur, pushClip, pushColorMatrix, pushCrossFade, pushGlShader, pushOpacity, pushRepeat, pushRoundedClip, pushShadow, ref, refSink, renderBackground, renderFocus, renderFrame, renderInsertionCursor, renderLayout, restore, rotate, rotate3d, runDispose, save, scale, scale3d, stealData, stealQdata, thawNotify, toNode, toPaintable, transform, transformMatrix, translate, translate3d, unref, watchClosure.
Getters
getData, getProperty, getQdata.
Setters
appendBorder
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> RoundedRect |
|
-> [Float] |
|
-> [RGBA] |
|
-> m () |
Appends a stroked border rectangle inside the given outline
. The
4 sides of the border can have different widths and colors.
appendCairo
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> Rect |
|
-> m Context | Returns: a cairo_t suitable for drawing the contents of the newly created render node |
Creates a new render node and appends it to the current render
node of snapshot
, without changing the current node.
appendColor
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> RGBA |
|
-> Rect |
|
-> m () |
Creates a new render node drawing the color
into the given bounds
and appends it
to the current render node of snapshot
.
You should try to avoid calling this function if color
is transparent.
appendConicGradient
snapshotAppendConicGradient Source #
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> Rect |
|
-> Point |
|
-> Float |
|
-> [ColorStop] |
|
-> m () |
Appends a conic gradient node with the given stops to snapshot
.
appendInsetShadow
snapshotAppendInsetShadow Source #
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> RoundedRect |
|
-> RGBA |
|
-> Float |
|
-> Float |
|
-> Float |
|
-> Float |
|
-> m () |
Appends an inset shadow into the box given by outline
.
appendLayout
snapshotAppendLayout :: (HasCallStack, MonadIO m, IsSnapshot a, IsLayout b) => a -> b -> RGBA -> m () Source #
No description available in the introspection data.
appendLinearGradient
snapshotAppendLinearGradient Source #
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> Rect |
|
-> Point |
|
-> Point |
|
-> [ColorStop] |
|
-> m () |
Appends a linear gradient node with the given stops to snapshot
.
appendNode
:: (HasCallStack, MonadIO m, IsSnapshot a, IsRenderNode b) | |
=> a |
|
-> b |
|
-> m () |
Appends node
to the current render node of snapshot
,
without changing the current node. If snapshot
does
not have a current node yet, node
will become the
initial node.
appendOutsetShadow
snapshotAppendOutsetShadow Source #
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> RoundedRect |
|
-> RGBA |
|
-> Float |
|
-> Float |
|
-> Float |
|
-> Float |
|
-> m () |
Appends an outset shadow node around the box given by outline
.
appendRadialGradient
snapshotAppendRadialGradient Source #
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> Rect |
|
-> Point |
|
-> Float |
|
-> Float |
|
-> Float |
|
-> Float |
|
-> [ColorStop] |
|
-> m () |
Appends a radial gradient node with the given stops to snapshot
.
appendRepeatingLinearGradient
snapshotAppendRepeatingLinearGradient Source #
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> Rect |
|
-> Point |
|
-> Point |
|
-> [ColorStop] |
|
-> m () |
Appends a repeating linear gradient node with the given stops to snapshot
.
appendRepeatingRadialGradient
snapshotAppendRepeatingRadialGradient Source #
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> Rect |
|
-> Point |
|
-> Float |
|
-> Float |
|
-> Float |
|
-> Float |
|
-> [ColorStop] |
|
-> m () |
Appends a repeating radial gradient node with the given stops to snapshot
.
appendTexture
snapshotAppendTexture Source #
:: (HasCallStack, MonadIO m, IsSnapshot a, IsTexture b) | |
=> a |
|
-> b |
|
-> Rect |
|
-> m () |
Creates a new render node drawing the texture
into the given bounds
and appends it
to the current render node of snapshot
.
glShaderPopTexture
snapshotGlShaderPopTexture Source #
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> m () |
Removes the top element from the stack of render nodes and
adds it to the nearest GskGLShaderNode below it. This must be called the
same number of times as the number of textures is needed for the
shader in snapshotPushGlShader
.
new
:: (HasCallStack, MonadIO m) | |
=> m Snapshot | Returns: a newly-allocated |
Creates a new GtkSnapshot
.
perspective
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> Float |
|
-> m () |
Applies a perspective projection transform.
See transformPerspective
for a discussion on the details.
pop
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> m () |
Removes the top element from the stack of render nodes, and appends it to the node underneath it.
pushBlend
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> BlendMode |
|
-> m () |
Blends together 2 images with the given blend mode.
Until the first call to snapshotPop
, the bottom image for the
blend operation will be recorded. After that call, the top image to
be blended will be recorded until the second call to snapshotPop
.
Calling this function requires 2 subsequent calls to snapshotPop
.
pushBlur
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> Double |
|
-> m () |
Blurs an image.
The image is recorded until the next call to snapshotPop
.
pushClip
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> Rect |
|
-> m () |
Clips an image to a rectangle.
The image is recorded until the next call to snapshotPop
.
pushColorMatrix
snapshotPushColorMatrix Source #
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> Matrix |
|
-> Vec4 |
|
-> m () |
Modifies the colors of an image by applying an affine transformation in RGB space.
The image is recorded until the next call to snapshotPop
.
pushCrossFade
snapshotPushCrossFade Source #
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> Double |
|
-> m () |
Snapshots a cross-fade operation between two images with the
given progress
.
Until the first call to snapshotPop
, the start image
will be snapshot. After that call, the end image will be recorded
until the second call to snapshotPop
.
Calling this function requires 2 calls to snapshotPop
.
pushGlShader
:: (HasCallStack, MonadIO m, IsSnapshot a, IsGLShader b) | |
=> a |
|
-> b |
|
-> Rect |
|
-> Bytes |
|
-> m () |
Push a GLShaderNode
with a specific GLShader
and a set of uniform values
to use while rendering. Additionally this takes a list of nChildren
other nodes
which will be passed to the GLShaderNode
.
The takeArgs
argument is a block of data to use for uniform
arguments, as per types and offsets defined by the shader
. Normally this is
generated by gsk_gl_shader_format_args()
or GskGLShaderArgBuilder
.
The snapshotter takes ownership of takeArgs
, so the caller should not free it
after this.
If the renderer doesn't support GL shaders, or if there is any problem when
compiling the shader, then the node will draw pink. You should use
gLShaderCompile
to ensure the shader
will work for the renderer
before using it.
If the shader requires textures (see gLShaderGetNTextures
), then it is
expected that you call snapshotGlShaderPopTexture
the number of times that are
required. Each of these calls will generate a node that is added as a child to the gl shader
node, which in turn will render these offscreen and pass as a texture to the shader.
Once all textures (if any) are pop:ed, you must call the regular snapshotPop
.
If you want to use pre-existing textures as input to the shader rather than
rendering new ones, use snapshotAppendTexture
to push a texture node. These
will be used directly rather than being re-rendered.
For details on how to write shaders, see GLShader
.
pushOpacity
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> Double |
|
-> m () |
Modifies the opacity of an image.
The image is recorded until the next call to snapshotPop
.
pushRepeat
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> Rect |
|
-> Maybe Rect |
|
-> m () |
Creates a node that repeats the child node.
The child is recorded until the next call to snapshotPop
.
pushRoundedClip
snapshotPushRoundedClip Source #
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> RoundedRect |
|
-> m () |
Clips an image to a rounded rectangle.
The image is recorded until the next call to snapshotPop
.
pushShadow
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> Shadow |
|
-> Word64 |
|
-> m () |
Applies a shadow to an image.
The image is recorded until the next call to snapshotPop
.
renderBackground
snapshotRenderBackground Source #
:: (HasCallStack, MonadIO m, IsSnapshot a, IsStyleContext b) | |
=> a |
|
-> b |
|
-> Double |
|
-> Double |
|
-> Double |
|
-> Double |
|
-> m () |
Creates a render node for the CSS background according to context
,
and appends it to the current node of snapshot
, without changing
the current node.
renderFocus
:: (HasCallStack, MonadIO m, IsSnapshot a, IsStyleContext b) | |
=> a |
|
-> b |
|
-> Double |
|
-> Double |
|
-> Double |
|
-> Double |
|
-> m () |
Creates a render node for the focus outline according to context
,
and appends it to the current node of snapshot
, without changing
the current node.
renderFrame
:: (HasCallStack, MonadIO m, IsSnapshot a, IsStyleContext b) | |
=> a |
|
-> b |
|
-> Double |
|
-> Double |
|
-> Double |
|
-> Double |
|
-> m () |
Creates a render node for the CSS border according to context
,
and appends it to the current node of snapshot
, without changing
the current node.
renderInsertionCursor
snapshotRenderInsertionCursor Source #
:: (HasCallStack, MonadIO m, IsSnapshot a, IsStyleContext b, IsLayout c) | |
=> a |
|
-> b |
|
-> Double |
|
-> Double |
|
-> c |
|
-> Int32 |
|
-> Direction |
|
-> m () |
Draws a text caret using snapshot
at the specified index of layout
.
renderLayout
:: (HasCallStack, MonadIO m, IsSnapshot a, IsStyleContext b, IsLayout c) | |
=> a |
|
-> b |
|
-> Double |
|
-> Double |
|
-> c |
|
-> m () |
Creates a render node for rendering layout
according to the style
information in context
, and appends it to the current node of snapshot
,
without changing the current node.
restore
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> m () |
Restores snapshot
to the state saved by a preceding call to
snapshotSave
and removes that state from the stack of
saved states.
rotate
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> Float |
|
-> m () |
Rotates @snapshot
's coordinate system by angle
degrees in 2D space -
or in 3D speak, rotates around the z axis.
rotate3d
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> Float |
|
-> Vec3 |
|
-> m () |
Rotates snapshot
's coordinate system by angle
degrees around axis
.
For a rotation in 2D space, use transformRotate
.
save
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> m () |
Makes a copy of the current state of snapshot
and saves it
on an internal stack of saved states for snapshot
. When
snapshotRestore
is called, snapshot
will be restored to
the saved state. Multiple calls to snapshotSave
and
snapshotRestore
can be nested; each call to
snapshotRestore
restores the state from the matching paired
snapshotSave
.
It is necessary to clear all saved states with corresponding calls
to snapshotRestore
.
scale
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> Float |
|
-> Float |
|
-> m () |
Scales snapshot
's coordinate system in 2-dimensional space by
the given factors.
Use snapshotScale3d
to scale in all 3 dimensions.
scale3d
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> Float |
|
-> Float |
|
-> Float |
|
-> m () |
Scales snapshot
's coordinate system by the given factors.
toNode
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> m RenderNode | Returns: the constructed |
Returns the render node that was constructed
by snapshot
. After calling this function, it
is no longer possible to add more nodes to
snapshot
. The only function that should be
called after this is objectUnref
.
toPaintable
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> Maybe Size |
|
-> m Paintable | Returns: a new |
Returns a paintable encapsulating the render node
that was constructed by snapshot
. After calling
this function, it is no longer possible to add more
nodes to snapshot
. The only function that should be
called after this is objectUnref
.
transform
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> Maybe Transform |
|
-> m () |
Transforms snapshot
's coordinate system with the given transform
.
transformMatrix
snapshotTransformMatrix Source #
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> Matrix |
|
-> m () |
Transforms snapshot
's coordinate system with the given matrix
.
translate
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> Point |
|
-> m () |
Translates snapshot
's coordinate system by point
in 2-dimensional space.
translate3d
:: (HasCallStack, MonadIO m, IsSnapshot a) | |
=> a |
|
-> Point3D |
|
-> m () |
Translates snapshot
's coordinate system by point
.