-
Notifications
You must be signed in to change notification settings - Fork 79
UI / UX Changes #175
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
Open
Pizzaandy
wants to merge
4
commits into
SirRamEsq:master
Choose a base branch
from
Pizzaandy:ui-ux-changes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
UI / UX Changes #175
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,8 @@ var ICON_SNAP: Texture2D = load("res://addons/rmsmartshape/assets/icon_editor_sn | |
| var ICON_IMPORT_CLOSED: Texture2D = load("res://addons/rmsmartshape/assets/closed_shape.png") | ||
| var ICON_IMPORT_OPEN: Texture2D = load("res://addons/rmsmartshape/assets/open_shape.png") | ||
|
|
||
| const HANDLE_RADIUS: float = 13 | ||
|
|
||
| const FUNC = preload("plugin_functionality.gd") | ||
| const ActionAddCollisionNodes := preload("res://addons/rmsmartshape/actions/action_add_collision_nodes.gd") | ||
| const ActionMoveVerticies := preload("res://addons/rmsmartshape/actions/action_move_verticies.gd") | ||
|
|
@@ -457,21 +459,18 @@ func _forward_canvas_gui_input(event: InputEvent) -> bool: | |
| cached_shape_global_transform = shape.get_global_transform() | ||
|
|
||
| var et: Transform2D = get_et() | ||
| var grab_threshold: float = EditorInterface.get_editor_settings().get( | ||
| "editors/polygon_editor/point_grab_radius" | ||
| ) | ||
|
|
||
| var key_return_value := false | ||
| if event is InputEventKey: | ||
| key_return_value = _input_handle_keyboard_event(event) | ||
|
|
||
| var mb_return_value := false | ||
| if event is InputEventMouseButton: | ||
| mb_return_value = _input_handle_mouse_button_event(event, et, grab_threshold) | ||
| mb_return_value = _input_handle_mouse_button_event(event, et, HANDLE_RADIUS) | ||
|
|
||
| var mm_return_value := false | ||
| if event is InputEventMouseMotion: | ||
| mb_return_value = _input_handle_mouse_motion_event(event, et, grab_threshold) | ||
| mb_return_value = _input_handle_mouse_motion_event(event, et, HANDLE_RADIUS) | ||
|
|
||
| var return_value := key_return_value == true or mb_return_value == true or mm_return_value == true | ||
| _gui_update_info_panels() | ||
|
|
@@ -733,12 +732,15 @@ func _forward_canvas_draw_over_viewport(overlay: Control) -> void: | |
| if not is_shape_valid() or not is_inside_tree(): | ||
| return | ||
|
|
||
| if Input.is_key_pressed(KEY_H): | ||
| return | ||
|
|
||
| match current_mode: | ||
| MODE.CREATE_VERT: | ||
| draw_mode_edit_vert(overlay) | ||
| if Input.is_key_pressed(KEY_ALT) and Input.is_key_pressed(KEY_SHIFT): | ||
| draw_new_shape_preview(overlay) | ||
| elif Input.is_key_pressed(KEY_ALT): | ||
| elif Input.is_key_pressed(KEY_ALT) or shape.is_shape_closed(): | ||
| draw_new_point_close_preview(overlay) | ||
| else: | ||
| draw_new_point_preview(overlay) | ||
|
|
@@ -777,8 +779,8 @@ func draw_mode_edit_edge(overlay: Control, color_normal: Color, color_highlight: | |
| var t: Transform2D = get_et() * shape.get_global_transform() | ||
| var verts: PackedVector2Array = shape.get_vertices() | ||
|
|
||
| draw_shape_outline(overlay, t, verts, Color.BLACK, 3) | ||
| draw_shape_outline(overlay, t, verts, color_normal) | ||
| draw_vert_handles(overlay, t, verts, false) | ||
|
|
||
| if current_action.type == ACTION_VERT.MOVE_VERT: | ||
| var edge_point_keys := current_action.keys | ||
|
|
@@ -824,38 +826,40 @@ func draw_mode_edit_vert(overlay: Control, show_vert_handles: bool = true) -> vo | |
| var t: Transform2D = get_et() * shape.get_global_transform() | ||
| var verts: PackedVector2Array = shape.get_vertices() | ||
| var points: PackedVector2Array = shape.get_tessellated_points() | ||
| draw_shape_outline(overlay, t, points, shape.modulate) | ||
| var color := Color(1, 1, 1, 0.6) | ||
| draw_shape_outline(overlay, t, points, color) | ||
| if show_vert_handles: | ||
| draw_vert_handles(overlay, t, verts, true) | ||
| if on_edge: | ||
| overlay.draw_texture(ICON_ADD_HANDLE, edge_point - ICON_ADD_HANDLE.get_size() * 0.5) | ||
|
|
||
| # Draw Highlighted Handle | ||
| if current_action.is_single_vert_selected(): | ||
| var tex: Texture2D = ICON_HANDLE_SELECTED | ||
| overlay.draw_texture( | ||
| tex, t * verts[current_action.current_point_index(shape)] - tex.get_size() * 0.5 | ||
| ) | ||
|
|
||
|
|
||
| func draw_shape_outline( | ||
| overlay: Control, t: Transform2D, points: PackedVector2Array, color: Color, width: float = 2.0 | ||
| overlay: Control, t: Transform2D, points: PackedVector2Array, color: Color, width: float = 1.0 | ||
| ) -> void: | ||
| if points.size() >= 2: | ||
| overlay.draw_polyline(t * points, Color.BLACK, width * 1.5, true) | ||
| overlay.draw_polyline(t * points, color, width, true) | ||
|
|
||
|
|
||
| func draw_vert_handles( | ||
| overlay: Control, t: Transform2D, verts: PackedVector2Array, control_points: bool | ||
| ) -> void: | ||
| var transformed_verts := t * verts | ||
| for i in verts.size(): | ||
| var draw_vert_count: int = max(verts.size() - 1, 0) if shape.is_shape_closed() else verts.size() | ||
|
|
||
| for i in draw_vert_count: | ||
| # Draw Vert handles | ||
| var hp: Vector2 = transformed_verts[i] | ||
| var icon: Texture2D = ICON_HANDLE_BEZIER if (Input.is_key_pressed(KEY_SHIFT) and not current_mode == MODE.FREEHAND) else ICON_HANDLE | ||
| var icon: Texture2D = ICON_HANDLE | ||
| overlay.draw_texture(icon, hp - icon.get_size() * 0.5) | ||
|
|
||
| # Draw Highlighted Handle | ||
| if current_action.is_single_vert_selected(): | ||
| var tex: Texture2D = ICON_HANDLE_SELECTED | ||
| overlay.draw_texture( | ||
| tex, t * verts[current_action.current_point_index(shape)] - tex.get_size() * 0.5 | ||
| ) | ||
|
|
||
| # Draw Width handle | ||
| var offset: float = WIDTH_HANDLE_OFFSET | ||
| var width_handle_key: int = closest_key | ||
|
|
@@ -885,26 +889,30 @@ func draw_vert_handles( | |
| for i in verts.size(): | ||
| var key: int = shape.get_point_key_at_index(i) | ||
| var hp: Vector2 = transformed_verts[i] | ||
| var is_bezier_vert: bool = false | ||
|
|
||
| # Drawing the point-out for the last point makes no sense, as there's no point ahead of it | ||
| if i < verts.size() - 1: | ||
| var pointout: Vector2 = t * (verts[i] + shape.get_point_out(key)) | ||
| if hp != pointout: | ||
| _draw_control_point_line(overlay, hp, pointout, ICON_HANDLE_CONTROL) | ||
| is_bezier_vert = true | ||
| # Drawing the point-in for point 0 makes no sense, as there's no point behind it | ||
| if i > 0: | ||
| var pointin: Vector2 = t * (verts[i] + shape.get_point_in(key)) | ||
| if hp != pointin: | ||
| _draw_control_point_line(overlay, hp, pointin, ICON_HANDLE_CONTROL) | ||
| is_bezier_vert = true | ||
|
|
||
| if is_bezier_vert: | ||
| overlay.draw_texture(ICON_HANDLE_BEZIER, hp - ICON_HANDLE_BEZIER.get_size() * 0.5) | ||
|
|
||
|
|
||
| func _draw_control_point_line(c: Control, vert: Vector2, cp: Vector2, tex: Texture2D) -> void: | ||
| # Draw the line with a dark and light color to be visible on all backgrounds | ||
| var color_dark := Color(0, 0, 0, 0.3) | ||
| var color_light := Color(1, 1, 1, .5) | ||
| var color_light := Color(1, 1, 1, .6) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the color constant from before. |
||
| var width := 2.0 | ||
| var normal := (cp - vert).normalized() | ||
| c.draw_line(vert + normal * 4 + Vector2.DOWN, cp + Vector2.DOWN, color_dark, width) | ||
| c.draw_line(vert + normal * 4, cp, color_light, width) | ||
| c.draw_texture(tex, cp - tex.get_size() * 0.5) | ||
|
|
||
|
|
@@ -918,13 +926,8 @@ func draw_new_point_preview(overlay: Control) -> void: | |
| var mouse: Vector2 = overlay.get_local_mouse_position() | ||
|
|
||
| if verts.size() > 0: | ||
| var a: Vector2 | ||
| if shape.is_shape_closed() and verts.size() > 1: | ||
| a = t * verts[verts.size() - 2] | ||
| overlay.draw_line(mouse, t * verts[0], color,width * .5) | ||
| else: | ||
| a = t * verts[verts.size() - 1] | ||
| overlay.draw_line(mouse, a, color, width) | ||
| var a: Vector2 = t * verts[verts.size() - 1] | ||
| overlay.draw_dashed_line(mouse, a, color, width, width * 3) | ||
|
|
||
| overlay.draw_texture(ICON_ADD_HANDLE, mouse - ICON_ADD_HANDLE.get_size() * 0.5) | ||
|
|
||
|
|
@@ -938,9 +941,8 @@ func draw_new_point_close_preview(overlay: Control) -> void: | |
| var mouse: Vector2 = overlay.get_local_mouse_position() | ||
| var a: Vector2 = t * shape.get_point_position(closest_edge_keys[0]) | ||
| var b: Vector2 = t * shape.get_point_position(closest_edge_keys[1]) | ||
| overlay.draw_line(mouse, a, color, width) | ||
| color.a = 0.1 | ||
| overlay.draw_line(mouse, b, color, width) | ||
| overlay.draw_dashed_line(mouse, a, color, width, width * 3) | ||
| overlay.draw_dashed_line(mouse, b, color, width, width * 3) | ||
| overlay.draw_texture(ICON_ADD_HANDLE, mouse - ICON_ADD_HANDLE.get_size() * 0.5) | ||
|
|
||
|
|
||
|
|
@@ -1053,12 +1055,13 @@ func _input_handle_left_click( | |
|
|
||
| if current_mode == MODE.EDIT_VERT or current_mode == MODE.CREATE_VERT: | ||
| gui_edge_info_panel.visible = false | ||
| var can_add_point: bool = Input.is_key_pressed(KEY_ALT) or current_mode == MODE.CREATE_VERT | ||
| var is_first_selected: bool = current_action.is_single_vert_selected() and current_action.current_point_key() == shape.get_point_key_at_index(0) | ||
|
|
||
| if _defer_mesh_updates: | ||
| shape.begin_update() | ||
|
|
||
| var can_add_point: bool = Input.is_key_pressed(KEY_ALT) or current_mode == MODE.CREATE_VERT | ||
| var is_first_selected: bool = current_action.is_single_vert_selected() and current_action.current_point_key() == shape.get_point_key_at_index(0) | ||
|
|
||
| # Close the shape if the first point is clicked | ||
| if can_add_point and is_first_selected and shape.can_close(): | ||
| var close_action := ActionCloseShape.new(shape) | ||
|
|
@@ -1070,7 +1073,7 @@ func _input_handle_left_click( | |
| return true | ||
|
|
||
| # Any nearby control points to move? | ||
| if not Input.is_key_pressed(KEY_ALT): | ||
| if not Input.is_key_pressed(KEY_ALT) and current_mode != MODE.CREATE_VERT: | ||
| if _input_move_control_points(mb, vp_m_pos, grab_threshold): | ||
| return true | ||
|
|
||
|
|
@@ -1105,7 +1108,7 @@ func _input_handle_left_click( | |
| selection.clear() | ||
| selection.add_node(copy) | ||
| shape = copy | ||
| elif Input.is_key_pressed(KEY_ALT): | ||
| elif Input.is_key_pressed(KEY_ALT) or shape.is_shape_closed(): | ||
| # Add point between start and end points of the closest edge | ||
| idx = shape.get_point_index(closest_edge_keys[1]) | ||
| var add_point := ActionAddPoint.new(shape, local_position, idx, not _defer_mesh_updates) | ||
|
|
@@ -1212,6 +1215,9 @@ func _input_handle_keyboard_event(event: InputEventKey) -> bool: | |
| if kb.keycode == KEY_ALT: | ||
| update_overlays() | ||
|
|
||
| if kb.keycode == KEY_H: | ||
| update_overlays() | ||
|
|
||
| return true | ||
| return false | ||
|
|
||
|
|
@@ -1230,6 +1236,8 @@ func _is_valid_keyboard_scancode(kb: InputEventKey) -> bool: | |
| return true | ||
| KEY_CTRL: | ||
| return true | ||
| KEY_H: | ||
| return true | ||
| return false | ||
|
|
||
|
|
||
|
|
@@ -1530,7 +1538,7 @@ func _input_handle_mouse_motion_event( | |
| on_edge = false | ||
| on_width_handle = true | ||
| current_action = select_verticies([mouse_over_width_handle], ACTION_VERT.NONE) | ||
| elif Input.is_key_pressed(KEY_ALT): | ||
| elif Input.is_key_pressed(KEY_ALT) or current_mode == MODE.CREATE_VERT: | ||
| _input_find_closest_edge_keys(mm) | ||
| else: | ||
| deselect_verts() | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Make this color a constant to make it reusable and to prevent needless allocations.