mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 17:38:10 +00:00
fix drag region
This commit is contained in:
1 parent
9e57aacb05
commit
8596bf2087
10 files changed
+139
-21
No files matched your search
Generated
+54
@@ -659,6 +659,7 @@ dependencies = [
|
||||
"build_metadata",
|
||||
"bytes 1.10.1",
|
||||
"chrono",
|
||||
"cocoa",
|
||||
"cookie_store 0.0.1",
|
||||
"directories",
|
||||
"dirs",
|
||||
@@ -1327,6 +1328,12 @@ dependencies = [
|
||||
"constant_time_eq 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.9.0"
|
||||
@@ -2026,6 +2033,35 @@ dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cocoa"
|
||||
version = "0.26.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ad36507aeb7e16159dfe68db81ccc27571c3ccd4b76fb2fb72fc59e7a4b1b64c"
|
||||
dependencies = [
|
||||
"bitflags 2.5.0",
|
||||
"block",
|
||||
"cocoa-foundation",
|
||||
"core-foundation 0.10.0",
|
||||
"core-graphics",
|
||||
"foreign-types 0.5.0",
|
||||
"libc",
|
||||
"objc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cocoa-foundation"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81411967c50ee9a1fc11365f8c585f863a22a9697c89239c452292c40ba79b0d"
|
||||
dependencies = [
|
||||
"bitflags 2.5.0",
|
||||
"block",
|
||||
"core-foundation 0.10.0",
|
||||
"core-graphics-types",
|
||||
"objc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "collections"
|
||||
version = "0.0.1"
|
||||
@@ -6104,6 +6140,15 @@ dependencies = [
|
||||
"tiger",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "malloc_buf"
|
||||
version = "0.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "markdown"
|
||||
version = "0.0.1"
|
||||
@@ -6869,6 +6914,15 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"
|
||||
dependencies = [
|
||||
"malloc_buf",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc-sys"
|
||||
version = "0.3.5"
|
||||
|
||||
@@ -79,6 +79,12 @@ tauri-plugin-http = { path = "../../vendor/tauri-plugin-http" }
|
||||
# types and can't do threading. We need to wait for a new version to unpin from Git.
|
||||
discord-rich-presence = { git = "https://github.com/vionya/discord-rich-presence" }
|
||||
|
||||
# Transparent title bar on MacOS
|
||||
# NB: See the notes here:
|
||||
# https://v2.tauri.app/learn/window-customization/
|
||||
[target."cfg(target_os = \"macos\")".dependencies]
|
||||
cocoa = "0.26"
|
||||
|
||||
[dev-dependencies]
|
||||
serial_test = "3.2.0"
|
||||
|
||||
|
||||
@@ -5,13 +5,16 @@
|
||||
"windows": ["main"],
|
||||
"permissions": [
|
||||
"core:default",
|
||||
"log:default",
|
||||
"core:window:allow-minimize",
|
||||
"core:window:allow-toggle-maximize",
|
||||
"core:window:allow-close",
|
||||
"core:window:allow-minimize",
|
||||
"core:window:allow-start-dragging",
|
||||
"core:window:allow-toggle-maximize",
|
||||
"core:window:default",
|
||||
"dialog:default",
|
||||
"http:allow-fetch",
|
||||
"log:default",
|
||||
"upload:allow-download",
|
||||
"upload:default",
|
||||
"http:allow-fetch",
|
||||
{
|
||||
"identifier": "http:default",
|
||||
"allow": [
|
||||
@@ -22,7 +25,6 @@
|
||||
"url": "http://localhost:12345"
|
||||
}
|
||||
]
|
||||
},
|
||||
"dialog:default"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,2 +1,3 @@
|
||||
mod tasks;
|
||||
pub mod handle_tauri_startup;
|
||||
mod tasks;
|
||||
pub mod setup_main_window;
|
||||
@@ -0,0 +1,51 @@
|
||||
use tauri::{AppHandle, TitleBarStyle, WebviewUrl, WebviewWindowBuilder};
|
||||
use tauri::window::Color;
|
||||
use errors::AnyhowResult;
|
||||
|
||||
pub async fn setup_main_window(
|
||||
app: &AppHandle,
|
||||
) -> AnyhowResult<()> {
|
||||
|
||||
let win_builder =
|
||||
WebviewWindowBuilder::new(app, "main", WebviewUrl::default())
|
||||
.title("Artcraft")
|
||||
//.decorations(false) // NB: This breaks Mac!
|
||||
.resizable(true)
|
||||
.fullscreen(false)
|
||||
.background_color(Color(0, 0, 0, 0))
|
||||
.enable_clipboard_access()
|
||||
.inner_size(800.0, 600.0);
|
||||
|
||||
// set transparent title bar only when building for macOS
|
||||
#[cfg(target_os = "macos")]
|
||||
let win_builder = win_builder
|
||||
.decorations(true) // NB: Mac requires decorations. Tons of capabilities disappear without it.
|
||||
.title_bar_style(TitleBarStyle::Overlay)
|
||||
.hidden_title(true)
|
||||
.accept_first_mouse(true) // https://github.com/tauri-apps/tauri/issues/11605#issuecomment-2460112096
|
||||
.focusable(true)
|
||||
.focused(true);
|
||||
|
||||
let window = win_builder.build()?;
|
||||
|
||||
/*// set background color only when building for macOS
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
use cocoa::appkit::{NSColor, NSWindow};
|
||||
use cocoa::base::{id, nil};
|
||||
|
||||
let ns_window = window.ns_window().unwrap() as id;
|
||||
unsafe {
|
||||
let bg_color = NSColor::colorWithRed_green_blue_alpha_(
|
||||
nil,
|
||||
50.0 / 255.0,
|
||||
158.0 / 255.0,
|
||||
163.5 / 255.0,
|
||||
0.0,
|
||||
);
|
||||
ns_window.setBackgroundColor_(bg_color);
|
||||
}
|
||||
}*/
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -18,6 +18,7 @@ use crate::core::commands::platform_info_command::platform_info_command;
|
||||
use crate::core::commands::providers::get_provider_order_command::get_provider_order_command;
|
||||
use crate::core::commands::providers::set_provider_order_command::set_provider_order_command;
|
||||
use crate::core::lifecycle::startup::handle_tauri_startup::handle_tauri_startup;
|
||||
use crate::core::lifecycle::startup::setup_main_window::setup_main_window;
|
||||
use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs;
|
||||
use crate::core::state::app_preferences::app_preferences_manager::load_app_preferences_or_default;
|
||||
use crate::core::state::data_dir::app_data_root::AppDataRoot;
|
||||
@@ -121,6 +122,8 @@ pub fn run() {
|
||||
let fal_tasks = fal_task_queue_2.clone();
|
||||
|
||||
tauri::async_runtime::block_on(async move {
|
||||
let result = setup_main_window(&app).await;
|
||||
|
||||
let result = handle_tauri_startup(
|
||||
handle,
|
||||
root,
|
||||
|
||||
@@ -7,13 +7,6 @@
|
||||
},
|
||||
"app": {
|
||||
"windows": [
|
||||
{
|
||||
"title": "ArtCraft",
|
||||
"resizable": true,
|
||||
"fullscreen": false,
|
||||
"dragDropEnabled": false,
|
||||
"decorations": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -167,14 +167,16 @@ export const TopBar = ({ pageName, loginSignUpPressed }: Props) => {
|
||||
<nav
|
||||
className="mx-auto grid h-[56px] w-screen grid-cols-3 items-center justify-between ps-3"
|
||||
aria-label="navigation"
|
||||
data-tauri-drag-region
|
||||
>
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="mr-2">
|
||||
<span className="sr-only">ArtCraft</span>
|
||||
<div className="flex items-center gap-3" data-tauri-drag-region>
|
||||
<div className="mr-2" data-tauri-drag-region>
|
||||
<span className="sr-only" data-tauri-drag-region>ArtCraft</span>
|
||||
<img
|
||||
className="h-[24px] w-auto"
|
||||
src="/resources/images/artcraft-logo-3.png"
|
||||
alt="Logo ArtCraft"
|
||||
data-tauri-drag-region
|
||||
/>
|
||||
</div>
|
||||
<MenuIconSelector
|
||||
@@ -211,15 +213,16 @@ export const TopBar = ({ pageName, loginSignUpPressed }: Props) => {
|
||||
|
||||
<div
|
||||
className={`${tabStore.activeTabId === "3D" ? "no-drag" : ""} flex items-center justify-center gap-2 font-medium`}
|
||||
data-tauri-drag-region
|
||||
>
|
||||
{tabStore.activeTabId === "3D" ? (
|
||||
<SceneTitleInput pageName={pageName} />
|
||||
) : (
|
||||
<h1>{pageTitle}</h1>
|
||||
<h1 data-tauri-drag-region>{pageTitle}</h1>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex justify-end gap-2">
|
||||
<div className="flex justify-end gap-2" data-tauri-drag-region>
|
||||
<div className="no-drag flex gap-2">
|
||||
{/* - Uncomment for pricing modal - BFlat */}
|
||||
{/* <Button
|
||||
|
||||
@@ -76,7 +76,10 @@ createRoot(document.getElementById("root")!).render(
|
||||
<StrictMode>
|
||||
<BrowserRouter>
|
||||
<GlobalSettingsManager env={ENV} />
|
||||
<div className="topbar-spacer" />
|
||||
<div className="topbar-spacer"
|
||||
|
||||
data-tauri-drag-region={true}
|
||||
/>
|
||||
<PageEnigma />
|
||||
</BrowserRouter>
|
||||
</StrictMode>
|
||||
|
||||
@@ -60,7 +60,9 @@ export default function App() {
|
||||
<Links />
|
||||
</head>
|
||||
<body className="overflow-hidden bg-ui-background">
|
||||
<div className="topbar-spacer" />
|
||||
<div className="topbar-spacer"
|
||||
data-tauri-drag-region={true}
|
||||
/>
|
||||
<PostHogProvider client={posthog}>
|
||||
<Outlet />
|
||||
</PostHogProvider>
|
||||
|
||||
Reference in new issue
Block a user