2020-10-15 14:57:07 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020, Ben Jilks <benjyjilks@gmail.com>
|
2022-02-10 16:28:48 -03:00
|
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
2020-10-15 14:57:07 -03:00
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-10-15 14:57:07 -03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "ToolPropertiesWidget.h"
|
2021-09-17 04:54:55 -03:00
|
|
|
#include "Tools/Tool.h"
|
2020-10-15 14:57:07 -03:00
|
|
|
#include <LibGUI/BoxLayout.h>
|
|
|
|
|
#include <LibGUI/GroupBox.h>
|
|
|
|
|
|
2021-05-15 19:03:13 -03:00
|
|
|
REGISTER_WIDGET(PixelPaint, ToolPropertiesWidget);
|
|
|
|
|
|
2020-10-15 14:57:07 -03:00
|
|
|
namespace PixelPaint {
|
|
|
|
|
|
|
|
|
|
ToolPropertiesWidget::ToolPropertiesWidget()
|
|
|
|
|
{
|
|
|
|
|
set_layout<GUI::VerticalBoxLayout>();
|
|
|
|
|
|
2022-07-11 14:32:29 -03:00
|
|
|
m_group_box = add<GUI::GroupBox>("Tool properties"sv);
|
2020-10-15 14:57:07 -03:00
|
|
|
auto& layout = m_group_box->set_layout<GUI::VerticalBoxLayout>();
|
2021-09-15 12:56:01 -03:00
|
|
|
layout.set_margins({ 8 });
|
2021-08-06 06:57:56 -03:00
|
|
|
m_tool_widget_stack = m_group_box->add<GUI::StackWidget>();
|
|
|
|
|
m_blank_widget = m_tool_widget_stack->add<GUI::Widget>();
|
2020-10-15 14:57:07 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ToolPropertiesWidget::set_active_tool(Tool* tool)
|
|
|
|
|
{
|
|
|
|
|
if (tool == m_active_tool)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_active_tool = tool;
|
|
|
|
|
m_active_tool_widget = tool->get_properties_widget();
|
2021-08-06 06:57:56 -03:00
|
|
|
|
|
|
|
|
if (m_active_tool_widget == nullptr) {
|
|
|
|
|
m_tool_widget_stack->set_active_widget(m_blank_widget);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!m_tool_widget_stack->is_ancestor_of(*m_active_tool_widget))
|
|
|
|
|
m_tool_widget_stack->add_child(*m_active_tool_widget);
|
|
|
|
|
|
|
|
|
|
m_tool_widget_stack->set_active_widget(m_active_tool_widget);
|
2020-10-15 14:57:07 -03:00
|
|
|
}
|
|
|
|
|
}
|