VOXEDIT: extracted into modifier panel
parent
74df94db80
commit
b439d1fd50
|
@ -4,6 +4,7 @@ set(SRCS
|
|||
AnimationPanel.h AnimationPanel.cpp
|
||||
LayerPanel.h LayerPanel.cpp
|
||||
LSystemPanel.h LSystemPanel.cpp
|
||||
ModifierPanel.h ModifierPanel.cpp
|
||||
NoisePanel.h NoisePanel.cpp
|
||||
ScriptPanel.h ScriptPanel.cpp
|
||||
TreePanel.h TreePanel.cpp
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#include "ModifierPanel.h"
|
||||
#include "voxedit-util/SceneManager.h"
|
||||
#include "ui/imgui/IMGUI.h"
|
||||
#include "ui/imgui/IconsForkAwesome.h"
|
||||
#include "ui/imgui/IconsFontAwesome5.h"
|
||||
|
||||
namespace voxedit {
|
||||
|
||||
bool ModifierPanel::mirrorAxisRadioButton(const char *title, math::Axis type) {
|
||||
voxedit::ModifierFacade &modifier = sceneMgr().modifier();
|
||||
if (ImGui::RadioButton(title, modifier.mirrorAxis() == type)) {
|
||||
modifier.setMirrorAxis(type, sceneMgr().referencePosition());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ModifierPanel::update(const char *title, command::CommandExecutionListener &listener) {
|
||||
if (ImGui::Begin(title, nullptr, ImGuiWindowFlags_NoDecoration)) {
|
||||
const float windowWidth = ImGui::GetWindowWidth();
|
||||
ImGui::CommandButton(ICON_FA_CROP " Crop layer", "crop", "Crop the current layer to the voxel boundaries", windowWidth, &listener);
|
||||
ImGui::CommandButton(ICON_FA_EXPAND_ARROWS_ALT " Extend all layers", "resize", nullptr, windowWidth, &listener);
|
||||
ImGui::CommandButton(ICON_FA_OBJECT_UNGROUP " Layer from color", "colortolayer", "Create a new layer from the current selected color", windowWidth, &listener);
|
||||
ImGui::CommandButton(ICON_FA_COMPRESS_ALT " Scale", "scale", "Scale the current layer down", windowWidth, &listener);
|
||||
|
||||
ImGui::NewLine();
|
||||
|
||||
if (ImGui::CollapsingHeader("Rotate on axis", ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
ImGui::CommandButton(ICON_FK_REPEAT " X", "rotate 90 0 0", nullptr, windowWidth / 3.0f, &listener);
|
||||
ImGui::TooltipText("Rotate by 90 degree on the x axis");
|
||||
ImGui::SameLine();
|
||||
ImGui::CommandButton(ICON_FK_REPEAT " Y", "rotate 0 90 0", nullptr, windowWidth / 3.0f, &listener);
|
||||
ImGui::TooltipText("Rotate by 90 degree on the y axis");
|
||||
ImGui::SameLine();
|
||||
ImGui::CommandButton(ICON_FK_REPEAT " Z", "rotate 0 0 90", nullptr, windowWidth / 3.0f, &listener);
|
||||
ImGui::TooltipText("Rotate by 90 degree on the z axis");
|
||||
}
|
||||
|
||||
ImGui::NewLine();
|
||||
|
||||
if (ImGui::CollapsingHeader("Flip on axis", ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
ImGui::CommandButton("X", "flip x", nullptr, windowWidth / 3.0f, &listener);
|
||||
ImGui::SameLine();
|
||||
ImGui::CommandButton("Y", "flip y", nullptr, windowWidth / 3.0f, &listener);
|
||||
ImGui::SameLine();
|
||||
ImGui::CommandButton("Z", "flip z", nullptr, windowWidth / 3.0f, &listener);
|
||||
}
|
||||
|
||||
ImGui::NewLine();
|
||||
|
||||
if (ImGui::CollapsingHeader("Mirror on axis", ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
mirrorAxisRadioButton("none", math::Axis::None);
|
||||
mirrorAxisRadioButton("x", math::Axis::X);
|
||||
mirrorAxisRadioButton("y", math::Axis::Y);
|
||||
mirrorAxisRadioButton("z", math::Axis::Z);
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "command/CommandHandler.h"
|
||||
#include "math/Axis.h"
|
||||
|
||||
namespace voxedit {
|
||||
|
||||
class ModifierPanel {
|
||||
private:
|
||||
bool mirrorAxisRadioButton(const char *title, math::Axis type);
|
||||
|
||||
public:
|
||||
void update(const char *title, command::CommandExecutionListener &listener);
|
||||
};
|
||||
|
||||
}
|
|
@ -91,19 +91,6 @@ bool VoxEditWindow::actionMenuItem(const char *title, const char *command, bool
|
|||
return ImGui::CommandMenuItem(title, command, enabled, &_lastExecutedCommand);
|
||||
}
|
||||
|
||||
bool VoxEditWindow::actionButton(const char *title, const char *command, const char *tooltip, float width) {
|
||||
return ImGui::CommandButton(title, command, tooltip, width, &_lastExecutedCommand);
|
||||
}
|
||||
|
||||
bool VoxEditWindow::mirrorAxisRadioButton(const char *title, math::Axis type) {
|
||||
voxedit::ModifierFacade &modifier = sceneMgr().modifier();
|
||||
if (ImGui::RadioButton(title, modifier.mirrorAxis() == type)) {
|
||||
modifier.setMirrorAxis(type, sceneMgr().referencePosition());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VoxEditWindow::init() {
|
||||
_showAxisVar = core::Var::get(cfg::VoxEditShowaxis, "1");
|
||||
_showGridVar = core::Var::get(cfg::VoxEditShowgrid, "1");
|
||||
|
@ -359,8 +346,7 @@ void VoxEditWindow::palette() {
|
|||
ImGui::SetCursorPosY(pos.y + usedHeight);
|
||||
ImGui::Text("Color: %i (voxel %i)", voxelColorSelectedIndex, voxelColorTraceIndex);
|
||||
ImGui::TooltipText("Palette color index for current voxel under cursor");
|
||||
//sceneMgr().modifier().setCursorVoxel(voxel::createVoxel(voxel::VoxelType::Generic, voxelColorIndex));
|
||||
actionButton("Import palette", "importpalette");
|
||||
ImGui::CommandButton("Import palette", "importpalette", nullptr, 0.0f, &_lastExecutedCommand);
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Load palette##button")) {
|
||||
reloadAvailablePalettes();
|
||||
|
@ -495,7 +481,7 @@ void VoxEditWindow::mainWidget() {
|
|||
|
||||
void VoxEditWindow::rightWidget() {
|
||||
positionsPanel();
|
||||
modifierPanel();
|
||||
_modifierPanel.update(TITLE_MODIFIERS, _lastExecutedCommand);
|
||||
_animationPanel.update(TITLE_ANIMATION_SETTINGS, _lastExecutedCommand);
|
||||
_treePanel.update(TITLE_TREES);
|
||||
_scriptPanel.update(TITLE_SCRIPTPANEL, WINDOW_TITLE_SCRIPT_EDITOR, _app);
|
||||
|
@ -557,49 +543,6 @@ void VoxEditWindow::positionsPanel() {
|
|||
ImGui::End();
|
||||
}
|
||||
|
||||
void VoxEditWindow::modifierPanel() {
|
||||
if (ImGui::Begin(TITLE_MODIFIERS, nullptr, ImGuiWindowFlags_NoDecoration)) {
|
||||
const float windowWidth = ImGui::GetWindowWidth();
|
||||
actionButton(ICON_FA_CROP " Crop layer", "crop", "Crop the current layer to the voxel boundaries", windowWidth);
|
||||
actionButton(ICON_FA_EXPAND_ARROWS_ALT " Extend all layers", "resize", nullptr, windowWidth);
|
||||
actionButton(ICON_FA_OBJECT_UNGROUP " Layer from color", "colortolayer", "Create a new layer from the current selected color", windowWidth);
|
||||
actionButton(ICON_FA_COMPRESS_ALT " Scale", "scale", "Scale the current layer down", windowWidth);
|
||||
|
||||
ImGui::NewLine();
|
||||
|
||||
if (ImGui::CollapsingHeader("Rotate on axis", ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
actionButton(ICON_FK_REPEAT " X", "rotate 90 0 0", nullptr, windowWidth / 3.0f);
|
||||
ImGui::TooltipText("Rotate by 90 degree on the x axis");
|
||||
ImGui::SameLine();
|
||||
actionButton(ICON_FK_REPEAT " Y", "rotate 0 90 0", nullptr, windowWidth / 3.0f);
|
||||
ImGui::TooltipText("Rotate by 90 degree on the y axis");
|
||||
ImGui::SameLine();
|
||||
actionButton(ICON_FK_REPEAT " Z", "rotate 0 0 90", nullptr, windowWidth / 3.0f);
|
||||
ImGui::TooltipText("Rotate by 90 degree on the z axis");
|
||||
}
|
||||
|
||||
ImGui::NewLine();
|
||||
|
||||
if (ImGui::CollapsingHeader("Flip on axis", ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
actionButton("X", "flip x", nullptr, windowWidth / 3.0f);
|
||||
ImGui::SameLine();
|
||||
actionButton("Y", "flip y", nullptr, windowWidth / 3.0f);
|
||||
ImGui::SameLine();
|
||||
actionButton("Z", "flip z", nullptr, windowWidth / 3.0f);
|
||||
}
|
||||
|
||||
ImGui::NewLine();
|
||||
|
||||
if (ImGui::CollapsingHeader("Mirror on axis", ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
mirrorAxisRadioButton("none", math::Axis::None);
|
||||
mirrorAxisRadioButton("x", math::Axis::X);
|
||||
mirrorAxisRadioButton("y", math::Axis::Y);
|
||||
mirrorAxisRadioButton("z", math::Axis::Z);
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void VoxEditWindow::updateSettings() {
|
||||
SceneManager &mgr = sceneMgr();
|
||||
mgr.setGridResolution(_gridSizeVar->intVal());
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "voxedit-ui/AnimationPanel.h"
|
||||
#include "voxedit-ui/LSystemPanel.h"
|
||||
#include "voxedit-ui/LayerPanel.h"
|
||||
#include "voxedit-ui/ModifierPanel.h"
|
||||
#include "voxedit-ui/NoisePanel.h"
|
||||
#include "voxedit-ui/ScriptPanel.h"
|
||||
#include "voxedit-ui/TreePanel.h"
|
||||
|
@ -67,6 +68,7 @@ private:
|
|||
TreePanel _treePanel;
|
||||
LayerPanel _layerPanel;
|
||||
AnimationPanel _animationPanel;
|
||||
ModifierPanel _modifierPanel;
|
||||
|
||||
void reloadAvailablePalettes();
|
||||
|
||||
|
@ -92,7 +94,6 @@ private:
|
|||
bool mirrorAxisRadioButton(const char *title, math::Axis type);
|
||||
bool saveImage(const char *file);
|
||||
|
||||
void modifierPanel();
|
||||
void positionsPanel();
|
||||
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue