From 6198cc961af466c8c6410e5aaeb200b75e997e81 Mon Sep 17 00:00:00 2001 From: "Adrian O.V" <83074853+CodexAdrian@users.noreply.github.com> Date: Wed, 14 Jun 2023 20:16:16 -0400 Subject: [PATCH] Backlog fixes (#141) * Backlog fixes * Clear searching * slider units * Run lint * errant editing * Toggle selected * Update Mods.vue * update disablers * titlebar position --------- Co-authored-by: Jai A --- Cargo.lock | 2 + theseus_gui/package.json | 2 +- theseus_gui/pnpm-lock.yaml | 8 +- theseus_gui/src-tauri/Cargo.toml | 4 + theseus_gui/src-tauri/src/api/mod.rs | 1 + theseus_gui/src-tauri/src/api/window_ext.rs | 71 ++++++ theseus_gui/src-tauri/src/main.rs | 176 ++++++++------ theseus_gui/src/components/GridDisplay.vue | 3 + .../src/components/ui/RunningAppBar.vue | 169 +++++++++++-- theseus_gui/src/pages/Browse.vue | 4 + theseus_gui/src/pages/Settings.vue | 1 + theseus_gui/src/pages/instance/Mods.vue | 224 +++++++++++++++--- theseus_gui/src/pages/instance/Options.vue | 1 + 13 files changed, 542 insertions(+), 124 deletions(-) create mode 100644 theseus_gui/src-tauri/src/api/window_ext.rs diff --git a/Cargo.lock b/Cargo.lock index 5db151a6..ddc15d8f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4281,8 +4281,10 @@ name = "theseus_gui" version = "0.0.0" dependencies = [ "chrono", + "cocoa", "daedalus", "futures", + "objc", "os_info", "regex", "serde", diff --git a/theseus_gui/package.json b/theseus_gui/package.json index afa75149..9454c045 100644 --- a/theseus_gui/package.json +++ b/theseus_gui/package.json @@ -17,7 +17,7 @@ "dayjs": "^1.11.7", "floating-vue": "^2.0.0-beta.20", "ofetch": "^1.0.1", - "omorphia": "^0.4.24", + "omorphia": "^0.4.27", "pinia": "^2.1.3", "vite-svg-loader": "^4.0.0", "vue": "^3.3.4", diff --git a/theseus_gui/pnpm-lock.yaml b/theseus_gui/pnpm-lock.yaml index de5732e9..737267d7 100644 --- a/theseus_gui/pnpm-lock.yaml +++ b/theseus_gui/pnpm-lock.yaml @@ -14,8 +14,8 @@ dependencies: specifier: ^1.0.1 version: 1.0.1 omorphia: - specifier: ^0.4.24 - version: 0.4.24 + specifier: ^0.4.27 + version: 0.4.27 pinia: specifier: ^2.1.3 version: 2.1.3(vue@3.3.4) @@ -1326,8 +1326,8 @@ packages: ufo: 1.1.2 dev: false - /omorphia@0.4.24: - resolution: {integrity: sha512-tYhg88wkv9yfCNF8uVDkt6MIZ5WuCEezWrWJuBpHXP0X1yNGey6ICbH0LSuNuOMtqhGJEIupGEB7uV4Db9b7uQ==} + /omorphia@0.4.27: + resolution: {integrity: sha512-DvT8jTAE0RW9qAD2LAIkztVmhZkkITZ3ER587guK69KD2iErm+ZRSKCUJIOXFet94B9+d8+M3eM2pIiBnAkD9Q==} dependencies: dayjs: 1.11.7 floating-vue: 2.0.0-beta.20(vue@3.3.4) diff --git a/theseus_gui/src-tauri/Cargo.toml b/theseus_gui/src-tauri/Cargo.toml index 981ca985..33a5c11c 100644 --- a/theseus_gui/src-tauri/Cargo.toml +++ b/theseus_gui/src-tauri/Cargo.toml @@ -37,6 +37,10 @@ tracing = "0.1.37" tracing-subscriber = "0.2" tracing-error = "0.1" +[target.'cfg(target_os = "macos")'.dependencies] +cocoa = "0.24.1" +objc = "0.2.7" + [features] # by default Tauri runs in production mode # when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL diff --git a/theseus_gui/src-tauri/src/api/mod.rs b/theseus_gui/src-tauri/src/api/mod.rs index 19468db3..2594d9b5 100644 --- a/theseus_gui/src-tauri/src/api/mod.rs +++ b/theseus_gui/src-tauri/src/api/mod.rs @@ -13,6 +13,7 @@ pub mod profile_create; pub mod settings; pub mod tags; pub mod utils; +pub mod window_ext; pub type Result = std::result::Result; diff --git a/theseus_gui/src-tauri/src/api/window_ext.rs b/theseus_gui/src-tauri/src/api/window_ext.rs new file mode 100644 index 00000000..67c4cbd7 --- /dev/null +++ b/theseus_gui/src-tauri/src/api/window_ext.rs @@ -0,0 +1,71 @@ +/// from: https://github.com/tauri-apps/tauri/issues/4789, full credit to haasal +#[cfg(target_os = "macos")] +use tauri::{Runtime, Window}; + +#[cfg(target_os = "macos")] +pub trait WindowExt { + fn set_transparent_titlebar(&self, transparent: bool); + fn position_traffic_lights(&self, x: f64, y: f64); +} + +#[cfg(target_os = "macos")] +impl WindowExt for Window { + fn set_transparent_titlebar(&self, transparent: bool) { + use cocoa::appkit::{NSWindow, NSWindowTitleVisibility}; + + let window = self.ns_window().unwrap() as cocoa::base::id; + + unsafe { + window.setTitleVisibility_( + NSWindowTitleVisibility::NSWindowTitleHidden, + ); + + if transparent { + window.setTitlebarAppearsTransparent_(cocoa::base::YES); + } else { + window.setTitlebarAppearsTransparent_(cocoa::base::NO); + } + } + } + + fn position_traffic_lights(&self, x: f64, y: f64) { + use cocoa::appkit::{NSView, NSWindow, NSWindowButton}; + use cocoa::foundation::NSRect; + use objc::{msg_send, sel, sel_impl}; + + let window = self.ns_window().unwrap() as cocoa::base::id; + + unsafe { + let close = window + .standardWindowButton_(NSWindowButton::NSWindowCloseButton); + let miniaturize = window.standardWindowButton_( + NSWindowButton::NSWindowMiniaturizeButton, + ); + let zoom = window + .standardWindowButton_(NSWindowButton::NSWindowZoomButton); + + let title_bar_container_view = close.superview().superview(); + + let close_rect: NSRect = msg_send![close, frame]; + let button_height = close_rect.size.height; + + let title_bar_frame_height = button_height + y; + let mut title_bar_rect = NSView::frame(title_bar_container_view); + title_bar_rect.size.height = title_bar_frame_height; + title_bar_rect.origin.y = + NSView::frame(window).size.height - title_bar_frame_height; + let _: () = + msg_send![title_bar_container_view, setFrame: title_bar_rect]; + + let window_buttons = vec![close, miniaturize, zoom]; + let space_between = NSView::frame(miniaturize).origin.x + - NSView::frame(close).origin.x; + + for (i, button) in window_buttons.into_iter().enumerate() { + let mut rect: NSRect = NSView::frame(button); + rect.origin.x = x + (i as f64 * space_between); + button.setFrameOrigin(rect.origin); + } + } + } +} diff --git a/theseus_gui/src-tauri/src/main.rs b/theseus_gui/src-tauri/src/main.rs index 6c79971a..84a164d5 100644 --- a/theseus_gui/src-tauri/src/main.rs +++ b/theseus_gui/src-tauri/src/main.rs @@ -5,7 +5,7 @@ use theseus::prelude::*; -use tauri::Manager; +use tauri::{Manager, WindowEvent}; use tracing_error::ErrorLayer; use tracing_subscriber::EnvFilter; @@ -55,86 +55,108 @@ fn main() { tracing::subscriber::set_global_default(subscriber) .expect("setting default subscriber failed"); - tauri::Builder::default() + let mut builder = tauri::Builder::default() .plugin(tauri_plugin_single_instance::init(|app, argv, cwd| { app.emit_all("single-instance", Payload { args: argv, cwd }) .unwrap(); })) - .plugin(tauri_plugin_window_state::Builder::default().build()) - .invoke_handler(tauri::generate_handler![ - initialize_state, - api::progress_bars_list, - api::profile_create::profile_create_empty, - api::profile_create::profile_create, - api::profile::profile_remove, - api::profile::profile_get, - api::profile::profile_get_optimal_jre_key, - api::profile::profile_list, - api::profile::profile_install, - api::profile::profile_update_all, - api::profile::profile_update_project, - api::profile::profile_add_project_from_version, - api::profile::profile_add_project_from_path, - api::profile::profile_toggle_disable_project, - api::profile::profile_remove_project, - api::profile::profile_run, - api::profile::profile_run_wait, - api::profile::profile_run_credentials, - api::profile::profile_run_wait_credentials, - api::profile::profile_edit, - api::profile::profile_edit_icon, - api::profile::profile_check_installed, - api::pack::pack_install_version_id, - api::pack::pack_install_file, - api::auth::auth_authenticate_begin_flow, - api::auth::auth_authenticate_await_completion, - api::auth::auth_cancel_flow, - api::auth::auth_refresh, - api::auth::auth_remove_user, - api::auth::auth_has_user, - api::auth::auth_users, - api::auth::auth_get_user, - api::tags::tags_get_categories, - api::tags::tags_get_donation_platforms, - api::tags::tags_get_game_versions, - api::tags::tags_get_loaders, - api::tags::tags_get_report_types, - api::tags::tags_get_tag_bundle, - api::settings::settings_get, - api::settings::settings_set, - api::jre::jre_get_all_jre, - api::jre::jre_autodetect_java_globals, - api::jre::jre_find_jre_18plus_jres, - api::jre::jre_find_jre_17_jres, - api::jre::jre_find_jre_8_jres, - api::jre::jre_validate_globals, - api::jre::jre_get_jre, - api::jre::jre_auto_install_java, - api::jre::jre_get_max_memory, - api::process::process_get_all_uuids, - api::process::process_get_all_running_uuids, - api::process::process_get_uuids_by_profile_path, - api::process::process_get_all_running_profile_paths, - api::process::process_get_all_running_profiles, - api::process::process_get_exit_status_by_uuid, - api::process::process_has_finished_by_uuid, - api::process::process_get_stderr_by_uuid, - api::process::process_get_stdout_by_uuid, - api::process::process_kill_by_uuid, - api::process::process_wait_for_by_uuid, - api::metadata::metadata_get_game_versions, - api::metadata::metadata_get_fabric_versions, - api::metadata::metadata_get_forge_versions, - api::metadata::metadata_get_quilt_versions, - api::logs::logs_get_logs, - api::logs::logs_get_logs_by_datetime, - api::logs::logs_get_stdout_by_datetime, - api::logs::logs_get_stderr_by_datetime, - api::logs::logs_delete_logs, - api::logs::logs_delete_logs_by_datetime, - api::utils::show_in_folder, - api::utils::should_disable_mouseover, - ]) + .plugin(tauri_plugin_window_state::Builder::default().build()); + + #[cfg(target_os = "macos")] + { + builder = builder + .setup(|app| { + use api::window_ext::WindowExt; + let win = app.get_window("main").unwrap(); + win.set_transparent_titlebar(true); + win.position_traffic_lights(0.0, 0.0); + Ok(()) + }) + .on_window_event(|e| { + use api::window_ext::WindowExt; + if let WindowEvent::Resized(..) = e.event() { + let win = e.window(); + win.position_traffic_lights(0., 0.); + } + }) + } + + builder = builder.invoke_handler(tauri::generate_handler![ + initialize_state, + api::progress_bars_list, + api::profile_create::profile_create_empty, + api::profile_create::profile_create, + api::profile::profile_remove, + api::profile::profile_get, + api::profile::profile_get_optimal_jre_key, + api::profile::profile_list, + api::profile::profile_install, + api::profile::profile_update_all, + api::profile::profile_update_project, + api::profile::profile_add_project_from_version, + api::profile::profile_add_project_from_path, + api::profile::profile_toggle_disable_project, + api::profile::profile_remove_project, + api::profile::profile_run, + api::profile::profile_run_wait, + api::profile::profile_run_credentials, + api::profile::profile_run_wait_credentials, + api::profile::profile_edit, + api::profile::profile_edit_icon, + api::profile::profile_check_installed, + api::pack::pack_install_version_id, + api::pack::pack_install_file, + api::auth::auth_authenticate_begin_flow, + api::auth::auth_authenticate_await_completion, + api::auth::auth_cancel_flow, + api::auth::auth_refresh, + api::auth::auth_remove_user, + api::auth::auth_has_user, + api::auth::auth_users, + api::auth::auth_get_user, + api::tags::tags_get_categories, + api::tags::tags_get_donation_platforms, + api::tags::tags_get_game_versions, + api::tags::tags_get_loaders, + api::tags::tags_get_report_types, + api::tags::tags_get_tag_bundle, + api::settings::settings_get, + api::settings::settings_set, + api::jre::jre_get_all_jre, + api::jre::jre_autodetect_java_globals, + api::jre::jre_find_jre_18plus_jres, + api::jre::jre_find_jre_17_jres, + api::jre::jre_find_jre_8_jres, + api::jre::jre_validate_globals, + api::jre::jre_get_jre, + api::jre::jre_auto_install_java, + api::jre::jre_get_max_memory, + api::process::process_get_all_uuids, + api::process::process_get_all_running_uuids, + api::process::process_get_uuids_by_profile_path, + api::process::process_get_all_running_profile_paths, + api::process::process_get_all_running_profiles, + api::process::process_get_exit_status_by_uuid, + api::process::process_has_finished_by_uuid, + api::process::process_get_stderr_by_uuid, + api::process::process_get_stdout_by_uuid, + api::process::process_kill_by_uuid, + api::process::process_wait_for_by_uuid, + api::metadata::metadata_get_game_versions, + api::metadata::metadata_get_fabric_versions, + api::metadata::metadata_get_forge_versions, + api::metadata::metadata_get_quilt_versions, + api::logs::logs_get_logs, + api::logs::logs_get_logs_by_datetime, + api::logs::logs_get_stdout_by_datetime, + api::logs::logs_get_stderr_by_datetime, + api::logs::logs_delete_logs, + api::logs::logs_delete_logs_by_datetime, + api::utils::show_in_folder, + api::utils::should_disable_mouseover, + ]); + + builder .run(tauri::generate_context!()) .expect("error while running tauri application"); } diff --git a/theseus_gui/src/components/GridDisplay.vue b/theseus_gui/src/components/GridDisplay.vue index b200546a..27f2314c 100644 --- a/theseus_gui/src/components/GridDisplay.vue +++ b/theseus_gui/src/components/GridDisplay.vue @@ -189,6 +189,9 @@ const filteredResults = computed(() => {
+
Sort by diff --git a/theseus_gui/src/components/ui/RunningAppBar.vue b/theseus_gui/src/components/ui/RunningAppBar.vue index be9a899a..de81a002 100644 --- a/theseus_gui/src/components/ui/RunningAppBar.vue +++ b/theseus_gui/src/components/ui/RunningAppBar.vue @@ -1,9 +1,17 @@ diff --git a/theseus_gui/src/pages/Browse.vue b/theseus_gui/src/pages/Browse.vue index 1b3d6562..582b70bb 100644 --- a/theseus_gui/src/pages/Browse.vue +++ b/theseus_gui/src/pages/Browse.vue @@ -14,6 +14,7 @@ import { formatCategoryHeader, formatCategory, Promotion, + XIcon, DropdownSelect, } from 'omorphia' import Multiselect from 'vue-multiselect' @@ -630,6 +631,9 @@ const showLoaders = computed( :placeholder="`Search ${projectType}s...`" @input="onSearchChange(1)" /> +
Sort by diff --git a/theseus_gui/src/pages/Settings.vue b/theseus_gui/src/pages/Settings.vue index 001afe61..abc3f179 100644 --- a/theseus_gui/src/pages/Settings.vue +++ b/theseus_gui/src/pages/Settings.vue @@ -209,6 +209,7 @@ watch( :min="256" :max="maxMemory" :step="1" + unit="mb" />
diff --git a/theseus_gui/src/pages/instance/Mods.vue b/theseus_gui/src/pages/instance/Mods.vue index edec3aae..da9da5e2 100644 --- a/theseus_gui/src/pages/instance/Mods.vue +++ b/theseus_gui/src/pages/instance/Mods.vue @@ -13,6 +13,9 @@ class="text-input" autocomplete="off" /> + @@ -39,22 +42,63 @@ - +
+ + + + + + + + + + + + + +
- +
Name
Version
@@ -68,17 +112,7 @@ @contextmenu.prevent.stop="(c) => handleRightClick(c, mod)" >
- - +
+ +
+ + +