Jazz2::Editor::EditorTool class

Tool used in the view of the level editor.

Derived classes

class EventTool
Places, selects, moves and erases events.
class EyedropperTool
Picks tiles of the layer as the stamp.
class GroundLineTool
Draws ground along a line, with slopes as steep as the line, and changes it later.
class HandTool
Moves the view.
class MeasureTool
Measures distances in the level and shows how far the player jumps.
class PathTool
Places the event to place along a path, at even distances — a row or an arc of coins or gems.
class SelectTool
Selects a rectangle of tiles.
class StrokeTool
Base of the tools that paint tiles.
class TilePixelTool
Paints the pixels of a tile right in the level, for the tile editor.
class WandTool
Selects an area of the same tiles.

Constructors, destructors, conversion operators

EditorTool(IToolHost& host) explicit
Creates a new instance.
~EditorTool() virtual

Public functions

auto GetType() const -> EditorToolType pure virtual
Returns the type.
void OnActivate() virtual
Called when the tool is chosen.
void OnDeactivate() virtual
Called when another tool is chosen, anything in progress is cancelled.
void OnPointerDown(const ToolPointer& pointer) virtual
Called when the pointer is pressed over the view.
void OnPointerMove(const ToolPointer& pointer) virtual
Called when the pointer moves over the view, pressed or not.
void OnPointerUp(const ToolPointer& pointer) virtual
Called when the pointer is released.
auto OnKeyPressed(const KeyboardEvent& event) -> bool virtual
Called when a key is pressed over the view, returns true if the tool takes it, no action runs by it then.
void OnKeyReleased(const KeyboardEvent& event) virtual
Called when a key is released, whatever got it when it was pressed.
void Cancel() virtual
Cancels what the tool is doing.
auto IsBusy() const -> bool virtual
Returns true if the tool is in the middle of something.
auto HasPointerCapture() const -> bool virtual
Returns true if the tool follows the pointer pressed, another tool can't be taken for a while then.
void DrawOverlay(Painter& painter, const ToolPointer& hover, bool hoverValid) virtual
Draws what the tool shows over the view.
auto GetHint() const -> StringView virtual
Returns a hint of how the tool is used.
void BuildOptions(ToolOptionsBuilder& builder) virtual
Makes the options of the tool shown in the toolbar while it's chosen, none by default.
void SetSettings(ToolSettings* settings)
Gives the tool the options shared by the tools, see ToolManager::GetSettings().

Protected static functions

static void AddStampOptions(ToolOptionsBuilder& builder)
Adds the options of the stamp to the options of a tool — flipping, turning and painting its tiles at random.
static void AddModifierOptions(ToolOptionsBuilder& builder)
Adds the options of the modifier the tiles are painted with to the options of a tool.
static void AddAreaOptions(ToolOptionsBuilder& builder)
Adds the options of finding an area of the same tiles, as the fill and the magic wand do, to the options of a tool.

Protected functions

auto GetSettings() const -> const ToolSettings&
Returns the options shared by the tools.
void DrawCellsOutline(Painter& painter, const LayerView& view, Vector2i from, Vector2i to, const Colorf& color)
Draws the outline of cells of a layer on the screen.
void DrawStampGhost(Painter& painter, const LayerView& view, const TileStamp& stamp, Vector2i cell, Vector2i anchor, float alpha, bool emptyToo = false)
Draws a stamp on the screen, its cell at the anchor at a cell of a layer.

Protected variables

IToolHost& _host
ToolSettings* _settings

Function documentation

bool Jazz2::Editor::EditorTool::HasPointerCapture() const virtual

Returns true if the tool follows the pointer pressed, another tool can't be taken for a while then.

A tool in the middle of something clicked point by point, as a path, doesn't, the hand can move the view between the clicks. It's IsBusy() by default.

void Jazz2::Editor::EditorTool::DrawStampGhost(Painter& painter, const LayerView& view, const TileStamp& stamp, Vector2i cell, Vector2i anchor, float alpha, bool emptyToo = false) protected

Draws a stamp on the screen, its cell at the anchor at a cell of a layer.

Its events are drawn too while the sprite layer is edited. Empty tiles that are transparent (see TileStamp::EmptyIsTransparent) are left out unless emptyToo, as they're painted.