Clean up Element API and start on docs
This commit is contained in:
parent
5f2bb82ef3
commit
83923fd6d5
125 changed files with 370 additions and 335 deletions
|
@ -304,9 +304,9 @@ impl ActivityIndicator {
|
||||||
impl EventEmitter<Event> for ActivityIndicator {}
|
impl EventEmitter<Event> for ActivityIndicator {}
|
||||||
|
|
||||||
impl Render for ActivityIndicator {
|
impl Render for ActivityIndicator {
|
||||||
type Element = Stateful<Div>;
|
type Output = Stateful<Div>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
let content = self.content_to_render(cx);
|
let content = self.content_to_render(cx);
|
||||||
|
|
||||||
let mut result = h_stack()
|
let mut result = h_stack()
|
||||||
|
|
|
@ -1101,9 +1101,9 @@ fn build_api_key_editor(cx: &mut ViewContext<AssistantPanel>) -> View<Editor> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for AssistantPanel {
|
impl Render for AssistantPanel {
|
||||||
type Element = Focusable<Div>;
|
type Output = Focusable<Div>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
if let Some(api_key_editor) = self.api_key_editor.clone() {
|
if let Some(api_key_editor) = self.api_key_editor.clone() {
|
||||||
v_stack()
|
v_stack()
|
||||||
.on_action(cx.listener(AssistantPanel::save_credentials))
|
.on_action(cx.listener(AssistantPanel::save_credentials))
|
||||||
|
@ -2513,9 +2513,9 @@ impl ConversationEditor {
|
||||||
impl EventEmitter<ConversationEditorEvent> for ConversationEditor {}
|
impl EventEmitter<ConversationEditorEvent> for ConversationEditor {}
|
||||||
|
|
||||||
impl Render for ConversationEditor {
|
impl Render for ConversationEditor {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
div()
|
div()
|
||||||
.key_context("ConversationEditor")
|
.key_context("ConversationEditor")
|
||||||
.capture_action(cx.listener(ConversationEditor::cancel_last_assist))
|
.capture_action(cx.listener(ConversationEditor::cancel_last_assist))
|
||||||
|
@ -2618,9 +2618,9 @@ struct InlineAssistant {
|
||||||
impl EventEmitter<InlineAssistantEvent> for InlineAssistant {}
|
impl EventEmitter<InlineAssistantEvent> for InlineAssistant {}
|
||||||
|
|
||||||
impl Render for InlineAssistant {
|
impl Render for InlineAssistant {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
let measurements = self.measurements.get();
|
let measurements = self.measurements.get();
|
||||||
h_stack()
|
h_stack()
|
||||||
.w_full()
|
.w_full()
|
||||||
|
|
|
@ -13,9 +13,9 @@ pub struct UpdateNotification {
|
||||||
impl EventEmitter<DismissEvent> for UpdateNotification {}
|
impl EventEmitter<DismissEvent> for UpdateNotification {}
|
||||||
|
|
||||||
impl Render for UpdateNotification {
|
impl Render for UpdateNotification {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Self::Output {
|
||||||
let app_name = cx.global::<ReleaseChannel>().display_name();
|
let app_name = cx.global::<ReleaseChannel>().display_name();
|
||||||
|
|
||||||
v_stack()
|
v_stack()
|
||||||
|
|
|
@ -30,9 +30,9 @@ impl Breadcrumbs {
|
||||||
impl EventEmitter<ToolbarItemEvent> for Breadcrumbs {}
|
impl EventEmitter<ToolbarItemEvent> for Breadcrumbs {}
|
||||||
|
|
||||||
impl Render for Breadcrumbs {
|
impl Render for Breadcrumbs {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
let element = h_stack().text_ui();
|
let element = h_stack().text_ui();
|
||||||
let Some(active_item) = self.active_item.as_ref() else {
|
let Some(active_item) = self.active_item.as_ref() else {
|
||||||
return element;
|
return element;
|
||||||
|
|
|
@ -222,9 +222,9 @@ impl ChannelView {
|
||||||
impl EventEmitter<EditorEvent> for ChannelView {}
|
impl EventEmitter<EditorEvent> for ChannelView {}
|
||||||
|
|
||||||
impl Render for ChannelView {
|
impl Render for ChannelView {
|
||||||
type Element = AnyView;
|
type Output = AnyView;
|
||||||
|
|
||||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
self.editor.clone().into()
|
self.editor.clone().into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -549,9 +549,9 @@ impl ChatPanel {
|
||||||
impl EventEmitter<Event> for ChatPanel {}
|
impl EventEmitter<Event> for ChatPanel {}
|
||||||
|
|
||||||
impl Render for ChatPanel {
|
impl Render for ChatPanel {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
div()
|
div()
|
||||||
.full()
|
.full()
|
||||||
.child(if self.client.user_id().is_some() {
|
.child(if self.client.user_id().is_some() {
|
||||||
|
|
|
@ -196,9 +196,9 @@ impl MessageEditor {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for MessageEditor {
|
impl Render for MessageEditor {
|
||||||
type Element = AnyView;
|
type Output = AnyView;
|
||||||
|
|
||||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
self.editor.to_any()
|
self.editor.to_any()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2263,9 +2263,9 @@ fn render_tree_branch(is_last: bool, cx: &mut WindowContext) -> impl IntoElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for CollabPanel {
|
impl Render for CollabPanel {
|
||||||
type Element = Focusable<Div>;
|
type Output = Focusable<Div>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
v_stack()
|
v_stack()
|
||||||
.key_context("CollabPanel")
|
.key_context("CollabPanel")
|
||||||
.on_action(cx.listener(CollabPanel::cancel))
|
.on_action(cx.listener(CollabPanel::cancel))
|
||||||
|
@ -2453,9 +2453,9 @@ struct DraggedChannelView {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for DraggedChannelView {
|
impl Render for DraggedChannelView {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
let ui_font = ThemeSettings::get_global(cx).ui_font.family.clone();
|
let ui_font = ThemeSettings::get_global(cx).ui_font.family.clone();
|
||||||
h_stack()
|
h_stack()
|
||||||
.font(ui_font)
|
.font(ui_font)
|
||||||
|
|
|
@ -142,9 +142,9 @@ impl FocusableView for ChannelModal {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for ChannelModal {
|
impl Render for ChannelModal {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
let channel_store = self.channel_store.read(cx);
|
let channel_store = self.channel_store.read(cx);
|
||||||
let Some(channel) = channel_store.channel_for_id(self.channel_id) else {
|
let Some(channel) = channel_store.channel_for_id(self.channel_id) else {
|
||||||
return div();
|
return div();
|
||||||
|
|
|
@ -35,7 +35,7 @@ impl ContactFinder {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for ContactFinder {
|
impl Render for ContactFinder {
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
v_stack()
|
v_stack()
|
||||||
.elevation_3(cx)
|
.elevation_3(cx)
|
||||||
.child(
|
.child(
|
||||||
|
@ -52,7 +52,7 @@ impl Render for ContactFinder {
|
||||||
.w(rems(34.))
|
.w(rems(34.))
|
||||||
}
|
}
|
||||||
|
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ContactFinderDelegate {
|
pub struct ContactFinderDelegate {
|
||||||
|
|
|
@ -56,9 +56,9 @@ pub struct CollabTitlebarItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for CollabTitlebarItem {
|
impl Render for CollabTitlebarItem {
|
||||||
type Element = Stateful<Div>;
|
type Output = Stateful<Div>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
let room = ActiveCall::global(cx).read(cx).room().cloned();
|
let room = ActiveCall::global(cx).read(cx).room().cloned();
|
||||||
let current_user = self.user_store.read(cx).current_user();
|
let current_user = self.user_store.read(cx).current_user();
|
||||||
let client = self.client.clone();
|
let client = self.client.clone();
|
||||||
|
|
|
@ -9,9 +9,9 @@ pub struct FacePile {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for FacePile {
|
impl RenderOnce for FacePile {
|
||||||
type Rendered = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(self, _: &mut WindowContext) -> Self::Rendered {
|
fn render(self, _: &mut WindowContext) -> Self::Output {
|
||||||
let player_count = self.faces.len();
|
let player_count = self.faces.len();
|
||||||
let player_list = self.faces.into_iter().enumerate().map(|(ix, player)| {
|
let player_list = self.faces.into_iter().enumerate().map(|(ix, player)| {
|
||||||
let isnt_last = ix < player_count - 1;
|
let isnt_last = ix < player_count - 1;
|
||||||
|
|
|
@ -540,7 +540,7 @@ impl NotificationPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for NotificationPanel {
|
impl Render for NotificationPanel {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Div {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Div {
|
||||||
v_stack()
|
v_stack()
|
||||||
|
@ -706,9 +706,9 @@ impl NotificationToast {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for NotificationToast {
|
impl Render for NotificationToast {
|
||||||
type Element = Stateful<Div>;
|
type Output = Stateful<Div>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
let user = self.actor.clone();
|
let user = self.actor.clone();
|
||||||
|
|
||||||
h_stack()
|
h_stack()
|
||||||
|
|
|
@ -117,9 +117,9 @@ impl IncomingCallNotification {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for IncomingCallNotification {
|
impl Render for IncomingCallNotification {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
// TODO: Is there a better place for us to initialize the font?
|
// TODO: Is there a better place for us to initialize the font?
|
||||||
let (ui_font, ui_font_size) = {
|
let (ui_font, ui_font_size) = {
|
||||||
let theme_settings = ThemeSettings::get_global(cx);
|
let theme_settings = ThemeSettings::get_global(cx);
|
||||||
|
|
|
@ -120,9 +120,9 @@ impl ProjectSharedNotification {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for ProjectSharedNotification {
|
impl Render for ProjectSharedNotification {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
// TODO: Is there a better place for us to initialize the font?
|
// TODO: Is there a better place for us to initialize the font?
|
||||||
let (ui_font, ui_font_size) = {
|
let (ui_font, ui_font_size) = {
|
||||||
let theme_settings = ThemeSettings::get_global(cx);
|
let theme_settings = ThemeSettings::get_global(cx);
|
||||||
|
|
|
@ -83,9 +83,9 @@ impl FocusableView for CommandPalette {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for CommandPalette {
|
impl Render for CommandPalette {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
v_stack().w(rems(34.)).child(self.picker.clone())
|
v_stack().w(rems(34.)).child(self.picker.clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,9 +181,9 @@ impl CopilotCodeVerification {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for CopilotCodeVerification {
|
impl Render for CopilotCodeVerification {
|
||||||
type Element = Stateful<Div>;
|
type Output = Stateful<Div>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
let prompt = match &self.status {
|
let prompt = match &self.status {
|
||||||
Status::SigningIn {
|
Status::SigningIn {
|
||||||
prompt: Some(prompt),
|
prompt: Some(prompt),
|
||||||
|
|
|
@ -34,9 +34,9 @@ pub struct CopilotButton {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for CopilotButton {
|
impl Render for CopilotButton {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
let all_language_settings = all_language_settings(None, cx);
|
let all_language_settings = all_language_settings(None, cx);
|
||||||
if !all_language_settings.copilot.feature_enabled {
|
if !all_language_settings.copilot.feature_enabled {
|
||||||
return div();
|
return div();
|
||||||
|
|
|
@ -91,9 +91,9 @@ struct DiagnosticGroupState {
|
||||||
impl EventEmitter<EditorEvent> for ProjectDiagnosticsEditor {}
|
impl EventEmitter<EditorEvent> for ProjectDiagnosticsEditor {}
|
||||||
|
|
||||||
impl Render for ProjectDiagnosticsEditor {
|
impl Render for ProjectDiagnosticsEditor {
|
||||||
type Element = Focusable<Div>;
|
type Output = Focusable<Div>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
let child = if self.path_states.is_empty() {
|
let child = if self.path_states.is_empty() {
|
||||||
div()
|
div()
|
||||||
.bg(cx.theme().colors().editor_background)
|
.bg(cx.theme().colors().editor_background)
|
||||||
|
|
|
@ -21,9 +21,9 @@ pub struct DiagnosticIndicator {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for DiagnosticIndicator {
|
impl Render for DiagnosticIndicator {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
let diagnostic_indicator = match (self.summary.error_count, self.summary.warning_count) {
|
let diagnostic_indicator = match (self.summary.error_count, self.summary.warning_count) {
|
||||||
(0, 0) => h_stack().child(
|
(0, 0) => h_stack().child(
|
||||||
IconElement::new(Icon::Check)
|
IconElement::new(Icon::Check)
|
||||||
|
|
|
@ -9,9 +9,9 @@ pub struct ToolbarControls {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for ToolbarControls {
|
impl Render for ToolbarControls {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
let include_warnings = self
|
let include_warnings = self
|
||||||
.editor
|
.editor
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
|
|
@ -9291,9 +9291,9 @@ impl FocusableView for Editor {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for Editor {
|
impl Render for Editor {
|
||||||
type Element = EditorElement;
|
type Output = EditorElement;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
let settings = ThemeSettings::get_global(cx);
|
let settings = ThemeSettings::get_global(cx);
|
||||||
let text_style = match self.mode {
|
let text_style = match self.mode {
|
||||||
EditorMode::SingleLine | EditorMode::AutoHeight { .. } => TextStyle {
|
EditorMode::SingleLine | EditorMode::AutoHeight { .. } => TextStyle {
|
||||||
|
|
|
@ -2757,7 +2757,7 @@ enum Invisible {
|
||||||
impl Element for EditorElement {
|
impl Element for EditorElement {
|
||||||
type State = ();
|
type State = ();
|
||||||
|
|
||||||
fn layout(
|
fn request_layout(
|
||||||
&mut self,
|
&mut self,
|
||||||
_element_state: Option<Self::State>,
|
_element_state: Option<Self::State>,
|
||||||
cx: &mut gpui::WindowContext,
|
cx: &mut gpui::WindowContext,
|
||||||
|
|
|
@ -1193,9 +1193,9 @@ impl CursorPosition {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for CursorPosition {
|
impl Render for CursorPosition {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, _: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, _: &mut ViewContext<Self>) -> Self::Output {
|
||||||
div().when_some(self.position, |el, position| {
|
div().when_some(self.position, |el, position| {
|
||||||
let mut text = format!(
|
let mut text = format!(
|
||||||
"{}{FILE_ROW_COLUMN_DELIMITER}{}",
|
"{}{FILE_ROW_COLUMN_DELIMITER}{}",
|
||||||
|
|
|
@ -17,9 +17,9 @@ impl DeployFeedbackButton {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for DeployFeedbackButton {
|
impl Render for DeployFeedbackButton {
|
||||||
type Element = AnyElement;
|
type Output = AnyElement;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
let is_open = self
|
let is_open = self
|
||||||
.workspace
|
.workspace
|
||||||
.upgrade()
|
.upgrade()
|
||||||
|
|
|
@ -396,9 +396,9 @@ impl FeedbackModal {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for FeedbackModal {
|
impl Render for FeedbackModal {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
self.update_submission_state(cx);
|
self.update_submission_state(cx);
|
||||||
|
|
||||||
let submit_button_text = if self.awaiting_submission() {
|
let submit_button_text = if self.awaiting_submission() {
|
||||||
|
|
|
@ -118,9 +118,9 @@ impl FocusableView for FileFinder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Render for FileFinder {
|
impl Render for FileFinder {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
v_stack().w(rems(34.)).child(self.picker.clone())
|
v_stack().w(rems(34.)).child(self.picker.clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,9 +153,9 @@ impl GoToLine {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for GoToLine {
|
impl Render for GoToLine {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
div()
|
div()
|
||||||
.elevation_2(cx)
|
.elevation_2(cx)
|
||||||
.key_context("GoToLine")
|
.key_context("GoToLine")
|
||||||
|
|
|
@ -733,9 +733,9 @@ impl AnyWindowHandle {
|
||||||
pub struct EmptyView {}
|
pub struct EmptyView {}
|
||||||
|
|
||||||
impl Render for EmptyView {
|
impl Render for EmptyView {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, _cx: &mut crate::ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, _cx: &mut crate::ViewContext<Self>) -> Self::Output {
|
||||||
div()
|
div()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,23 +6,61 @@ use derive_more::{Deref, DerefMut};
|
||||||
pub(crate) use smallvec::SmallVec;
|
pub(crate) use smallvec::SmallVec;
|
||||||
use std::{any::Any, fmt::Debug};
|
use std::{any::Any, fmt::Debug};
|
||||||
|
|
||||||
pub trait Render: 'static + Sized {
|
/// Elements describe the contents of a window for a given frame.
|
||||||
type Element: Element + 'static;
|
/// Like HTML elements, elements form a tree and participate in layout.
|
||||||
|
/// In GPUI, elements are single-use objects that do not outlive a single frame.
|
||||||
|
/// Elements are associated with state.
|
||||||
|
/// If the element has an identifier, the element's state persists across frames in which the element appears.
|
||||||
|
/// If the element is anonymous, the state only persists across from layout request to paint in is referred to as "frame state".
|
||||||
|
/// A potential improvement would be to separate this temporary frame state from persistent element state at the type level, and request element state from the context with an id. /cc @as-cii\
|
||||||
|
/// To render the contents of a window, we first walk over the tree of elements recursively via [request_layout], giving each an opportunity to register with the layout engine.
|
||||||
|
/// Then we compute the requested layout and use the computed bounds to paint the element tree recursively with [paint].
|
||||||
|
/// You can implement this trait yourself for performance or other special situations, but you'll typically compose existing elements such as `Div`, `Img`, etc.
|
||||||
|
pub trait Element: 'static + IntoElement {
|
||||||
|
/// State that is carried from [request_layout] to [paint] for anonymous elements, and between frames for elements that have an id.
|
||||||
|
type State: 'static;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element;
|
/// Recursively register this element and all its descendants with the layout engine.
|
||||||
|
/// If this element has an id, you'll receive the [State] from the previous frame if an element with this id existed in that frame.
|
||||||
|
/// Return the [LayoutId] you requested from the engine and whatever state you want to carry over to [paint], and also the next frame if this element has an id.
|
||||||
|
fn request_layout(
|
||||||
|
&mut self,
|
||||||
|
state: Option<Self::State>,
|
||||||
|
cx: &mut WindowContext,
|
||||||
|
) -> (LayoutId, Self::State);
|
||||||
|
|
||||||
|
/// Recursively paint this element by populating the current frame's [Scene] with geometric primitives such as quads, sprites, paths, etc.
|
||||||
|
/// Receives the state from layout, and potentially the previous frame if this element has an id.
|
||||||
|
fn paint(&mut self, bounds: Bounds<Pixels>, state: &mut Self::State, cx: &mut WindowContext);
|
||||||
|
|
||||||
|
/// Convert into a dynamically-typed [AnyElement].
|
||||||
|
/// Before an element can be painted, it must be converted into an [AnyElement].
|
||||||
|
/// It's also useful in situations where you need to own an element, but don't care about its specific type.
|
||||||
|
fn into_any(self) -> AnyElement {
|
||||||
|
AnyElement::new(self)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Implemented by any type that can be converted into an element.
|
||||||
pub trait IntoElement: Sized {
|
pub trait IntoElement: Sized {
|
||||||
type Element: Element + 'static;
|
/// The specific type of element into which the implementing type is converted.
|
||||||
|
type Element: Element;
|
||||||
|
|
||||||
|
/// The [ElementId] of self once converted into an [Element].
|
||||||
|
/// If present, the resulting element's state will be carried across frames.
|
||||||
fn element_id(&self) -> Option<ElementId>;
|
fn element_id(&self) -> Option<ElementId>;
|
||||||
|
|
||||||
|
/// Convert self into a type that implements [Element].
|
||||||
fn into_element(self) -> Self::Element;
|
fn into_element(self) -> Self::Element;
|
||||||
|
|
||||||
|
/// Convert self into a dynamically-typed [AnyElement].
|
||||||
fn into_any_element(self) -> AnyElement {
|
fn into_any_element(self) -> AnyElement {
|
||||||
self.into_element().into_any()
|
self.into_element().into_any()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Convert into an element, then draw in the current window at the given origin.
|
||||||
|
/// The provided available space is provided to the layout engine to determine the size of the root element.
|
||||||
|
/// Once the element is drawn, its associated element staet is yielded to the given callback.
|
||||||
fn draw_and_update_state<T, R>(
|
fn draw_and_update_state<T, R>(
|
||||||
self,
|
self,
|
||||||
origin: Point<Pixels>,
|
origin: Point<Pixels>,
|
||||||
|
@ -54,6 +92,7 @@ pub trait IntoElement: Sized {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Convert self to another type by calling the given closure. Useful in rendering code.
|
||||||
fn map<U>(self, f: impl FnOnce(Self) -> U) -> U
|
fn map<U>(self, f: impl FnOnce(Self) -> U) -> U
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
|
@ -62,6 +101,7 @@ pub trait IntoElement: Sized {
|
||||||
f(self)
|
f(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Conditionally chain onto self with the given closure. Useful in rendering code.
|
||||||
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
|
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
|
@ -69,6 +109,8 @@ pub trait IntoElement: Sized {
|
||||||
self.map(|this| if condition { then(this) } else { this })
|
self.map(|this| if condition { then(this) } else { this })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Conditionally chain onto self with the given closure if the given option is Some.
|
||||||
|
/// The contents of the option are provided to the closure.
|
||||||
fn when_some<T>(self, option: Option<T>, then: impl FnOnce(Self, T) -> Self) -> Self
|
fn when_some<T>(self, option: Option<T>, then: impl FnOnce(Self, T) -> Self) -> Self
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
|
@ -83,35 +125,46 @@ pub trait IntoElement: Sized {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Element: 'static + IntoElement {
|
pub trait Render: 'static + Sized {
|
||||||
type State: 'static;
|
type Output: IntoElement;
|
||||||
|
|
||||||
fn layout(
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output;
|
||||||
&mut self,
|
|
||||||
state: Option<Self::State>,
|
|
||||||
cx: &mut WindowContext,
|
|
||||||
) -> (LayoutId, Self::State);
|
|
||||||
|
|
||||||
fn paint(&mut self, bounds: Bounds<Pixels>, state: &mut Self::State, cx: &mut WindowContext);
|
|
||||||
|
|
||||||
fn into_any(self) -> AnyElement {
|
|
||||||
AnyElement::new(self)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait RenderOnce: 'static {
|
pub trait RenderOnce: 'static {
|
||||||
type Rendered: IntoElement;
|
type Output: IntoElement;
|
||||||
|
|
||||||
fn render(self, cx: &mut WindowContext) -> Self::Rendered;
|
fn render(self, cx: &mut WindowContext) -> Self::Output;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait ParentElement {
|
||||||
|
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement; 2]>;
|
||||||
|
|
||||||
|
fn child(mut self, child: impl IntoElement) -> Self
|
||||||
|
where
|
||||||
|
Self: Sized,
|
||||||
|
{
|
||||||
|
self.children_mut().push(child.into_element().into_any());
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
fn children(mut self, children: impl IntoIterator<Item = impl IntoElement>) -> Self
|
||||||
|
where
|
||||||
|
Self: Sized,
|
||||||
|
{
|
||||||
|
self.children_mut()
|
||||||
|
.extend(children.into_iter().map(|child| child.into_any_element()));
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Component<C> {
|
pub struct Component<C> {
|
||||||
component: Option<C>,
|
component: Option<C>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct CompositeElementState<C: RenderOnce> {
|
pub struct ComponentState<C: RenderOnce> {
|
||||||
rendered_element: Option<<C::Rendered as IntoElement>::Element>,
|
rendered_element: Option<<C::Output as IntoElement>::Element>,
|
||||||
rendered_element_state: Option<<<C::Rendered as IntoElement>::Element as Element>::State>,
|
rendered_element_state: Option<<<C::Output as IntoElement>::Element as Element>::State>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C> Component<C> {
|
impl<C> Component<C> {
|
||||||
|
@ -123,9 +176,9 @@ impl<C> Component<C> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: RenderOnce> Element for Component<C> {
|
impl<C: RenderOnce> Element for Component<C> {
|
||||||
type State = CompositeElementState<C>;
|
type State = ComponentState<C>;
|
||||||
|
|
||||||
fn layout(
|
fn request_layout(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: Option<Self::State>,
|
state: Option<Self::State>,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
|
@ -133,16 +186,16 @@ impl<C: RenderOnce> Element for Component<C> {
|
||||||
let mut element = self.component.take().unwrap().render(cx).into_element();
|
let mut element = self.component.take().unwrap().render(cx).into_element();
|
||||||
if let Some(element_id) = element.element_id() {
|
if let Some(element_id) = element.element_id() {
|
||||||
let layout_id =
|
let layout_id =
|
||||||
cx.with_element_state(element_id, |state, cx| element.layout(state, cx));
|
cx.with_element_state(element_id, |state, cx| element.request_layout(state, cx));
|
||||||
let state = CompositeElementState {
|
let state = ComponentState {
|
||||||
rendered_element: Some(element),
|
rendered_element: Some(element),
|
||||||
rendered_element_state: None,
|
rendered_element_state: None,
|
||||||
};
|
};
|
||||||
(layout_id, state)
|
(layout_id, state)
|
||||||
} else {
|
} else {
|
||||||
let (layout_id, state) =
|
let (layout_id, state) =
|
||||||
element.layout(state.and_then(|s| s.rendered_element_state), cx);
|
element.request_layout(state.and_then(|s| s.rendered_element_state), cx);
|
||||||
let state = CompositeElementState {
|
let state = ComponentState {
|
||||||
rendered_element: Some(element),
|
rendered_element: Some(element),
|
||||||
rendered_element_state: Some(state),
|
rendered_element_state: Some(state),
|
||||||
};
|
};
|
||||||
|
@ -183,27 +236,6 @@ impl<C: RenderOnce> IntoElement for Component<C> {
|
||||||
#[derive(Deref, DerefMut, Default, Clone, Debug, Eq, PartialEq, Hash)]
|
#[derive(Deref, DerefMut, Default, Clone, Debug, Eq, PartialEq, Hash)]
|
||||||
pub struct GlobalElementId(SmallVec<[ElementId; 32]>);
|
pub struct GlobalElementId(SmallVec<[ElementId; 32]>);
|
||||||
|
|
||||||
pub trait ParentElement {
|
|
||||||
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement; 2]>;
|
|
||||||
|
|
||||||
fn child(mut self, child: impl IntoElement) -> Self
|
|
||||||
where
|
|
||||||
Self: Sized,
|
|
||||||
{
|
|
||||||
self.children_mut().push(child.into_element().into_any());
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
fn children(mut self, children: impl IntoIterator<Item = impl IntoElement>) -> Self
|
|
||||||
where
|
|
||||||
Self: Sized,
|
|
||||||
{
|
|
||||||
self.children_mut()
|
|
||||||
.extend(children.into_iter().map(|child| child.into_any_element()));
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
trait ElementObject {
|
trait ElementObject {
|
||||||
fn element_id(&self) -> Option<ElementId>;
|
fn element_id(&self) -> Option<ElementId>;
|
||||||
|
|
||||||
|
@ -262,11 +294,14 @@ impl<E: Element> DrawableElement<E> {
|
||||||
let (layout_id, frame_state) = if let Some(id) = self.element.as_ref().unwrap().element_id()
|
let (layout_id, frame_state) = if let Some(id) = self.element.as_ref().unwrap().element_id()
|
||||||
{
|
{
|
||||||
let layout_id = cx.with_element_state(id, |element_state, cx| {
|
let layout_id = cx.with_element_state(id, |element_state, cx| {
|
||||||
self.element.as_mut().unwrap().layout(element_state, cx)
|
self.element
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
.request_layout(element_state, cx)
|
||||||
});
|
});
|
||||||
(layout_id, None)
|
(layout_id, None)
|
||||||
} else {
|
} else {
|
||||||
let (layout_id, frame_state) = self.element.as_mut().unwrap().layout(None, cx);
|
let (layout_id, frame_state) = self.element.as_mut().unwrap().request_layout(None, cx);
|
||||||
(layout_id, Some(frame_state))
|
(layout_id, Some(frame_state))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -454,7 +489,7 @@ impl AnyElement {
|
||||||
impl Element for AnyElement {
|
impl Element for AnyElement {
|
||||||
type State = ();
|
type State = ();
|
||||||
|
|
||||||
fn layout(
|
fn request_layout(
|
||||||
&mut self,
|
&mut self,
|
||||||
_: Option<Self::State>,
|
_: Option<Self::State>,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
|
@ -502,7 +537,7 @@ impl IntoElement for () {
|
||||||
impl Element for () {
|
impl Element for () {
|
||||||
type State = ();
|
type State = ();
|
||||||
|
|
||||||
fn layout(
|
fn request_layout(
|
||||||
&mut self,
|
&mut self,
|
||||||
_state: Option<Self::State>,
|
_state: Option<Self::State>,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
|
|
|
@ -29,7 +29,7 @@ impl IntoElement for Canvas {
|
||||||
impl Element for Canvas {
|
impl Element for Canvas {
|
||||||
type State = Style;
|
type State = Style;
|
||||||
|
|
||||||
fn layout(
|
fn request_layout(
|
||||||
&mut self,
|
&mut self,
|
||||||
_: Option<Self::State>,
|
_: Option<Self::State>,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
|
|
|
@ -768,7 +768,7 @@ impl ParentElement for Div {
|
||||||
impl Element for Div {
|
impl Element for Div {
|
||||||
type State = DivState;
|
type State = DivState;
|
||||||
|
|
||||||
fn layout(
|
fn request_layout(
|
||||||
&mut self,
|
&mut self,
|
||||||
element_state: Option<Self::State>,
|
element_state: Option<Self::State>,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
|
@ -1818,12 +1818,12 @@ where
|
||||||
{
|
{
|
||||||
type State = E::State;
|
type State = E::State;
|
||||||
|
|
||||||
fn layout(
|
fn request_layout(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: Option<Self::State>,
|
state: Option<Self::State>,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
) -> (LayoutId, Self::State) {
|
) -> (LayoutId, Self::State) {
|
||||||
self.element.layout(state, cx)
|
self.element.request_layout(state, cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn paint(&mut self, bounds: Bounds<Pixels>, state: &mut Self::State, cx: &mut WindowContext) {
|
fn paint(&mut self, bounds: Bounds<Pixels>, state: &mut Self::State, cx: &mut WindowContext) {
|
||||||
|
@ -1892,12 +1892,12 @@ where
|
||||||
{
|
{
|
||||||
type State = E::State;
|
type State = E::State;
|
||||||
|
|
||||||
fn layout(
|
fn request_layout(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: Option<Self::State>,
|
state: Option<Self::State>,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
) -> (LayoutId, Self::State) {
|
) -> (LayoutId, Self::State) {
|
||||||
self.element.layout(state, cx)
|
self.element.request_layout(state, cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn paint(&mut self, bounds: Bounds<Pixels>, state: &mut Self::State, cx: &mut WindowContext) {
|
fn paint(&mut self, bounds: Bounds<Pixels>, state: &mut Self::State, cx: &mut WindowContext) {
|
||||||
|
|
|
@ -71,7 +71,7 @@ impl Img {
|
||||||
impl Element for Img {
|
impl Element for Img {
|
||||||
type State = InteractiveElementState;
|
type State = InteractiveElementState;
|
||||||
|
|
||||||
fn layout(
|
fn request_layout(
|
||||||
&mut self,
|
&mut self,
|
||||||
element_state: Option<Self::State>,
|
element_state: Option<Self::State>,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
|
|
|
@ -302,7 +302,7 @@ pub struct ListOffset {
|
||||||
impl Element for List {
|
impl Element for List {
|
||||||
type State = ();
|
type State = ();
|
||||||
|
|
||||||
fn layout(
|
fn request_layout(
|
||||||
&mut self,
|
&mut self,
|
||||||
_state: Option<Self::State>,
|
_state: Option<Self::State>,
|
||||||
cx: &mut crate::WindowContext,
|
cx: &mut crate::WindowContext,
|
||||||
|
|
|
@ -60,7 +60,7 @@ impl ParentElement for Overlay {
|
||||||
impl Element for Overlay {
|
impl Element for Overlay {
|
||||||
type State = OverlayState;
|
type State = OverlayState;
|
||||||
|
|
||||||
fn layout(
|
fn request_layout(
|
||||||
&mut self,
|
&mut self,
|
||||||
_: Option<Self::State>,
|
_: Option<Self::State>,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
|
|
|
@ -26,7 +26,7 @@ impl Svg {
|
||||||
impl Element for Svg {
|
impl Element for Svg {
|
||||||
type State = InteractiveElementState;
|
type State = InteractiveElementState;
|
||||||
|
|
||||||
fn layout(
|
fn request_layout(
|
||||||
&mut self,
|
&mut self,
|
||||||
element_state: Option<Self::State>,
|
element_state: Option<Self::State>,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
|
|
|
@ -12,7 +12,7 @@ use util::ResultExt;
|
||||||
impl Element for &'static str {
|
impl Element for &'static str {
|
||||||
type State = TextState;
|
type State = TextState;
|
||||||
|
|
||||||
fn layout(
|
fn request_layout(
|
||||||
&mut self,
|
&mut self,
|
||||||
_: Option<Self::State>,
|
_: Option<Self::State>,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
|
@ -42,7 +42,7 @@ impl IntoElement for &'static str {
|
||||||
impl Element for SharedString {
|
impl Element for SharedString {
|
||||||
type State = TextState;
|
type State = TextState;
|
||||||
|
|
||||||
fn layout(
|
fn request_layout(
|
||||||
&mut self,
|
&mut self,
|
||||||
_: Option<Self::State>,
|
_: Option<Self::State>,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
|
@ -118,7 +118,7 @@ impl StyledText {
|
||||||
impl Element for StyledText {
|
impl Element for StyledText {
|
||||||
type State = TextState;
|
type State = TextState;
|
||||||
|
|
||||||
fn layout(
|
fn request_layout(
|
||||||
&mut self,
|
&mut self,
|
||||||
_: Option<Self::State>,
|
_: Option<Self::State>,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
|
@ -331,7 +331,7 @@ impl InteractiveText {
|
||||||
impl Element for InteractiveText {
|
impl Element for InteractiveText {
|
||||||
type State = InteractiveTextState;
|
type State = InteractiveTextState;
|
||||||
|
|
||||||
fn layout(
|
fn request_layout(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: Option<Self::State>,
|
state: Option<Self::State>,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
|
@ -340,14 +340,14 @@ impl Element for InteractiveText {
|
||||||
mouse_down_index, ..
|
mouse_down_index, ..
|
||||||
}) = state
|
}) = state
|
||||||
{
|
{
|
||||||
let (layout_id, text_state) = self.text.layout(None, cx);
|
let (layout_id, text_state) = self.text.request_layout(None, cx);
|
||||||
let element_state = InteractiveTextState {
|
let element_state = InteractiveTextState {
|
||||||
text_state,
|
text_state,
|
||||||
mouse_down_index,
|
mouse_down_index,
|
||||||
};
|
};
|
||||||
(layout_id, element_state)
|
(layout_id, element_state)
|
||||||
} else {
|
} else {
|
||||||
let (layout_id, text_state) = self.text.layout(None, cx);
|
let (layout_id, text_state) = self.text.request_layout(None, cx);
|
||||||
let element_state = InteractiveTextState {
|
let element_state = InteractiveTextState {
|
||||||
text_state,
|
text_state,
|
||||||
mouse_down_index: Rc::default(),
|
mouse_down_index: Rc::default(),
|
||||||
|
|
|
@ -116,7 +116,7 @@ pub struct UniformListState {
|
||||||
impl Element for UniformList {
|
impl Element for UniformList {
|
||||||
type State = UniformListState;
|
type State = UniformListState;
|
||||||
|
|
||||||
fn layout(
|
fn request_layout(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: Option<Self::State>,
|
state: Option<Self::State>,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
|
|
|
@ -205,9 +205,9 @@ impl ExternalPaths {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for ExternalPaths {
|
impl Render for ExternalPaths {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, _: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, _: &mut ViewContext<Self>) -> Self::Output {
|
||||||
div() // Intentionally left empty because the platform will render icons for the dragged files
|
div() // Intentionally left empty because the platform will render icons for the dragged files
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -305,9 +305,9 @@ mod test {
|
||||||
actions!(test, [TestAction]);
|
actions!(test, [TestAction]);
|
||||||
|
|
||||||
impl Render for TestView {
|
impl Render for TestView {
|
||||||
type Element = Stateful<Div>;
|
type Output = Stateful<Div>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Self::Output {
|
||||||
div().id("testview").child(
|
div().id("testview").child(
|
||||||
div()
|
div()
|
||||||
.key_context("parent")
|
.key_context("parent")
|
||||||
|
|
|
@ -81,12 +81,12 @@ impl<V: 'static> View<V> {
|
||||||
impl<V: Render> Element for View<V> {
|
impl<V: Render> Element for View<V> {
|
||||||
type State = Option<AnyElement>;
|
type State = Option<AnyElement>;
|
||||||
|
|
||||||
fn layout(
|
fn request_layout(
|
||||||
&mut self,
|
&mut self,
|
||||||
_state: Option<Self::State>,
|
_state: Option<Self::State>,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
) -> (LayoutId, Self::State) {
|
) -> (LayoutId, Self::State) {
|
||||||
let mut element = self.update(cx, |view, cx| view.render(cx).into_any());
|
let mut element = self.update(cx, |view, cx| view.render(cx).into_any_element());
|
||||||
let layout_id = element.layout(cx);
|
let layout_id = element.layout(cx);
|
||||||
(layout_id, Some(element))
|
(layout_id, Some(element))
|
||||||
}
|
}
|
||||||
|
@ -229,7 +229,7 @@ impl<V: Render> From<View<V>> for AnyView {
|
||||||
impl Element for AnyView {
|
impl Element for AnyView {
|
||||||
type State = Option<AnyElement>;
|
type State = Option<AnyElement>;
|
||||||
|
|
||||||
fn layout(
|
fn request_layout(
|
||||||
&mut self,
|
&mut self,
|
||||||
_state: Option<Self::State>,
|
_state: Option<Self::State>,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
|
@ -317,22 +317,22 @@ where
|
||||||
T: 'static + FnMut(&mut WindowContext) -> E,
|
T: 'static + FnMut(&mut WindowContext) -> E,
|
||||||
E: 'static + Send + Element,
|
E: 'static + Send + Element,
|
||||||
{
|
{
|
||||||
type Element = E;
|
type Output = E;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
(self)(cx)
|
(self)(cx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod any_view {
|
mod any_view {
|
||||||
use crate::{AnyElement, AnyView, Element, LayoutId, Render, WindowContext};
|
use crate::{AnyElement, AnyView, IntoElement, LayoutId, Render, WindowContext};
|
||||||
|
|
||||||
pub(crate) fn layout<V: 'static + Render>(
|
pub(crate) fn layout<V: 'static + Render>(
|
||||||
view: &AnyView,
|
view: &AnyView,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
) -> (LayoutId, AnyElement) {
|
) -> (LayoutId, AnyElement) {
|
||||||
let view = view.clone().downcast::<V>().unwrap();
|
let view = view.clone().downcast::<V>().unwrap();
|
||||||
let mut element = view.update(cx, |view, cx| view.render(cx).into_any());
|
let mut element = view.update(cx, |view, cx| view.render(cx).into_any_element());
|
||||||
let layout_id = element.layout(cx);
|
let layout_id = element.layout(cx);
|
||||||
(layout_id, element)
|
(layout_id, element)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,9 @@ pub fn derive_render(input: TokenStream) -> TokenStream {
|
||||||
impl #impl_generics gpui::Render for #type_name #type_generics
|
impl #impl_generics gpui::Render for #type_name #type_generics
|
||||||
#where_clause
|
#where_clause
|
||||||
{
|
{
|
||||||
type Element = ();
|
type Output = ();
|
||||||
|
|
||||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
()
|
()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ impl ActiveBufferLanguage {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for ActiveBufferLanguage {
|
impl Render for ActiveBufferLanguage {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Div {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Div {
|
||||||
div().when_some(self.active_language.as_ref(), |el, active_language| {
|
div().when_some(self.active_language.as_ref(), |el, active_language| {
|
||||||
|
|
|
@ -67,9 +67,9 @@ impl LanguageSelector {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for LanguageSelector {
|
impl Render for LanguageSelector {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
v_stack().w(rems(34.)).child(self.picker.clone())
|
v_stack().w(rems(34.)).child(self.picker.clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -595,9 +595,9 @@ fn log_contents(lines: &VecDeque<String>) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for LspLogView {
|
impl Render for LspLogView {
|
||||||
type Element = EditorElement;
|
type Output = EditorElement;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
self.editor.update(cx, |editor, cx| editor.render(cx))
|
self.editor.update(cx, |editor, cx| editor.render(cx))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -709,9 +709,9 @@ impl ToolbarItemView for LspLogToolbarItemView {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for LspLogToolbarItemView {
|
impl Render for LspLogToolbarItemView {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
let Some(log_view) = self.log_view.clone() else {
|
let Some(log_view) = self.log_view.clone() else {
|
||||||
return div();
|
return div();
|
||||||
};
|
};
|
||||||
|
|
|
@ -305,9 +305,9 @@ impl SyntaxTreeView {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for SyntaxTreeView {
|
impl Render for SyntaxTreeView {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut gpui::ViewContext<'_, Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut gpui::ViewContext<'_, Self>) -> Self::Output {
|
||||||
let settings = ThemeSettings::get_global(cx);
|
let settings = ThemeSettings::get_global(cx);
|
||||||
let line_height = cx
|
let line_height = cx
|
||||||
.text_style()
|
.text_style()
|
||||||
|
@ -507,7 +507,7 @@ fn format_node_range(node: Node) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for SyntaxTreeToolbarItemView {
|
impl Render for SyntaxTreeToolbarItemView {
|
||||||
type Element = PopoverMenu<ContextMenu>;
|
type Output = PopoverMenu<ContextMenu>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<'_, Self>) -> PopoverMenu<ContextMenu> {
|
fn render(&mut self, cx: &mut ViewContext<'_, Self>) -> PopoverMenu<ContextMenu> {
|
||||||
self.render_menu(cx)
|
self.render_menu(cx)
|
||||||
|
|
|
@ -57,9 +57,9 @@ impl EventEmitter<DismissEvent> for OutlineView {}
|
||||||
impl ModalView for OutlineView {}
|
impl ModalView for OutlineView {}
|
||||||
|
|
||||||
impl Render for OutlineView {
|
impl Render for OutlineView {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
v_stack().w(rems(34.)).child(self.picker.clone())
|
v_stack().w(rems(34.)).child(self.picker.clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -228,9 +228,9 @@ impl<D: PickerDelegate> EventEmitter<DismissEvent> for Picker<D> {}
|
||||||
impl<D: PickerDelegate> ModalView for Picker<D> {}
|
impl<D: PickerDelegate> ModalView for Picker<D> {}
|
||||||
|
|
||||||
impl<D: PickerDelegate> Render for Picker<D> {
|
impl<D: PickerDelegate> Render for Picker<D> {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
let picker_editor = h_stack()
|
let picker_editor = h_stack()
|
||||||
.overflow_hidden()
|
.overflow_hidden()
|
||||||
.flex_none()
|
.flex_none()
|
||||||
|
|
|
@ -1480,9 +1480,9 @@ impl ProjectPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for ProjectPanel {
|
impl Render for ProjectPanel {
|
||||||
type Element = Focusable<Stateful<Div>>;
|
type Output = Focusable<Stateful<Div>>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Self::Output {
|
||||||
let has_worktree = self.visible_entries.len() != 0;
|
let has_worktree = self.visible_entries.len() != 0;
|
||||||
|
|
||||||
if has_worktree {
|
if has_worktree {
|
||||||
|
@ -1548,9 +1548,9 @@ impl Render for ProjectPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for DraggedProjectEntryView {
|
impl Render for DraggedProjectEntryView {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
let settings = ProjectPanelSettings::get_global(cx);
|
let settings = ProjectPanelSettings::get_global(cx);
|
||||||
let ui_font = ThemeSettings::get_global(cx).ui_font.family.clone();
|
let ui_font = ThemeSettings::get_global(cx).ui_font.family.clone();
|
||||||
h_stack()
|
h_stack()
|
||||||
|
|
|
@ -36,9 +36,9 @@ impl QuickActionBar {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for QuickActionBar {
|
impl Render for QuickActionBar {
|
||||||
type Element = Stateful<Div>;
|
type Output = Stateful<Div>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
let Some(editor) = self.active_editor() else {
|
let Some(editor) = self.active_editor() else {
|
||||||
return div().id("empty quick action bar");
|
return div().id("empty quick action bar");
|
||||||
};
|
};
|
||||||
|
@ -138,9 +138,9 @@ impl QuickActionBarButton {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for QuickActionBarButton {
|
impl RenderOnce for QuickActionBarButton {
|
||||||
type Rendered = IconButton;
|
type Output = IconButton;
|
||||||
|
|
||||||
fn render(self, _: &mut WindowContext) -> Self::Rendered {
|
fn render(self, _: &mut WindowContext) -> Self::Output {
|
||||||
let tooltip = self.tooltip.clone();
|
let tooltip = self.tooltip.clone();
|
||||||
let action = self.action.boxed_clone();
|
let action = self.action.boxed_clone();
|
||||||
|
|
||||||
|
|
|
@ -43,9 +43,9 @@ impl HighlightedText {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for HighlightedText {
|
impl RenderOnce for HighlightedText {
|
||||||
type Rendered = HighlightedLabel;
|
type Output = HighlightedLabel;
|
||||||
|
|
||||||
fn render(self, _cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, _cx: &mut WindowContext) -> Self::Output {
|
||||||
HighlightedLabel::new(self.text, self.highlight_positions)
|
HighlightedLabel::new(self.text, self.highlight_positions)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,9 +103,9 @@ impl FocusableView for RecentProjects {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for RecentProjects {
|
impl Render for RecentProjects {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
v_stack()
|
v_stack()
|
||||||
.w(rems(self.rem_width))
|
.w(rems(self.rem_width))
|
||||||
.child(self.picker.clone())
|
.child(self.picker.clone())
|
||||||
|
|
|
@ -101,9 +101,9 @@ impl BufferSearchBar {
|
||||||
impl EventEmitter<Event> for BufferSearchBar {}
|
impl EventEmitter<Event> for BufferSearchBar {}
|
||||||
impl EventEmitter<workspace::ToolbarItemEvent> for BufferSearchBar {}
|
impl EventEmitter<workspace::ToolbarItemEvent> for BufferSearchBar {}
|
||||||
impl Render for BufferSearchBar {
|
impl Render for BufferSearchBar {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
if self.dismissed {
|
if self.dismissed {
|
||||||
return div();
|
return div();
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,9 +279,9 @@ pub enum ViewEvent {
|
||||||
impl EventEmitter<ViewEvent> for ProjectSearchView {}
|
impl EventEmitter<ViewEvent> for ProjectSearchView {}
|
||||||
|
|
||||||
impl Render for ProjectSearchView {
|
impl Render for ProjectSearchView {
|
||||||
type Element = AnyElement;
|
type Output = AnyElement;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
if self.has_matches() {
|
if self.has_matches() {
|
||||||
div()
|
div()
|
||||||
.flex_1()
|
.flex_1()
|
||||||
|
@ -1494,9 +1494,9 @@ impl ProjectSearchBar {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for ProjectSearchBar {
|
impl Render for ProjectSearchBar {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
let Some(search) = self.active_project_search.clone() else {
|
let Some(search) = self.active_project_search.clone() else {
|
||||||
return div();
|
return div();
|
||||||
};
|
};
|
||||||
|
|
|
@ -74,9 +74,9 @@ impl ParentElement for StoryContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for StoryContainer {
|
impl RenderOnce for StoryContainer {
|
||||||
type Rendered = Stateful<Div>;
|
type Output = Stateful<Div>;
|
||||||
|
|
||||||
fn render(self, _cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, _cx: &mut WindowContext) -> Self::Output {
|
||||||
div()
|
div()
|
||||||
.size_full()
|
.size_full()
|
||||||
.flex()
|
.flex()
|
||||||
|
@ -294,9 +294,9 @@ impl StoryItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for StoryItem {
|
impl RenderOnce for StoryItem {
|
||||||
type Rendered = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(self, _cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, _cx: &mut WindowContext) -> Self::Output {
|
||||||
div()
|
div()
|
||||||
.my_2()
|
.my_2()
|
||||||
.flex()
|
.flex()
|
||||||
|
@ -358,9 +358,9 @@ impl StorySection {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for StorySection {
|
impl RenderOnce for StorySection {
|
||||||
type Rendered = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(self, _cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, _cx: &mut WindowContext) -> Self::Output {
|
||||||
let children: SmallVec<[AnyElement; 2]> = SmallVec::from_iter(Itertools::intersperse_with(
|
let children: SmallVec<[AnyElement; 2]> = SmallVec::from_iter(Itertools::intersperse_with(
|
||||||
self.children.into_iter(),
|
self.children.into_iter(),
|
||||||
|| Story::divider().into_any_element(),
|
|| Story::divider().into_any_element(),
|
||||||
|
|
|
@ -22,9 +22,9 @@ impl AutoHeightEditorStory {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for AutoHeightEditorStory {
|
impl Render for AutoHeightEditorStory {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
div()
|
div()
|
||||||
.size_full()
|
.size_full()
|
||||||
.bg(white())
|
.bg(white())
|
||||||
|
|
|
@ -5,9 +5,9 @@ use ui::prelude::*;
|
||||||
pub struct CursorStory;
|
pub struct CursorStory;
|
||||||
|
|
||||||
impl Render for CursorStory {
|
impl Render for CursorStory {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
let all_cursors: [(&str, Box<dyn Fn(Stateful<Div>) -> Stateful<Div>>); 19] = [
|
let all_cursors: [(&str, Box<dyn Fn(Stateful<Div>) -> Stateful<Div>>); 19] = [
|
||||||
(
|
(
|
||||||
"cursor_default",
|
"cursor_default",
|
||||||
|
|
|
@ -57,9 +57,9 @@ impl FocusStory {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for FocusStory {
|
impl Render for FocusStory {
|
||||||
type Element = Focusable<Stateful<Div>>;
|
type Output = Focusable<Stateful<Div>>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Self::Output {
|
||||||
let theme = cx.theme();
|
let theme = cx.theme();
|
||||||
let color_1 = theme.status().created;
|
let color_1 = theme.status().created;
|
||||||
let color_2 = theme.status().modified;
|
let color_2 = theme.status().modified;
|
||||||
|
|
|
@ -14,9 +14,9 @@ impl KitchenSinkStory {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for KitchenSinkStory {
|
impl Render for KitchenSinkStory {
|
||||||
type Element = Stateful<Div>;
|
type Output = Stateful<Div>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
let component_stories = ComponentStory::iter()
|
let component_stories = ComponentStory::iter()
|
||||||
.map(|selector| selector.story(cx))
|
.map(|selector| selector.story(cx))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
|
@ -6,9 +6,9 @@ use ui::prelude::*;
|
||||||
pub struct OverflowScrollStory;
|
pub struct OverflowScrollStory;
|
||||||
|
|
||||||
impl Render for OverflowScrollStory {
|
impl Render for OverflowScrollStory {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
Story::container()
|
Story::container()
|
||||||
.child(Story::title("Overflow Scroll"))
|
.child(Story::title("Overflow Scroll"))
|
||||||
.child(Story::label("`overflow_x_scroll`"))
|
.child(Story::label("`overflow_x_scroll`"))
|
||||||
|
|
|
@ -202,9 +202,9 @@ impl PickerStory {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for PickerStory {
|
impl Render for PickerStory {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Self::Output {
|
||||||
div()
|
div()
|
||||||
.bg(cx.theme().styles.colors.background)
|
.bg(cx.theme().styles.colors.background)
|
||||||
.size_full()
|
.size_full()
|
||||||
|
|
|
@ -11,9 +11,9 @@ impl ScrollStory {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for ScrollStory {
|
impl Render for ScrollStory {
|
||||||
type Element = Stateful<Div>;
|
type Output = Stateful<Div>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Self::Output {
|
||||||
let theme = cx.theme();
|
let theme = cx.theme();
|
||||||
let color_1 = theme.status().created;
|
let color_1 = theme.status().created;
|
||||||
let color_2 = theme.status().modified;
|
let color_2 = theme.status().modified;
|
||||||
|
|
|
@ -14,9 +14,9 @@ impl TextStory {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for TextStory {
|
impl Render for TextStory {
|
||||||
type Element = Component<StoryContainer>;
|
type Output = Component<StoryContainer>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Self::Output {
|
||||||
StoryContainer::new("Text Story", "crates/storybook2/src/stories/text.rs")
|
StoryContainer::new("Text Story", "crates/storybook2/src/stories/text.rs")
|
||||||
.children(
|
.children(
|
||||||
vec![
|
vec![
|
||||||
|
|
|
@ -6,9 +6,9 @@ use ui::prelude::*;
|
||||||
pub struct ViewportUnitsStory;
|
pub struct ViewportUnitsStory;
|
||||||
|
|
||||||
impl Render for ViewportUnitsStory {
|
impl Render for ViewportUnitsStory {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
Story::container().child(
|
Story::container().child(
|
||||||
div()
|
div()
|
||||||
.flex()
|
.flex()
|
||||||
|
|
|
@ -7,9 +7,9 @@ use ui::prelude::*;
|
||||||
pub struct ZIndexStory;
|
pub struct ZIndexStory;
|
||||||
|
|
||||||
impl Render for ZIndexStory {
|
impl Render for ZIndexStory {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
Story::container().child(Story::title("z-index")).child(
|
Story::container().child(Story::title("z-index")).child(
|
||||||
div()
|
div()
|
||||||
.flex()
|
.flex()
|
||||||
|
@ -82,9 +82,9 @@ struct ZIndexExample {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for ZIndexExample {
|
impl RenderOnce for ZIndexExample {
|
||||||
type Rendered = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(self, _cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, _cx: &mut WindowContext) -> Self::Output {
|
||||||
div()
|
div()
|
||||||
.relative()
|
.relative()
|
||||||
.size_full()
|
.size_full()
|
||||||
|
|
|
@ -113,9 +113,9 @@ impl StoryWrapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for StoryWrapper {
|
impl Render for StoryWrapper {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
div()
|
div()
|
||||||
.flex()
|
.flex()
|
||||||
.flex_col()
|
.flex_col()
|
||||||
|
|
|
@ -750,7 +750,7 @@ impl TerminalElement {
|
||||||
impl Element for TerminalElement {
|
impl Element for TerminalElement {
|
||||||
type State = InteractiveElementState;
|
type State = InteractiveElementState;
|
||||||
|
|
||||||
fn layout(
|
fn request_layout(
|
||||||
&mut self,
|
&mut self,
|
||||||
element_state: Option<Self::State>,
|
element_state: Option<Self::State>,
|
||||||
cx: &mut WindowContext<'_>,
|
cx: &mut WindowContext<'_>,
|
||||||
|
|
|
@ -329,9 +329,9 @@ impl TerminalPanel {
|
||||||
impl EventEmitter<PanelEvent> for TerminalPanel {}
|
impl EventEmitter<PanelEvent> for TerminalPanel {}
|
||||||
|
|
||||||
impl Render for TerminalPanel {
|
impl Render for TerminalPanel {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
div().size_full().child(self.pane.clone())
|
div().size_full().child(self.pane.clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -617,9 +617,9 @@ impl TerminalView {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for TerminalView {
|
impl Render for TerminalView {
|
||||||
type Element = Focusable<Div>;
|
type Output = Focusable<Div>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
let terminal_handle = self.terminal.clone();
|
let terminal_handle = self.terminal.clone();
|
||||||
|
|
||||||
let focused = self.focus_handle.is_focused(cx);
|
let focused = self.focus_handle.is_focused(cx);
|
||||||
|
|
|
@ -67,9 +67,9 @@ impl FocusableView for ThemeSelector {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for ThemeSelector {
|
impl Render for ThemeSelector {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
v_stack().w(rems(34.)).child(self.picker.clone())
|
v_stack().w(rems(34.)).child(self.picker.clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,9 @@ pub struct Avatar {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for Avatar {
|
impl RenderOnce for Avatar {
|
||||||
type Rendered = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(mut self, cx: &mut WindowContext) -> Self::Rendered {
|
fn render(mut self, cx: &mut WindowContext) -> Self::Output {
|
||||||
if self.image.style().corner_radii.top_left.is_none() {
|
if self.image.style().corner_radii.top_left.is_none() {
|
||||||
self = self.shape(Shape::Circle);
|
self = self.shape(Shape::Circle);
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,9 +136,9 @@ impl ButtonCommon for Button {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for Button {
|
impl RenderOnce for Button {
|
||||||
type Rendered = ButtonLike;
|
type Output = ButtonLike;
|
||||||
|
|
||||||
fn render(self, _cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, _cx: &mut WindowContext) -> Self::Output {
|
||||||
let is_disabled = self.base.disabled;
|
let is_disabled = self.base.disabled;
|
||||||
let is_selected = self.base.selected;
|
let is_selected = self.base.selected;
|
||||||
|
|
||||||
|
|
|
@ -63,9 +63,9 @@ impl Selectable for ButtonIcon {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for ButtonIcon {
|
impl RenderOnce for ButtonIcon {
|
||||||
type Rendered = IconElement;
|
type Output = IconElement;
|
||||||
|
|
||||||
fn render(self, _cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, _cx: &mut WindowContext) -> Self::Output {
|
||||||
let icon = self
|
let icon = self
|
||||||
.selected_icon
|
.selected_icon
|
||||||
.filter(|_| self.selected)
|
.filter(|_| self.selected)
|
||||||
|
|
|
@ -363,9 +363,9 @@ impl ParentElement for ButtonLike {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for ButtonLike {
|
impl RenderOnce for ButtonLike {
|
||||||
type Rendered = Stateful<Div>;
|
type Output = Stateful<Div>;
|
||||||
|
|
||||||
fn render(self, cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, cx: &mut WindowContext) -> Self::Output {
|
||||||
self.base
|
self.base
|
||||||
.h_flex()
|
.h_flex()
|
||||||
.id(self.id.clone())
|
.id(self.id.clone())
|
||||||
|
|
|
@ -106,9 +106,9 @@ impl VisibleOnHover for IconButton {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for IconButton {
|
impl RenderOnce for IconButton {
|
||||||
type Rendered = ButtonLike;
|
type Output = ButtonLike;
|
||||||
|
|
||||||
fn render(self, _cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, _cx: &mut WindowContext) -> Self::Output {
|
||||||
let is_disabled = self.base.disabled;
|
let is_disabled = self.base.disabled;
|
||||||
let is_selected = self.base.selected;
|
let is_selected = self.base.selected;
|
||||||
|
|
||||||
|
|
|
@ -99,9 +99,9 @@ impl ButtonCommon for ToggleButton {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for ToggleButton {
|
impl RenderOnce for ToggleButton {
|
||||||
type Rendered = ButtonLike;
|
type Output = ButtonLike;
|
||||||
|
|
||||||
fn render(self, _cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, _cx: &mut WindowContext) -> Self::Output {
|
||||||
let is_disabled = self.base.disabled;
|
let is_disabled = self.base.disabled;
|
||||||
let is_selected = self.base.selected;
|
let is_selected = self.base.selected;
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,9 @@ pub struct Checkbox {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for Checkbox {
|
impl RenderOnce for Checkbox {
|
||||||
type Rendered = gpui::Stateful<Div>;
|
type Output = gpui::Stateful<Div>;
|
||||||
|
|
||||||
fn render(self, cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, cx: &mut WindowContext) -> Self::Output {
|
||||||
let group_id = format!("checkbox_group_{:?}", self.id);
|
let group_id = format!("checkbox_group_{:?}", self.id);
|
||||||
|
|
||||||
let icon = match self.checked {
|
let icon = match self.checked {
|
||||||
|
|
|
@ -232,9 +232,9 @@ impl ContextMenuItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for ContextMenu {
|
impl Render for ContextMenu {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
div().elevation_2(cx).flex().flex_row().child(
|
div().elevation_2(cx).flex().flex_row().child(
|
||||||
v_stack()
|
v_stack()
|
||||||
.min_w(px(200.))
|
.min_w(px(200.))
|
||||||
|
|
|
@ -28,9 +28,9 @@ impl Disclosure {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for Disclosure {
|
impl RenderOnce for Disclosure {
|
||||||
type Rendered = IconButton;
|
type Output = IconButton;
|
||||||
|
|
||||||
fn render(self, _cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, _cx: &mut WindowContext) -> Self::Output {
|
||||||
IconButton::new(
|
IconButton::new(
|
||||||
self.id,
|
self.id,
|
||||||
match self.is_open {
|
match self.is_open {
|
||||||
|
|
|
@ -31,9 +31,9 @@ pub struct Divider {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for Divider {
|
impl RenderOnce for Divider {
|
||||||
type Rendered = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(self, cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, cx: &mut WindowContext) -> Self::Output {
|
||||||
div()
|
div()
|
||||||
.map(|this| match self.direction {
|
.map(|this| match self.direction {
|
||||||
DividerDirection::Horizontal => {
|
DividerDirection::Horizontal => {
|
||||||
|
|
|
@ -196,9 +196,9 @@ pub struct IconElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for IconElement {
|
impl RenderOnce for IconElement {
|
||||||
type Rendered = Svg;
|
type Output = Svg;
|
||||||
|
|
||||||
fn render(self, cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, cx: &mut WindowContext) -> Self::Output {
|
||||||
svg()
|
svg()
|
||||||
.size(self.size.rems())
|
.size(self.size.rems())
|
||||||
.flex_none()
|
.flex_none()
|
||||||
|
|
|
@ -45,9 +45,9 @@ impl Indicator {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for Indicator {
|
impl RenderOnce for Indicator {
|
||||||
type Rendered = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(self, cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, cx: &mut WindowContext) -> Self::Output {
|
||||||
div()
|
div()
|
||||||
.flex_none()
|
.flex_none()
|
||||||
.map(|this| match self.style {
|
.map(|this| match self.style {
|
||||||
|
|
|
@ -11,9 +11,9 @@ pub struct KeyBinding {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for KeyBinding {
|
impl RenderOnce for KeyBinding {
|
||||||
type Rendered = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(self, cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, cx: &mut WindowContext) -> Self::Output {
|
||||||
h_stack()
|
h_stack()
|
||||||
.flex_none()
|
.flex_none()
|
||||||
.gap_2()
|
.gap_2()
|
||||||
|
@ -91,9 +91,9 @@ pub struct Key {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for Key {
|
impl RenderOnce for Key {
|
||||||
type Rendered = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(self, cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, cx: &mut WindowContext) -> Self::Output {
|
||||||
let single_char = self.key.len() == 1;
|
let single_char = self.key.len() == 1;
|
||||||
|
|
||||||
div()
|
div()
|
||||||
|
@ -125,9 +125,9 @@ pub struct KeyIcon {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for KeyIcon {
|
impl RenderOnce for KeyIcon {
|
||||||
type Rendered = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(self, _cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, _cx: &mut WindowContext) -> Self::Output {
|
||||||
div()
|
div()
|
||||||
.w(rems(14. / 16.))
|
.w(rems(14. / 16.))
|
||||||
.child(IconElement::new(self.icon).size(IconSize::Small))
|
.child(IconElement::new(self.icon).size(IconSize::Small))
|
||||||
|
|
|
@ -46,9 +46,9 @@ impl LabelCommon for HighlightedLabel {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for HighlightedLabel {
|
impl RenderOnce for HighlightedLabel {
|
||||||
type Rendered = LabelLike;
|
type Output = LabelLike;
|
||||||
|
|
||||||
fn render(self, cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, cx: &mut WindowContext) -> Self::Output {
|
||||||
let highlight_color = cx.theme().colors().text_accent;
|
let highlight_color = cx.theme().colors().text_accent;
|
||||||
|
|
||||||
let mut highlight_indices = self.highlight_indices.iter().copied().peekable();
|
let mut highlight_indices = self.highlight_indices.iter().copied().peekable();
|
||||||
|
|
|
@ -40,9 +40,9 @@ impl LabelCommon for Label {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for Label {
|
impl RenderOnce for Label {
|
||||||
type Rendered = LabelLike;
|
type Output = LabelLike;
|
||||||
|
|
||||||
fn render(self, _cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, _cx: &mut WindowContext) -> Self::Output {
|
||||||
self.base.child(self.label)
|
self.base.child(self.label)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,9 +76,9 @@ impl ParentElement for LabelLike {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for LabelLike {
|
impl RenderOnce for LabelLike {
|
||||||
type Rendered = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(self, cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, cx: &mut WindowContext) -> Self::Output {
|
||||||
div()
|
div()
|
||||||
.when(self.strikethrough, |this| {
|
.when(self.strikethrough, |this| {
|
||||||
this.relative().child(
|
this.relative().child(
|
||||||
|
|
|
@ -46,9 +46,9 @@ impl ParentElement for List {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for List {
|
impl RenderOnce for List {
|
||||||
type Rendered = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(self, _cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, _cx: &mut WindowContext) -> Self::Output {
|
||||||
v_stack().w_full().py_1().children(self.header).map(|this| {
|
v_stack().w_full().py_1().children(self.header).map(|this| {
|
||||||
match (self.children.is_empty(), self.toggle) {
|
match (self.children.is_empty(), self.toggle) {
|
||||||
(false, _) => this.children(self.children),
|
(false, _) => this.children(self.children),
|
||||||
|
|
|
@ -76,9 +76,9 @@ impl Selectable for ListHeader {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for ListHeader {
|
impl RenderOnce for ListHeader {
|
||||||
type Rendered = Stateful<Div>;
|
type Output = Stateful<Div>;
|
||||||
|
|
||||||
fn render(self, cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, cx: &mut WindowContext) -> Self::Output {
|
||||||
h_stack()
|
h_stack()
|
||||||
.id(self.label.clone())
|
.id(self.label.clone())
|
||||||
.w_full()
|
.w_full()
|
||||||
|
|
|
@ -147,9 +147,9 @@ impl ParentElement for ListItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for ListItem {
|
impl RenderOnce for ListItem {
|
||||||
type Rendered = Stateful<Div>;
|
type Output = Stateful<Div>;
|
||||||
|
|
||||||
fn render(self, cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, cx: &mut WindowContext) -> Self::Output {
|
||||||
h_stack()
|
h_stack()
|
||||||
.id(self.id)
|
.id(self.id)
|
||||||
.w_full()
|
.w_full()
|
||||||
|
|
|
@ -6,9 +6,9 @@ use crate::prelude::*;
|
||||||
pub struct ListSeparator;
|
pub struct ListSeparator;
|
||||||
|
|
||||||
impl RenderOnce for ListSeparator {
|
impl RenderOnce for ListSeparator {
|
||||||
type Rendered = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(self, cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, cx: &mut WindowContext) -> Self::Output {
|
||||||
div()
|
div()
|
||||||
.h_px()
|
.h_px()
|
||||||
.w_full()
|
.w_full()
|
||||||
|
|
|
@ -26,9 +26,9 @@ impl ListSubHeader {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for ListSubHeader {
|
impl RenderOnce for ListSubHeader {
|
||||||
type Rendered = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(self, _cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, _cx: &mut WindowContext) -> Self::Output {
|
||||||
h_stack().flex_1().w_full().relative().py_1().child(
|
h_stack().flex_1().w_full().relative().py_1().child(
|
||||||
div()
|
div()
|
||||||
.h_6()
|
.h_6()
|
||||||
|
|
|
@ -41,9 +41,9 @@ pub struct Popover {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for Popover {
|
impl RenderOnce for Popover {
|
||||||
type Rendered = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(self, cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, cx: &mut WindowContext) -> Self::Output {
|
||||||
div()
|
div()
|
||||||
.flex()
|
.flex()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
|
|
|
@ -130,7 +130,7 @@ pub struct PopoverMenuState<M> {
|
||||||
impl<M: ManagedView> Element for PopoverMenu<M> {
|
impl<M: ManagedView> Element for PopoverMenu<M> {
|
||||||
type State = PopoverMenuState<M>;
|
type State = PopoverMenuState<M>;
|
||||||
|
|
||||||
fn layout(
|
fn request_layout(
|
||||||
&mut self,
|
&mut self,
|
||||||
element_state: Option<Self::State>,
|
element_state: Option<Self::State>,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
|
|
|
@ -60,7 +60,7 @@ pub struct MenuHandleState<M> {
|
||||||
impl<M: ManagedView> Element for RightClickMenu<M> {
|
impl<M: ManagedView> Element for RightClickMenu<M> {
|
||||||
type State = MenuHandleState<M>;
|
type State = MenuHandleState<M>;
|
||||||
|
|
||||||
fn layout(
|
fn request_layout(
|
||||||
&mut self,
|
&mut self,
|
||||||
element_state: Option<Self::State>,
|
element_state: Option<Self::State>,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
|
|
|
@ -7,9 +7,9 @@ use crate::Avatar;
|
||||||
pub struct AvatarStory;
|
pub struct AvatarStory;
|
||||||
|
|
||||||
impl Render for AvatarStory {
|
impl Render for AvatarStory {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
Story::container()
|
Story::container()
|
||||||
.child(Story::title_for::<Avatar>())
|
.child(Story::title_for::<Avatar>())
|
||||||
.child(Story::label("Default"))
|
.child(Story::label("Default"))
|
||||||
|
|
|
@ -7,9 +7,9 @@ use crate::{Button, ButtonStyle};
|
||||||
pub struct ButtonStory;
|
pub struct ButtonStory;
|
||||||
|
|
||||||
impl Render for ButtonStory {
|
impl Render for ButtonStory {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
Story::container()
|
Story::container()
|
||||||
.child(Story::title_for::<Button>())
|
.child(Story::title_for::<Button>())
|
||||||
.child(Story::label("Default"))
|
.child(Story::label("Default"))
|
||||||
|
|
|
@ -7,9 +7,9 @@ use crate::{h_stack, Checkbox};
|
||||||
pub struct CheckboxStory;
|
pub struct CheckboxStory;
|
||||||
|
|
||||||
impl Render for CheckboxStory {
|
impl Render for CheckboxStory {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
Story::container()
|
Story::container()
|
||||||
.child(Story::title_for::<Checkbox>())
|
.child(Story::title_for::<Checkbox>())
|
||||||
.child(Story::label("Default"))
|
.child(Story::label("Default"))
|
||||||
|
|
|
@ -20,9 +20,9 @@ fn build_menu(cx: &mut WindowContext, header: impl Into<SharedString>) -> View<C
|
||||||
pub struct ContextMenuStory;
|
pub struct ContextMenuStory;
|
||||||
|
|
||||||
impl Render for ContextMenuStory {
|
impl Render for ContextMenuStory {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
Story::container()
|
Story::container()
|
||||||
.on_action(|_: &PrintCurrentDate, _| {
|
.on_action(|_: &PrintCurrentDate, _| {
|
||||||
println!("printing unix time!");
|
println!("printing unix time!");
|
||||||
|
|
|
@ -7,9 +7,9 @@ use crate::Disclosure;
|
||||||
pub struct DisclosureStory;
|
pub struct DisclosureStory;
|
||||||
|
|
||||||
impl Render for DisclosureStory {
|
impl Render for DisclosureStory {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
Story::container()
|
Story::container()
|
||||||
.child(Story::title_for::<Disclosure>())
|
.child(Story::title_for::<Disclosure>())
|
||||||
.child(Story::label("Toggled"))
|
.child(Story::label("Toggled"))
|
||||||
|
|
|
@ -8,9 +8,9 @@ use crate::{Icon, IconElement};
|
||||||
pub struct IconStory;
|
pub struct IconStory;
|
||||||
|
|
||||||
impl Render for IconStory {
|
impl Render for IconStory {
|
||||||
type Element = Div;
|
type Output = Div;
|
||||||
|
|
||||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
let icons = Icon::iter();
|
let icons = Icon::iter();
|
||||||
|
|
||||||
Story::container()
|
Story::container()
|
||||||
|
|
|
@ -7,9 +7,9 @@ use crate::{Icon, IconButton};
|
||||||
pub struct IconButtonStory;
|
pub struct IconButtonStory;
|
||||||
|
|
||||||
impl Render for IconButtonStory {
|
impl Render for IconButtonStory {
|
||||||
type Element = Component<StoryContainer>;
|
type Output = Component<StoryContainer>;
|
||||||
|
|
||||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
|
||||||
let default_button = StoryItem::new(
|
let default_button = StoryItem::new(
|
||||||
"Default",
|
"Default",
|
||||||
IconButton::new("default_icon_button", Icon::Hash),
|
IconButton::new("default_icon_button", Icon::Hash),
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue