Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Draw command list
This is the low-level list of polygons that ImGui functions are filling.
At the end of the frame, all command lists are passed to your ImGuiIO::RenderDrawListFn
function for rendering.
Each dear imgui window contains its own ImDrawList.
You can use getWindowDrawList
to access the current window draw list and draw custom primitives.
You can interleave normal ImGui calls and adding primitives to the current draw list.
In single viewport mode, top-left is == GetMainViewport()->Pos
(generally 0,0
),
bottom-right is == GetMainViewport()->Pos+Size
(generally io.DisplaySize).
You are totally free to apply whatever transformation matrix to want to the data (depending on the use of the transformation you may want to apply it to ClipRect as well!).
Important: Primitives are always added to the list and not culled (culling is done at higher-level by ImGui functions), if you use this API a lot consider coarse culling your drawn objects.
Synopsis
- newtype DrawList = DrawList (Ptr ImDrawList)
- new :: MonadIO m => m DrawList
- destroy :: MonadIO m => DrawList -> m ()
- addLine :: MonadIO m => DrawList -> Ptr ImVec2 -> Ptr ImVec2 -> ImU32 -> CFloat -> m ()
- addRect :: MonadIO m => DrawList -> Ptr ImVec2 -> Ptr ImVec2 -> ImU32 -> CFloat -> ImDrawFlags -> CFloat -> m ()
- addRectFilled :: MonadIO m => DrawList -> Ptr ImVec2 -> Ptr ImVec2 -> ImU32 -> CFloat -> ImDrawFlags -> m ()
- addRectFilledMultiColor :: MonadIO m => DrawList -> Ptr ImVec2 -> Ptr ImVec2 -> ImU32 -> ImU32 -> ImU32 -> ImU32 -> m ()
- addQuad :: MonadIO m => DrawList -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> ImU32 -> CFloat -> m ()
- addQuadFilled :: MonadIO m => DrawList -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> ImU32 -> m ()
- addTriangle :: MonadIO m => DrawList -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> ImU32 -> CFloat -> m ()
- addTriangleFilled :: MonadIO m => DrawList -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> ImU32 -> m ()
- addCircle :: MonadIO m => DrawList -> Ptr ImVec2 -> CFloat -> ImU32 -> CInt -> CFloat -> m ()
- addCircleFilled :: MonadIO m => DrawList -> Ptr ImVec2 -> CFloat -> ImU32 -> CInt -> m ()
- addNgon :: MonadIO m => DrawList -> Ptr ImVec2 -> CFloat -> ImU32 -> CInt -> CFloat -> m ()
- addNgonFilled :: MonadIO m => DrawList -> Ptr ImVec2 -> CFloat -> ImU32 -> CInt -> m ()
- addText_ :: MonadIO m => DrawList -> Ptr ImVec2 -> ImU32 -> CString -> CString -> m ()
- addText :: MonadIO m => DrawList -> Ptr ImFont -> CFloat -> Ptr ImVec2 -> ImU32 -> CString -> CString -> CFloat -> Ptr ImVec4 -> m ()
- addPolyLine :: MonadIO m => DrawList -> Ptr ImVec2 -> CInt -> ImU32 -> ImDrawFlags -> CFloat -> m ()
- addConvexPolyFilled :: MonadIO m => DrawList -> Ptr ImVec2 -> CInt -> ImU32 -> m ()
- addBezierCubic :: MonadIO m => DrawList -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> ImU32 -> CFloat -> CInt -> m ()
- addBezierQuadratic :: MonadIO m => DrawList -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> ImU32 -> CFloat -> CInt -> m ()
- addImage :: MonadIO m => DrawList -> Ptr () -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> ImU32 -> m ()
- addImageQuad :: MonadIO m => DrawList -> Ptr () -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> ImU32 -> m ()
- addImageRounded :: MonadIO m => DrawList -> Ptr () -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> ImU32 -> CFloat -> ImDrawFlags -> m ()
- pathClear :: MonadIO m => DrawList -> m ()
- pathLineTo :: MonadIO m => DrawList -> Ptr ImVec2 -> m ()
- pathLineToMergeDuplicate :: MonadIO m => DrawList -> Ptr ImVec2 -> m ()
- pathFillConvex :: MonadIO m => DrawList -> ImU32 -> m ()
- pathStroke :: MonadIO m => DrawList -> ImU32 -> ImDrawFlags -> CFloat -> m ()
- pathArcTo :: MonadIO m => DrawList -> Ptr ImVec2 -> CFloat -> CFloat -> CFloat -> CInt -> m ()
- pathArcToFast :: MonadIO m => DrawList -> Ptr ImVec2 -> CFloat -> CInt -> CInt -> m ()
- pathBezierCubicCurveTo :: MonadIO m => DrawList -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> CInt -> m ()
- pathBezierQuadraticCurveTo :: MonadIO m => DrawList -> Ptr ImVec2 -> Ptr ImVec2 -> CInt -> m ()
- pathRect :: MonadIO m => DrawList -> Ptr ImVec2 -> Ptr ImVec2 -> CFloat -> ImDrawFlags -> m ()
- addDrawCmd :: MonadIO m => DrawList -> m ()
- cloneOutput :: MonadIO m => DrawList -> m DrawList
- pushClipRect :: MonadIO m => DrawList -> Ptr ImVec2 -> Ptr ImVec2 -> CBool -> m ()
- pushClipRectFullScreen :: MonadIO m => DrawList -> m ()
- popClipRect :: MonadIO m => DrawList -> m ()
- getClipRectMin :: MonadIO m => DrawList -> m ImVec2
- getClipRectMax :: MonadIO m => DrawList -> m ImVec2
- pushTextureID :: MonadIO m => DrawList -> Ptr () -> m ()
- popTextureID :: MonadIO m => DrawList -> m ()
Documentation
A single draw command list. Generally one per window, conceptually you may see this as a dynamic "mesh" builder.
Primitives
- For rectangular primitives,
p_min
andp_max
represent the upper-left and lower-right corners. - For circle primitives, use
num_segments == 0
to automatically calculate tessellation (preferred). In older versions (until Dear ImGui 1.77) theaddCircle
functions defaulted to num_segments == 12. In future versions we will use textures to provide cheaper and higher-quality circles. UseaddNgon
andaddNgonFilled
functions if you need to guaranteed a specific number of sides.
addRect :: MonadIO m => DrawList -> Ptr ImVec2 -> Ptr ImVec2 -> ImU32 -> CFloat -> ImDrawFlags -> CFloat -> m () Source #
addRectFilled :: MonadIO m => DrawList -> Ptr ImVec2 -> Ptr ImVec2 -> ImU32 -> CFloat -> ImDrawFlags -> m () Source #
addRectFilledMultiColor :: MonadIO m => DrawList -> Ptr ImVec2 -> Ptr ImVec2 -> ImU32 -> ImU32 -> ImU32 -> ImU32 -> m () Source #
addQuad :: MonadIO m => DrawList -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> ImU32 -> CFloat -> m () Source #
addQuadFilled :: MonadIO m => DrawList -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> ImU32 -> m () Source #
addTriangle :: MonadIO m => DrawList -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> ImU32 -> CFloat -> m () Source #
addTriangleFilled :: MonadIO m => DrawList -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> ImU32 -> m () Source #
addCircle :: MonadIO m => DrawList -> Ptr ImVec2 -> CFloat -> ImU32 -> CInt -> CFloat -> m () Source #
addNgon :: MonadIO m => DrawList -> Ptr ImVec2 -> CFloat -> ImU32 -> CInt -> CFloat -> m () Source #
addText :: MonadIO m => DrawList -> Ptr ImFont -> CFloat -> Ptr ImVec2 -> ImU32 -> CString -> CString -> CFloat -> Ptr ImVec4 -> m () Source #
addPolyLine :: MonadIO m => DrawList -> Ptr ImVec2 -> CInt -> ImU32 -> ImDrawFlags -> CFloat -> m () Source #
addBezierCubic :: MonadIO m => DrawList -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> ImU32 -> CFloat -> CInt -> m () Source #
addBezierQuadratic :: MonadIO m => DrawList -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> ImU32 -> CFloat -> CInt -> m () Source #
Image primitives
- Read FAQ to understand what
ImTextureID
is. p_min
andp_max
represent the upper-left and lower-right corners of the rectangle.uv_min
anduv_max
represent the normalized texture coordinates to use for those corners. Using(0,0)->(1,1)
texture coordinates will generally display the entire texture.
addImage :: MonadIO m => DrawList -> Ptr () -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> ImU32 -> m () Source #
addImageQuad :: MonadIO m => DrawList -> Ptr () -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> ImU32 -> m () Source #
addImageRounded :: MonadIO m => DrawList -> Ptr () -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> ImU32 -> CFloat -> ImDrawFlags -> m () Source #
Stateful path API
Add points then finish with pathFillConvex
or pathStroke
.
pathFillConvex :: MonadIO m => DrawList -> ImU32 -> m () Source #
Note: Anti-aliased filling requires points to be in clockwise order.
pathStroke :: MonadIO m => DrawList -> ImU32 -> ImDrawFlags -> CFloat -> m () Source #
pathArcTo :: MonadIO m => DrawList -> Ptr ImVec2 -> CFloat -> CFloat -> CFloat -> CInt -> m () Source #
pathArcToFast :: MonadIO m => DrawList -> Ptr ImVec2 -> CFloat -> CInt -> CInt -> m () Source #
Use precomputed angles for a 12 steps circle.
pathBezierCubicCurveTo :: MonadIO m => DrawList -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> CInt -> m () Source #
pathBezierQuadraticCurveTo :: MonadIO m => DrawList -> Ptr ImVec2 -> Ptr ImVec2 -> CInt -> m () Source #
pathRect :: MonadIO m => DrawList -> Ptr ImVec2 -> Ptr ImVec2 -> CFloat -> ImDrawFlags -> m () Source #
Advanced
addDrawCmd :: MonadIO m => DrawList -> m () Source #
This is useful if you need to forcefully create a new draw call (to allow for dependent rendering / blending). Otherwise primitives are merged into the same draw-call as much as possible.
cloneOutput :: MonadIO m => DrawList -> m DrawList Source #
Create a clone of the CmdBufferIdxBufferVtxBuffer.
Internal state
pushClipRectFullScreen :: MonadIO m => DrawList -> m () Source #
popClipRect :: MonadIO m => DrawList -> m () Source #
popTextureID :: MonadIO m => DrawList -> m () Source #