Skip to content

Commit

Permalink
Add Corner to geometry and make names of corner methods consistent (z…
Browse files Browse the repository at this point in the history
…ed-industries#22119)

Release Notes:

- N/A
  • Loading branch information
mgsloan authored and helgemahrt committed Dec 18, 2024
1 parent 90a7970 commit 0c4e500
Show file tree
Hide file tree
Showing 39 changed files with 325 additions and 254 deletions.
2 changes: 1 addition & 1 deletion crates/activity_indicator/src/activity_indicator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ impl Render for ActivityIndicator {
}),
),
)
.anchor(gpui::AnchorCorner::BottomLeft)
.anchor(gpui::Corner::BottomLeft)
.menu(move |cx| {
let strong_this = this.upgrade()?;
let mut has_work = false;
Expand Down
2 changes: 1 addition & 1 deletion crates/assistant/src/inline_assistant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1556,7 +1556,7 @@ impl Render for PromptEditor {
anchored()
.position_mode(gpui::AnchoredPositionMode::Local)
.position(point(px(0.), px(24.)))
.anchor(gpui::AnchorCorner::TopLeft)
.anchor(gpui::Corner::TopLeft)
.child(self.render_rate_limit_notice(cx)),
)
})),
Expand Down
4 changes: 2 additions & 2 deletions crates/assistant/src/slash_command_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ impl<T: PopoverTrigger> RenderOnce for SlashCommandSelector<T> {
PopoverMenu::new("model-switcher")
.menu(move |_cx| Some(picker_view.clone()))
.trigger(self.trigger)
.attach(gpui::AnchorCorner::TopLeft)
.anchor(gpui::AnchorCorner::BottomLeft)
.attach(gpui::Corner::TopLeft)
.anchor(gpui::Corner::BottomLeft)
.offset(gpui::Point {
x: px(0.0),
y: px(-16.0),
Expand Down
4 changes: 2 additions & 2 deletions crates/assistant2/src/context_strip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ impl Render for ContextStrip {
)
}),
)
.attach(gpui::AnchorCorner::TopLeft)
.anchor(gpui::AnchorCorner::BottomLeft)
.attach(gpui::Corner::TopLeft)
.anchor(gpui::Corner::BottomLeft)
.offset(gpui::Point {
x: px(0.0),
y: px(-16.0),
Expand Down
2 changes: 1 addition & 1 deletion crates/assistant2/src/inline_assistant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1673,7 +1673,7 @@ impl Render for PromptEditor {
gpui::AnchoredPositionMode::Local,
)
.position(point(px(0.), px(24.)))
.anchor(gpui::AnchorCorner::TopLeft)
.anchor(gpui::Corner::TopLeft)
.child(self.render_rate_limit_notice(cx)),
)
})),
Expand Down
2 changes: 1 addition & 1 deletion crates/collab_ui/src/collab_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2708,7 +2708,7 @@ impl Render for CollabPanel {
deferred(
anchored()
.position(*position)
.anchor(gpui::AnchorCorner::TopLeft)
.anchor(gpui::Corner::TopLeft)
.child(menu.clone()),
)
.with_priority(1)
Expand Down
2 changes: 1 addition & 1 deletion crates/collab_ui/src/collab_panel/channel_modal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ impl PickerDelegate for ChannelModalDelegate {
Some(
deferred(
anchored()
.anchor(gpui::AnchorCorner::TopRight)
.anchor(gpui::Corner::TopRight)
.child(menu.clone()),
)
.with_priority(1),
Expand Down
2 changes: 1 addition & 1 deletion crates/collab_ui/src/collab_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn notification_window_options(
let notification_margin_height = px(-48.);

let bounds = gpui::Bounds::<Pixels> {
origin: screen.bounds().upper_right()
origin: screen.bounds().top_right()
- point(
size.width + notification_margin_width,
notification_margin_height,
Expand Down
30 changes: 15 additions & 15 deletions crates/editor/src/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ use file_icons::FileIcons;
use git::{blame::BlameEntry, diff::DiffHunkStatus, Oid};
use gpui::{
anchored, deferred, div, fill, outline, point, px, quad, relative, size, svg,
transparent_black, Action, AnchorCorner, AnyElement, AvailableSpace, Bounds, ClickEvent,
ClipboardItem, ContentMask, Corners, CursorStyle, DispatchPhase, Edges, Element,
ElementInputHandler, Entity, FontId, GlobalElementId, HighlightStyle, Hitbox, Hsla,
InteractiveElement, IntoElement, Length, ModifiersChangedEvent, MouseButton, MouseDownEvent,
MouseMoveEvent, MouseUpEvent, PaintQuad, ParentElement, Pixels, ScrollDelta, ScrollWheelEvent,
ShapedLine, SharedString, Size, StatefulInteractiveElement, Style, Styled, Subscription,
TextRun, TextStyleRefinement, View, ViewContext, WeakView, WindowContext,
transparent_black, Action, AnyElement, AvailableSpace, Bounds, ClickEvent, ClipboardItem,
ContentMask, Corner, Corners, CursorStyle, DispatchPhase, Edges, Element, ElementInputHandler,
Entity, FontId, GlobalElementId, HighlightStyle, Hitbox, Hsla, InteractiveElement, IntoElement,
Length, ModifiersChangedEvent, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent,
PaintQuad, ParentElement, Pixels, ScrollDelta, ScrollWheelEvent, ShapedLine, SharedString,
Size, StatefulInteractiveElement, Style, Styled, Subscription, TextRun, TextStyleRefinement,
View, ViewContext, WeakView, WindowContext,
};
use itertools::Itertools;
use language::{
Expand Down Expand Up @@ -706,7 +706,7 @@ impl EditorElement {
let mut scroll_delta = gpui::Point::<f32>::default();
let vertical_margin = position_map.line_height.min(text_bounds.size.height / 3.0);
let top = text_bounds.origin.y + vertical_margin;
let bottom = text_bounds.lower_left().y - vertical_margin;
let bottom = text_bounds.bottom_left().y - vertical_margin;
if event.position.y < top {
scroll_delta.y = -scale_vertical_mouse_autoscroll_delta(top - event.position.y);
}
Expand All @@ -716,7 +716,7 @@ impl EditorElement {

let horizontal_margin = position_map.line_height.min(text_bounds.size.width / 3.0);
let left = text_bounds.origin.x + horizontal_margin;
let right = text_bounds.upper_right().x - horizontal_margin;
let right = text_bounds.top_right().x - horizontal_margin;
if event.position.x < left {
scroll_delta.x = -scale_horizontal_mouse_autoscroll_delta(left - event.position.x);
}
Expand Down Expand Up @@ -1213,7 +1213,7 @@ impl EditorElement {

let track_bounds = Bounds::from_corners(
point(self.scrollbar_left(&bounds), bounds.origin.y),
point(bounds.lower_right().x, bounds.lower_left().y),
point(bounds.bottom_right().x, bounds.bottom_left().y),
);

let settings = EditorSettings::get_global(cx);
Expand Down Expand Up @@ -2824,7 +2824,7 @@ impl EditorElement {
list_origin.x = (cx.viewport_size().width - list_width).max(Pixels::ZERO);
}

if list_origin.y + list_height > text_hitbox.lower_right().y {
if list_origin.y + list_height > text_hitbox.bottom_right().y {
list_origin.y -= line_height + list_height;
}

Expand Down Expand Up @@ -3067,7 +3067,7 @@ impl EditorElement {
anchored()
.position(position)
.child(context_menu)
.anchor(AnchorCorner::TopLeft)
.anchor(Corner::TopLeft)
.snap_to_window_with_margin(px(8.)),
)
.with_priority(1)
Expand Down Expand Up @@ -3132,7 +3132,7 @@ impl EditorElement {
for mut hover_popover in hover_popovers {
let size = hover_popover.layout_as_root(AvailableSpace::min_size(), cx);
let horizontal_offset =
(text_hitbox.upper_right().x - (hovered_point.x + size.width)).min(Pixels::ZERO);
(text_hitbox.top_right().x - (hovered_point.x + size.width)).min(Pixels::ZERO);

overall_height += HOVER_POPOVER_GAP + size.height;

Expand Down Expand Up @@ -4407,7 +4407,7 @@ impl EditorElement {
}

fn scrollbar_left(&self, bounds: &Bounds<Pixels>) -> Pixels {
bounds.upper_right().x - self.style.scrollbar_width
bounds.top_right().x - self.style.scrollbar_width
}

fn column_pixels(&self, column: usize, cx: &WindowContext) -> Pixels {
Expand Down Expand Up @@ -5488,7 +5488,7 @@ impl Element for EditorElement {
cx.insert_hitbox(gutter_bounds(bounds, gutter_dimensions), false);
let text_hitbox = cx.insert_hitbox(
Bounds {
origin: gutter_hitbox.upper_right(),
origin: gutter_hitbox.top_right(),
size: size(text_width, bounds.size.height),
},
false,
Expand Down
5 changes: 2 additions & 3 deletions crates/editor/src/hunk_diff.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use collections::{HashMap, HashSet};
use git::diff::DiffHunkStatus;
use gpui::{
Action, AnchorCorner, AppContext, CursorStyle, Hsla, Model, MouseButton, Subscription, Task,
View,
Action, AppContext, Corner, CursorStyle, Hsla, Model, MouseButton, Subscription, Task, View,
};
use language::{Buffer, BufferId, Point};
use multi_buffer::{
Expand Down Expand Up @@ -743,7 +742,7 @@ impl Editor {
},
),
)
.anchor(AnchorCorner::TopRight)
.anchor(Corner::TopRight)
.with_handle(hunk_controls_menu_handle)
.menu(move |cx| {
let focus = focus.clone();
Expand Down
4 changes: 2 additions & 2 deletions crates/file_finder/src/file_finder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1261,8 +1261,8 @@ impl PickerDelegate for FileFinderDelegate {
.child(
PopoverMenu::new("menu-popover")
.with_handle(self.popover_menu_handle.clone())
.attach(gpui::AnchorCorner::TopRight)
.anchor(gpui::AnchorCorner::BottomRight)
.attach(gpui::Corner::TopRight)
.anchor(gpui::Corner::BottomRight)
.trigger(
Button::new("actions-trigger", "Split Options")
.selected_label_color(Color::Accent)
Expand Down
8 changes: 4 additions & 4 deletions crates/gpui/examples/gradient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,13 @@ impl Render for GradientViewer {
let height = square_bounds.size.height;
let horizontal_offset = height;
let vertical_offset = px(30.);
let mut path = gpui::Path::new(square_bounds.lower_left());
let mut path = gpui::Path::new(square_bounds.bottom_left());
path.line_to(square_bounds.origin + point(horizontal_offset, vertical_offset));
path.line_to(
square_bounds.upper_right() + point(-horizontal_offset, vertical_offset),
square_bounds.top_right() + point(-horizontal_offset, vertical_offset),
);
path.line_to(square_bounds.lower_right());
path.line_to(square_bounds.lower_left());
path.line_to(square_bounds.bottom_right());
path.line_to(square_bounds.bottom_left());
cx.paint_path(
path,
linear_gradient(
Expand Down
10 changes: 5 additions & 5 deletions crates/gpui/examples/painting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ impl PaintingViewer {
let height = square_bounds.size.height;
let horizontal_offset = height;
let vertical_offset = px(30.);
let mut path = Path::new(square_bounds.lower_left());
let mut path = Path::new(square_bounds.bottom_left());
path.curve_to(
square_bounds.origin + point(horizontal_offset, vertical_offset),
square_bounds.origin + point(px(0.0), vertical_offset),
);
path.line_to(square_bounds.upper_right() + point(-horizontal_offset, vertical_offset));
path.line_to(square_bounds.top_right() + point(-horizontal_offset, vertical_offset));
path.curve_to(
square_bounds.lower_right(),
square_bounds.upper_right() + point(px(0.0), vertical_offset),
square_bounds.bottom_right(),
square_bounds.top_right() + point(px(0.0), vertical_offset),
);
path.line_to(square_bounds.lower_left());
path.line_to(square_bounds.bottom_left());
lines.push(path);

Self {
Expand Down
6 changes: 3 additions & 3 deletions crates/gpui/examples/window_positioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fn main() {
.unwrap();

let bounds = Bounds {
origin: screen.bounds().upper_right()
origin: screen.bounds().top_right()
- point(size.width + margin_offset, -margin_offset),
size,
};
Expand All @@ -101,7 +101,7 @@ fn main() {
.unwrap();

let bounds = Bounds {
origin: screen.bounds().lower_left()
origin: screen.bounds().bottom_left()
- point(-margin_offset, size.height + margin_offset),
size,
};
Expand All @@ -116,7 +116,7 @@ fn main() {
.unwrap();

let bounds = Bounds {
origin: screen.bounds().lower_right()
origin: screen.bounds().bottom_right()
- point(size.width + margin_offset, size.height + margin_offset),
size,
};
Expand Down
Loading

0 comments on commit 0c4e500

Please sign in to comment.