diff --git a/src/noggit/MapView.cpp b/src/noggit/MapView.cpp
index 99c2f4ae..0bf7f3ae 100755
--- a/src/noggit/MapView.cpp
+++ b/src/noggit/MapView.cpp
@@ -231,7 +231,7 @@ void MapView::set_editing_mode(editing_mode mode)
{
_world->renderer()->getTerrainParamsUniformBlock()->draw_areaid_overlay = false;
_world->renderer()->getTerrainParamsUniformBlock()->draw_impass_overlay = false;
- _world->renderer()->getTerrainParamsUniformBlock()->draw_paintability_overlay = _left_sec_toolbar->showUnpaintableChunk();
+ _world->renderer()->getTerrainParamsUniformBlock()->draw_paintability_overlay = false;
_world->renderer()->getTerrainParamsUniformBlock()->draw_selection_overlay = false;
_minimap->use_selection(nullptr);
@@ -248,6 +248,10 @@ void MapView::set_editing_mode(editing_mode mode)
{
texturingTool->updateMaskImage();
}
+ if (_left_sec_toolbar->showUnpaintableChunk())
+ {
+ _world->renderer()->getTerrainParamsUniformBlock()->draw_paintability_overlay = true;
+ }
break;
case editing_mode::mccv:
if (shaderTool->getImageMaskSelector()->isEnabled())
diff --git a/src/noggit/ui/MapViewOverlay.ui b/src/noggit/ui/MapViewOverlay.ui
index 5de98bb5..e5c12ac5 100755
--- a/src/noggit/ui/MapViewOverlay.ui
+++ b/src/noggit/ui/MapViewOverlay.ui
@@ -84,6 +84,22 @@
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+
-
@@ -137,16 +153,6 @@
-
-
-
-
-
-
- 0
- 0
-
-
-
-
-
diff --git a/src/noggit/ui/tools/ViewToolbar/Ui/ViewToolbar.cpp b/src/noggit/ui/tools/ViewToolbar/Ui/ViewToolbar.cpp
index 0862bcc2..dd50cb52 100755
--- a/src/noggit/ui/tools/ViewToolbar/Ui/ViewToolbar.cpp
+++ b/src/noggit/ui/tools/ViewToolbar/Ui/ViewToolbar.cpp
@@ -136,7 +136,8 @@ ViewToolbar::ViewToolbar(MapView* mapView, editing_mode mode)
{
setContextMenuPolicy(Qt::PreventContextMenu);
setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
- setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
+ setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
+ setOrientation(Qt::Vertical);
mapView->getLeftSecondaryToolbar()->hide();
{
@@ -144,25 +145,31 @@ ViewToolbar::ViewToolbar(MapView* mapView, editing_mode mode)
* FLATTEN/BLUE SECONDARY TOOL
*/
- IconAction* _icon = new IconAction(FontNoggitIcon{ FontNoggit::TOOL_FLATTEN_BLUR });
+ SubToolBarAction* _toolbar = new SubToolBarAction();
- CheckBoxAction* _raise = new CheckBoxAction(tr("Raise"));
- _raise->setChecked(true);
- connect(_raise->checkbox(), &QCheckBox::stateChanged, [mapView](int state)
- {
- mapView->getFlattenTool()->_flatten_mode.raise = state;
- });
+ {
+ IconAction* _icon = new IconAction(FontNoggitIcon{ FontNoggit::TOOL_FLATTEN_BLUR });
- CheckBoxAction* _lower = new CheckBoxAction(tr("Lower"));
- _lower->setChecked(true);
- connect(_lower->checkbox(), &QCheckBox::stateChanged, [mapView](int state)
- {
- mapView->getFlattenTool()->_flatten_mode.lower = state;
- });
+ CheckBoxAction* _raise = new CheckBoxAction(tr("Raise"), true);
+ connect(_raise->checkbox(), &QCheckBox::stateChanged, [mapView](int state)
+ {
+ mapView->getFlattenTool()->_flatten_mode.raise = 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;
+ CheckBoxAction* _lower = new CheckBoxAction(tr("Lower"), true);
+ connect(_lower->checkbox(), &QCheckBox::stateChanged, [mapView](int state)
+ {
+ mapView->getFlattenTool()->_flatten_mode.lower = state;
+ });
+
+
+ _toolbar->ADD_ACTION(_icon);
+ _toolbar->ADD_ACTION(_raise); raise_index = 1;
+ _toolbar->ADD_ACTION(_lower); lower_index = 2;
+ _toolbar->SETUP_WIDGET(false);
+ }
+
+ _flatten_secondary_tool.push_back(_toolbar);
}
{
@@ -170,18 +177,66 @@ ViewToolbar::ViewToolbar(MapView* mapView, editing_mode mode)
* TEXTURE PAINTER SECONDARY TOOL
*/
- IconAction* _icon = new IconAction(FontNoggitIcon{ FontNoggit::TOOL_TEXTURE_PAINT });
+ SubToolBarAction* _toolbar = new SubToolBarAction();
- CheckBoxAction* _unpaintable_chunk = new CheckBoxAction(tr("Unpaintable chunk"));
- _unpaintable_chunk->setChecked(false);
- connect(_unpaintable_chunk->checkbox(), &QCheckBox::toggled, [mapView](bool checked)
- {
- mapView->getWorld()->renderer()->getTerrainParamsUniformBlock()->draw_paintability_overlay = checked;
- mapView->getWorld()->renderer()->markTerrainParamsUniformBlockDirty();
- });
+ {
+ IconAction* _icon = new IconAction(FontNoggitIcon{ FontNoggit::TOOL_TEXTURE_PAINT });
- _texture_secondary_tool.push_back(_icon);
- _texture_secondary_tool.push_back(_unpaintable_chunk); unpaintable_chunk_index = 1;
+ CheckBoxAction* _unpaintable_chunk = new CheckBoxAction(tr("Unpaintable chunk"));
+ connect(_unpaintable_chunk->checkbox(), &QCheckBox::toggled, [mapView](bool checked)
+ {
+ mapView->getWorld()->renderer()->getTerrainParamsUniformBlock()->draw_paintability_overlay = checked;
+ mapView->getWorld()->renderer()->markTerrainParamsUniformBlockDirty();
+ });
+
+ _toolbar->ADD_ACTION(_icon);
+ _toolbar->ADD_ACTION(_unpaintable_chunk); unpaintable_chunk_index = 1;
+ _toolbar->SETUP_WIDGET(false);
+ }
+
+ _texture_secondary_tool.push_back(_toolbar);
+ }
+
+ {
+ /*
+ * OBJECT SECONDARY TOOL
+ */
+
+ SubToolBarAction* _up_toolbar = new SubToolBarAction();
+
+ {
+ QVector _up_temp;
+
+ IconAction* _icon = new IconAction(FontNoggitIcon{ FontNoggit::TOOL_OBJECT_EDITOR });
+ CheckBoxAction* _rotate_follow_cursor = new CheckBoxAction(tr("Rotate following cursor"), true);
+ CheckBoxAction* _smooth_follow_rotation = new CheckBoxAction(tr("Smooth follow rotation"), true);
+ CheckBoxAction* _random_all_on_rotation = new CheckBoxAction(tr("Random Rotation/Tilt/Scale on Rotation"));
+ CheckBoxAction* _magnetic_to_ground = new CheckBoxAction(tr("Magnetic to ground when dragging"));
+
+ _up_toolbar->ADD_ACTION(_icon);
+ _up_toolbar->ADD_ACTION(_rotate_follow_cursor);
+ _up_toolbar->ADD_ACTION(_smooth_follow_rotation);
+ _up_toolbar->ADD_ACTION(_random_all_on_rotation);
+ _up_toolbar->ADD_ACTION(_magnetic_to_ground);
+ _up_toolbar->SETUP_WIDGET(false);
+ }
+
+ SubToolBarAction* _down_toolbar = new SubToolBarAction();
+
+ {
+ QVector _down_temp;
+
+ CheckBoxAction* _magnetic_to_ground = new CheckBoxAction(tr("Magnetic to ground when dragging"));
+ CheckBoxAction* _rotation_around_pivot = new CheckBoxAction(tr("Rotate around pivot"), true);
+
+ _down_toolbar->ADD_ACTION(_magnetic_to_ground);
+ _down_toolbar->ADD_ACTION(_rotation_around_pivot);
+ _down_toolbar->SETUP_WIDGET(true);
+ }
+
+
+ _object_secondary_tool.push_back(_up_toolbar);
+ _object_secondary_tool.push_back(_down_toolbar);
}
}
@@ -208,6 +263,12 @@ void ViewToolbar::setCurrentMode(MapView* mapView, editing_mode mode)
mapView->getLeftSecondaryToolbar()->show();
}
break;
+ case editing_mode::object:
+ if (_object_secondary_tool.size() > 0)
+ {
+ //setupWidget(_object_secondary_tool, true);
+ //mapView->getLeftSecondaryToolbar()->show();
+ }
default:
break;
}
@@ -245,33 +306,31 @@ void ViewToolbar::add_tool_icon(MapView* mapView,
action->setChecked(view_state->get());
}
-void ViewToolbar::setupWidget(QVector _to_setup)
+void ViewToolbar::setupWidget(QVector _to_setup, bool ignoreSeparator)
{
clear();
for (int i = 0; i < _to_setup.size(); ++i)
{
addAction(_to_setup[i]);
- (i == _to_setup.size() - 1) ? NULL : addSeparator();
+ (i == _to_setup.size() - 1) ? NULL : (ignoreSeparator) ? NULL : addSeparator();
}
}
bool ViewToolbar::showUnpaintableChunk()
{
- if ((unpaintable_chunk_index >= _texture_secondary_tool.size()) ||
- (unpaintable_chunk_index < 0) ||
- (current_mode != editing_mode::paint))
- return false;
-
- return _texture_secondary_tool[unpaintable_chunk_index];
+ return static_cast(_texture_secondary_tool[0])->GET(unpaintable_chunk_index)->checkbox()->isChecked() && current_mode == editing_mode::paint;
}
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]);
+ CheckBoxAction* _raise_option = static_cast(_flatten_secondary_tool[0])->GET(raise_index);
+ CheckBoxAction* _lower_option = static_cast(_flatten_secondary_tool[0])->GET(lower_index);
- _flatten_secondary_tool[raise_index]->setChecked(true);
- _flatten_secondary_tool[lower_index]->setChecked(true);
+ QSignalBlocker const raise_lock(_raise_option);
+ QSignalBlocker const lower_lock(_lower_option);
+
+ _raise_option->setChecked(true);
+ _lower_option->setChecked(true);
}
diff --git a/src/noggit/ui/tools/ViewToolbar/Ui/ViewToolbar.hpp b/src/noggit/ui/tools/ViewToolbar/Ui/ViewToolbar.hpp
index 65b0d14b..8c97998f 100755
--- a/src/noggit/ui/tools/ViewToolbar/Ui/ViewToolbar.hpp
+++ b/src/noggit/ui/tools/ViewToolbar/Ui/ViewToolbar.hpp
@@ -25,7 +25,6 @@ namespace Noggit
ViewToolbar(MapView* mapView, editing_mode mode);
void setCurrentMode(MapView* mapView, editing_mode mode);
- void setupWidget(QVector _to_setup);
/*secondary top tool*/
QVector _climb_secondary_tool;
@@ -36,6 +35,7 @@ namespace Noggit
QVector _flatten_secondary_tool;
QVector _texture_secondary_tool;
+ QVector _object_secondary_tool;
private:
QActionGroup _tool_group;
@@ -45,6 +45,7 @@ namespace Noggit
int lower_index = -1;
int unpaintable_chunk_index = -1;
+ void setupWidget(QVector _to_setup, bool ignoreSeparator = false);
void add_tool_icon(MapView* mapView,
Noggit::BoolToggleProperty* view_state,
const QString& name,
@@ -62,6 +63,8 @@ namespace Noggit
{
QWidget* _widget = new QWidget(NULL);
QHBoxLayout* _layout = new QHBoxLayout();
+ _layout->setSpacing(3);
+ _layout->setMargin(0);
QLabel* _label = new QLabel(title);
QLabel* _display = new QLabel(tr("49 degrees"));
@@ -100,6 +103,7 @@ namespace Noggit
{
QWidget* _widget = new QWidget(NULL);
QHBoxLayout* _layout = new QHBoxLayout();
+ _layout->setMargin(0);
_push = new QPushButton(text);
@@ -118,13 +122,15 @@ namespace Noggit
class CheckBoxAction : public QWidgetAction
{
public:
- CheckBoxAction (const QString& text)
+ CheckBoxAction (const QString& text, bool checked = false)
: QWidgetAction(NULL)
{
QWidget* _widget = new QWidget(NULL);
QHBoxLayout* _layout = new QHBoxLayout();
+ _layout->setMargin(0);
_checkbox = new QCheckBox(text);
+ _checkbox->setChecked(checked);
_layout->addWidget(_checkbox);
_widget->setLayout(_layout);
@@ -146,13 +152,13 @@ namespace Noggit
{
QWidget* _widget = new QWidget(NULL);
QHBoxLayout* _layout = new QHBoxLayout();
+ _layout->setMargin(0);
_icon = new QLabel();
- _icon->setPixmap(icon.pixmap(QSize(24,24)));
+ _icon->setPixmap(icon.pixmap(QSize(22,22)));
_layout->addWidget(_icon);
_widget->setLayout(_layout);
-
setDefaultWidget(_widget);
}
@@ -161,5 +167,87 @@ namespace Noggit
private:
QLabel *_icon;
};
+
+ class SpacerAction : public QWidgetAction
+ {
+ public:
+ SpacerAction(Qt::Orientation orientation)
+ : QWidgetAction(NULL)
+ {
+ QWidget* _widget = new QWidget(NULL);
+ QHBoxLayout* _layout = new QHBoxLayout();
+ _layout->setMargin(0);
+
+ if (orientation == Qt::Vertical)
+ _layout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));
+
+ if (orientation == Qt::Horizontal)
+ _layout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum));
+
+ _widget->setLayout(_layout);
+ setDefaultWidget(_widget);
+ }
+ };
+
+ class SubToolBarAction : public QWidgetAction
+ {
+ public:
+ SubToolBarAction()
+ : QWidgetAction(NULL)
+ {
+ QWidget* _widget = new QWidget(NULL);
+ QHBoxLayout* _layout = new QHBoxLayout();
+ _layout->setSpacing(5);
+ _layout->setMargin(0);
+
+ _toolbar = new QToolBar();
+ _toolbar->setContextMenuPolicy(Qt::PreventContextMenu);
+ _toolbar->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
+ _toolbar->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
+ _toolbar->setOrientation(Qt::Horizontal);
+
+ _layout->addWidget(_toolbar);
+ _widget->setLayout(_layout);
+
+ setDefaultWidget(_widget);
+ };
+
+ QToolBar* toolbar() { return _toolbar; };
+
+ template
+ T GET(int index)
+ {
+ if (index >= 0 && index < _actions.size())
+ return static_cast(_actions[index]);
+
+ return T();
+ }
+
+ void ADD_ACTION(QWidgetAction* _act) { _actions.push_back(_act); };
+ void SETUP_WIDGET(bool forceSpacer, Qt::Orientation orientation = Qt::Horizontal) {
+ _toolbar->clear();
+ for (int i = 0; i < _actions.size(); ++i)
+ {
+ _toolbar->addAction(_actions[i]);
+ if (i == _actions.size() - 1)
+ {
+ if (forceSpacer)
+ {
+ /* TODO: fix this spacer */
+
+ _toolbar->addAction(new SpacerAction(orientation));
+ }
+ }
+ else
+ {
+ _toolbar->addSeparator();
+ }
+ }
+ };
+
+ private:
+ QToolBar* _toolbar;
+ QVector _actions;
+ };
}
}