mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-25 01:34:02 +00:00
WIP: Trying to display the toolbar but tired. May be worth discarding this.
This commit is contained in:
parent
23bc11f8b3
commit
3a61fd503f
6 changed files with 80 additions and 38 deletions
3
assets/icons/hamburger_15.svg
Normal file
3
assets/icons/hamburger_15.svg
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M1.5 3C1.22386 3 1 3.22386 1 3.5C1 3.77614 1.22386 4 1.5 4H13.5C13.7761 4 14 3.77614 14 3.5C14 3.22386 13.7761 3 13.5 3H1.5ZM1 7.5C1 7.22386 1.22386 7 1.5 7H13.5C13.7761 7 14 7.22386 14 7.5C14 7.77614 13.7761 8 13.5 8H1.5C1.22386 8 1 7.77614 1 7.5ZM1 11.5C1 11.2239 1.22386 11 1.5 11H13.5C13.7761 11 14 11.2239 14 11.5C14 11.7761 13.7761 12 13.5 12H1.5C1.22386 12 1 11.7761 1 11.5Z" fill="#CCCAC2"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 552 B |
|
@ -30,6 +30,7 @@ use std::{
|
||||||
borrow::Cow, cell::RefCell, cmp, env, fmt::Write, io, iter, ops::Range, path::PathBuf, rc::Rc,
|
borrow::Cow, cell::RefCell, cmp, env, fmt::Write, io, iter, ops::Range, path::PathBuf, rc::Rc,
|
||||||
sync::Arc, time::Duration,
|
sync::Arc, time::Duration,
|
||||||
};
|
};
|
||||||
|
use theme::{ui::IconStyle, IconButton, Theme};
|
||||||
use util::{
|
use util::{
|
||||||
channel::ReleaseChannel, paths::CONVERSATIONS_DIR, post_inc, truncate_and_trailoff, ResultExt,
|
channel::ReleaseChannel, paths::CONVERSATIONS_DIR, post_inc, truncate_and_trailoff, ResultExt,
|
||||||
TryFutureExt,
|
TryFutureExt,
|
||||||
|
@ -259,6 +260,16 @@ impl AssistantPanel {
|
||||||
self.conversation_editors
|
self.conversation_editors
|
||||||
.get(self.active_conversation_index)
|
.get(self.active_conversation_index)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn render_hamburger_button(
|
||||||
|
&self,
|
||||||
|
style: &IconStyle,
|
||||||
|
cx: &ViewContext<Self>,
|
||||||
|
) -> impl Element<Self> {
|
||||||
|
Svg::for_style(style.icon.clone())
|
||||||
|
.contained()
|
||||||
|
.with_style(style.container)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_api_key_editor(cx: &mut ViewContext<AssistantPanel>) -> ViewHandle<Editor> {
|
fn build_api_key_editor(cx: &mut ViewContext<AssistantPanel>) -> ViewHandle<Editor> {
|
||||||
|
@ -282,7 +293,8 @@ impl View for AssistantPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> AnyElement<Self> {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> AnyElement<Self> {
|
||||||
let style = &theme::current(cx).assistant;
|
let theme = &theme::current(cx);
|
||||||
|
let style = &theme.assistant;
|
||||||
if let Some(api_key_editor) = self.api_key_editor.as_ref() {
|
if let Some(api_key_editor) = self.api_key_editor.as_ref() {
|
||||||
Flex::column()
|
Flex::column()
|
||||||
.with_child(
|
.with_child(
|
||||||
|
@ -303,7 +315,17 @@ impl View for AssistantPanel {
|
||||||
.aligned()
|
.aligned()
|
||||||
.into_any()
|
.into_any()
|
||||||
} else if let Some(editor) = self.active_conversation_editor() {
|
} else if let Some(editor) = self.active_conversation_editor() {
|
||||||
ChildView::new(editor, cx).into_any()
|
Flex::column()
|
||||||
|
.with_child(
|
||||||
|
Flex::row()
|
||||||
|
.with_child(self.render_hamburger_button(&style.hamburger_button, cx))
|
||||||
|
.contained()
|
||||||
|
.with_style(theme.workspace.tab_bar.container)
|
||||||
|
.constrained()
|
||||||
|
.with_height(theme.workspace.tab_bar.height),
|
||||||
|
)
|
||||||
|
.with_child(ChildView::new(editor, cx).flex(1., true))
|
||||||
|
.into_any()
|
||||||
} else {
|
} else {
|
||||||
Empty::new().into_any()
|
Empty::new().into_any()
|
||||||
}
|
}
|
||||||
|
@ -1401,7 +1423,7 @@ impl ConversationEditor {
|
||||||
.aligned()
|
.aligned()
|
||||||
.left()
|
.left()
|
||||||
.contained()
|
.contained()
|
||||||
.with_style(style.header)
|
.with_style(style.message_header)
|
||||||
.into_any()
|
.into_any()
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
use std::{borrow::Cow, ops::Range};
|
use super::constrain_size_preserving_aspect_ratio;
|
||||||
|
use crate::json::ToJson;
|
||||||
use serde_json::json;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
color::Color,
|
color::Color,
|
||||||
geometry::{
|
geometry::{
|
||||||
|
@ -10,6 +8,9 @@ use crate::{
|
||||||
},
|
},
|
||||||
scene, Element, LayoutContext, SceneBuilder, SizeConstraint, View, ViewContext,
|
scene, Element, LayoutContext, SceneBuilder, SizeConstraint, View, ViewContext,
|
||||||
};
|
};
|
||||||
|
use serde_derive::Deserialize;
|
||||||
|
use serde_json::json;
|
||||||
|
use std::{borrow::Cow, ops::Range};
|
||||||
|
|
||||||
pub struct Svg {
|
pub struct Svg {
|
||||||
path: Cow<'static, str>,
|
path: Cow<'static, str>,
|
||||||
|
@ -24,6 +25,15 @@ impl Svg {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn for_style<V: View>(style: SvgStyle) -> impl Element<V> {
|
||||||
|
Self::new(style.asset)
|
||||||
|
.with_color(style.color)
|
||||||
|
.constrained()
|
||||||
|
.constrained()
|
||||||
|
.with_width(style.dimensions.width)
|
||||||
|
.with_height(style.dimensions.height)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn with_color(mut self, color: Color) -> Self {
|
pub fn with_color(mut self, color: Color) -> Self {
|
||||||
self.color = color;
|
self.color = color;
|
||||||
self
|
self
|
||||||
|
@ -105,9 +115,24 @@ impl<V: View> Element<V> for Svg {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use crate::json::ToJson;
|
#[derive(Clone, Deserialize, Default)]
|
||||||
|
pub struct SvgStyle {
|
||||||
|
pub color: Color,
|
||||||
|
pub asset: String,
|
||||||
|
pub dimensions: Dimensions,
|
||||||
|
}
|
||||||
|
|
||||||
use super::constrain_size_preserving_aspect_ratio;
|
#[derive(Clone, Deserialize, Default)]
|
||||||
|
pub struct Dimensions {
|
||||||
|
pub width: f32,
|
||||||
|
pub height: f32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Dimensions {
|
||||||
|
pub fn to_vec(&self) -> Vector2F {
|
||||||
|
vec2f(self.width, self.height)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn from_usvg_rect(rect: usvg::Rect) -> RectF {
|
fn from_usvg_rect(rect: usvg::Rect) -> RectF {
|
||||||
RectF::new(
|
RectF::new(
|
||||||
|
|
|
@ -4,7 +4,7 @@ pub mod ui;
|
||||||
|
|
||||||
use gpui::{
|
use gpui::{
|
||||||
color::Color,
|
color::Color,
|
||||||
elements::{ContainerStyle, ImageStyle, LabelStyle, Shadow, TooltipStyle},
|
elements::{ContainerStyle, ImageStyle, LabelStyle, Shadow, SvgStyle, TooltipStyle},
|
||||||
fonts::{HighlightStyle, TextStyle},
|
fonts::{HighlightStyle, TextStyle},
|
||||||
platform, AppContext, AssetSource, Border, MouseState,
|
platform, AppContext, AssetSource, Border, MouseState,
|
||||||
};
|
};
|
||||||
|
@ -12,7 +12,7 @@ use serde::{de::DeserializeOwned, Deserialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use settings::SettingsStore;
|
use settings::SettingsStore;
|
||||||
use std::{collections::HashMap, sync::Arc};
|
use std::{collections::HashMap, sync::Arc};
|
||||||
use ui::{ButtonStyle, CheckboxStyle, IconStyle, ModalStyle, SvgStyle};
|
use ui::{ButtonStyle, CheckboxStyle, IconStyle, ModalStyle};
|
||||||
|
|
||||||
pub use theme_registry::*;
|
pub use theme_registry::*;
|
||||||
pub use theme_settings::*;
|
pub use theme_settings::*;
|
||||||
|
@ -994,7 +994,8 @@ pub struct TerminalStyle {
|
||||||
#[derive(Clone, Deserialize, Default)]
|
#[derive(Clone, Deserialize, Default)]
|
||||||
pub struct AssistantStyle {
|
pub struct AssistantStyle {
|
||||||
pub container: ContainerStyle,
|
pub container: ContainerStyle,
|
||||||
pub header: ContainerStyle,
|
pub hamburger_button: IconStyle,
|
||||||
|
pub message_header: ContainerStyle,
|
||||||
pub sent_at: ContainedText,
|
pub sent_at: ContainedText,
|
||||||
pub user_sender: Interactive<ContainedText>,
|
pub user_sender: Interactive<ContainedText>,
|
||||||
pub assistant_sender: Interactive<ContainedText>,
|
pub assistant_sender: Interactive<ContainedText>,
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use gpui::{
|
use gpui::{
|
||||||
color::Color,
|
|
||||||
elements::{
|
elements::{
|
||||||
ConstrainedBox, Container, ContainerStyle, Empty, Flex, KeystrokeLabel, Label,
|
ConstrainedBox, Container, ContainerStyle, Dimensions, Empty, Flex, KeystrokeLabel, Label,
|
||||||
MouseEventHandler, ParentElement, Stack, Svg,
|
MouseEventHandler, ParentElement, Stack, Svg, SvgStyle,
|
||||||
},
|
},
|
||||||
fonts::TextStyle,
|
fonts::TextStyle,
|
||||||
geometry::vector::{vec2f, Vector2F},
|
geometry::vector::Vector2F,
|
||||||
platform,
|
platform,
|
||||||
platform::MouseButton,
|
platform::MouseButton,
|
||||||
scene::MouseClick,
|
scene::MouseClick,
|
||||||
|
@ -93,25 +92,6 @@ where
|
||||||
.with_cursor_style(platform::CursorStyle::PointingHand)
|
.with_cursor_style(platform::CursorStyle::PointingHand)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Deserialize, Default)]
|
|
||||||
pub struct SvgStyle {
|
|
||||||
pub color: Color,
|
|
||||||
pub asset: String,
|
|
||||||
pub dimensions: Dimensions,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Deserialize, Default)]
|
|
||||||
pub struct Dimensions {
|
|
||||||
pub width: f32,
|
|
||||||
pub height: f32,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Dimensions {
|
|
||||||
pub fn to_vec(&self) -> Vector2F {
|
|
||||||
vec2f(self.width, self.height)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn svg<V: View>(style: &SvgStyle) -> ConstrainedBox<V> {
|
pub fn svg<V: View>(style: &SvgStyle) -> ConstrainedBox<V> {
|
||||||
Svg::new(style.asset.clone())
|
Svg::new(style.asset.clone())
|
||||||
.with_color(style.color)
|
.with_color(style.color)
|
||||||
|
@ -122,8 +102,8 @@ pub fn svg<V: View>(style: &SvgStyle) -> ConstrainedBox<V> {
|
||||||
|
|
||||||
#[derive(Clone, Deserialize, Default)]
|
#[derive(Clone, Deserialize, Default)]
|
||||||
pub struct IconStyle {
|
pub struct IconStyle {
|
||||||
icon: SvgStyle,
|
pub icon: SvgStyle,
|
||||||
container: ContainerStyle,
|
pub container: ContainerStyle,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn icon<V: View>(style: &IconStyle) -> Container<V> {
|
pub fn icon<V: View>(style: &IconStyle) -> Container<V> {
|
||||||
|
|
|
@ -9,11 +9,22 @@ export default function assistant(colorScheme: ColorScheme) {
|
||||||
background: editor(colorScheme).background,
|
background: editor(colorScheme).background,
|
||||||
padding: { left: 12 },
|
padding: { left: 12 },
|
||||||
},
|
},
|
||||||
header: {
|
messageHeader: {
|
||||||
border: border(layer, "default", { bottom: true, top: true }),
|
border: border(layer, "default", { bottom: true, top: true }),
|
||||||
margin: { bottom: 6, top: 6 },
|
margin: { bottom: 6, top: 6 },
|
||||||
background: editor(colorScheme).background,
|
background: editor(colorScheme).background,
|
||||||
},
|
},
|
||||||
|
hamburgerButton: {
|
||||||
|
icon: {
|
||||||
|
color: text(layer, "sans", "default", { size: "sm" }).color,
|
||||||
|
asset: "icons/hamburger.svg",
|
||||||
|
dimensions: {
|
||||||
|
width: 15,
|
||||||
|
height: 15,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
container: {}
|
||||||
|
},
|
||||||
userSender: {
|
userSender: {
|
||||||
...text(layer, "sans", "default", { size: "sm", weight: "bold" }),
|
...text(layer, "sans", "default", { size: "sm", weight: "bold" }),
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue