2020-10-15 14:57:07 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020, Ben Jilks <benjyjilks@gmail.com>
|
|
|
|
|
*
|
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>();
|
|
|
|
|
|
|
|
|
|
m_group_box = add<GUI::GroupBox>("Tool properties");
|
|
|
|
|
auto& layout = m_group_box->set_layout<GUI::VerticalBoxLayout>();
|
Userland+LibGUI: Add shorthand versions of the Margins constructor
This allows for typing [8] instead of [8, 8, 8, 8] to specify the same
margin on all edges, for example. The constructors follow CSS' style of
specifying margins. The added constructors are:
- Margins(int all): Sets the same margin on all edges.
- Margins(int vertical, int horizontal): Sets the first argument to top
and bottom margins, and the second argument to left and right margins.
- Margins(int top, int vertical, int bottom): Sets the first argument to
the top margin, the second argument to the left and right margins,
and the third argument to the bottom margin.
2021-08-16 21:11:38 -03:00
|
|
|
layout.set_margins({ 20, 10, 10 });
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolPropertiesWidget::~ToolPropertiesWidget()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|