properly constrained tab
This commit is contained in:
parent
ab9f073443
commit
03a344a272
2 changed files with 95 additions and 81 deletions
|
@ -107,6 +107,9 @@ impl<V: View> DragAndDrop<V> {
|
|||
Container::new(render(payload, cx))
|
||||
.with_margin_left(position.x())
|
||||
.with_margin_top(position.y())
|
||||
.aligned()
|
||||
.top()
|
||||
.left()
|
||||
.boxed()
|
||||
})
|
||||
.on_up(MouseButton::Left, |_, cx| {
|
||||
|
|
|
@ -3,6 +3,7 @@ use crate::{toolbar::Toolbar, Item, NewFile, NewSearch, NewTerminal, WeakItemHan
|
|||
use anyhow::Result;
|
||||
use collections::{HashMap, HashSet, VecDeque};
|
||||
use context_menu::{ContextMenu, ContextMenuItem};
|
||||
use drag_and_drop::Draggable;
|
||||
use futures::StreamExt;
|
||||
use gpui::{
|
||||
actions,
|
||||
|
@ -906,6 +907,7 @@ impl Pane {
|
|||
MouseEventHandler::new::<Tab, _, _>(ix, cx, {
|
||||
let item = item.clone();
|
||||
let pane = pane.clone();
|
||||
let detail = detail.clone();
|
||||
let hovered = mouse_state.hovered;
|
||||
|
||||
move |_, cx| {
|
||||
|
@ -929,6 +931,7 @@ impl Pane {
|
|||
cx.dispatch_action(ActivateItem(ix));
|
||||
})
|
||||
.on_click(MouseButton::Middle, {
|
||||
let item = item.clone();
|
||||
let pane = pane.clone();
|
||||
move |_, cx: &mut EventContext| {
|
||||
cx.dispatch_action(CloseItem {
|
||||
|
@ -937,6 +940,15 @@ impl Pane {
|
|||
})
|
||||
}
|
||||
})
|
||||
.as_draggable(item, {
|
||||
let pane = pane.clone();
|
||||
let detail = detail.clone();
|
||||
|
||||
move |item, cx: &mut RenderContext<Workspace>| {
|
||||
let pane = pane.clone();
|
||||
Pane::render_tab(item, pane, detail, false, pane_active, tab_active, cx)
|
||||
}
|
||||
})
|
||||
.boxed()
|
||||
})
|
||||
}
|
||||
|
@ -1005,7 +1017,6 @@ impl Pane {
|
|||
let tab_style = theme.workspace.tab_bar.tab_style(pane_active, tab_active);
|
||||
let title = item.tab_content(detail, tab_style, cx);
|
||||
|
||||
Container::new(
|
||||
Flex::row()
|
||||
.with_child(
|
||||
Align::new({
|
||||
|
@ -1021,8 +1032,7 @@ impl Pane {
|
|||
ConstrainedBox::new(
|
||||
Canvas::new(move |bounds, _, cx| {
|
||||
if let Some(color) = icon_color {
|
||||
let square =
|
||||
RectF::new(bounds.origin(), vec2f(diameter, diameter));
|
||||
let square = RectF::new(bounds.origin(), vec2f(diameter, diameter));
|
||||
cx.scene.push_quad(Quad {
|
||||
bounds: square,
|
||||
background: Some(color),
|
||||
|
@ -1089,9 +1099,10 @@ impl Pane {
|
|||
)
|
||||
.boxed(),
|
||||
)
|
||||
.boxed(),
|
||||
)
|
||||
.contained()
|
||||
.with_style(tab_style.container)
|
||||
.constrained()
|
||||
.with_height(tab_style.height)
|
||||
.boxed()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue