Add Corner to geometry and make names of corner methods consistent (#22119)
Release Notes: - N/A
This commit is contained in:
parent
3052fc2565
commit
fc5a810408
39 changed files with 325 additions and 254 deletions
|
@ -3,18 +3,17 @@
|
|||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
use gpui::{
|
||||
anchored, deferred, div, px, AnchorCorner, AnyElement, Bounds, DismissEvent, DispatchPhase,
|
||||
Element, ElementId, GlobalElementId, Hitbox, InteractiveElement, IntoElement, LayoutId,
|
||||
ManagedView, MouseButton, MouseDownEvent, ParentElement, Pixels, Point, View, VisualContext,
|
||||
WindowContext,
|
||||
anchored, deferred, div, px, AnyElement, Bounds, Corner, DismissEvent, DispatchPhase, Element,
|
||||
ElementId, GlobalElementId, Hitbox, InteractiveElement, IntoElement, LayoutId, ManagedView,
|
||||
MouseButton, MouseDownEvent, ParentElement, Pixels, Point, View, VisualContext, WindowContext,
|
||||
};
|
||||
|
||||
pub struct RightClickMenu<M: ManagedView> {
|
||||
id: ElementId,
|
||||
child_builder: Option<Box<dyn FnOnce(bool) -> AnyElement + 'static>>,
|
||||
menu_builder: Option<Rc<dyn Fn(&mut WindowContext) -> View<M> + 'static>>,
|
||||
anchor: Option<AnchorCorner>,
|
||||
attach: Option<AnchorCorner>,
|
||||
anchor: Option<Corner>,
|
||||
attach: Option<Corner>,
|
||||
}
|
||||
|
||||
impl<M: ManagedView> RightClickMenu<M> {
|
||||
|
@ -30,13 +29,13 @@ impl<M: ManagedView> RightClickMenu<M> {
|
|||
|
||||
/// anchor defines which corner of the menu to anchor to the attachment point
|
||||
/// (by default the cursor position, but see attach)
|
||||
pub fn anchor(mut self, anchor: AnchorCorner) -> Self {
|
||||
pub fn anchor(mut self, anchor: Corner) -> Self {
|
||||
self.anchor = Some(anchor);
|
||||
self
|
||||
}
|
||||
|
||||
/// attach defines which corner of the handle to attach the menu's anchor to
|
||||
pub fn attach(mut self, attach: AnchorCorner) -> Self {
|
||||
pub fn attach(mut self, attach: Corner) -> Self {
|
||||
self.attach = Some(attach);
|
||||
self
|
||||
}
|
||||
|
@ -238,7 +237,7 @@ impl<M: ManagedView> Element for RightClickMenu<M> {
|
|||
*menu.borrow_mut() = Some(new_menu);
|
||||
*position.borrow_mut() = if let Some(child_bounds) = child_bounds {
|
||||
if let Some(attach) = attach {
|
||||
attach.corner(child_bounds)
|
||||
child_bounds.corner(attach)
|
||||
} else {
|
||||
cx.mouse_position()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue