1// Aseprite
2// Copyright (C) 2019-2021 Igara Studio S.A.
3// Copyright (C) 2001-2017 David Capello
4//
5// This program is distributed under the terms of
6// the End-User License Agreement for Aseprite.
7
8#ifndef APP_UI_EDITOR_TOOL_LOOP_IMPL_H_INCLUDED
9#define APP_UI_EDITOR_TOOL_LOOP_IMPL_H_INCLUDED
10#pragma once
11
12#include "app/color.h"
13#include "app/tools/freehand_algorithm.h"
14#include "app/tools/ink_type.h"
15#include "app/tools/pointer.h"
16#include "app/tools/tool_loop.h"
17#include "doc/brush.h"
18#include "doc/image_ref.h"
19#include "gfx/fwd.h"
20
21namespace doc {
22 class Image;
23}
24
25namespace app {
26 class Color;
27 class Context;
28 class Editor;
29 class Site;
30
31 struct ToolLoopParams {
32 tools::Tool* tool = nullptr;
33 tools::Ink* ink = nullptr;
34 tools::Controller* controller = nullptr;
35
36 tools::ToolLoop::Button button = tools::ToolLoop::Left;
37 tools::InkType inkType = tools::InkType::DEFAULT;
38 app::Color fg;
39 app::Color bg;
40 doc::BrushRef brush;
41
42 // Options equal to (and with the same default as in)
43 // <preferences><tool>...</tool></preferences> from
44 // "data/pref.xml" file.
45 int opacity = 255;
46 int tolerance = 0;
47 bool contiguous = true;
48 tools::FreehandAlgorithm freehandAlgorithm = tools::FreehandAlgorithm::DEFAULT;
49
50 // For selection tools executed from scripts
51 tools::ToolLoopModifiers modifiers = tools::ToolLoopModifiers::kNone;
52 };
53
54 //////////////////////////////////////////////////////////////////////
55 // For UI
56
57#ifdef ENABLE_UI
58
59 tools::ToolLoop* create_tool_loop(
60 Editor* editor,
61 Context* context,
62 const tools::Pointer::Button button,
63 const bool convertLineToFreehand,
64 const bool selectTiles);
65
66 tools::ToolLoop* create_tool_loop_preview(
67 Editor* editor,
68 const doc::BrushRef& brush,
69 doc::Image* image,
70 const gfx::Point& celOrigin);
71
72#endif // ENABLE_UI
73
74 //////////////////////////////////////////////////////////////////////
75 // For scripting
76
77#ifdef ENABLE_SCRIPTING
78
79 tools::ToolLoop* create_tool_loop_for_script(
80 Context* context,
81 const Site& site,
82 ToolLoopParams& params);
83
84#endif // ENABLE_SCRIPTING
85
86} // namespace app
87
88#endif
89