Add Corner to geometry and make names of corner methods consistent (#22119)

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2024-12-16 22:57:15 -07:00 committed by GitHub
parent 3052fc2565
commit fc5a810408
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 325 additions and 254 deletions

View file

@ -3,10 +3,10 @@ use crate::{status_bar::StatusItemView, Workspace};
use crate::{DraggedDock, Event, Pane};
use client::proto;
use gpui::{
deferred, div, px, Action, AnchorCorner, AnyView, AppContext, Axis, Entity, EntityId,
EventEmitter, FocusHandle, FocusableView, IntoElement, KeyContext, MouseButton, MouseDownEvent,
MouseUpEvent, ParentElement, Render, SharedString, StyleRefinement, Styled, Subscription, View,
ViewContext, VisualContext, WeakView, WindowContext,
deferred, div, px, Action, AnyView, AppContext, Axis, Corner, Entity, EntityId, EventEmitter,
FocusHandle, FocusableView, IntoElement, KeyContext, MouseButton, MouseDownEvent, MouseUpEvent,
ParentElement, Render, SharedString, StyleRefinement, Styled, Subscription, View, ViewContext,
VisualContext, WeakView, WindowContext,
};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
@ -719,10 +719,8 @@ impl Render for PanelButtons {
let dock_position = dock.position;
let (menu_anchor, menu_attach) = match dock.position {
DockPosition::Left => (AnchorCorner::BottomLeft, AnchorCorner::TopLeft),
DockPosition::Bottom | DockPosition::Right => {
(AnchorCorner::BottomRight, AnchorCorner::TopRight)
}
DockPosition::Left => (Corner::BottomLeft, Corner::TopLeft),
DockPosition::Bottom | DockPosition::Right => (Corner::BottomRight, Corner::TopRight),
};
let buttons = dock

View file

@ -14,8 +14,8 @@ use anyhow::Result;
use collections::{BTreeSet, HashMap, HashSet, VecDeque};
use futures::{stream::FuturesUnordered, StreamExt};
use gpui::{
actions, anchored, deferred, impl_actions, prelude::*, Action, AnchorCorner, AnyElement,
AppContext, AsyncWindowContext, ClickEvent, ClipboardItem, Div, DragMoveEvent, EntityId,
actions, anchored, deferred, impl_actions, prelude::*, Action, AnyElement, AppContext,
AsyncWindowContext, ClickEvent, ClipboardItem, Corner, Div, DragMoveEvent, EntityId,
EventEmitter, ExternalPaths, FocusHandle, FocusOutEvent, FocusableView, KeyContext, Model,
MouseButton, MouseDownEvent, NavigationDirection, Pixels, Point, PromptLevel, Render,
ScrollHandle, Subscription, Task, View, ViewContext, VisualContext, WeakFocusHandle, WeakView,
@ -432,7 +432,7 @@ impl Pane {
.icon_size(IconSize::Small)
.tooltip(|cx| Tooltip::text("New...", cx)),
)
.anchor(AnchorCorner::TopRight)
.anchor(Corner::TopRight)
.with_handle(pane.new_item_context_menu_handle.clone())
.menu(move |cx| {
Some(ContextMenu::build(cx, |menu, _| {
@ -465,7 +465,7 @@ impl Pane {
.icon_size(IconSize::Small)
.tooltip(|cx| Tooltip::text("Split Pane", cx)),
)
.anchor(AnchorCorner::TopRight)
.anchor(Corner::TopRight)
.with_handle(pane.split_item_context_menu_handle.clone())
.menu(move |cx| {
ContextMenu::build(cx, |menu, _| {
@ -2506,12 +2506,7 @@ impl Pane {
pub fn render_menu_overlay(menu: &View<ContextMenu>) -> Div {
div().absolute().bottom_0().right_0().size_0().child(
deferred(
anchored()
.anchor(AnchorCorner::TopRight)
.child(menu.clone()),
)
.with_priority(1),
deferred(anchored().anchor(Corner::TopRight).child(menu.clone())).with_priority(1),
)
}

View file

@ -758,9 +758,9 @@ impl SplitDirection {
pub fn edge(&self, rect: Bounds<Pixels>) -> Pixels {
match self {
Self::Up => rect.origin.y,
Self::Down => rect.lower_left().y,
Self::Left => rect.lower_left().x,
Self::Right => rect.lower_right().x,
Self::Down => rect.bottom_left().y,
Self::Left => rect.bottom_left().x,
Self::Right => rect.bottom_right().x,
}
}
@ -771,7 +771,7 @@ impl SplitDirection {
size: size(bounds.size.width, length),
},
Self::Down => Bounds {
origin: point(bounds.lower_left().x, bounds.lower_left().y - length),
origin: point(bounds.bottom_left().x, bounds.bottom_left().y - length),
size: size(bounds.size.width, length),
},
Self::Left => Bounds {
@ -779,7 +779,7 @@ impl SplitDirection {
size: size(length, bounds.size.height),
},
Self::Right => Bounds {
origin: point(bounds.lower_right().x - length, bounds.lower_left().y),
origin: point(bounds.bottom_right().x - length, bounds.bottom_left().y),
size: size(length, bounds.size.height),
},
}