Skip to content

Commit

Permalink
#5348: Switch the crosshair cursor back to default after leaving clip…
Browse files Browse the repository at this point in the history
… mode
  • Loading branch information
codereader committed Oct 2, 2020
1 parent b1365b0 commit b016b34
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 25 deletions.
16 changes: 15 additions & 1 deletion radiant/xyview/tools/ClipperTool.cpp
Expand Up @@ -10,6 +10,10 @@
namespace ui
{

ClipperTool::ClipperTool() :
_crossHairEnabled(false)
{}

const std::string& ClipperTool::getName()
{
static std::string name("ClipperTool");
Expand Down Expand Up @@ -37,7 +41,7 @@ MouseTool::Result ClipperTool::onMouseDown(Event& ev)

GlobalClipper().setMovingClip(foundClipPoint);

if (foundClipPoint == NULL)
if (foundClipPoint == nullptr)
{
dropClipPoint(xyEvent);
}
Expand All @@ -61,6 +65,13 @@ MouseTool::Result ClipperTool::onMouseMove(Event& ev)

if (!GlobalClipper().clipMode())
{
// Check if we need to clean up the XY cursor state
if (_crossHairEnabled)
{
xyEvent.getView().setCursorType(IOrthoView::CursorType::Default);
_crossHairEnabled = false;
}

return Result::Ignored;
}

Expand All @@ -80,11 +91,14 @@ MouseTool::Result ClipperTool::onMouseMove(Event& ev)
if (GlobalClipper().find(xyEvent.getWorldPos(), xyEvent.getViewType(), xyEvent.getScale()) != NULL)
{
xyEvent.getView().setCursorType(IOrthoView::CursorType::Crosshair);
// Remember to clean up the cursor when clip mode is deactivated
_crossHairEnabled = true;
return Result::Continued;
}
else
{
xyEvent.getView().setCursorType(IOrthoView::CursorType::Default);
_crossHairEnabled = false;
return Result::Continued;
}
}
Expand Down
5 changes: 5 additions & 0 deletions radiant/xyview/tools/ClipperTool.h
Expand Up @@ -14,7 +14,12 @@ class XYMouseToolEvent;
class ClipperTool :
public MouseTool
{
private:
bool _crossHairEnabled;

public:
ClipperTool();

const std::string& getName() override;
const std::string& getDisplayName() override;

Expand Down
49 changes: 25 additions & 24 deletions radiantcore/clipper/Clipper.h
@@ -1,18 +1,20 @@
#ifndef CLIPPER_H
#define CLIPPER_H
#pragma once

#include "iclipper.h"
#include "iregistry.h"
#include "icommandsystem.h"
#include "ClipPoint.h"
#include "math/AABB.h"

namespace {
namespace
{
const unsigned int NUM_CLIP_POINTS = 3;
}

class Clipper : public IClipper
class Clipper :
public IClipper
{
private:
// Hold the currently active xy view type
EViewType _viewType;

Expand Down Expand Up @@ -40,40 +42,40 @@ class Clipper : public IClipper

void constructPreferences();

EViewType getViewType() const;
void setViewType(EViewType viewType);
ClipPoint* getMovingClip();
EViewType getViewType() const override;
void setViewType(EViewType viewType) override;
ClipPoint* getMovingClip() override;

Vector3& getMovingClipCoords();
void setMovingClip(ClipPoint* clipPoint);
Vector3& getMovingClipCoords() override;
void setMovingClip(ClipPoint* clipPoint) override;

bool useCaulkForNewFaces() const;
const std::string& getCaulkShader() const;
bool useCaulkForNewFaces() const override;
const std::string& getCaulkShader() const override;

// greebo: Cycles through the three possible clip points and returns the nearest to point (for selectiontest)
ClipPoint* find(const Vector3& point, EViewType viewtype, float scale);
ClipPoint* find(const Vector3& point, EViewType viewtype, float scale) override;

// Returns true if at least two clip points are set
bool valid() const;
void draw(float scale);
void draw(float scale) override;
void getPlanePoints(Vector3 planepts[3], const AABB& bounds) const;

void setClipPlane(const Plane3& plane);

void update();
void flipClip();
void update() override;
void flipClip() override;
void reset();
void clip();
void clip() override;

void splitClip();
bool clipMode() const;
void onClipMode(bool enabled);
void newClipPoint(const Vector3& point);
void splitClip() override;
bool clipMode() const override;
void onClipMode(bool enabled) override;
void newClipPoint(const Vector3& point) override;

// RegisterableModule implementation
virtual const std::string& getName() const;
virtual const StringSet& getDependencies() const;
virtual void initialiseModule(const IApplicationContext& ctx);
const std::string& getName() const override;
const StringSet& getDependencies() const override;
void initialiseModule(const IApplicationContext& ctx) override;

// Command targets
void clipSelectionCmd(const cmd::ArgumentList& args);
Expand All @@ -82,4 +84,3 @@ class Clipper : public IClipper

}; // class Clipper

#endif /* CLIPPER_H */

0 comments on commit b016b34

Please sign in to comment.