mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 05:15:00 +00:00
Fix layout of elements in the feedback editor's toolbar
Co-Authored-By: Kay Simmons <3323631+Kethku@users.noreply.github.com> Co-Authored-By: Julia <30666851+ForLoveOfCats@users.noreply.github.com>
This commit is contained in:
parent
bbe8297297
commit
83f9d51dee
3 changed files with 83 additions and 2 deletions
|
@ -540,6 +540,8 @@ impl View for FeedbackInfoText {
|
||||||
.contained()
|
.contained()
|
||||||
.with_style(theme.workspace.titlebar.outdated_warning.container)
|
.with_style(theme.workspace.titlebar.outdated_warning.container)
|
||||||
.aligned()
|
.aligned()
|
||||||
|
.left()
|
||||||
|
.clipped()
|
||||||
.boxed()
|
.boxed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -554,7 +556,9 @@ impl ToolbarItemView for FeedbackInfoText {
|
||||||
if let Some(feedback_editor) = active_pane_item.and_then(|i| i.downcast::<FeedbackEditor>())
|
if let Some(feedback_editor) = active_pane_item.and_then(|i| i.downcast::<FeedbackEditor>())
|
||||||
{
|
{
|
||||||
self.active_item = Some(feedback_editor);
|
self.active_item = Some(feedback_editor);
|
||||||
ToolbarItemLocation::PrimaryLeft { flex: None }
|
ToolbarItemLocation::PrimaryLeft {
|
||||||
|
flex: Some((1., false)),
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
self.active_item = None;
|
self.active_item = None;
|
||||||
ToolbarItemLocation::Hidden
|
ToolbarItemLocation::Hidden
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
mod align;
|
mod align;
|
||||||
mod canvas;
|
mod canvas;
|
||||||
|
mod clipped;
|
||||||
mod constrained_box;
|
mod constrained_box;
|
||||||
mod container;
|
mod container;
|
||||||
mod empty;
|
mod empty;
|
||||||
|
@ -19,12 +20,12 @@ mod text;
|
||||||
mod tooltip;
|
mod tooltip;
|
||||||
mod uniform_list;
|
mod uniform_list;
|
||||||
|
|
||||||
use self::expanded::Expanded;
|
|
||||||
pub use self::{
|
pub use self::{
|
||||||
align::*, canvas::*, constrained_box::*, container::*, empty::*, flex::*, hook::*, image::*,
|
align::*, canvas::*, constrained_box::*, container::*, empty::*, flex::*, hook::*, image::*,
|
||||||
keystroke_label::*, label::*, list::*, mouse_event_handler::*, overlay::*, resizable::*,
|
keystroke_label::*, label::*, list::*, mouse_event_handler::*, overlay::*, resizable::*,
|
||||||
stack::*, svg::*, text::*, tooltip::*, uniform_list::*,
|
stack::*, svg::*, text::*, tooltip::*, uniform_list::*,
|
||||||
};
|
};
|
||||||
|
use self::{clipped::Clipped, expanded::Expanded};
|
||||||
pub use crate::presenter::ChildView;
|
pub use crate::presenter::ChildView;
|
||||||
use crate::{
|
use crate::{
|
||||||
geometry::{
|
geometry::{
|
||||||
|
@ -135,6 +136,13 @@ pub trait Element {
|
||||||
Align::new(self.boxed())
|
Align::new(self.boxed())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn clipped(self) -> Clipped
|
||||||
|
where
|
||||||
|
Self: 'static + Sized,
|
||||||
|
{
|
||||||
|
Clipped::new(self.boxed())
|
||||||
|
}
|
||||||
|
|
||||||
fn contained(self) -> Container
|
fn contained(self) -> Container
|
||||||
where
|
where
|
||||||
Self: 'static + Sized,
|
Self: 'static + Sized,
|
||||||
|
|
69
crates/gpui/src/elements/clipped.rs
Normal file
69
crates/gpui/src/elements/clipped.rs
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
use std::ops::Range;
|
||||||
|
|
||||||
|
use pathfinder_geometry::{rect::RectF, vector::Vector2F};
|
||||||
|
use serde_json::json;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
json, DebugContext, Element, ElementBox, LayoutContext, MeasurementContext, PaintContext,
|
||||||
|
SizeConstraint,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub struct Clipped {
|
||||||
|
child: ElementBox,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Clipped {
|
||||||
|
pub fn new(child: ElementBox) -> Self {
|
||||||
|
Self { child }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Element for Clipped {
|
||||||
|
type LayoutState = ();
|
||||||
|
type PaintState = ();
|
||||||
|
|
||||||
|
fn layout(
|
||||||
|
&mut self,
|
||||||
|
constraint: SizeConstraint,
|
||||||
|
cx: &mut LayoutContext,
|
||||||
|
) -> (Vector2F, Self::LayoutState) {
|
||||||
|
(self.child.layout(constraint, cx), ())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn paint(
|
||||||
|
&mut self,
|
||||||
|
bounds: RectF,
|
||||||
|
visible_bounds: RectF,
|
||||||
|
_: &mut Self::LayoutState,
|
||||||
|
cx: &mut PaintContext,
|
||||||
|
) -> Self::PaintState {
|
||||||
|
cx.scene.push_layer(Some(bounds));
|
||||||
|
self.child.paint(bounds.origin(), visible_bounds, cx);
|
||||||
|
cx.scene.pop_layer();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn rect_for_text_range(
|
||||||
|
&self,
|
||||||
|
range_utf16: Range<usize>,
|
||||||
|
_: RectF,
|
||||||
|
_: RectF,
|
||||||
|
_: &Self::LayoutState,
|
||||||
|
_: &Self::PaintState,
|
||||||
|
cx: &MeasurementContext,
|
||||||
|
) -> Option<RectF> {
|
||||||
|
self.child.rect_for_text_range(range_utf16, cx)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn debug(
|
||||||
|
&self,
|
||||||
|
_: RectF,
|
||||||
|
_: &Self::LayoutState,
|
||||||
|
_: &Self::PaintState,
|
||||||
|
cx: &DebugContext,
|
||||||
|
) -> json::Value {
|
||||||
|
json!({
|
||||||
|
"type": "Clipped",
|
||||||
|
"child": self.child.debug(cx)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue