Skip to content

Commit

Permalink
#5776: Some manipulation buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Oct 10, 2021
1 parent a85b6cc commit d56a453
Show file tree
Hide file tree
Showing 8 changed files with 597 additions and 2 deletions.
Binary file added install/bitmaps/arrow_left_blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added install/bitmaps/arrow_right_blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
431 changes: 431 additions & 0 deletions install/ui/texturetoolmanipulationpanel.fbp

Large diffs are not rendered by default.

70 changes: 70 additions & 0 deletions install/ui/texturetoolmanipulationpanel.xrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<resource xmlns="http://www.wxwindows.org/wxxrc" version="2.3.0.1">
<object class="wxPanel" name="TextureToolManipulatorPanel">
<style>wxTAB_TRAVERSAL</style>
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<option>0</option>
<flag>wxALL|wxEXPAND</flag>
<border>12</border>
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<option>0</option>
<flag>wxALIGN_CENTER|wxBOTTOM</flag>
<border>6</border>
<object class="wxStaticText" name="ShiftLabel">
<label>Shift</label>
<wrap>-1</wrap>
</object>
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxALIGN_CENTER</flag>
<border>0</border>
<object class="wxBitmapButton" name="ShiftUpButton">
<bitmap stock_id="darkradiant:arrow_up_blue.png" stock_client="">undefined.png</bitmap>
<default>0</default>
</object>
</object>
<object class="sizeritem">
<option>1</option>
<flag>wxALIGN_CENTER|wxBOTTOM|wxTOP</flag>
<border>3</border>
<object class="wxBoxSizer">
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<option>0</option>
<flag>wxALIGN_CENTER|wxBOTTOM</flag>
<border>0</border>
<object class="wxBitmapButton" name="ShiftLeftButton">
<bitmap stock_id="darkradiant:arrow_left_blue.png" stock_client="">undefined.png</bitmap>
<default>0</default>
</object>
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxLEFT</flag>
<border>6</border>
<object class="wxBitmapButton" name="ShiftRightButton">
<bitmap stock_id="darkradiant:arrow_right_blue.png" stock_client="">undefined.png</bitmap>
<default>0</default>
</object>
</object>
</object>
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxALIGN_CENTER</flag>
<border>0</border>
<object class="wxBitmapButton" name="ShiftDownButton">
<bitmap stock_id="darkradiant:arrow_down_blue.png" stock_client="">undefined.png</bitmap>
<default>0</default>
</object>
</object>
</object>
</object>
</object>
</object>
</resource>
31 changes: 30 additions & 1 deletion radiant/textool/TexTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,26 @@ void TexTool::populateWindow()
GetSizer()->Add(textoolbar, 0, wxEXPAND);
}

GetSizer()->Add(_glWidget, 1, wxEXPAND);
auto horizontalSizer = new wxBoxSizer(wxHORIZONTAL);

horizontalSizer->Add(_glWidget, 1, wxEXPAND);
horizontalSizer->Add(createManipulationPanel(), 0, wxEXPAND);

GetSizer()->Add(horizontalSizer, 1, wxEXPAND);
}

wxWindow* TexTool::createManipulationPanel()
{
auto panel = loadNamedPanel(this, "TextureToolManipulatorPanel");

findNamedObject<wxButton>(panel, "ShiftUpButton")->Bind(wxEVT_BUTTON, [this] (wxCommandEvent&) { onShiftSelected("up"); });
findNamedObject<wxButton>(panel, "ShiftDownButton")->Bind(wxEVT_BUTTON, [this] (wxCommandEvent&) { onShiftSelected("down"); });
findNamedObject<wxButton>(panel, "ShiftLeftButton")->Bind(wxEVT_BUTTON, [this] (wxCommandEvent&) { onShiftSelected("left"); });
findNamedObject<wxButton>(panel, "ShiftRightButton")->Bind(wxEVT_BUTTON, [this] (wxCommandEvent&) { onShiftSelected("right"); });

makeLabelBold(panel, "ShiftLabel");

return panel;
}

// Pre-hide callback
Expand Down Expand Up @@ -930,4 +949,14 @@ void TexTool::determineThemeBasedOnPixelData(const std::vector<unsigned char>& p
updateThemeButtons();
}

void TexTool::onShiftSelected(const std::string& direction)
{
GlobalCommandSystem().executeCommand("TexToolShiftSelected", direction);
}

void TexTool::updateManipulationPanel()
{

}

} // namespace ui
9 changes: 8 additions & 1 deletion radiant/textool/TexTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <sigc++/trackable.h>
#include "wxutil/MouseToolHandler.h"
#include "wxutil/FreezePointer.h"
#include "wxutil/XmlResourceBasedWidget.h"
#include "tools/TextureToolMouseEvent.h"
#include "render/TextureToolView.h"
#include "messages/ManipulatorModeToggleRequest.h"
Expand All @@ -39,7 +40,8 @@ class TexTool :
public wxutil::TransientWindow,
public IOrthoViewBase,
public sigc::trackable,
protected wxutil::MouseToolHandler
protected wxutil::MouseToolHandler,
protected wxutil::XmlResourceBasedWidget
{
private:
// GL widget
Expand Down Expand Up @@ -91,6 +93,7 @@ class TexTool :

// Creates, packs and connects the child widgets
void populateWindow();
wxWindow* createManipulationPanel();

/** greebo: Calculates the extents of the entire scene selection in texture space.
*
Expand Down Expand Up @@ -132,6 +135,8 @@ class TexTool :
void onMouseMotion(wxMouseEvent& ev);
void onMouseScroll(wxMouseEvent& ev);

void onShiftSelected(const std::string& direction);

// UndoSystem event handler
void onUndoRedoOperation();

Expand Down Expand Up @@ -212,6 +217,8 @@ class TexTool :
TextureToolMouseEvent createMouseEvent(const Vector2& point, const Vector2& delta = Vector2(0, 0));

void handleGLCapturedMouseMotion(const MouseToolPtr& tool, int x, int y, unsigned int mouseState);

void updateManipulationPanel();
};

} // namespace ui
57 changes: 57 additions & 0 deletions radiantcore/selection/textool/TextureToolSelectionSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ void TextureToolSelectionSystem::initialiseModule(const IApplicationContext& ctx
std::bind(&TextureToolSelectionSystem::mergeSelectionCmd, this, std::placeholders::_1),
{ cmd::ARGTYPE_VECTOR2 | cmd::ARGTYPE_OPTIONAL });

GlobalCommandSystem().addCommand("TexToolShiftSelected",
std::bind(&TextureToolSelectionSystem::shiftSelectionCmd, this, std::placeholders::_1),
{ cmd::ARGTYPE_STRING });

GlobalCommandSystem().addCommand("TexToolFlipS",
std::bind(&TextureToolSelectionSystem::flipHorizontallyCmd, this, std::placeholders::_1));
GlobalCommandSystem().addCommand("TexToolFlipT",
Expand Down Expand Up @@ -739,6 +743,59 @@ void TextureToolSelectionSystem::normaliseSelectionCmd(const cmd::ArgumentList&
foreachSelectedNode(normaliser);
}

void TextureToolSelectionSystem::shiftSelectionCmd(const cmd::ArgumentList& args)
{
UndoableCommand cmd("shiftTexcoords");

Vector2 translation(0, 0);

if (args.size() > 0)
{
auto gridSize = GlobalGrid().getGridSize(grid::Space::Texture);

if (args[0].getString() == "up")
{
translation = Vector2(0, -gridSize);
}
else if (args[0].getString() == "down")
{
translation = Vector2(0, gridSize);
}
else if (args[0].getString() == "left")
{
translation = Vector2(-gridSize, 0);
}
else if (args[0].getString() == "right")
{
translation = Vector2(gridSize, 0);
}
}

auto transform = Matrix3::getTranslation(translation);

foreachSelectedNodeOfAnyType([&](const INode::Ptr& node)
{
node->beginTransformation();

if (getSelectionMode() == textool::SelectionMode::Surface)
{
node->transform(transform);
}
else
{
auto componentTransformable = std::dynamic_pointer_cast<IComponentTransformable>(node);

if (componentTransformable)
{
componentTransformable->transformComponents(transform);
}
}

node->commitTransformation();
return true;
});
}

module::StaticModule<TextureToolSelectionSystem> _textureToolSelectionSystemModule;

}
1 change: 1 addition & 0 deletions radiantcore/selection/textool/TextureToolSelectionSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class TextureToolSelectionSystem :
void flipHorizontallyCmd(const cmd::ArgumentList& args);
void flipVerticallyCmd(const cmd::ArgumentList& args);
void normaliseSelectionCmd(const cmd::ArgumentList& args);
void shiftSelectionCmd(const cmd::ArgumentList& args);

void flipSelected(int axis);
void performSelectionTest(Selector& selector, SelectionTest& test);
Expand Down

0 comments on commit d56a453

Please sign in to comment.