Let the sidebar divider be dragged

This commit is contained in:
Georg Bauer
2026-07-26 00:12:04 +02:00
parent 9bd648d77b
commit b182e7007c
6 changed files with 82 additions and 5 deletions

View File

@@ -6,8 +6,8 @@ mod stats;
use model_manager::{download_status_bar, format_bytes, format_duration};
use super::{
ActiveDownload, App, DetailTab, Message, MetricsPoint, ModelDownload, ModelOperation,
chat_scroll_id, composer_id, models_path,
ActiveDownload, App, DetailTab, MAX_SIDEBAR_WIDTH, MIN_SIDEBAR_WIDTH, Message, MetricsPoint,
ModelDownload, ModelOperation, chat_scroll_id, composer_id, models_path,
};
use crate::database::{ProjectWithSessions, Session, SessionState};
use crate::model::{
@@ -17,7 +17,8 @@ use crate::settings::{GIB, REASONING_MODES};
use iced::theme::{Palette, palette};
use iced::widget::{
Button, Space, Svg, Tooltip, button, checkbox, column, container, horizontal_rule, markdown,
opaque, pick_list, progress_bar, row, scrollable, stack, svg, text, text_input, tooltip,
mouse_area, opaque, pick_list, progress_bar, row, scrollable, stack, svg, text, text_input,
tooltip,
};
use iced::{Alignment, Background, Border, Color, Element, Length, Padding, Theme, window};
use std::collections::VecDeque;
@@ -65,6 +66,17 @@ impl App {
let mut body = row![].width(Length::Fill).height(Length::Fill);
if !self.preferences.sidebar_collapsed {
body = body.push(self.sidebar());
body = body.push(
mouse_area(
container(Space::with_width(Length::Fill))
.width(5)
.height(Length::Fill)
.style(divider_style),
)
.interaction(iced::mouse::Interaction::ResizingHorizontally)
.on_press(Message::StartSidebarDrag)
.on_release(Message::EndSidebarDrag),
);
}
body = body.push(
container(self.detail())
@@ -259,7 +271,11 @@ impl App {
]
.spacing(10),
)
.width(276)
.width(
self.preferences
.sidebar_width
.clamp(MIN_SIDEBAR_WIDTH, MAX_SIDEBAR_WIDTH) as f32,
)
.height(Length::Fill)
.padding(Padding::new(16.0).top(16.0 + TITLE_BAR_HEIGHT))
.style(sidebar_style)
@@ -808,6 +824,10 @@ fn muted_text() -> Color {
Color::from_rgb8(174, 174, 178)
}
fn divider_style(_: &Theme) -> container::Style {
container::Style::default().background(Color::from_rgb8(38, 38, 40))
}
fn sidebar_style(_: &Theme) -> container::Style {
container::Style::default().background(Color::from_rgb8(23, 23, 25))
}