fix window loosing focus on switching editing modes, add widget for holes mode
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
#include <noggit/ui/terrain_tool.hpp>
|
||||
#include <noggit/ui/texture_swapper.hpp>
|
||||
#include <noggit/ui/texturing_tool.hpp>
|
||||
#include <noggit/ui/hole_tool.hpp>
|
||||
#include <noggit/ui/texture_palette_small.hpp>
|
||||
#include <opengl/scoped.hpp>
|
||||
|
||||
@@ -88,6 +89,8 @@ void MapView::set_editing_mode (editing_mode mode)
|
||||
|
||||
terrainMode = mode;
|
||||
_toolbar->check_tool (mode);
|
||||
|
||||
this->activateWindow();
|
||||
}
|
||||
|
||||
void MapView::setToolPropertyWidgetVisibility(editing_mode mode)
|
||||
@@ -120,6 +123,9 @@ void MapView::setToolPropertyWidgetVisibility(editing_mode mode)
|
||||
case editing_mode::object:
|
||||
_object_editor_dock->setVisible(!ui_hidden);
|
||||
break;
|
||||
case editing_mode::holes:
|
||||
_hole_tool_dock->setVisible(!ui_hidden);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -218,6 +224,11 @@ void MapView::createGUI()
|
||||
_texturing_dock->setWidget(texturingTool);
|
||||
_tool_properties_docks.insert(_texturing_dock);
|
||||
|
||||
_hole_tool_dock = new QDockWidget("Holes", this);
|
||||
holeTool = new noggit::ui::hole_tool(_hole_tool_dock);
|
||||
_hole_tool_dock->setWidget(holeTool);
|
||||
_tool_properties_docks.insert(_hole_tool_dock);
|
||||
|
||||
_areaid_editor_dock = new QDockWidget("Area ID", this);
|
||||
ZoneIDBrowser = new noggit::ui::zone_id_browser(_areaid_editor_dock);
|
||||
_areaid_editor_dock->setWidget(ZoneIDBrowser);
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace noggit
|
||||
class water;
|
||||
class zone_id_browser;
|
||||
class texture_palette_small;
|
||||
class hole_tool;
|
||||
struct main_window;
|
||||
struct tileset_chooser;
|
||||
}
|
||||
@@ -306,4 +307,6 @@ private:
|
||||
QDockWidget* _vertex_shading_dock;
|
||||
noggit::ui::texturing_tool* texturingTool;
|
||||
QDockWidget* _texturing_dock;
|
||||
noggit::ui::hole_tool* holeTool;
|
||||
QDockWidget* _hole_tool_dock;
|
||||
};
|
||||
|
||||
52
src/noggit/ui/hole_tool.cpp
Normal file
52
src/noggit/ui/hole_tool.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
#include "hole_tool.hpp"
|
||||
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
#include <QtWidgets/QFormLayout>
|
||||
|
||||
namespace noggit
|
||||
{
|
||||
namespace ui
|
||||
{
|
||||
hole_tool::hole_tool(QWidget* parent) : QWidget(parent)
|
||||
{
|
||||
auto layout = new QFormLayout(this);
|
||||
|
||||
_radius_spin = new QDoubleSpinBox (this);
|
||||
_radius_spin->setRange (0.0f, 250.0f);
|
||||
_radius_spin->setDecimals (2);
|
||||
_radius_spin->setValue (_radius);
|
||||
|
||||
layout->addRow ("Radius:", _radius_spin);
|
||||
|
||||
_radius_slider = new QSlider (Qt::Orientation::Horizontal, this);
|
||||
_radius_slider->setRange (0, 100);
|
||||
_radius_slider->setSliderPosition (_radius);
|
||||
|
||||
layout->addRow (_radius_slider);
|
||||
|
||||
connect ( _radius_spin, qOverload<double> (&QDoubleSpinBox::valueChanged)
|
||||
, [&] (double v)
|
||||
{
|
||||
_radius = v;
|
||||
QSignalBlocker const blocker(_radius_slider);
|
||||
_radius_slider->setSliderPosition ((int)std::round (v));
|
||||
}
|
||||
);
|
||||
|
||||
connect ( _radius_slider, &QSlider::valueChanged
|
||||
, [&] (int v)
|
||||
{
|
||||
_radius = v;
|
||||
QSignalBlocker const blocker(_radius_spin);
|
||||
_radius_spin->setValue(v);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void hole_tool::changeRadius(float change)
|
||||
{
|
||||
_radius_spin->setValue (_radius + change);
|
||||
}
|
||||
}
|
||||
}
|
||||
38
src/noggit/ui/hole_tool.hpp
Normal file
38
src/noggit/ui/hole_tool.hpp
Normal file
@@ -0,0 +1,38 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QtWidgets/QWidget>
|
||||
#include <QtWidgets/QTreeWidget>
|
||||
#include <QtWidgets/QDoubleSpinBox>
|
||||
#include <QtWidgets/QSlider>
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
namespace noggit
|
||||
{
|
||||
namespace ui
|
||||
{
|
||||
class hole_tool : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
hole_tool(QWidget* parent = nullptr);
|
||||
|
||||
void changeRadius(float change);
|
||||
|
||||
float brushRadius() const { return _radius; }
|
||||
|
||||
private:
|
||||
|
||||
QSlider* _radius_slider;
|
||||
QDoubleSpinBox* _radius_spin;
|
||||
|
||||
float _radius = 15.0f;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user