-
-
Notifications
You must be signed in to change notification settings - Fork 202
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
First snapping implementation #507
Conversation
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.
Thank you so much for this amazing submission.
Pretty much every comment I left is purely from a code formatting point of view. Let me know if you don't want to take care of this I can do that for you :D
// This is a temporary approach to end operations. In the future we may want to have more specific | ||
// methods. | ||
selected_bound_manager.alert_held_button_release (); |
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.
Maybe this method could be called on_butten_release ()
Lib.Items.CanvasItem item, | ||
double event_x, | ||
double event_y | ||
) { |
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.
We can inline this with private void move_from_event (Items.CanvasItem item, double event_x, double event_y) {
double event_x, | ||
double event_y | ||
) { | ||
|
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.
Remove the empty line.
// Make adjustment basted on snaps | ||
// Double the sensitivity to allow for reuse of grid after snap |
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.
We usually try to end all the inline comments with a period.
// then be translated again. | ||
// Make adjustment basted on snaps | ||
// Double the sensitivity to allow for reuse of grid after snap | ||
var sensitivity = (int) Utils.Snapping.adjusted_sensitivity (canvas.current_scale); |
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 we always need an INTEGER from this method, we should return directly an integer from the method instead of type casting it every time we use it.
src/Utils/Snapping.vala
Outdated
List<weak Goo.CanvasItem> v_candidates, | ||
List<weak Goo.CanvasItem> h_candidates, | ||
List<Lib.Items.CanvasItem> selection |
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.
Indent these attributes.
src/Utils/Snapping.vala
Outdated
var candidate_item = cand as Lib.Items.CanvasItem; | ||
if (candidate_item != null && selection.find (candidate_item) == null) { | ||
populate_vertical_snaps (candidate_item, ref grid.v_snaps); | ||
} |
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.
The indentation here is a bit wrong, as well as in the next foreach loop.
src/Utils/Snapping.vala
Outdated
return grid; | ||
} | ||
|
||
/// Populates the horizontal snaps of an item |
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.
Comment block for methods, please :D
src/Utils/Snapping.vala
Outdated
|
||
/// Populates the horizontal snaps of an item | ||
private static void populate_horizontal_snaps (Lib.Items.CanvasItem item, ref Gee.HashMap<int, SnapMeta> map) { | ||
int x_1 = (int)item.bounds.x1; |
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.
Space after (int)
src/Utils/Snapping.vala
Outdated
if (map.has_key (pos)) { | ||
SnapMeta k = map.get (pos); | ||
k.normals.add (n1); | ||
k.normals.add (n2); | ||
k.normals.add (n3); | ||
k.polarity += polarity; | ||
} | ||
else { | ||
var v = new SnapMeta (); | ||
v.normals = new Gee.HashSet<int> (); | ||
v.normals.add (n1); | ||
v.normals.add (n2); | ||
v.normals.add (n3); | ||
v.polarity = polarity; | ||
map.set (pos, v); | ||
} |
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.
Since nothing happens after the callback condition, we can do an early return;
in the first condition, and avoid the else.
Implements snapping between objects. Lays the groundwork for a future, more complete implementation.
Notable features:
Notable missing features are: