Skip to content

Commit

Permalink
Combine appearance and preferences window
Browse files Browse the repository at this point in the history
  • Loading branch information
melody-rs committed Nov 24, 2023
1 parent 23ee401 commit 6a0a0d8
Showing 5 changed files with 62 additions and 116 deletions.
5 changes: 2 additions & 3 deletions crates/ui/src/lib.rs
Original file line number Diff line number Diff line change
@@ -172,12 +172,11 @@ tab_enum! {
window_enum! {
pub enum Window {
About(windows::about::Window),
Appearance(windows::appearance::Window),
CommonEvent(windows::common_event_edit::Window),
ProjectConfig(windows::config_window::Window),
Console(windows::console::Window),
EventEdit(windows::event_edit::Window),
GlobalConfig(windows::global_config_window::Window),
Preferences(windows::preferences::Window),
Items(windows::items::Window),
MapPicker(windows::map_picker::Window),
EguiInspection(windows::misc::EguiInspection),
@@ -196,7 +195,7 @@ window_enum! {
CommonEvent(windows::common_event_edit::Window),
ProjectConfig(windows::config_window::Window),
EventEdit(windows::event_edit::Window),
GlobalConfig(windows::global_config_window::Window),
GlobalConfig(windows::preferences::Window),
Items(windows::items::Window),
MapPicker(windows::map_picker::Window),
EguiInspection(windows::misc::EguiInspection),
103 changes: 0 additions & 103 deletions crates/ui/src/windows/appearance.rs

This file was deleted.

3 changes: 1 addition & 2 deletions crates/ui/src/windows/mod.rs
Original file line number Diff line number Diff line change
@@ -24,7 +24,6 @@

/// The about window.
pub mod about;
pub mod appearance;
/// The common event editor.
pub mod common_event_edit;
/// Config window
@@ -34,7 +33,6 @@ pub mod config_window;
pub mod console;
/// The event editor.
pub mod event_edit;
pub mod global_config_window;
/// The item editor.
pub mod items;
/// The map picker.
@@ -43,6 +41,7 @@ pub mod map_picker;
pub mod misc;
/// New project window
pub mod new_project;
pub mod preferences;
/// The script editor
pub mod script_edit;
/// The sound test.
Original file line number Diff line number Diff line change
@@ -21,15 +21,32 @@
// it with Steamworks API by Valve Corporation, containing parts covered by
// terms of the Steamworks API by Valve Corporation, the licensors of this
// Program grant you additional permission to convey the resulting work.

use std::ops::Not;
use strum::IntoEnumIterator;

#[derive(Default)]
pub struct Window {
edit_rtp_path_name: String,
edit_rtp_path_path: String,

appearance_mode: AppearanceMode,
}

#[derive(Clone, Copy)]
#[derive(Default, PartialEq, Eq)]
#[derive(strum::EnumIter, strum::Display)]
enum AppearanceMode {
#[default]
#[strum(to_string = "Egui Style")]
EguiStyle,
#[strum(to_string = "Style Presets")]
StylePresets,
#[strum(to_string = "Code Theme")]
CodeTheme,
}

const CODE_SAMPLE: &str = include_str!("../../assets/code_sample.rb");

impl luminol_core::Window for Window {
fn name(&self) -> String {
"Luminol Preferences".to_string()
@@ -85,6 +102,46 @@ impl luminol_core::Window for Window {

update_state.global_config.rtp_paths = new_rtp_paths;
});

ui.separator();

ui.horizontal(|ui| {
for mode in AppearanceMode::iter() {
ui.selectable_value(&mut self.appearance_mode, mode, mode.to_string());
ui.separator();
}
});
ui.separator();

match self.appearance_mode {
AppearanceMode::EguiStyle => {
ctx.style_ui(ui);
}
AppearanceMode::StylePresets => {}
AppearanceMode::CodeTheme => {
ui.horizontal(|ui| {
ui.vertical(|ui| {
for t in luminol_config::SyntectTheme::iter() {
ui.radio_value(
&mut update_state.global_config.theme.syntect_theme,
t,
t.to_string(),
);
}
});

ui.vertical(|ui| {
ui.label("Code sample");
ui.label(luminol_components::syntax_highlighting::highlight(
ui.ctx(),
update_state.global_config.theme,
CODE_SAMPLE,
"rb",
));
});
});
}
}
});
}
}
8 changes: 1 addition & 7 deletions src/app/top_bar.rs
Original file line number Diff line number Diff line change
@@ -130,13 +130,7 @@ impl TopBar {
if ui.button("Preferences").clicked() {
update_state
.edit_windows
.add_window(luminol_ui::windows::global_config_window::Window::default())
}

if ui.button("Appearance").clicked() {
update_state
.edit_windows
.add_window(luminol_ui::windows::appearance::Window::default())
.add_window(luminol_ui::windows::preferences::Window::default())
}
});

0 comments on commit 6a0a0d8

Please sign in to comment.