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

#include <graphics_scratch_view.h>

Inheritance diagram for yaze::editor::GraphicsScratchView:

Classes

class  LibraryEdit
 

Public Member Functions

 GraphicsScratchView (GraphicsEditorState *state, UndoManager *history, std::string library_path="")
 
 ~GraphicsScratchView () override
 
std::string GetId () const override
 Unique identifier for this panel.
 
std::string GetDisplayName () const override
 Human-readable name shown in menus and title bars.
 
std::string GetIcon () const override
 Material Design icon for this panel.
 
std::string GetEditorCategory () const override
 Editor category this panel belongs to.
 
WindowPresentationPolicy GetPresentationPolicy () const override
 How this content is hosted and advertised by workspace chrome.
 
int GetPriority () const override
 Get display priority for menu ordering.
 
float GetPreferredWidth () const override
 Get preferred width for this panel (optional)
 
void Draw (bool *p_open) override
 Draw the panel content.
 
bool HasPendingChanges () const
 
bool HasActiveStroke () const
 
absl::Status Flush ()
 
void FinishGesture ()
 
absl::Status CaptureSheet ()
 
absl::Status ImportBin (const std::string &path, int bpp, size_t offset, const gfx::SnesPalette &palette={})
 
absl::Status ApplyToSheet ()
 
absl::Status ExportBin (const std::string &path)
 
absl::Status SwapColorIds (const std::vector< ScratchColorIdTarget > &targets, const ColorIdPermutation &permutation)
 
const GraphicsScratchLibrary & library () const
 
void SetAssociatedPreview (std::string label, ScratchPreviewCallback callback)
 
void SetApplyValidator (std::function< absl::Status(uint16_t)> validator)
 
void SetExportValidator (std::function< absl::Status(const std::string &)> validator)
 
- Public Member Functions inherited from yaze::editor::WindowContent
virtual ~WindowContent ()=default
 
virtual void OnFirstDraw ()
 Called once before the first Draw() in a session.
 
virtual bool RequiresLazyInit () const
 Whether this panel uses lazy initialization.
 
void InvalidateLazyInit ()
 Reset lazy init state so OnFirstDraw() runs again.
 
virtual void OnOpen ()
 Called when panel becomes visible.
 
virtual void OnClose ()
 Called when panel is hidden.
 
virtual void OnFocus ()
 Called when panel receives focus.
 
virtual WindowLifecycle GetWindowLifecycle () const
 Get the lifecycle category for this window.
 
virtual WindowContextScope GetContextScope () const
 Optional context binding for this window (room/selection/etc)
 
virtual WindowScope GetScope () const
 Get the registration scope for this window.
 
virtual bool IsEnabled () const
 Check if this panel is currently enabled.
 
virtual std::string GetDisabledTooltip () const
 Get tooltip text when panel is disabled.
 
virtual std::string GetShortcutHint () const
 Get keyboard shortcut hint for display.
 
virtual std::string GetWorkflowGroup () const
 Optional workflow group for hack-centric actions.
 
virtual std::string GetWorkflowLabel () const
 Optional workflow label for menus/command palette.
 
virtual std::string GetWorkflowDescription () const
 Optional workflow description for menus/command palette.
 
virtual int GetWorkflowPriority () const
 Optional workflow ordering priority (lower sorts first).
 
virtual bool HasExactPreferredWidth () const
 Whether GetPreferredWidth() is an exact content width.
 
virtual float GetPreferredHeight () const
 Get preferred height for this panel (optional)
 
virtual bool PrefersFloating () const
 
virtual bool PreferAutoHideTabBar () const
 Whether the dock node hosting this panel should auto-hide its tab bar.
 
virtual bool IsVisibleByDefault () const
 Whether this panel should be visible by default.
 
virtual std::string GetParentPanelId () const
 Get parent panel ID for cascade behavior.
 
virtual bool CascadeCloseChildren () const
 Whether closing this panel should close child panels.
 
void DrawWithLazyInit (bool *p_open)
 Execute lazy initialization if needed, then call Draw()
 

Private Member Functions

void Load ()
 
absl::Status Record (GraphicsScratchLibrary before)
 
absl::Status PrepareCommand ()
 
void RefreshPublishedBaselines ()
 
void SetStatus (absl::Status status)
 
void DrawPixels (GraphicsScratchAsset &asset)
 
void DrawColorIdSwap (const GraphicsScratchAsset &selected)
 
void DrawAssociatedPreview ()
 
GraphicsScratchAsset * Selected ()
 

Private Attributes

GraphicsEditorState * state_
 
UndoManager * history_
 
GraphicsScratchLibrary library_
 
std::optional< GraphicsScratchLibrary > stroke_
 
uint64_t selected_id_ = 0
 
std::string path_
 
std::string loaded_bytes_
 
bool existed_ = false
 
bool load_ok_ = false
 
bool dirty_ = false
 
std::string error_
 
std::string asset_name_ = "Untitled sheet"
 
std::string bin_path_
 
int bpp_ = 4
 
int bin_offset_ = 0
 
int color_ = 1
 
int swap_from_id_ = 1
 
int swap_to_id_ = 2
 
bool swap_all_at_depth_ = false
 
float zoom_ = 4
 
std::function< absl::Status(uint16_t)> apply_validator_
 
std::function< absl::Status(const std::string &) export_validator_ )
 
ScratchPreviewCallback preview_callback_
 
std::string preview_label_
 
std::string preview_error_
 
uint64_t preview_asset_id_ = 0
 
std::optional< uint64_t > preview_hash_
 
gfx::Bitmap preview_bitmap_
 
gui::Canvas preview_canvas_
 
std::map< std::tuple< std::string, uint64_t, int >, std::vector< uint8_t > > published_chunks_
 

Friends

struct GraphicsScratchBinTestPeer
 
struct ScratchSpritePreviewTestPeer
 

Additional Inherited Members

- Protected Member Functions inherited from yaze::editor::WindowContent
void InvalidateCache ()
 Invalidate all cached computations.
 
template<typename T >
T & GetCached (const std::string &key, std::function< T()> compute)
 Get or compute a cached value.
 
bool IsCacheValid () const
 Check if cache has been invalidated.
 
void ClearCache ()
 Clear all cached values (more aggressive than InvalidateCache)
 

Detailed Description

Definition at line 25 of file graphics_scratch_view.h.

Constructor & Destructor Documentation

◆ GraphicsScratchView()

yaze::editor::GraphicsScratchView::GraphicsScratchView ( GraphicsEditorState * state,
UndoManager * history,
std::string library_path = "" )

Definition at line 59 of file graphics_scratch_view.cc.

References Load().

Here is the call graph for this function:

◆ ~GraphicsScratchView()

yaze::editor::GraphicsScratchView::~GraphicsScratchView ( )
override

Definition at line 66 of file graphics_scratch_view.cc.

References yaze::gfx::Arena::Get(), preview_bitmap_, and yaze::gfx::Arena::RetireBitmap().

Here is the call graph for this function:

Member Function Documentation

◆ GetId()

std::string yaze::editor::GraphicsScratchView::GetId ( ) const
inlineoverridevirtual

Unique identifier for this panel.

Returns
Panel ID in format "{category}.{name}" (e.g., "dungeon.room_selector")

IDs should be:

  • Lowercase with underscores
  • Prefixed with editor category
  • Unique across all panels

Implements yaze::editor::WindowContent.

Definition at line 33 of file graphics_scratch_view.h.

◆ GetDisplayName()

std::string yaze::editor::GraphicsScratchView::GetDisplayName ( ) const
inlineoverridevirtual

Human-readable name shown in menus and title bars.

Returns
Display name (e.g., "Room Selector")

Implements yaze::editor::WindowContent.

Definition at line 34 of file graphics_scratch_view.h.

◆ GetIcon()

std::string yaze::editor::GraphicsScratchView::GetIcon ( ) const
inlineoverridevirtual

Material Design icon for this panel.

Returns
Icon constant (e.g., ICON_MD_LIST)

Implements yaze::editor::WindowContent.

Definition at line 35 of file graphics_scratch_view.h.

References ICON_MD_BRUSH.

◆ GetEditorCategory()

std::string yaze::editor::GraphicsScratchView::GetEditorCategory ( ) const
inlineoverridevirtual

Editor category this panel belongs to.

Returns
Category name matching EditorType (e.g., "Dungeon", "Overworld")

Implements yaze::editor::WindowContent.

Definition at line 36 of file graphics_scratch_view.h.

◆ GetPresentationPolicy()

WindowPresentationPolicy yaze::editor::GraphicsScratchView::GetPresentationPolicy ( ) const
inlineoverridevirtual

How this content is hosted and advertised by workspace chrome.

Every panel must override this and return one of the named policies (CoreWorkspace, EmbeddedTool, OptionalPopOut, Diagnostic). The base implementation returns an undeclared policy that keeps the historical listed pop-out behavior, but the panel admission audit (test/unit/editor/panel_admission_test.cc) fails until the panel chooses. See docs/internal/architecture/editor-ui-module-pattern.md, "Panel admission".

Reimplemented from yaze::editor::WindowContent.

Definition at line 37 of file graphics_scratch_view.h.

References yaze::editor::WindowPresentationPolicy::OptionalPopOut().

Here is the call graph for this function:

◆ GetPriority()

int yaze::editor::GraphicsScratchView::GetPriority ( ) const
inlineoverridevirtual

Get display priority for menu ordering.

Returns
Priority value (lower = higher in list, default 50)

Reimplemented from yaze::editor::WindowContent.

Definition at line 40 of file graphics_scratch_view.h.

◆ GetPreferredWidth()

float yaze::editor::GraphicsScratchView::GetPreferredWidth ( ) const
inlineoverridevirtual

Get preferred width for this panel (optional)

Returns
Preferred width in pixels, or 0 to use default (250px)

Override this to specify content-based sizing. For example, a tile selector with 8 tiles at 16px × 2.0 scale would return ~276px.

Reimplemented from yaze::editor::WindowContent.

Definition at line 41 of file graphics_scratch_view.h.

◆ Draw()

void yaze::editor::GraphicsScratchView::Draw ( bool * p_open)
overridevirtual

◆ HasPendingChanges()

bool yaze::editor::GraphicsScratchView::HasPendingChanges ( ) const
inline

Definition at line 43 of file graphics_scratch_view.h.

References dirty_, and stroke_.

◆ HasActiveStroke()

bool yaze::editor::GraphicsScratchView::HasActiveStroke ( ) const
inline

Definition at line 44 of file graphics_scratch_view.h.

References stroke_.

◆ Flush()

absl::Status yaze::editor::GraphicsScratchView::Flush ( )

Definition at line 107 of file graphics_scratch_view.cc.

References ASSIGN_OR_RETURN, dirty_, existed_, library_, load_ok_, loaded_bytes_, path_, yaze::editor::graphics_scratch_storage::SaveLibrary(), and stroke_.

Referenced by Draw(), ExportBin(), and Record().

Here is the call graph for this function:

◆ FinishGesture()

void yaze::editor::GraphicsScratchView::FinishGesture ( )

Definition at line 141 of file graphics_scratch_view.cc.

References Record(), and stroke_.

Referenced by Draw(), and PrepareCommand().

Here is the call graph for this function:

◆ CaptureSheet()

◆ ImportBin()

absl::Status yaze::editor::GraphicsScratchView::ImportBin ( const std::string & path,
int bpp,
size_t offset,
const gfx::SnesPalette & palette = {} )

◆ ApplyToSheet()

◆ ExportBin()

absl::Status yaze::editor::GraphicsScratchView::ExportBin ( const std::string & path)

◆ SwapColorIds()

absl::Status yaze::editor::GraphicsScratchView::SwapColorIds ( const std::vector< ScratchColorIdTarget > & targets,
const ColorIdPermutation & permutation )

◆ library()

const GraphicsScratchLibrary & yaze::editor::GraphicsScratchView::library ( ) const
inline

Definition at line 56 of file graphics_scratch_view.h.

References library_.

Referenced by yaze::editor::GraphicsScratchView::LibraryEdit::Restore().

◆ SetAssociatedPreview()

void yaze::editor::GraphicsScratchView::SetAssociatedPreview ( std::string label,
ScratchPreviewCallback callback )

◆ SetApplyValidator()

void yaze::editor::GraphicsScratchView::SetApplyValidator ( std::function< absl::Status(uint16_t)> validator)
inline

Definition at line 60 of file graphics_scratch_view.h.

References apply_validator_.

◆ SetExportValidator()

void yaze::editor::GraphicsScratchView::SetExportValidator ( std::function< absl::Status(const std::string &)> validator)
inline

Definition at line 63 of file graphics_scratch_view.h.

References export_validator_.

◆ Load()

void yaze::editor::GraphicsScratchView::Load ( )
private

◆ Record()

absl::Status yaze::editor::GraphicsScratchView::Record ( GraphicsScratchLibrary before)
private

Definition at line 132 of file graphics_scratch_view.cc.

References dirty_, Flush(), history_, library_, yaze::editor::UndoManager::Push(), and SetStatus().

Referenced by CaptureSheet(), Draw(), FinishGesture(), ImportBin(), and SwapColorIds().

Here is the call graph for this function:

◆ PrepareCommand()

absl::Status yaze::editor::GraphicsScratchView::PrepareCommand ( )
private

Definition at line 149 of file graphics_scratch_view.cc.

References FinishGesture(), and stroke_.

Referenced by ApplyToSheet(), CaptureSheet(), ExportBin(), ImportBin(), and SwapColorIds().

Here is the call graph for this function:

◆ RefreshPublishedBaselines()

void yaze::editor::GraphicsScratchView::RefreshPublishedBaselines ( )
private

◆ SetStatus()

void yaze::editor::GraphicsScratchView::SetStatus ( absl::Status status)
private

Definition at line 103 of file graphics_scratch_view.cc.

References error_.

Referenced by Draw(), DrawColorIdSwap(), Load(), and Record().

◆ DrawPixels()

void yaze::editor::GraphicsScratchView::DrawPixels ( GraphicsScratchAsset & asset)
private

◆ DrawColorIdSwap()

◆ DrawAssociatedPreview()

◆ Selected()

GraphicsScratchAsset * yaze::editor::GraphicsScratchView::Selected ( )
private

Friends And Related Symbol Documentation

◆ GraphicsScratchBinTestPeer

friend struct GraphicsScratchBinTestPeer
friend

Definition at line 26 of file graphics_scratch_view.h.

◆ ScratchSpritePreviewTestPeer

friend struct ScratchSpritePreviewTestPeer
friend

Definition at line 27 of file graphics_scratch_view.h.

Member Data Documentation

◆ state_

GraphicsEditorState* yaze::editor::GraphicsScratchView::state_
private

Definition at line 79 of file graphics_scratch_view.h.

Referenced by ApplyToSheet(), and CaptureSheet().

◆ history_

UndoManager* yaze::editor::GraphicsScratchView::history_
private

Definition at line 80 of file graphics_scratch_view.h.

Referenced by ApplyToSheet(), and Record().

◆ library_

◆ stroke_

std::optional<GraphicsScratchLibrary> yaze::editor::GraphicsScratchView::stroke_
private

◆ selected_id_

uint64_t yaze::editor::GraphicsScratchView::selected_id_ = 0
private

Definition at line 83 of file graphics_scratch_view.h.

Referenced by CaptureSheet(), Draw(), ImportBin(), Load(), and Selected().

◆ path_

std::string yaze::editor::GraphicsScratchView::path_
private

Definition at line 84 of file graphics_scratch_view.h.

Referenced by Draw(), ExportBin(), Flush(), and Load().

◆ loaded_bytes_

std::string yaze::editor::GraphicsScratchView::loaded_bytes_
private

Definition at line 85 of file graphics_scratch_view.h.

Referenced by Flush(), and Load().

◆ existed_

bool yaze::editor::GraphicsScratchView::existed_ = false
private

Definition at line 86 of file graphics_scratch_view.h.

Referenced by Flush(), and Load().

◆ load_ok_

bool yaze::editor::GraphicsScratchView::load_ok_ = false
private

Definition at line 87 of file graphics_scratch_view.h.

Referenced by CaptureSheet(), Draw(), Flush(), ImportBin(), Load(), and SwapColorIds().

◆ dirty_

bool yaze::editor::GraphicsScratchView::dirty_ = false
private

◆ error_

std::string yaze::editor::GraphicsScratchView::error_
private

Definition at line 89 of file graphics_scratch_view.h.

Referenced by Draw(), and SetStatus().

◆ asset_name_

std::string yaze::editor::GraphicsScratchView::asset_name_ = "Untitled sheet"
private

Definition at line 90 of file graphics_scratch_view.h.

Referenced by CaptureSheet(), Draw(), and ImportBin().

◆ bin_path_

std::string yaze::editor::GraphicsScratchView::bin_path_
private

Definition at line 91 of file graphics_scratch_view.h.

Referenced by Draw().

◆ bpp_

int yaze::editor::GraphicsScratchView::bpp_ = 4
private

Definition at line 92 of file graphics_scratch_view.h.

Referenced by CaptureSheet(), and Draw().

◆ bin_offset_

int yaze::editor::GraphicsScratchView::bin_offset_ = 0
private

Definition at line 93 of file graphics_scratch_view.h.

Referenced by Draw().

◆ color_

int yaze::editor::GraphicsScratchView::color_ = 1
private

Definition at line 94 of file graphics_scratch_view.h.

Referenced by DrawPixels().

◆ swap_from_id_

int yaze::editor::GraphicsScratchView::swap_from_id_ = 1
private

Definition at line 95 of file graphics_scratch_view.h.

Referenced by DrawColorIdSwap().

◆ swap_to_id_

int yaze::editor::GraphicsScratchView::swap_to_id_ = 2
private

Definition at line 96 of file graphics_scratch_view.h.

Referenced by DrawColorIdSwap().

◆ swap_all_at_depth_

bool yaze::editor::GraphicsScratchView::swap_all_at_depth_ = false
private

Definition at line 97 of file graphics_scratch_view.h.

Referenced by DrawColorIdSwap().

◆ zoom_

float yaze::editor::GraphicsScratchView::zoom_ = 4
private

Definition at line 98 of file graphics_scratch_view.h.

Referenced by DrawPixels().

◆ apply_validator_

std::function<absl::Status(uint16_t)> yaze::editor::GraphicsScratchView::apply_validator_
private

Definition at line 99 of file graphics_scratch_view.h.

Referenced by ApplyToSheet(), and SetApplyValidator().

◆ export_validator_

std::function<absl::Status(const std::string&) yaze::editor::GraphicsScratchView::export_validator_)
private

Definition at line 100 of file graphics_scratch_view.h.

Referenced by ExportBin(), and SetExportValidator().

◆ preview_callback_

ScratchPreviewCallback yaze::editor::GraphicsScratchView::preview_callback_
private

Definition at line 101 of file graphics_scratch_view.h.

Referenced by DrawAssociatedPreview(), and SetAssociatedPreview().

◆ preview_label_

std::string yaze::editor::GraphicsScratchView::preview_label_
private

Definition at line 102 of file graphics_scratch_view.h.

Referenced by DrawAssociatedPreview(), and SetAssociatedPreview().

◆ preview_error_

std::string yaze::editor::GraphicsScratchView::preview_error_
private

Definition at line 103 of file graphics_scratch_view.h.

Referenced by DrawAssociatedPreview(), and SetAssociatedPreview().

◆ preview_asset_id_

uint64_t yaze::editor::GraphicsScratchView::preview_asset_id_ = 0
private

Definition at line 104 of file graphics_scratch_view.h.

Referenced by DrawAssociatedPreview(), and SetAssociatedPreview().

◆ preview_hash_

std::optional<uint64_t> yaze::editor::GraphicsScratchView::preview_hash_
private

Definition at line 105 of file graphics_scratch_view.h.

Referenced by DrawAssociatedPreview(), and SetAssociatedPreview().

◆ preview_bitmap_

gfx::Bitmap yaze::editor::GraphicsScratchView::preview_bitmap_
private

◆ preview_canvas_

gui::Canvas yaze::editor::GraphicsScratchView::preview_canvas_
private
Initial value:
{"ScratchSourcePreview", ImVec2(256, 256),

Definition at line 107 of file graphics_scratch_view.h.

Referenced by DrawAssociatedPreview().

◆ published_chunks_

std::map<std::tuple<std::string, uint64_t, int>, std::vector<uint8_t> > yaze::editor::GraphicsScratchView::published_chunks_
private

Definition at line 112 of file graphics_scratch_view.h.

Referenced by ExportBin(), and RefreshPublishedBaselines().


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