#include <graphics_scratch_view.h>

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) | |
Definition at line 25 of file graphics_scratch_view.h.
| yaze::editor::GraphicsScratchView::GraphicsScratchView | ( | GraphicsEditorState * | state, |
| UndoManager * | history, | ||
| std::string | library_path = "" ) |
Definition at line 59 of file graphics_scratch_view.cc.
References Load().

|
override |
Definition at line 66 of file graphics_scratch_view.cc.
References yaze::gfx::Arena::Get(), preview_bitmap_, and yaze::gfx::Arena::RetireBitmap().

|
inlineoverridevirtual |
Unique identifier for this panel.
IDs should be:
Implements yaze::editor::WindowContent.
Definition at line 33 of file graphics_scratch_view.h.
|
inlineoverridevirtual |
Human-readable name shown in menus and title bars.
Implements yaze::editor::WindowContent.
Definition at line 34 of file graphics_scratch_view.h.
|
inlineoverridevirtual |
Material Design icon for this panel.
Implements yaze::editor::WindowContent.
Definition at line 35 of file graphics_scratch_view.h.
References ICON_MD_BRUSH.
|
inlineoverridevirtual |
Editor category this panel belongs to.
Implements yaze::editor::WindowContent.
Definition at line 36 of file graphics_scratch_view.h.
|
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().

|
inlineoverridevirtual |
Get display priority for menu ordering.
Reimplemented from yaze::editor::WindowContent.
Definition at line 40 of file graphics_scratch_view.h.
|
inlineoverridevirtual |
Get preferred width for this panel (optional)
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.
|
overridevirtual |
Draw the panel content.
| p_open | Pointer to visibility flag (nullptr if not closable) |
Called by WorkspaceWindowManager when the panel is visible. Do NOT call ImGui::Begin/End - the PanelWindow wrapper handles that. Just draw your content directly.
Implements yaze::editor::WindowContent.
Definition at line 455 of file graphics_scratch_view.cc.
References yaze::editor::GraphicsScratchLibrary::Add(), ApplyToSheet(), asset_name_, yaze::editor::GraphicsScratchLibrary::assets, bin_offset_, bin_path_, yaze::editor::GraphicsScratchAsset::bpp, bpp_, CaptureSheet(), DrawAssociatedPreview(), DrawColorIdSwap(), DrawPixels(), error_, ExportBin(), FinishGesture(), Flush(), ImportBin(), library_, load_ok_, yaze::editor::GraphicsScratchAsset::name, path_, Record(), Selected(), selected_id_, SetStatus(), yaze::util::FileDialogWrapper::ShowOpenFileDialog(), yaze::util::FileDialogWrapper::ShowSaveFileDialog(), and stroke_.
|
inline |
Definition at line 43 of file graphics_scratch_view.h.
|
inline |
Definition at line 44 of file graphics_scratch_view.h.
References stroke_.
| 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().

| void yaze::editor::GraphicsScratchView::FinishGesture | ( | ) |
Definition at line 141 of file graphics_scratch_view.cc.
References Record(), and stroke_.
Referenced by Draw(), and PrepareCommand().

| absl::Status yaze::editor::GraphicsScratchView::CaptureSheet | ( | ) |
Definition at line 166 of file graphics_scratch_view.cc.
References yaze::editor::ActiveSheetStore(), yaze::editor::GraphicsScratchLibrary::Add(), asset_name_, yaze::editor::GraphicsScratchLibrary::assets, yaze::editor::GraphicsScratchAsset::bpp, bpp_, yaze::editor::GraphicsEditorState::current_sheet_id, yaze::gfx::Arena::Get(), yaze::platform::GetSurfacePalette(), yaze::gfx::Arena::gfx_sheets(), library_, load_ok_, yaze::editor::GraphicsScratchAsset::name, yaze::editor::GraphicsScratchAsset::palette, yaze::editor::GraphicsScratchAsset::pixels, PrepareCommand(), Record(), RETURN_IF_ERROR, selected_id_, yaze::editor::GraphicsScratchAsset::source, yaze::editor::GraphicsEditorState::SourceTarget(), and state_.
Referenced by Draw().
| absl::Status yaze::editor::GraphicsScratchView::ImportBin | ( | const std::string & | path, |
| int | bpp, | ||
| size_t | offset, | ||
| const gfx::SnesPalette & | palette = {} ) |
Definition at line 200 of file graphics_scratch_view.cc.
References yaze::editor::GraphicsScratchLibrary::Add(), asset_name_, yaze::editor::GraphicsScratchLibrary::assets, ASSIGN_OR_RETURN, yaze::editor::graphics_scratch_storage::ImportBin(), library_, load_ok_, PrepareCommand(), Record(), RETURN_IF_ERROR, selected_id_, and yaze::gfx::SnesPalette::size().
Referenced by Draw().
| absl::Status yaze::editor::GraphicsScratchView::ApplyToSheet | ( | ) |
Definition at line 220 of file graphics_scratch_view.cc.
References yaze::editor::ActiveSheetStore(), apply_validator_, yaze::editor::CommitSheetPixels(), yaze::editor::GraphicsEditorState::current_sheet_id, yaze::zelda3::GetGfxSheetStorageKind(), history_, yaze::zelda3::kCompressed2bpp, yaze::editor::MakeSheetPixelDiff(), PrepareCommand(), yaze::editor::UndoManager::Push(), RETURN_IF_ERROR, Selected(), and state_.
Referenced by Draw().
| absl::Status yaze::editor::GraphicsScratchView::ExportBin | ( | const std::string & | path | ) |
Definition at line 253 of file graphics_scratch_view.cc.
References ASSIGN_OR_RETURN, dirty_, export_validator_, yaze::editor::graphics_scratch_storage::ExportBin(), Flush(), path_, PrepareCommand(), published_chunks_, RefreshPublishedBaselines(), RETURN_IF_ERROR, and Selected().
Referenced by Draw().
| absl::Status yaze::editor::GraphicsScratchView::SwapColorIds | ( | const std::vector< ScratchColorIdTarget > & | targets, |
| const ColorIdPermutation & | permutation ) |
Definition at line 275 of file graphics_scratch_view.cc.
References yaze::editor::ApplyScratchColorIdPlan(), ASSIGN_OR_RETURN, library_, load_ok_, yaze::editor::PlanScratchColorIdPermutation(), PrepareCommand(), Record(), and RETURN_IF_ERROR.
Referenced by DrawColorIdSwap().

|
inline |
Definition at line 56 of file graphics_scratch_view.h.
References library_.
Referenced by yaze::editor::GraphicsScratchView::LibraryEdit::Restore().
| void yaze::editor::GraphicsScratchView::SetAssociatedPreview | ( | std::string | label, |
| ScratchPreviewCallback | callback ) |
Definition at line 70 of file graphics_scratch_view.cc.
References yaze::gfx::Arena::Get(), preview_asset_id_, preview_bitmap_, preview_callback_, preview_error_, preview_hash_, preview_label_, yaze::gfx::Arena::RetireBitmap(), and Selected().

|
inline |
Definition at line 60 of file graphics_scratch_view.h.
References apply_validator_.
|
inline |
Definition at line 63 of file graphics_scratch_view.h.
References export_validator_.
|
private |
Definition at line 81 of file graphics_scratch_view.cc.
References yaze::editor::GraphicsScratchLibrary::assets, existed_, yaze::util::PlatformPaths::GetConfigDirectory(), library_, load_ok_, loaded_bytes_, yaze::editor::graphics_scratch_storage::LoadLibrary(), path_, selected_id_, and SetStatus().
Referenced by GraphicsScratchView().

|
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().

|
private |
Definition at line 149 of file graphics_scratch_view.cc.
References FinishGesture(), and stroke_.
Referenced by ApplyToSheet(), CaptureSheet(), ExportBin(), ImportBin(), and SwapColorIds().

|
private |
Definition at line 157 of file graphics_scratch_view.cc.
References yaze::editor::GraphicsScratchLibrary::assets, library_, and published_chunks_.
Referenced by ExportBin(), and yaze::editor::GraphicsScratchView::LibraryEdit::Restore().
|
private |
Definition at line 103 of file graphics_scratch_view.cc.
References error_.
Referenced by Draw(), DrawColorIdSwap(), Load(), and Record().
|
private |
Definition at line 331 of file graphics_scratch_view.cc.
References yaze::gui::AutoRegisterLastItem(), yaze::editor::GraphicsScratchAsset::bpp, color_, library_, yaze::editor::GraphicsScratchAsset::palette, yaze::editor::GraphicsScratchAsset::pixels, stroke_, and zoom_.
Referenced by Draw().

|
private |
Definition at line 292 of file graphics_scratch_view.cc.
References yaze::editor::GraphicsScratchLibrary::assets, yaze::gui::AutoRegisterLastItem(), yaze::editor::GraphicsScratchAsset::bpp, yaze::editor::GraphicsScratchAsset::id, library_, yaze::editor::MakeColorIdSwap(), SetStatus(), stroke_, swap_all_at_depth_, swap_from_id_, swap_to_id_, SwapColorIds(), and yaze::editor::WholeScratchAssetSelection().
Referenced by Draw().
|
private |
Definition at line 377 of file graphics_scratch_view.cc.
References yaze::gui::BeginCanvas(), yaze::gui::BeginChildWithScrollbar(), yaze::gui::CanvasFrameOptions::canvas_size, yaze::gfx::Bitmap::Create(), yaze::gfx::Arena::CREATE, yaze::gfx::Bitmap::depth(), yaze::gui::CanvasFrameOptions::draw_context_menu, yaze::gui::CanvasFrameOptions::draw_grid, yaze::gui::CanvasFrameOptions::draw_overlay, yaze::gui::Canvas::DrawBitmap(), yaze::gui::EndCanvas(), yaze::gfx::Arena::Get(), yaze::gfx::Bitmap::height(), yaze::gfx::Bitmap::is_active(), yaze::editor::usage_preview::PreviewImage::kIndexed, yaze::gfx::Bitmap::kPreview, yaze::gfx::Bitmap::metadata(), preview_asset_id_, preview_bitmap_, preview_callback_, preview_canvas_, preview_error_, preview_hash_, preview_label_, yaze::gfx::Bitmap::BitmapMetadata::purpose, yaze::gfx::Arena::QueueTextureCommand(), yaze::gui::CanvasFrameOptions::render_popups, Selected(), yaze::gfx::Bitmap::set_data(), yaze::gfx::Bitmap::SetPalette(), yaze::gfx::Arena::UPDATE, yaze::gui::CanvasFrameOptions::use_child_window, and yaze::gfx::Bitmap::width().
Referenced by Draw().
|
private |
Definition at line 125 of file graphics_scratch_view.cc.
References yaze::editor::GraphicsScratchLibrary::assets, library_, and selected_id_.
Referenced by ApplyToSheet(), Draw(), DrawAssociatedPreview(), ExportBin(), and SetAssociatedPreview().
|
friend |
Definition at line 26 of file graphics_scratch_view.h.
|
friend |
Definition at line 27 of file graphics_scratch_view.h.
|
private |
Definition at line 79 of file graphics_scratch_view.h.
Referenced by ApplyToSheet(), and CaptureSheet().
|
private |
Definition at line 80 of file graphics_scratch_view.h.
Referenced by ApplyToSheet(), and Record().
|
private |
Definition at line 81 of file graphics_scratch_view.h.
Referenced by CaptureSheet(), Draw(), DrawColorIdSwap(), DrawPixels(), Flush(), ImportBin(), library(), Load(), Record(), RefreshPublishedBaselines(), yaze::editor::GraphicsScratchView::LibraryEdit::Restore(), Selected(), and SwapColorIds().
|
private |
Definition at line 82 of file graphics_scratch_view.h.
Referenced by Draw(), DrawColorIdSwap(), DrawPixels(), FinishGesture(), Flush(), HasActiveStroke(), HasPendingChanges(), and PrepareCommand().
|
private |
Definition at line 83 of file graphics_scratch_view.h.
Referenced by CaptureSheet(), Draw(), ImportBin(), Load(), and Selected().
|
private |
Definition at line 84 of file graphics_scratch_view.h.
Referenced by Draw(), ExportBin(), Flush(), and Load().
|
private |
Definition at line 85 of file graphics_scratch_view.h.
|
private |
Definition at line 86 of file graphics_scratch_view.h.
|
private |
Definition at line 87 of file graphics_scratch_view.h.
Referenced by CaptureSheet(), Draw(), Flush(), ImportBin(), Load(), and SwapColorIds().
|
private |
Definition at line 88 of file graphics_scratch_view.h.
Referenced by ExportBin(), Flush(), HasPendingChanges(), Record(), and yaze::editor::GraphicsScratchView::LibraryEdit::Restore().
|
private |
Definition at line 89 of file graphics_scratch_view.h.
Referenced by Draw(), and SetStatus().
|
private |
Definition at line 90 of file graphics_scratch_view.h.
Referenced by CaptureSheet(), Draw(), and ImportBin().
|
private |
Definition at line 91 of file graphics_scratch_view.h.
Referenced by Draw().
|
private |
Definition at line 92 of file graphics_scratch_view.h.
Referenced by CaptureSheet(), and Draw().
|
private |
Definition at line 93 of file graphics_scratch_view.h.
Referenced by Draw().
|
private |
Definition at line 94 of file graphics_scratch_view.h.
Referenced by DrawPixels().
|
private |
Definition at line 95 of file graphics_scratch_view.h.
Referenced by DrawColorIdSwap().
|
private |
Definition at line 96 of file graphics_scratch_view.h.
Referenced by DrawColorIdSwap().
|
private |
Definition at line 97 of file graphics_scratch_view.h.
Referenced by DrawColorIdSwap().
|
private |
Definition at line 98 of file graphics_scratch_view.h.
Referenced by DrawPixels().
|
private |
Definition at line 99 of file graphics_scratch_view.h.
Referenced by ApplyToSheet(), and SetApplyValidator().
|
private |
Definition at line 100 of file graphics_scratch_view.h.
Referenced by ExportBin(), and SetExportValidator().
|
private |
Definition at line 101 of file graphics_scratch_view.h.
Referenced by DrawAssociatedPreview(), and SetAssociatedPreview().
|
private |
Definition at line 102 of file graphics_scratch_view.h.
Referenced by DrawAssociatedPreview(), and SetAssociatedPreview().
|
private |
Definition at line 103 of file graphics_scratch_view.h.
Referenced by DrawAssociatedPreview(), and SetAssociatedPreview().
|
private |
Definition at line 104 of file graphics_scratch_view.h.
Referenced by DrawAssociatedPreview(), and SetAssociatedPreview().
|
private |
Definition at line 105 of file graphics_scratch_view.h.
Referenced by DrawAssociatedPreview(), and SetAssociatedPreview().
|
private |
Definition at line 106 of file graphics_scratch_view.h.
Referenced by DrawAssociatedPreview(), SetAssociatedPreview(), and ~GraphicsScratchView().
|
private |
Definition at line 107 of file graphics_scratch_view.h.
Referenced by DrawAssociatedPreview().
|
private |
Definition at line 112 of file graphics_scratch_view.h.
Referenced by ExportBin(), and RefreshPublishedBaselines().