yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::gui::ScopedCanvas Class Reference

RAII wrapper for Canvas (ImGui-style) More...

#include <canvas.h>

Collaboration diagram for yaze::gui::ScopedCanvas:

Public Member Functions

 ScopedCanvas (const std::string &id, ImVec2 canvas_size=ImVec2(0, 0))
 Construct and begin a new canvas (legacy constructor without renderer)
 
 ScopedCanvas (gfx::IRenderer *renderer, const std::string &id, ImVec2 canvas_size=ImVec2(0, 0))
 Construct and begin a new canvas (with optional renderer)
 
 ScopedCanvas (Canvas &canvas)
 Wrap existing canvas with RAII.
 
 ~ScopedCanvas ()
 Destructor automatically calls End()
 
 ScopedCanvas (const ScopedCanvas &)=delete
 
ScopedCanvasoperator= (const ScopedCanvas &)=delete
 
 ScopedCanvas (ScopedCanvas &&other) noexcept
 
Canvasoperator-> ()
 Arrow operator for clean syntax: scoped->DrawBitmap(...)
 
const Canvasoperator-> () const
 
Canvasoperator* ()
 Dereference operator for direct access: (*scoped).DrawBitmap(...)
 
const Canvasoperator* () const
 
Canvasget ()
 Get underlying canvas.
 
const Canvasget () const
 

Private Attributes

Canvascanvas_
 
bool owned_
 
bool active_
 

Detailed Description

RAII wrapper for Canvas (ImGui-style)

Automatically calls Begin() on construction and End() on destruction, preventing forgotten End() calls and ensuring proper cleanup.

Usage:

{
gui::ScopedCanvas canvas("MyCanvas", ImVec2(512, 512));
canvas->DrawBitmap(bitmap);
if (canvas->DrawTilePainter(tile, 16)) {
HandlePaint(canvas->drawn_tile_position());
}
} // Automatic End() and cleanup
RAII wrapper for Canvas (ImGui-style)
Definition canvas.h:521

Or wrap existing canvas:

Canvas my_canvas("Editor");
{
ScopedCanvas scoped(my_canvas);
scoped->DrawBitmap(bitmap);
} // Automatic End()
Modern, robust canvas for drawing and manipulating graphics.
Definition canvas.h:54

Definition at line 521 of file canvas.h.

Constructor & Destructor Documentation

◆ ScopedCanvas() [1/5]

yaze::gui::ScopedCanvas::ScopedCanvas ( const std::string &  id,
ImVec2  canvas_size = ImVec2(0, 0) 
)
inlineexplicit

Construct and begin a new canvas (legacy constructor without renderer)

Definition at line 526 of file canvas.h.

References yaze::gui::Canvas::Begin(), and canvas_.

Here is the call graph for this function:

◆ ScopedCanvas() [2/5]

yaze::gui::ScopedCanvas::ScopedCanvas ( gfx::IRenderer renderer,
const std::string &  id,
ImVec2  canvas_size = ImVec2(0, 0) 
)
inlineexplicit

Construct and begin a new canvas (with optional renderer)

Definition at line 534 of file canvas.h.

References yaze::gui::Canvas::Begin(), and canvas_.

Here is the call graph for this function:

◆ ScopedCanvas() [3/5]

yaze::gui::ScopedCanvas::ScopedCanvas ( Canvas canvas)
inlineexplicit

Wrap existing canvas with RAII.

Definition at line 542 of file canvas.h.

References yaze::gui::Canvas::Begin(), and canvas_.

Here is the call graph for this function:

◆ ~ScopedCanvas()

yaze::gui::ScopedCanvas::~ScopedCanvas ( )
inline

Destructor automatically calls End()

Definition at line 550 of file canvas.h.

References active_, canvas_, yaze::gui::Canvas::End(), and owned_.

Here is the call graph for this function:

◆ ScopedCanvas() [4/5]

yaze::gui::ScopedCanvas::ScopedCanvas ( const ScopedCanvas )
delete

◆ ScopedCanvas() [5/5]

yaze::gui::ScopedCanvas::ScopedCanvas ( ScopedCanvas &&  other)
inlinenoexcept

Definition at line 563 of file canvas.h.

Member Function Documentation

◆ operator=()

ScopedCanvas & yaze::gui::ScopedCanvas::operator= ( const ScopedCanvas )
delete

◆ operator->() [1/2]

Canvas * yaze::gui::ScopedCanvas::operator-> ( )
inline

Arrow operator for clean syntax: scoped->DrawBitmap(...)

Definition at line 572 of file canvas.h.

References canvas_.

◆ operator->() [2/2]

const Canvas * yaze::gui::ScopedCanvas::operator-> ( ) const
inline

Definition at line 573 of file canvas.h.

References canvas_.

◆ operator*() [1/2]

Canvas & yaze::gui::ScopedCanvas::operator* ( )
inline

Dereference operator for direct access: (*scoped).DrawBitmap(...)

Definition at line 578 of file canvas.h.

References canvas_.

◆ operator*() [2/2]

const Canvas & yaze::gui::ScopedCanvas::operator* ( ) const
inline

Definition at line 579 of file canvas.h.

References canvas_.

◆ get() [1/2]

Canvas * yaze::gui::ScopedCanvas::get ( )
inline

Get underlying canvas.

Definition at line 584 of file canvas.h.

References canvas_.

◆ get() [2/2]

const Canvas * yaze::gui::ScopedCanvas::get ( ) const
inline

Definition at line 585 of file canvas.h.

References canvas_.

Member Data Documentation

◆ canvas_

Canvas* yaze::gui::ScopedCanvas::canvas_
private

◆ owned_

bool yaze::gui::ScopedCanvas::owned_
private

Definition at line 589 of file canvas.h.

Referenced by ~ScopedCanvas().

◆ active_

bool yaze::gui::ScopedCanvas::active_
private

Definition at line 590 of file canvas.h.

Referenced by ~ScopedCanvas().


The documentation for this class was generated from the following file: