Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions crates/app/src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ fn copy_table_export(ctx: &egui::Context, payload: plotx_core::data_export::Clip
}

fn render_status(app: &PlotxApp, ui: &mut Ui, dark: bool) {
if !app.settings.appearance.show_status_bar {
return;
}
egui::Panel::bottom("status")
.frame(
card_frame(
Expand Down Expand Up @@ -620,6 +623,37 @@ fn flush_frame(dark: bool, inner_margin: egui::Margin) -> egui::Frame {
#[path = "sidebar_tests.rs"]
mod sidebar_tests;

#[cfg(test)]
mod status_bar_tests {
use super::*;
use egui::{Pos2, RawInput, Rect, vec2};

fn remaining_height(app: &PlotxApp) -> f32 {
let ctx = crate::typography::test_context();
let input = RawInput {
screen_rect: Some(Rect::from_min_size(Pos2::ZERO, vec2(800.0, 600.0))),
..Default::default()
};
let mut height = 0.0;
let _ = ctx.run_ui(input, |ui| {
render_status(app, ui, false);
height = ui.available_height();
});
height
}

#[test]
fn status_bar_only_reserves_workspace_when_enabled() {
let mut app = PlotxApp::new_with_settings(plotx_core::settings::Settings::default());
let hidden_height = remaining_height(&app);

app.settings.appearance.show_status_bar = true;
let shown_height = remaining_height(&app);

assert!(shown_height < hidden_height);
}
}

#[cfg(test)]
mod feedback_tests {
use super::*;
Expand Down
6 changes: 6 additions & 0 deletions crates/app/src/ui/properties/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,12 @@ pub const PRESENTATIONS: &[PropertyPresentation] = &[
&[LocalizedText("appearance theme")],
APPEARANCE_PREFERENCES_HOME,
),
preference_entry(
app_preferences::SHOW_STATUS_BAR,
"Show status bar",
&[LocalizedText("bottom status")],
APPEARANCE_PREFERENCES_HOME,
),
preference_entry(
app_preferences::GRAPHICS_POWER,
"Graphics processor",
Expand Down
4 changes: 2 additions & 2 deletions crates/app/src/ui/properties/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ fn migrated_preferences_keep_their_real_section_density() {
),
(
SettingsCategory::Appearance.section_id(),
3,
"theme, GPU, and the accent override row",
4,
"theme, status bar, GPU, and the accent override row",
),
(
SettingsCategory::Processing.section_id(),
Expand Down
12 changes: 12 additions & 0 deletions crates/core/src/properties/app_preferences.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub const KEEP_EMPTY_SOURCE_CANVAS: PropertyId =
pub const PROJECT_BACKUP_GENERATIONS: PropertyId =
PropertyId("settings.general.project_backup_generations");
pub const THEME: PropertyId = PropertyId("settings.appearance.theme");
pub const SHOW_STATUS_BAR: PropertyId = PropertyId("settings.appearance.show_status_bar");
pub const GRAPHICS_POWER: PropertyId = PropertyId("settings.appearance.graphics_power");
pub const ACCENT_COLOR: PropertyId = PropertyId("settings.appearance.accent.color");
pub const INCLUDE_VIEW_SNAPSHOTS: PropertyId = PropertyId("settings.export.include_view_snapshots");
Expand Down Expand Up @@ -145,6 +146,13 @@ pub(crate) const DEFINITIONS: &[PropertyDefinition] = &[
"Chrome theme",
&["appearance theme", "light mode", "dark mode"],
),
app_definition(
SHOW_STATUS_BAR,
ValueSchema::Bool,
DefaultPolicy::Fixed(PropertyValue::Bool(false)),
"Show status bar",
&["status bar", "bottom status"],
),
app_definition(
GRAPHICS_POWER,
ValueSchema::Enum {
Expand Down Expand Up @@ -316,6 +324,7 @@ fn value_of(app: &PlotxApp, id: PropertyId) -> Result<PropertyValue, PropertyErr
PropertyValue::Int(i64::from(settings.general.project_backup_generations))
}
THEME => PropertyValue::Enum(theme_key(settings.appearance.theme)),
SHOW_STATUS_BAR => PropertyValue::Bool(settings.appearance.show_status_bar),
GRAPHICS_POWER => PropertyValue::Enum(graphics_key(settings.appearance.graphics_power)),
ACCENT_COLOR => {
let [r, g, b] = settings.appearance.canvas_accent.unwrap_or([
Expand Down Expand Up @@ -390,6 +399,9 @@ fn write_value(
(THEME, PropertyValue::Enum(value)) => {
settings.appearance.theme = theme(value).expect("validated theme")
}
(SHOW_STATUS_BAR, PropertyValue::Bool(value)) => {
settings.appearance.show_status_bar = value
}
(GRAPHICS_POWER, PropertyValue::Enum(value)) => {
settings.appearance.graphics_power = graphics(value).expect("validated graphics power")
}
Expand Down
8 changes: 7 additions & 1 deletion crates/core/src/properties/app_preferences_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,14 @@ fn backup_bound_rejects_the_value_and_names_the_actual_limit() {
}

#[test]
fn all_twelve_app_preferences_reset_through_their_catalog_definitions() {
fn all_thirteen_app_preferences_reset_through_their_catalog_definitions() {
let mut settings = Settings::default();
settings.general.snap_enabled = false;
settings.general.equal_scale_homonuclear_2d_imports = false;
settings.general.keep_empty_source_canvas = true;
settings.general.project_backup_generations = MAX_PROJECT_BACKUP_GENERATIONS;
settings.appearance.theme = ThemeMode::Dark;
settings.appearance.show_status_bar = true;
settings.appearance.graphics_power = GraphicsPowerPreference::HighPerformance;
settings.appearance.canvas_accent = Some([12, 34, 56]);
settings.export.include_view_snapshots = true;
Expand All @@ -148,6 +149,7 @@ fn all_twelve_app_preferences_reset_through_their_catalog_definitions() {
KEEP_EMPTY_SOURCE_CANVAS,
PROJECT_BACKUP_GENERATIONS,
THEME,
SHOW_STATUS_BAR,
GRAPHICS_POWER,
ACCENT_COLOR,
INCLUDE_VIEW_SNAPSHOTS,
Expand All @@ -170,6 +172,10 @@ fn all_twelve_app_preferences_reset_through_their_catalog_definitions() {
let defaults = Settings::default();
assert_eq!(app.settings.general, defaults.general);
assert_eq!(app.settings.appearance.theme, defaults.appearance.theme);
assert_eq!(
app.settings.appearance.show_status_bar,
defaults.appearance.show_status_bar
);
assert_eq!(
app.settings.appearance.graphics_power,
defaults.appearance.graphics_power
Expand Down
2 changes: 2 additions & 0 deletions crates/core/src/settings/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ pub struct AppearanceSettings {
#[serde(default)]
pub theme: ThemeMode,
#[serde(default)]
pub show_status_bar: bool,
#[serde(default)]
pub ui_scale: UiScaleSettings,
#[serde(default)]
pub graphics_power: GraphicsPowerPreference,
Expand Down
3 changes: 3 additions & 0 deletions crates/core/src/settings/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ fn missing_fields_take_defaults() {
settings.appearance.graphics_power,
GraphicsPowerPreference::LowPower
);
assert!(!settings.appearance.show_status_bar);
assert_eq!(settings.window.task_cards.craft.width, 520.0);
assert_eq!(settings.window.task_cards.processing.width, 340.0);
}
Expand Down Expand Up @@ -103,6 +104,7 @@ fn save_and_load_roundtrip() {
settings.general.project_backup_generations = 3;
settings.export.include_view_snapshots = true;
settings.export.trim_to_visible_content = true;
settings.appearance.show_status_bar = true;
settings.window.task_cards.craft = TaskCardSize::new(612.0, 688.0);

io::save_to_path(&path, &settings).unwrap();
Expand All @@ -114,6 +116,7 @@ fn save_and_load_roundtrip() {
assert_eq!(loaded.general.project_backup_generations, 3);
assert!(loaded.export.include_view_snapshots);
assert!(loaded.export.trim_to_visible_content);
assert!(loaded.appearance.show_status_bar);
assert_eq!(
loaded.window.task_cards.craft,
TaskCardSize::new(612.0, 688.0)
Expand Down
3 changes: 2 additions & 1 deletion docs/src/content/docs/reference/ui-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ introduces the same regions in walkthrough form.
shortcut surface: everything on it is also in the menus or command palette.
See [the Ribbon](/reference/ribbon/) for every tab's groups.
- **Status bar** — the bottom strip, showing hints, progress, and selection
details.
details. It is hidden by default to leave more room for the workspace; enable
**Show status bar** under **Preferences → Appearance** when you want it.

Both Side Bars can be shown or hidden at any time: click the pair of layout
buttons at the right end of the Ribbon's task row, press
Expand Down
4 changes: 3 additions & 1 deletion docs/src/content/docs/zh-cn/reference/ui-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ PlotX 的界面为英文;手册中加粗的英文词即界面上的原文标
**Analyze**、**Figure**、**Arrange**、**View**)。在 macOS 上,其任务行
还承载原生窗口按钮和项目名。它是快捷入口:其上的一切也都能在菜单或命令面板中找到。
各页签的分组详见 [Ribbon](/zh-cn/reference/ribbon/)。
- **状态栏**——底部条带,显示提示、进度和选择详情。
- **状态栏**——底部条带,显示提示、进度和选择详情。默认隐藏,以便为工作区
留出更多空间;需要时可在 **Preferences → Appearance** 中开启
**Show status bar**。

两个侧栏随时可以显示或隐藏:点击 Ribbon 任务行右端的一对布局按钮,按
<kbd>Ctrl</kbd>+<kbd>B</kbd>(左)或 <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>B</kbd>
Expand Down
Loading