-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented rectangle drag placing objects #8 #439
base: master
Are you sure you want to change the base?
Implemented rectangle drag placing objects #8 #439
Conversation
Atria1234
commented
Sep 16, 2022
- hold shift while starting placing single object to initiate
- hold shift while starting placing single object to initiate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Program Test it works like a Charm, Tree and Button wise
So it may be approved but code wise is for me still not a thing to do
@FroggieFrog if you would please do this :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good.
The main changes I'd like to see is to move the class GeneratePointsInsideRect
, as it doesn't really fit inside IEnumerable extensions. Additionally, added some notes about hotkeys as well as some suggestions for if we should deal with all selected objects.
/// <param name="step">Increment between iterations.</param> | ||
/// <param name="inclusiveTo">Returns value after last iteration if set to true.</param> | ||
/// <returns>Sequence of doubles between provided bounds.</returns> | ||
public static IEnumerable<double> Range(double from, double to, double step = 1, bool inclusiveTo = false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like we only use this for the GeneratePointsInsideRect
method, so we could probably just keep this private for now.
var objectToClone = CurrentObjects[0]; | ||
var start = ScreenPointToObjectGridPosition(_mouseDragStart, objectToClone); | ||
var end = ScreenPointToObjectGridPosition(_mousePosition, objectToClone); | ||
var clones = Core.Extensions.IEnumerableExtensions.GeneratePointsInsideRect(start, end, objectToClone.Size, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is the only way we use this method, then it probably doesn't belong in the IEnumerableExtensions class.
We should probably make it some kind of helper, maybe something do with sequences, primitives, or shapes.
@@ -932,6 +934,24 @@ protected override void OnRender(DrawingContext drawingContext) | |||
objectsChanged = true; | |||
} | |||
|
|||
if (CurrentMode == MouseMode.RectPlaceObjects && CurrentObjects.Count == 1) | |||
{ | |||
var objectToClone = CurrentObjects[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a suggestion - do we only want this to work with one object?
Couldn't we technically figure out a bounding box and related to step size and clone entire groups of objects?
@@ -2106,8 +2120,17 @@ protected override void OnMouseDown(MouseButtonEventArgs e) | |||
} | |||
else if (e.LeftButton == MouseButtonState.Pressed && CurrentObjects.Count != 0) | |||
{ | |||
// place new object | |||
TryPlaceCurrentObjects(isContinuousDrawing: false); | |||
if (IsShiftPressed() && CurrentObjects.Count == 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be configurable, as other hotkeys are.