Adding flatten/blur secondary toolbar
This commit is contained in:
@@ -2202,7 +2202,7 @@ void MapView::setupHotkeys()
|
||||
, MOD_space
|
||||
, [&]
|
||||
{
|
||||
flattenTool->nextFlattenMode();
|
||||
_left_sec_toolbar->nextFlattenMode(this);
|
||||
}
|
||||
, [&] { return terrainMode == editing_mode::flatten_blur && !NOGGIT_CUR_ACTION; }
|
||||
);
|
||||
|
||||
@@ -284,6 +284,9 @@ public:
|
||||
[[nodiscard]]
|
||||
QWidget* getActiveStampModeItem();
|
||||
|
||||
[[nodiscard]]
|
||||
Noggit::Ui::flatten_blur_tool* getFlattenTool() { return flattenTool; };
|
||||
|
||||
[[nodiscard]]
|
||||
Noggit::NoggitRenderContext getRenderContext() { return _context; };
|
||||
|
||||
|
||||
@@ -70,22 +70,6 @@ namespace Noggit
|
||||
|
||||
layout->addWidget(settings_group);
|
||||
|
||||
QGroupBox* flatten_blur_group = new QGroupBox("Flatten/Blur", this);
|
||||
flatten_blur_group->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
|
||||
auto flatten_blur_layout = new QGridLayout(flatten_blur_group);
|
||||
|
||||
flatten_blur_layout->addWidget(_lock_up_checkbox = new QCheckBox(this), 0, 0);
|
||||
flatten_blur_layout->addWidget(_lock_down_checkbox = new QCheckBox(this), 0, 1);
|
||||
|
||||
_lock_up_checkbox->setChecked(_flatten_mode.raise);
|
||||
_lock_up_checkbox->setText("Raise");
|
||||
_lock_up_checkbox->setToolTip("Raise the terrain when using the tool");
|
||||
_lock_down_checkbox->setChecked(_flatten_mode.lower);
|
||||
_lock_down_checkbox->setText("Lower");
|
||||
_lock_down_checkbox->setToolTip("Lower the terrain when using the tool");
|
||||
|
||||
layout->addWidget(flatten_blur_group);
|
||||
|
||||
QGroupBox* flatten_only_group = new QGroupBox("Flatten only", this);
|
||||
auto flatten_only_layout = new QVBoxLayout(flatten_only_group);
|
||||
|
||||
@@ -150,20 +134,6 @@ namespace Noggit
|
||||
}
|
||||
);
|
||||
|
||||
connect( _lock_up_checkbox, &QCheckBox::stateChanged
|
||||
, [&] (int state)
|
||||
{
|
||||
_flatten_mode.raise = state;
|
||||
}
|
||||
);
|
||||
|
||||
connect( _lock_down_checkbox, &QCheckBox::stateChanged
|
||||
, [&] (int state)
|
||||
{
|
||||
_flatten_mode.lower = state;
|
||||
}
|
||||
);
|
||||
|
||||
connect ( _angle_slider, &QSlider::valueChanged
|
||||
, [&] (int v)
|
||||
{
|
||||
@@ -231,16 +201,6 @@ namespace Noggit
|
||||
_type_button_box->button (_flatten_type)->toggle();
|
||||
}
|
||||
|
||||
void flatten_blur_tool::nextFlattenMode()
|
||||
{
|
||||
_flatten_mode.next();
|
||||
|
||||
QSignalBlocker const up_lock(_lock_up_checkbox);
|
||||
QSignalBlocker const down_lock(_lock_down_checkbox);
|
||||
_lock_up_checkbox->setChecked(_flatten_mode.raise);
|
||||
_lock_down_checkbox->setChecked(_flatten_mode.lower);
|
||||
}
|
||||
|
||||
void flatten_blur_tool::toggleFlattenAngle()
|
||||
{
|
||||
_angle_group->setChecked(!angled_mode());
|
||||
|
||||
@@ -27,7 +27,6 @@ namespace Noggit
|
||||
void blur (World* world, glm::vec3 const& cursor_pos, float dt);
|
||||
|
||||
void nextFlattenType();
|
||||
void nextFlattenMode();
|
||||
void toggleFlattenAngle();
|
||||
void toggleFlattenLock();
|
||||
void lockPos (glm::vec3 const& cursor_pos);
|
||||
@@ -53,6 +52,7 @@ namespace Noggit
|
||||
Noggit::Ui::Tools::UiCommon::ExtendedSlider* getSpeedSlider() { return _speed_slider; };
|
||||
|
||||
QSize sizeHint() const override;
|
||||
flatten_mode _flatten_mode;
|
||||
|
||||
QJsonObject toJSON();
|
||||
void fromJSON(QJsonObject const& json);
|
||||
@@ -64,7 +64,6 @@ namespace Noggit
|
||||
glm::vec3 _lock_pos;
|
||||
|
||||
int _flatten_type;
|
||||
flatten_mode _flatten_mode;
|
||||
|
||||
private:
|
||||
QButtonGroup* _type_button_box;
|
||||
|
||||
@@ -139,6 +139,32 @@ ViewToolbar::ViewToolbar(MapView* mapView, editing_mode mode)
|
||||
setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
||||
mapView->getLeftSecondaryToolbar()->hide();
|
||||
|
||||
{
|
||||
/*
|
||||
* FLATTEN/BLUE SECONDARY TOOL
|
||||
*/
|
||||
|
||||
IconAction* _icon = new IconAction(FontNoggitIcon{ FontNoggit::TOOL_FLATTEN_BLUR });
|
||||
|
||||
CheckBoxAction* _raise = new CheckBoxAction(tr("Raise"));
|
||||
_raise->setChecked(true);
|
||||
connect(_raise->checkbox(), &QCheckBox::stateChanged, [mapView](int state)
|
||||
{
|
||||
mapView->getFlattenTool()->_flatten_mode.raise = state;
|
||||
});
|
||||
|
||||
CheckBoxAction* _lower = new CheckBoxAction(tr("Lower"));
|
||||
_lower->setChecked(true);
|
||||
connect(_lower->checkbox(), &QCheckBox::stateChanged, [mapView](int state)
|
||||
{
|
||||
mapView->getFlattenTool()->_flatten_mode.lower = state;
|
||||
});
|
||||
|
||||
_flatten_secondary_tool.push_back(_icon);
|
||||
_flatten_secondary_tool.push_back(_raise); raise_index = 1;
|
||||
_flatten_secondary_tool.push_back(_lower); lower_index = 2;
|
||||
}
|
||||
|
||||
{
|
||||
/*
|
||||
* TEXTURE PAINTER SECONDARY TOOL
|
||||
@@ -169,6 +195,11 @@ void ViewToolbar::setCurrentMode(MapView* mapView, editing_mode mode)
|
||||
case editing_mode::ground:
|
||||
break;
|
||||
case editing_mode::flatten_blur:
|
||||
if (_flatten_secondary_tool.size() > 0)
|
||||
{
|
||||
setupWidget(_flatten_secondary_tool);
|
||||
mapView->getLeftSecondaryToolbar()->show();
|
||||
}
|
||||
break;
|
||||
case editing_mode::paint:
|
||||
if (_texture_secondary_tool.size() > 0)
|
||||
@@ -233,3 +264,14 @@ bool ViewToolbar::showUnpaintableChunk()
|
||||
|
||||
return _texture_secondary_tool[unpaintable_chunk_index];
|
||||
}
|
||||
|
||||
void ViewToolbar::nextFlattenMode(MapView* mapView)
|
||||
{
|
||||
mapView->getFlattenTool()->_flatten_mode.next();
|
||||
|
||||
QSignalBlocker const raise_lock(_flatten_secondary_tool[raise_index]);
|
||||
QSignalBlocker const lower_lock(_flatten_secondary_tool[lower_index]);
|
||||
|
||||
_flatten_secondary_tool[raise_index]->setChecked(true);
|
||||
_flatten_secondary_tool[lower_index]->setChecked(true);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <noggit/MapView.h>
|
||||
#include <noggit/ui/FontNoggit.hpp>
|
||||
#include <noggit/BoolToggleProperty.hpp>
|
||||
#include <noggit/ui/FlattenTool.hpp>
|
||||
|
||||
namespace Noggit
|
||||
{
|
||||
@@ -31,12 +32,17 @@ namespace Noggit
|
||||
|
||||
/*secondary left tool*/
|
||||
bool showUnpaintableChunk();
|
||||
void nextFlattenMode(MapView* mapView);
|
||||
|
||||
QVector<QWidgetAction*> _flatten_secondary_tool;
|
||||
QVector<QWidgetAction*> _texture_secondary_tool;
|
||||
|
||||
private:
|
||||
QActionGroup _tool_group;
|
||||
editing_mode current_mode;
|
||||
|
||||
int raise_index = -1;
|
||||
int lower_index = -1;
|
||||
int unpaintable_chunk_index = -1;
|
||||
|
||||
void add_tool_icon(MapView* mapView,
|
||||
|
||||
Reference in New Issue
Block a user