Skip to content

Commit

Permalink
#5746: Start setting up the selection tool
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Sep 10, 2021
1 parent f073588 commit 1517261
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 8 deletions.
2 changes: 1 addition & 1 deletion install/input.xml
Expand Up @@ -33,7 +33,7 @@
</mouseToolMapping>
<!-- ID 2 = textool -->
<mouseToolMapping name="TextureTool" id="2">
<tool name="TexToolMoveViewTool" button="RMB" modifiers="" />
<tool name="TextureToolSelectionTool" button="LMB" modifiers="SHIFT" />
</mouseToolMapping>
</mouseToolMappings>
<cameraview>
Expand Down
2 changes: 2 additions & 0 deletions radiant/eventmanager/MouseToolGroup.cpp
Expand Up @@ -23,6 +23,8 @@ std::string MouseToolGroup::getDisplayName()
return _("XY View");
case Type::CameraView:
return _("Camera View");
case Type::TextureTool:
return _("Texture Tool");
default:
return _("Unknown");
};
Expand Down
3 changes: 1 addition & 2 deletions radiant/selection/SelectionMouseTools.h
Expand Up @@ -54,7 +54,6 @@ class SelectMouseTool: public MouseTool
class BasicSelectionTool: public SelectMouseTool
{
private:

Vector2 _start; // Position at mouseDown
Vector2 _current; // Position during mouseMove

Expand All @@ -79,7 +78,7 @@ class BasicSelectionTool: public SelectMouseTool
}

// Performs a drag- or point-selection test
void testSelect(Event& ev) override;
virtual void testSelect(Event& ev) override;

// Recalculates the rectangle used to draw the GUI overlay
void updateDragSelectionRectangle(Event& ev);
Expand Down
17 changes: 13 additions & 4 deletions radiant/textool/TexTool.cpp
Expand Up @@ -52,7 +52,9 @@ TexTool::TexTool() :
MouseToolHandler(IMouseToolGroup::Type::TextureTool),
_glWidget(new wxutil::GLWidget(this, std::bind(&TexTool::onGLDraw, this), "TexTool")),
_selectionInfo(GlobalSelectionSystem().getSelectionInfo()),
#if 0
_dragRectangle(false),
#endif
_manipulatorMode(false),
_grid(GRID_DEFAULT),
_gridActive(registry::getValue<bool>(RKEY_GRID_STATE)),
Expand Down Expand Up @@ -570,7 +572,7 @@ void TexTool::doMouseUp(const Vector2& coords, wxMouseEvent& event)
// Finish the undo recording, store the accumulated undomementos
endOperation("TexToolDrag");
}

#if 0
// If we are in selection mode, end the selection
if ((event.LeftUp() && event.ShiftDown())
&& _dragRectangle)
Expand Down Expand Up @@ -599,18 +601,21 @@ void TexTool::doMouseUp(const Vector2& coords, wxMouseEvent& event)
selectables[i]->toggle();
}
}

#endif
draw();
}

void TexTool::doMouseMove(const Vector2& coords, wxMouseEvent& event)
{
#if 0
if (_dragRectangle)
{
_selectionRectangle.bottomRight = coords;
draw();
}
else if (_manipulatorMode)
else
#endif
if (_manipulatorMode)
{
Vector2 delta = coords - _manipulateRectangle.topLeft;

Expand Down Expand Up @@ -660,7 +665,9 @@ void TexTool::doMouseMove(const Vector2& coords, wxMouseEvent& event)
void TexTool::doMouseDown(const Vector2& coords, wxMouseEvent& event)
{
_manipulatorMode = false;
#if 0
_dragRectangle = false;
#endif

if (event.LeftDown() && !event.HasAnyModifiers())
{
Expand All @@ -679,13 +686,15 @@ void TexTool::doMouseDown(const Vector2& coords, wxMouseEvent& event)
beginOperation();
}
}
#if 0
else if (event.LeftDown() && event.ShiftDown())
{
// Start a drag or click operation
_dragRectangle = true;
_selectionRectangle.topLeft = coords;
_selectionRectangle.bottomRight = coords;
}
#endif
}

void TexTool::selectRelatedItems() {
Expand Down Expand Up @@ -964,7 +973,7 @@ bool TexTool::onGLDraw()
}
}

#if 1
#if 0
if (_dragRectangle) {
// Create a working reference to save typing
textool::Rectangle& rectangle = _selectionRectangle;
Expand Down
5 changes: 4 additions & 1 deletion radiant/textool/TexTool.h
Expand Up @@ -69,14 +69,17 @@ class TexTool :
// The currently active objects in the textool window
textool::TexToolItemVec _items;

#if 0
// The draggable selection rectangle
textool::Rectangle _selectionRectangle;

#endif
// The rectangle defining the manipulation's start and end point
textool::Rectangle _manipulateRectangle;

#if 0
// TRUE if we are in selection mode
bool _dragRectangle;
#endif

// TRUE if a manipulation is currently ongoing
bool _manipulatorMode;
Expand Down
39 changes: 39 additions & 0 deletions radiant/textool/tools/TextureToolSelectionTool.h
@@ -0,0 +1,39 @@
#pragma once

#include "i18n.h"
#include "math/Vector2.h"
#include "selection/SelectionMouseTools.h"

namespace ui
{

class TextureToolSelectionTool :
public BasicSelectionTool
{
private:
Vector2 _start; // Position at mouseDown
Vector2 _current; // Position during mouseMove

public:
TextureToolSelectionTool()
{}

virtual const std::string& getName() override
{
static std::string name("TextureToolSelectionTool");
return name;
}

virtual const std::string& getDisplayName() override
{
static std::string displayName(_("Select"));
return displayName;
}

virtual void testSelect(Event& ev) override
{
int i = 6;
}
};

}
2 changes: 2 additions & 0 deletions radiant/ui/mousetool/RegistrationHelper.h
Expand Up @@ -5,6 +5,7 @@
#include "selection/ManipulateMouseTool.h"
#include "xyview/tools/MoveViewTool.h"
#include "xyview/tools/ZoomTool.h"
#include "textool/tools/TextureToolSelectionTool.h"

namespace ui
{
Expand Down Expand Up @@ -34,6 +35,7 @@ class MouseToolRegistrationHelper

texToolGroup.registerMouseTool(std::make_shared<MoveViewTool>());
texToolGroup.registerMouseTool(std::make_shared<ZoomTool>());
texToolGroup.registerMouseTool(std::make_shared<TextureToolSelectionTool>());
}
};

Expand Down
1 change: 1 addition & 0 deletions tools/msvc/DarkRadiant.vcxproj
Expand Up @@ -418,6 +418,7 @@
<ClInclude Include="..\..\radiant\settings\LocalisationProvider.h" />
<ClInclude Include="..\..\radiant\settings\Win32Registry.h" />
<ClInclude Include="..\..\radiant\textool\tools\TextureToolMouseEvent.h" />
<ClInclude Include="..\..\radiant\textool\tools\TextureToolSelectionTool.h" />
<ClInclude Include="..\..\radiant\ui\aas\AasControl.h" />
<ClInclude Include="..\..\radiant\ui\aas\AasControlDialog.h" />
<ClInclude Include="..\..\radiant\ui\aas\RenderableAasFile.h" />
Expand Down
3 changes: 3 additions & 0 deletions tools/msvc/DarkRadiant.vcxproj.filters
Expand Up @@ -1416,6 +1416,9 @@
<ClInclude Include="..\..\radiant\textool\tools\TextureToolMouseEvent.h">
<Filter>src\textool\tools</Filter>
</ClInclude>
<ClInclude Include="..\..\radiant\textool\tools\TextureToolSelectionTool.h">
<Filter>src\textool\tools</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\radiant\darkradiant.rc" />
Expand Down

0 comments on commit 1517261

Please sign in to comment.