summaryrefslogtreecommitdiff
path: root/Userland/Applications/PixelPaint/ToolboxWidget.h
blob: c4de0ffa778557634ec64ff27e1ef64f3d37ab46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
 * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/NonnullOwnPtrVector.h>
#include <LibGUI/ActionGroup.h>
#include <LibGUI/Widget.h>

namespace PixelPaint {

class Tool;

class ToolboxWidget final : public GUI::Widget {
    C_OBJECT(ToolboxWidget);

public:
    virtual ~ToolboxWidget() override;

    Function<void(Tool*)> on_tool_selection;

    template<typename Callback>
    void for_each_tool(Callback callback)
    {
        for (auto& tool : m_tools)
            callback(tool);
    }

private:
    friend class ToolButton;

    void setup_tools();

    explicit ToolboxWidget();
    RefPtr<GUI::Toolbar> m_toolbar;
    GUI::ActionGroup m_action_group;
    NonnullOwnPtrVector<Tool> m_tools;
};

}