Change sidebars to use the window width as a max width rather than participating in the flex

co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
Kay Simmons 2023-01-17 16:58:55 -08:00
parent 5ce0472a75
commit c9a306b4ac
2 changed files with 47 additions and 6 deletions

View file

@ -2,8 +2,10 @@ use collections::HashMap;
use gpui::{ use gpui::{
actions, actions,
elements::{ChildView, Container, Empty, MouseEventHandler, ParentElement, Side, Stack, Svg}, elements::{ChildView, Container, Empty, MouseEventHandler, ParentElement, Side, Stack, Svg},
geometry::vector::Vector2F,
impl_internal_actions, Border, CursorStyle, Element, ElementBox, Entity, MouseButton, impl_internal_actions, Border, CursorStyle, Element, ElementBox, Entity, MouseButton,
MutableAppContext, RenderContext, View, ViewContext, ViewHandle, WeakViewHandle, MutableAppContext, RenderContext, SizeConstraint, View, ViewContext, ViewHandle,
WeakViewHandle,
}; };
use serde::Deserialize; use serde::Deserialize;
use settings::{DockAnchor, Settings}; use settings::{DockAnchor, Settings};
@ -312,7 +314,27 @@ impl Dock {
} }
}); });
resizable.flex(5., false).boxed() if anchor == DockAnchor::Right {
resizable
.constrained()
.dynamically(|constraint, cx| {
SizeConstraint::new(
Vector2F::new(20., constraint.min.y()),
Vector2F::new(cx.window_size.x() * 0.8, constraint.max.y()),
)
})
.boxed()
} else {
resizable
.constrained()
.dynamically(|constraint, cx| {
SizeConstraint::new(
Vector2F::new(constraint.min.x(), 50.),
Vector2F::new(constraint.max.x(), cx.window_size.y() * 0.8),
)
})
.boxed()
}
} }
DockAnchor::Expanded => { DockAnchor::Expanded => {
enum ExpandedDockWash {} enum ExpandedDockWash {}

View file

@ -32,12 +32,13 @@ use futures::{
use gpui::{ use gpui::{
actions, actions,
elements::*, elements::*,
geometry::vector::Vector2F,
impl_actions, impl_internal_actions, impl_actions, impl_internal_actions,
keymap_matcher::KeymapContext, keymap_matcher::KeymapContext,
platform::{CursorStyle, WindowOptions}, platform::{CursorStyle, WindowOptions},
AnyModelHandle, AnyViewHandle, AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, AnyModelHandle, AnyViewHandle, AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle,
MouseButton, MutableAppContext, PathPromptOptions, PromptLevel, RenderContext, Task, View, MouseButton, MutableAppContext, PathPromptOptions, PromptLevel, RenderContext, SizeConstraint,
ViewContext, ViewHandle, WeakViewHandle, Task, View, ViewContext, ViewHandle, WeakViewHandle,
}; };
use item::{FollowableItem, FollowableItemHandle, Item, ItemHandle, ProjectItem}; use item::{FollowableItem, FollowableItemHandle, Item, ItemHandle, ProjectItem};
use language::LanguageRegistry; use language::LanguageRegistry;
@ -2471,7 +2472,16 @@ impl View for Workspace {
if self.left_sidebar.read(cx).active_item().is_some() { if self.left_sidebar.read(cx).active_item().is_some() {
Some( Some(
ChildView::new(&self.left_sidebar, cx) ChildView::new(&self.left_sidebar, cx)
.flex(0.8, false) .constrained()
.dynamically(|constraint, cx| {
SizeConstraint::new(
Vector2F::new(20., constraint.min.y()),
Vector2F::new(
cx.window_size.x() * 0.8,
constraint.max.y(),
),
)
})
.boxed(), .boxed(),
) )
} else { } else {
@ -2508,7 +2518,16 @@ impl View for Workspace {
if self.right_sidebar.read(cx).active_item().is_some() { if self.right_sidebar.read(cx).active_item().is_some() {
Some( Some(
ChildView::new(&self.right_sidebar, cx) ChildView::new(&self.right_sidebar, cx)
.flex(0.8, false) .constrained()
.dynamically(|constraint, cx| {
SizeConstraint::new(
Vector2F::new(20., constraint.min.y()),
Vector2F::new(
cx.window_size.x() * 0.8,
constraint.max.y(),
),
)
})
.boxed(), .boxed(),
) )
} else { } else {