Jazz2::Editor::TilePixelTool class

Paints the pixels of a tile right in the level, for the tile editor.

Every cell of the layer being edited that shows the tile is outlined, a stroke over any of them paints the pixels under the pointer — flipped as the cell shows the tile, so a pixel goes where it's seen. All the other places of the level that show the tile change with it. What is painted is up to the tile editor, see SetTarget(), the tool only finds the pixel.

Base classes

class EditorTool
Tool used in the view of the level editor.

Public types

using PaintFunction = Function<void(Vector2i, Vector2i, MouseButton, bool)>
Paints a line of pixels of the tile.

Constructors, destructors, conversion operators

TilePixelTool(IToolHost& host) explicit

Public functions

auto GetType() const -> EditorToolType override
Returns the type.
void OnPointerDown(const ToolPointer& pointer) override
Called when the pointer is pressed over the view.
void OnPointerMove(const ToolPointer& pointer) override
Called when the pointer moves over the view, pressed or not.
void OnPointerUp(const ToolPointer& pointer) override
Called when the pointer is released.
void Cancel() override
Cancels what the tool is doing.
auto IsBusy() const -> bool override
Returns true if the tool is in the middle of something.
void DrawOverlay(Painter& painter, const ToolPointer& hover, bool hoverValid) override
Draws what the tool shows over the view.
auto GetHint() const -> StringView override
Returns a hint of how the tool is used.
void SetTarget(std::int32_t tileId, PaintFunction&& paint)
Sets the tile, by its ID as the level file stores it, and what paints it, nullptr to stop.
auto GetTargetTile() const -> std::int32_t
Returns the tile painted, or -1.

Typedef documentation

using Jazz2::Editor::TilePixelTool::PaintFunction = Function<void(Vector2i, Vector2i, MouseButton, bool)>

Paints a line of pixels of the tile.

Gets the first and the last pixel of the line, the same one for a single pixel, the button and whether the stroke goes on — the first line of a stroke is a new step of the history, the others merge into it. A pointer moved fast over the same cell gives a line, so the stroke has no gaps.