first pass of merging in warp (doesn't build)
This commit is contained in:
@@ -1,57 +1,55 @@
|
||||
use crate::ui_components::blended_colors;
|
||||
use core::fmt::{self, Display};
|
||||
use itertools::Itertools as _;
|
||||
use pathfinder_color::ColorU;
|
||||
use std::borrow::Cow;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use super::{
|
||||
about_page::AboutPageView,
|
||||
ai_page::{AISettingsPageAction, AISettingsPageView},
|
||||
appearance_page::AppearanceSettingsPageView,
|
||||
billing_and_usage_page::BillingAndUsagePageView,
|
||||
code_page::CodeSettingsPageView,
|
||||
environments_page::EnvironmentsPageView,
|
||||
features_page::FeaturesPageView,
|
||||
keybindings::KeybindingsView,
|
||||
main_page::MainSettingsPageView,
|
||||
mcp_servers_page::MCPServersSettingsPageView,
|
||||
privacy_page::PrivacyPageView,
|
||||
show_blocks_view::ShowBlocksView,
|
||||
warp_drive_page::WarpDriveSettingsPageView,
|
||||
warpify_page::WarpifyPageView,
|
||||
SettingsSection,
|
||||
};
|
||||
use crate::{
|
||||
appearance::Appearance,
|
||||
settings::CloudPreferencesSettings,
|
||||
themes::theme::Fill,
|
||||
ui_components::icons::Icon,
|
||||
view_components::{Dropdown, SubmittableTextInput},
|
||||
};
|
||||
use galaxy_core::{
|
||||
settings::SyncToCloud,
|
||||
ui::{color::blend::Blend, theme::color::internal_colors},
|
||||
};
|
||||
use galaxyui::{
|
||||
elements::{
|
||||
new_scrollable::{ClippedAxisConfiguration, DualAxisConfig, SingleAxisConfig},
|
||||
Align, Border, ChildView, ClippedScrollStateHandle, ConstrainedBox, Container,
|
||||
CornerRadius, CrossAxisAlignment, Element, Empty, Expanded, Flex, Hoverable,
|
||||
MainAxisAlignment, MainAxisSize, MouseStateHandle, NewScrollable, ParentElement, Radius,
|
||||
SavePosition, ScrollTarget, ScrollToPositionMode, Shrinkable, SizeConstraintCondition,
|
||||
SizeConstraintSwitch, Text,
|
||||
},
|
||||
fonts::{Properties, Weight},
|
||||
platform::Cursor,
|
||||
ui_components::{
|
||||
button::{Button, ButtonVariant},
|
||||
components::{Coords, UiComponent, UiComponentStyles},
|
||||
},
|
||||
units::Pixels,
|
||||
Action, AppContext, SingletonEntity, ViewContext, ViewHandle,
|
||||
};
|
||||
use itertools::Itertools as _;
|
||||
use pathfinder_color::ColorU;
|
||||
use pathfinder_geometry::vector::vec2f;
|
||||
use settings::Setting;
|
||||
use galaxy_core::settings::SyncToCloud;
|
||||
use galaxy_core::ui::color::blend::Blend;
|
||||
use galaxy_core::ui::theme::color::internal_colors;
|
||||
use galaxyui::elements::new_scrollable::{
|
||||
ClippedAxisConfiguration, DualAxisConfig, SingleAxisConfig,
|
||||
};
|
||||
use galaxyui::elements::{
|
||||
Align, Border, ChildAnchor, ChildView, ClippedScrollStateHandle, ConstrainedBox, Container,
|
||||
CornerRadius, CrossAxisAlignment, Element, Empty, Expanded, Flex, Hoverable, MainAxisAlignment,
|
||||
MainAxisSize, MouseStateHandle, NewScrollable, OffsetPositioning, ParentAnchor, ParentElement,
|
||||
ParentOffsetBounds, Radius, SavePosition, ScrollTarget, ScrollToPositionMode, Shrinkable,
|
||||
SizeConstraintCondition, SizeConstraintSwitch, Stack, Text,
|
||||
};
|
||||
use galaxyui::fonts::{Properties, Weight};
|
||||
use galaxyui::platform::Cursor;
|
||||
use galaxyui::ui_components::button::{Button, ButtonVariant};
|
||||
use galaxyui::ui_components::components::{Coords, UiComponent, UiComponentStyles};
|
||||
use galaxyui::units::Pixels;
|
||||
use galaxyui::{Action, AppContext, SingletonEntity, ViewContext, ViewHandle};
|
||||
|
||||
use super::about_page::AboutPageView;
|
||||
use super::ai_page::{AISettingsPageAction, AISettingsPageView};
|
||||
use super::appearance_page::AppearanceSettingsPageView;
|
||||
use super::billing_and_usage_dispatch::BillingAndUsageDispatchView;
|
||||
use super::code_page::CodeSettingsPageView;
|
||||
use super::environments_page::EnvironmentsPageView;
|
||||
use super::features_page::FeaturesPageView;
|
||||
use super::keybindings::KeybindingsView;
|
||||
use super::main_page::MainSettingsPageView;
|
||||
use super::mcp_servers_page::MCPServersSettingsPageView;
|
||||
use super::privacy_page::PrivacyPageView;
|
||||
use super::referrals_page::ReferralsPageView;
|
||||
use super::scripting_page::ScriptingSettingsPageView;
|
||||
use super::show_blocks_view::ShowBlocksView;
|
||||
use super::teams_page::TeamsPageView;
|
||||
use super::warp_drive_page::WarpDriveSettingsPageView;
|
||||
use super::warpify_page::WarpifyPageView;
|
||||
use super::SettingsSection;
|
||||
use crate::appearance::Appearance;
|
||||
use crate::settings::CloudPreferencesSettings;
|
||||
use crate::themes::theme::Fill;
|
||||
use crate::ui_components::blended_colors;
|
||||
use crate::ui_components::icons::Icon;
|
||||
use crate::view_components::{Dropdown, DropdownItemAction, SubmittableTextInput};
|
||||
|
||||
pub const TOGGLE_BUTTON_RIGHT_PADDING: f32 = 5.;
|
||||
pub const HEADER_PADDING: f32 = 15.;
|
||||
@@ -66,6 +64,7 @@ const ALTERNATING_LIST_ITEM_PADDING: f32 = 8.0;
|
||||
const GREY_TEXT_OPACITY: u8 = 60;
|
||||
const MIN_PAGE_WIDTH: f32 = 520.;
|
||||
const MAX_PAGE_WIDTH: f32 = 800.;
|
||||
const INFO_TOOLTIP_MAX_WIDTH: f32 = 320.;
|
||||
|
||||
/// Left margin for top-level sidebar nav items (pages and umbrella labels).
|
||||
pub(super) const NAV_ITEM_LEFT_MARGIN: f32 = 12.;
|
||||
@@ -109,8 +108,11 @@ pub enum SettingsPageViewHandle {
|
||||
Code(ViewHandle<CodeSettingsPageView>),
|
||||
Privacy(ViewHandle<PrivacyPageView>),
|
||||
Warpify(ViewHandle<WarpifyPageView>),
|
||||
Referrals(ViewHandle<ReferralsPageView>),
|
||||
Scripting(ViewHandle<ScriptingSettingsPageView>),
|
||||
AI(ViewHandle<AISettingsPageView>),
|
||||
BillingAndUsage(ViewHandle<BillingAndUsagePageView>),
|
||||
CloudEnvironments(ViewHandle<EnvironmentsPageView>),
|
||||
BillingAndUsage(ViewHandle<BillingAndUsageDispatchView>),
|
||||
MCPServers(ViewHandle<MCPServersSettingsPageView>),
|
||||
WarpDrive(ViewHandle<WarpDriveSettingsPageView>),
|
||||
CloudEnvironments(ViewHandle<EnvironmentsPageView>),
|
||||
@@ -131,6 +133,8 @@ impl SettingsPageViewHandle {
|
||||
Code(view_handle) => ChildView::new(view_handle).finish(),
|
||||
Privacy(view_handle) => ChildView::new(view_handle).finish(),
|
||||
Warpify(view_handle) => ChildView::new(view_handle).finish(),
|
||||
Referrals(view_handle) => ChildView::new(view_handle).finish(),
|
||||
Scripting(view_handle) => ChildView::new(view_handle).finish(),
|
||||
AI(view_handle) => ChildView::new(view_handle).finish(),
|
||||
BillingAndUsage(view_handle) => ChildView::new(view_handle).finish(),
|
||||
MCPServers(view_handle) => ChildView::new(view_handle).finish(),
|
||||
@@ -545,26 +549,54 @@ pub fn render_info_icon<T: Clone + Action>(
|
||||
appearance: &Appearance,
|
||||
additional_info: AdditionalInfo<T>,
|
||||
) -> Box<dyn Element> {
|
||||
let info_button = appearance
|
||||
.ui_builder()
|
||||
.info_button_with_tooltip(
|
||||
13.,
|
||||
additional_info
|
||||
.tooltip_override_text
|
||||
.unwrap_or("Click to learn more in docs".to_owned()),
|
||||
additional_info.mouse_state.clone(),
|
||||
let tooltip_text = additional_info
|
||||
.tooltip_override_text
|
||||
.unwrap_or("Click to learn more in docs".to_owned());
|
||||
let icon = Container::new(
|
||||
ConstrainedBox::new(
|
||||
Icon::Info
|
||||
.to_warpui_icon(appearance.theme().active_ui_text_color())
|
||||
.finish(),
|
||||
)
|
||||
.on_click(move |ctx, _, _| {
|
||||
if let Some(on_click_action) = &additional_info.on_click_action {
|
||||
ctx.dispatch_typed_action(on_click_action.clone());
|
||||
}
|
||||
})
|
||||
.finish();
|
||||
.with_width(13.)
|
||||
.with_height(13.)
|
||||
.finish(),
|
||||
)
|
||||
.finish();
|
||||
|
||||
Container::new(info_button)
|
||||
let mut info_button = Hoverable::new(additional_info.mouse_state.clone(), move |state| {
|
||||
let mut stack = Stack::new().with_child(icon);
|
||||
if state.is_hovered() {
|
||||
let tool_tip = ConstrainedBox::new(
|
||||
appearance
|
||||
.ui_builder()
|
||||
.tool_tip(tooltip_text)
|
||||
.build()
|
||||
.finish(),
|
||||
)
|
||||
.with_max_width(INFO_TOOLTIP_MAX_WIDTH)
|
||||
.finish();
|
||||
stack.add_positioned_child(
|
||||
tool_tip,
|
||||
OffsetPositioning::offset_from_parent(
|
||||
vec2f(0., -3.),
|
||||
ParentOffsetBounds::WindowByPosition,
|
||||
ParentAnchor::TopMiddle,
|
||||
ChildAnchor::BottomMiddle,
|
||||
),
|
||||
);
|
||||
}
|
||||
stack.finish()
|
||||
})
|
||||
.with_cursor(Cursor::PointingHand);
|
||||
|
||||
if let Some(on_click_action) = additional_info.on_click_action {
|
||||
info_button = info_button
|
||||
.on_click(move |ctx, _, _| ctx.dispatch_typed_action(on_click_action.clone()));
|
||||
}
|
||||
|
||||
Container::new(Box::new(info_button))
|
||||
.with_margin_left(4.)
|
||||
// Since the icon is smaller than the font, we need some margin to be in alignment.
|
||||
.with_margin_top(1.5)
|
||||
.finish()
|
||||
}
|
||||
|
||||
@@ -582,11 +614,7 @@ pub fn render_local_only_icon(
|
||||
)
|
||||
.finish();
|
||||
|
||||
Container::new(info_button)
|
||||
.with_margin_left(4.)
|
||||
// Since the icon is smaller than the font, we need some margin to be in alignment.
|
||||
.with_margin_top(1.5)
|
||||
.finish()
|
||||
Container::new(info_button).with_margin_left(4.).finish()
|
||||
}
|
||||
|
||||
pub fn render_body_item_label<T: Clone + Action>(
|
||||
@@ -890,7 +918,7 @@ pub fn render_dropdown_item_label(
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn render_dropdown_item<T: Clone + Action>(
|
||||
pub(crate) fn render_dropdown_item<T: DropdownItemAction>(
|
||||
appearance: &Appearance,
|
||||
label: &str,
|
||||
secondary_text: Option<&str>,
|
||||
@@ -996,12 +1024,17 @@ pub(crate) fn render_settings_info_banner(
|
||||
.finish()
|
||||
}
|
||||
|
||||
const WORKSPACE_OVERRIDE_TOOLTIP_TEXT: &str =
|
||||
"This option is enforced by your organization's settings and cannot be customized.";
|
||||
|
||||
pub struct InputListItem<SettingsPageAction: Action + Clone> {
|
||||
pub item: String,
|
||||
pub mouse_state_handle: MouseStateHandle,
|
||||
pub on_remove_action: SettingsPageAction,
|
||||
pub is_disabled: bool,
|
||||
/// Must be pre-created (not inline during render) to preserve mouse tracking.
|
||||
pub tooltip_mouse_state: Option<MouseStateHandle>,
|
||||
}
|
||||
|
||||
/// Renders a title, an input field to add new items and a list of already
|
||||
/// added items.
|
||||
///
|
||||
@@ -1010,7 +1043,6 @@ pub fn render_input_list<SettingsPageAction: Action + Clone>(
|
||||
title: Option<&str>,
|
||||
items: impl IntoIterator<Item = InputListItem<SettingsPageAction>>,
|
||||
handle: Option<&ViewHandle<SubmittableTextInput>>,
|
||||
disabled: bool,
|
||||
appearance: &Appearance,
|
||||
) -> Box<dyn Element> {
|
||||
let mut column = Flex::column();
|
||||
@@ -1036,15 +1068,21 @@ pub fn render_input_list<SettingsPageAction: Action + Clone>(
|
||||
let background = appearance.theme().surface_1();
|
||||
let peekable = items.into_iter().peekable();
|
||||
for item in peekable {
|
||||
let mut container = Container::new(render_alternating_color_list_item(
|
||||
let disabled = item.is_disabled;
|
||||
let row_element = render_alternating_color_list_item(
|
||||
background,
|
||||
item.item,
|
||||
item.mouse_state_handle,
|
||||
item.on_remove_action,
|
||||
disabled,
|
||||
appearance,
|
||||
));
|
||||
container = container.with_margin_bottom(4.);
|
||||
);
|
||||
let row_element = if let Some(tooltip_mouse_state) = item.tooltip_mouse_state {
|
||||
render_workspace_override_row_tooltip(row_element, tooltip_mouse_state, appearance)
|
||||
} else {
|
||||
row_element
|
||||
};
|
||||
let container = Container::new(row_element).with_margin_bottom(4.);
|
||||
column.add_child(container.finish());
|
||||
}
|
||||
|
||||
@@ -1086,6 +1124,34 @@ pub fn render_alternating_color_list<
|
||||
}
|
||||
}
|
||||
|
||||
fn render_workspace_override_row_tooltip(
|
||||
child: Box<dyn Element>,
|
||||
mouse_state: MouseStateHandle,
|
||||
appearance: &Appearance,
|
||||
) -> Box<dyn Element> {
|
||||
Hoverable::new(mouse_state, |state| {
|
||||
let mut stack = Stack::new().with_child(child);
|
||||
if state.is_hovered() {
|
||||
let tooltip = appearance
|
||||
.ui_builder()
|
||||
.tool_tip(WORKSPACE_OVERRIDE_TOOLTIP_TEXT.to_string())
|
||||
.build()
|
||||
.finish();
|
||||
stack.add_positioned_child(
|
||||
tooltip,
|
||||
OffsetPositioning::offset_from_parent(
|
||||
vec2f(0., -4.),
|
||||
ParentOffsetBounds::Unbounded,
|
||||
ParentAnchor::TopLeft,
|
||||
ChildAnchor::BottomLeft,
|
||||
),
|
||||
);
|
||||
}
|
||||
stack.finish()
|
||||
})
|
||||
.finish()
|
||||
}
|
||||
|
||||
fn render_alternating_color_list_item<SettingsPageAction: Action + Clone>(
|
||||
background: impl Into<Fill>,
|
||||
item_label: String,
|
||||
@@ -1102,10 +1168,12 @@ fn render_alternating_color_list_item<SettingsPageAction: Action + Clone>(
|
||||
remove_button = remove_button.disabled();
|
||||
}
|
||||
|
||||
let remove_button = remove_button
|
||||
.build()
|
||||
.on_click(move |ctx, _, _| ctx.dispatch_typed_action(action.clone()))
|
||||
.finish();
|
||||
let mut remove_button = remove_button.build();
|
||||
if !disabled {
|
||||
remove_button =
|
||||
remove_button.on_click(move |ctx, _, _| ctx.dispatch_typed_action(action.clone()));
|
||||
}
|
||||
let remove_button = remove_button.finish();
|
||||
|
||||
let background = background.into();
|
||||
let font_color = if disabled {
|
||||
@@ -1147,7 +1215,7 @@ fn render_alternating_color_list_item<SettingsPageAction: Action + Clone>(
|
||||
.with_uniform_padding(ALTERNATING_LIST_ITEM_PADDING)
|
||||
.with_corner_radius(CornerRadius::with_all(Radius::Pixels(4.)))
|
||||
// The bottom has a bit of extra padding b/c lines of text have more space above the text
|
||||
// than below. This visually balances that to make it lok vertically centered.
|
||||
// than below. This visually balances that to make it look vertically centered.
|
||||
.with_padding_bottom(ALTERNATING_LIST_ITEM_PADDING + 2.)
|
||||
.finish()
|
||||
}
|
||||
@@ -1535,7 +1603,7 @@ impl<V: galaxyui::View> PageType<V> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(not(target_os = "linux"), allow(dead_code))]
|
||||
#[cfg_attr(not(any(target_os = "linux", target_os = "freebsd")), allow(dead_code))]
|
||||
pub fn scroll_by(&self, delta: Pixels) {
|
||||
match self {
|
||||
PageType::Monolith {
|
||||
|
||||
Reference in New Issue
Block a user