Skip to content
Open
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
22 changes: 22 additions & 0 deletions Custom Plugins/fullscreen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "fullscreen"
version = "1.0.0"
edition = "2024"
publish = false
license = "MIT OR Apache-2.0"
description = "Fullscreen mode plugin for ProCraft: toggle between windowed and fullscreen display, configure exclusive fullscreen and keyboard shortcuts"

[lib]
crate-type = ["cdylib"]

[dependencies]
kit = { package = "procraft-plugin-kit", path = "../../plugins/kit", default-features = false }

# Not a member of the app's workspace, and linked into nothing: it builds to a module of its own.
[workspace]

[profile.release]
opt-level = "s"
lto = true
panic = "abort"
strip = true
28 changes: 28 additions & 0 deletions Custom Plugins/fullscreen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Fullscreen Plugin for ProCraft
**Author**: raba7
**Description**: Immersive fullscreen canvas mode for ProCraft by raba7. Seamlessly switch between windowed and fullscreen display with F11 or Alt+Enter, featuring optional high-refresh rate exclusive fullscreen.

---

## Features
- **Fullscreen Mode Toggle**:
- Switch smoothly between standard windowed mode and fullscreen display.
- Trigger fullscreen toggle directly from the plugin card in **Actions -> Prefs -> Plugins -> Fullscreen -> Toggle Fullscreen**.
- **Exclusive Fullscreen Option**:
- Toggle between **Exclusive Fullscreen** (highest monitor refresh rate, minimal latency) and standard borderless windowed fullscreen.
- **Keyboard Shortcuts**:
- Support for industry standard **F11** and **Alt+Enter** keyboard shortcuts to toggle fullscreen on and off.
- Can be toggled on/off independently via the plugin control switch.

## How to Install / Import
1. Open **ProCraft**.
2. Open any canvas, or open the Gallery.
3. Open the **Actions** menu (wrench icon in top bar) -> **Help / Prefs** -> **Plugins**.
4. Tap **Import Plugin** and select `fullscreen.procraft-plugin` from this folder.
5. The **Fullscreen** plugin will now appear in your plugins list.

## Plugin Controls & Actions
- **Enable fullscreen features**: Master switch enabling/disabling fullscreen capability.
- **Exclusive fullscreen (max refresh rate)**: When enabled, runs in exclusive mode for highest monitor refresh rate.
- **Keyboard shortcuts (F11 / Alt+Enter)**: Allows toggling fullscreen via keyboard shortcuts.
- **Toggle Fullscreen**: Action button to immediately toggle fullscreen on or off.
20 changes: 20 additions & 0 deletions Custom Plugins/fullscreen/craft-extension.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"schema": 1,
"id": "io.github.artcraftandroid.fullscreen",
"name": "Fullscreen",
"version": "1.0.0",
"holds": ["hooks"],
"publisher": { "name": "raba7" },
"description": "Immersive fullscreen canvas mode for ProCraft by raba7. Seamlessly switch between windowed and fullscreen display with F11 or Alt+Enter, featuring optional high-refresh rate exclusive fullscreen.",
"compat": { "procraft": { "interface": 2 } },
"permissions": [],
"hooks": ["fullscreen"],
"controls": [
{ "key": "enabled", "type": "switch", "label": "Enable fullscreen features", "starts": true },
{ "key": "exclusive", "type": "switch", "label": "Exclusive fullscreen (max refresh rate)", "starts": false, "under": "enabled" },
{ "key": "shortcuts", "type": "switch", "label": "Keyboard shortcuts (F11 / Alt+Enter)", "starts": true, "under": "enabled" }
],
"actions": [
{ "key": "toggle", "label": "Toggle Fullscreen" }
]
}
Binary file added Custom Plugins/fullscreen/fullscreen.procraft-plugin
Binary file not shown.
Binary file added Custom Plugins/fullscreen/plugin.wasm
Binary file not shown.
29 changes: 29 additions & 0 deletions Custom Plugins/fullscreen/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//! Fullscreen plugin for ProCraft: controls window fullscreen modes,
//! exclusive fullscreen (maximum monitor refresh rate), and F11 / Alt+Enter shortcut toggles.

#![no_std]

/// Controls:
/// 0: enabled (switch, default on)
/// 1: exclusive (switch, default off -> borderless)
/// 2: shortcuts (switch, default on)
static CONTROLS: kit::Controls<3> = kit::Controls::new([1.0, 0.0, 1.0]);
kit::controls!(CONTROLS);

const ENABLED: usize = 0;
const EXCLUSIVE: usize = 1;
const SHORTCUTS: usize = 2;

kit::yes!(procraft_fullscreen, || CONTROLS.on(ENABLED));
kit::yes!(procraft_exclusive_fullscreen, || CONTROLS.on(ENABLED) && CONTROLS.on(EXCLUSIVE));
kit::yes!(procraft_fullscreen_shortcuts, || CONTROLS.on(ENABLED) && CONTROLS.on(SHORTCUTS));

#[unsafe(no_mangle)]
pub extern "C" fn procraft_action(_index: i32) -> i32 {
0
}

#[panic_handler]
fn panic(_: &core::panic::PanicInfo) -> ! {
core::arch::wasm32::unreachable()
}
22 changes: 22 additions & 0 deletions Custom Plugins/macos topbar/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "macos-topbar"
version = "1.0.1"
edition = "2024"
publish = false
license = "MIT OR Apache-2.0"
description = "A plugin for ProCraft: switches the top bar to macOS style with traffic light window controls"

[lib]
crate-type = ["cdylib"]

[dependencies]
kit = { package = "procraft-plugin-kit", path = "../kit", default-features = false }

# Not a member of the app's workspace, and linked into nothing: it builds to a module of its own.
[workspace]

[profile.release]
opt-level = "s"
lto = true
panic = "abort"
strip = true
30 changes: 30 additions & 0 deletions Custom Plugins/macos topbar/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# macOS Style Plugin for ProCraft
**Author**: raba7
**Version**: 1.0.1
**Description**: Transforms ProCraft's window into a clean macOS style with traffic light controls by raba7. When disabled, standard window decorations are restored.

---

## Features
- **Enabled (macOS Style)**:
- Frameless / borderless window styling.
- Sleek traffic light window control buttons (Close, Minimize, Maximize) with hover glyphs on the top left.
- Draggable top bar and gallery / tool headers with double-click to maximize/restore.
- Rounded top corner aesthetics.
- **Disabled (Default Windows Style)**:
- Standard native Windows title bar and window decorations.
- Native Windows minimize, maximize, and close controls in the top-right corner.
- Full native window snapping and window dragging.
- Standard default layout and margins.

## How to Install / Import
1. Open **ProCraft**.
2. Open any canvas, or open the Gallery.
3. Open the **Actions** menu (wrench icon in top bar) -> **Help / Prefs** -> **Plugins**.
4. Tap **Import Plugin** and select `macos-topbar.procraft-plugin` from this folder.
5. The **macOS Style** plugin will now appear in your plugins list.

## How to Toggle
- You can turn the plugin **ON** or **OFF** at any time from the Plugins page using its master toggle switch or its "macOS style top bar" control switch.
- When enabled, ProCraft instantly switches to the macOS top bar without needing a restart.
- When disabled, ProCraft restores the default Windows top bar and title decorations.
15 changes: 15 additions & 0 deletions Custom Plugins/macos topbar/craft-extension.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"schema": 1,
"id": "io.github.artcraftandroid.macos-topbar",
"name": "macOS Style",
"version": "1.0.1",
"holds": ["hooks"],
"publisher": { "name": "raba7" },
"description": "Transforms ProCraft's window into a clean macOS style with traffic light controls by raba7. When disabled, standard window decorations are restored.",
"compat": { "procraft": { "interface": 1 } },
"permissions": [],
"hooks": ["macos_top_bar"],
"controls": [
{ "key": "enabled", "type": "switch", "label": "macOS style top bar", "starts": true }
]
}
Binary file not shown.
Binary file added Custom Plugins/macos topbar/plugin.wasm
Binary file not shown.
16 changes: 16 additions & 0 deletions Custom Plugins/macos topbar/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//! macOS Top Bar: changes the window top bar to macOS style with traffic light window controls.
//! When disabled or turned off, ProCraft uses the platform's default window decorations.

#![no_std]

/// Controls: an enabled switch that defaults to on (1.0).
static CONTROLS: kit::Controls<1> = kit::Controls::new([1.0]);
kit::controls!(CONTROLS);
const ENABLED: usize = 0;

kit::yes!(procraft_macos_top_bar, || CONTROLS.on(ENABLED));

#[panic_handler]
fn panic(_: &core::panic::PanicInfo) -> ! {
core::arch::wasm32::unreachable()
}
95 changes: 95 additions & 0 deletions crates/core/src/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,31 @@ impl Hooks {
&& self.through(Hook::KeepClear, false, |running, said| Ok(said | running.keep_clear()?))
}

/// The macOS top bar hook: whether to show macOS style traffic lights and title bar (not 0),
/// or default to the platform's standard window decorations.
pub(crate) fn macos_top_bar(&self) -> bool {
self.has(Hook::MacosTopBar)
&& self.through(Hook::MacosTopBar, false, |running, said| Ok(said | running.macos_top_bar()?))
}

/// The fullscreen hook: whether fullscreen features are active.
pub(crate) fn fullscreen(&self) -> bool {
self.has(Hook::Fullscreen)
&& self.through(Hook::Fullscreen, false, |running, said| Ok(said | running.fullscreen()?))
}

/// Whether exclusive fullscreen mode is chosen.
pub(crate) fn exclusive_fullscreen(&self) -> bool {
self.has(Hook::Fullscreen)
&& self.through(Hook::Fullscreen, false, |running, said| Ok(said | running.exclusive_fullscreen()?))
}

/// Whether keyboard shortcuts for fullscreen are enabled.
pub(crate) fn fullscreen_shortcuts(&self) -> bool {
self.has(Hook::Fullscreen)
&& self.through(Hook::Fullscreen, false, |running, said| Ok(said | running.fullscreen_shortcuts()?))
}

/// The undo notice hook: whether undo and redo go by without the notice naming what they took
/// back or brought back.
pub(crate) fn hide_undo_notice(&self) -> bool {
Expand Down Expand Up @@ -2169,6 +2194,76 @@ pub(crate) mod tests {
let _ = std::fs::remove_dir_all(&dir);
}

#[test]
fn macos_top_bar_hook_answers_while_a_plugin_asks_for_it() {
let dir = store("macos-top-bar");
let module = wat::parse_str(
r#"(module
(global $on (mut i32) (i32.const 1))
(func (export "procraft_macos_top_bar") (result i32) (global.get $on))
(func (export "procraft_control") (param i32 f32)
(if (f32.ge (local.get 1) (f32.const 0.5))
(then (global.set $on (i32.const 1)))
(else (global.set $on (i32.const 0))))))"#,
)
.unwrap();
let plugins = Plugins::with_store(dir.clone());
let mut manifest = coded(ID, &module);
manifest["hooks"] = json!(["macos_top_bar"]);
manifest["controls"] = json!([
{ "key": "enabled", "type": "switch", "label": "macOS style top bar", "starts": true }
]);
assert_eq!(plugins.install(file(&manifest, &module)), None);
// off by default when installed
assert!(!plugins.macos_top_bar());
// turn on the plugin
assert!(plugins.set_on(ID.to_owned(), true));
assert!(plugins.macos_top_bar());
// toggle switch off
assert!(plugins.set_switch(format!("{ID}.enabled"), false));
assert!(!plugins.macos_top_bar());
// toggle switch back on
assert!(plugins.set_switch(format!("{ID}.enabled"), true));
assert!(plugins.macos_top_bar());
// turn plugin off
assert!(plugins.set_on(ID.to_owned(), false));
assert!(!plugins.macos_top_bar());
let _ = std::fs::remove_dir_all(&dir);
}

#[test]
fn fullscreen_hook_answers_while_a_plugin_asks_for_it() {
let dir = store("fullscreen-test");
let module = wat::parse_str(
r#"(module
(global $on (mut i32) (i32.const 1))
(func (export "procraft_fullscreen") (result i32) (global.get $on))
(func (export "procraft_exclusive_fullscreen") (result i32) (global.get $on))
(func (export "procraft_fullscreen_shortcuts") (result i32) (global.get $on))
(func (export "procraft_control") (param i32 f32)
(if (f32.ge (local.get 1) (f32.const 0.5))
(then (global.set $on (i32.const 1)))
(else (global.set $on (i32.const 0))))))"#,
)
.unwrap();
let plugins = Plugins::with_store(dir.clone());
let mut manifest = coded(ID, &module);
manifest["hooks"] = json!(["fullscreen"]);
manifest["controls"] = json!([
{ "key": "enabled", "type": "switch", "label": "Enable fullscreen features", "starts": true }
]);
assert_eq!(plugins.install(file(&manifest, &module)), None);
assert!(!plugins.fullscreen_active());
assert!(plugins.set_on(ID.to_owned(), true));
assert!(plugins.fullscreen_active());
assert!(plugins.exclusive_fullscreen());
assert!(plugins.fullscreen_shortcuts());
assert!(plugins.set_switch(format!("{ID}.enabled"), false));
assert!(!plugins.fullscreen_active());
assert!(plugins.set_on(ID.to_owned(), false));
let _ = std::fs::remove_dir_all(&dir);
}

#[test]
fn a_touch_with_a_panel_open_paints_at_once_and_leaves_it_while_a_plugin_pins_it() {
use crate::touch::{TouchCommand, TouchMove};
Expand Down
Loading
Loading