diff --git a/src/Preferences/PreferencesDialog.gd b/src/Preferences/PreferencesDialog.gd index eae40d0c1..920569487 100644 --- a/src/Preferences/PreferencesDialog.gd +++ b/src/Preferences/PreferencesDialog.gd @@ -156,7 +156,10 @@ func preference_update(prop : String) -> void: if prop in ["guide_color"]: for guide in Global.canvas.get_children(): - if guide is Guide: + if guide is SymmetryGuide: + # Add a subtle difference to the normal guide color by mixing in some blue + guide.default_color = Global.guide_color.linear_interpolate(Color(0.2 , 0.2, .65), .6) + elif guide is Guide: guide.default_color = Global.guide_color if prop in ["fps_limit"]: diff --git a/src/UI/Canvas/Rulers/Guide.gd b/src/UI/Canvas/Rulers/Guide.gd index a388e717c..f98c33534 100644 --- a/src/UI/Canvas/Rulers/Guide.gd +++ b/src/UI/Canvas/Rulers/Guide.gd @@ -13,6 +13,8 @@ func _ready() -> void: width = Global.camera.zoom.x * 2 default_color = Global.guide_color project.guides.append(self) + if outside_canvas(): + modulate.a = 0.5 func _input(_event : InputEvent): @@ -45,10 +47,17 @@ func _input(_event : InputEvent): var xx = stepify(mouse_pos.x, 0.5) points[0].x = xx points[1].x = xx + if outside_canvas(): + modulate.a = 0.5 + else: + modulate.a = 1 if Input.is_action_just_released("left_mouse"): Global.has_focus = true has_focus = false - if !outside_canvas(): + if outside_canvas(): + project.guides.erase(self) + queue_free() + else: update() @@ -63,7 +72,8 @@ func _draw() -> void: for p in range(viewport_poly.size()): viewport_poly[p] = viewport_poly[p].rotated(Global.camera.rotation) * zoom + Vector2(Global.camera.offset.x - (viewport_size.rotated(Global.camera.rotation).x / 2) * zoom.x, Global.camera.offset.y - (viewport_size.rotated(Global.camera.rotation).y / 2) * zoom.y) - var string = "%spx" % str(stepify(mouse_pos.y if type == Types.HORIZONTAL else mouse_pos.x, 0.5)) + var string := "%spx" % str(stepify(mouse_pos.y if type == Types.HORIZONTAL else mouse_pos.x, 0.5)) + var color: Color = Global.control.theme.get_color("font_color", "Label") # X and Y offsets for nicer looking spacing var x_offset := 5 var y_offset := -7 # Only used where the string is above the guide @@ -74,44 +84,37 @@ func _draw() -> void: if intersection: draw_set_transform(intersection, Global.camera.rotation, zoom * 2) if intersection.distance_squared_to(viewport_poly[0]) < intersection.distance_squared_to(viewport_poly[1]): - draw_string(font, Vector2(x_offset, font.get_height()), string) + draw_string(font, Vector2(x_offset, font.get_height()), string, color) else: - draw_string(font, Vector2(-font.get_string_size(string).x - x_offset, font.get_height()), string) + draw_string(font, Vector2(-font.get_string_size(string).x - x_offset, font.get_height()), string, color) return intersection = Geometry.segment_intersects_segment_2d(points[0], points[1], viewport_poly[3], viewport_poly[0]) if intersection: draw_set_transform(intersection, Global.camera.rotation, zoom * 2) if intersection.distance_squared_to(viewport_poly[3]) < intersection.distance_squared_to(viewport_poly[0]): - draw_string(font, Vector2(x_offset, y_offset), string) + draw_string(font, Vector2(x_offset, y_offset), string, color) else: - draw_string(font, Vector2(x_offset, font.get_height()), string) + draw_string(font, Vector2(x_offset, font.get_height()), string, color) return intersection = Geometry.segment_intersects_segment_2d(points[0], points[1], viewport_poly[1], viewport_poly[2]) if intersection: draw_set_transform(intersection, Global.camera.rotation, zoom * 2) if intersection.distance_squared_to(viewport_poly[1]) < intersection.distance_squared_to(viewport_poly[2]): - draw_string(font, Vector2(-font.get_string_size(string).x - x_offset, font.get_height()), string) + draw_string(font, Vector2(-font.get_string_size(string).x - x_offset, font.get_height()), string, color) else: - draw_string(font, Vector2(-font.get_string_size(string).x - x_offset, y_offset), string) + draw_string(font, Vector2(-font.get_string_size(string).x - x_offset, y_offset), string, color) return # If there's no intersection with a viewport edge, show string in top left corner draw_set_transform(viewport_poly[0], Global.camera.rotation, zoom * 2) - draw_string(font, Vector2(x_offset, font.get_height()), string) + draw_string(font, Vector2(x_offset, font.get_height()), string, color) func outside_canvas() -> bool: if type == Types.HORIZONTAL: - if points[0].y < 0 || points[0].y > project.size.y: - project.guides.erase(self) - queue_free() - return true + return points[0].y < 0 || points[0].y > project.size.y else: - if points[0].x < 0 || points[0].x > project.size.x: - project.guides.erase(self) - queue_free() - return true - return false + return points[0].x < 0 || points[0].x > project.size.x func point_in_rectangle(p : Vector2, coord1 : Vector2, coord2 : Vector2) -> bool: diff --git a/src/UI/Canvas/Rulers/SymmetryGuide.gd b/src/UI/Canvas/Rulers/SymmetryGuide.gd index 8a6ad34e3..d7e3ede54 100644 --- a/src/UI/Canvas/Rulers/SymmetryGuide.gd +++ b/src/UI/Canvas/Rulers/SymmetryGuide.gd @@ -11,25 +11,23 @@ func _ready() -> void: texture_mode = Line2D.LINE_TEXTURE_TILE width = Global.camera.zoom.x * 4 yield(get_tree().create_timer(0.01), "timeout") - modulate = Global.guide_color + # Add a subtle difference to the normal guide color by mixing in some blue + default_color = Global.guide_color.linear_interpolate(Color(0.2 , 0.2, .65), .6) func _input(_event : InputEvent) -> void: ._input(_event) if type == Types.HORIZONTAL: project.y_symmetry_point = points[0].y * 2 - 1 + points[0].y = clamp(points[0].y, 0, Global.current_project.size.y) + points[1].y = clamp(points[1].y, 0, Global.current_project.size.y) elif type == Types.VERTICAL: + points[0].x = clamp(points[0].x, 0, Global.current_project.size.x) + points[1].x = clamp(points[1].x, 0, Global.current_project.size.x) project.x_symmetry_point = points[0].x * 2 - 1 yield(get_tree().create_timer(0.01), "timeout") func outside_canvas() -> bool: - if type == Types.HORIZONTAL: - points[0].y = clamp(points[0].y, 0, Global.current_project.size.y) - points[1].y = clamp(points[1].y, 0, Global.current_project.size.y) - elif type == Types.VERTICAL: - points[0].x = clamp(points[0].x, 0, Global.current_project.size.x) - points[1].x = clamp(points[1].x, 0, Global.current_project.size.x) - return false