Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panel manager #300

Open
wants to merge 50 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
612ac1c
kindling-ui-demo: draw basic slider
airidaceae Dec 11, 2023
4421e78
kindling-ui-demo: make slider interactive
marceline-cramer Dec 11, 2023
75e7792
kindling-ui-demo: unclog event-redraw coupling
marceline-cramer Dec 11, 2023
2f17772
kindling-ui-demo: theme slider
airidaceae Dec 11, 2023
309e5b4
kindling-ui-demo: basic text drawing with cosmic-text
marceline-cramer Dec 12, 2023
7cdf789
kindling-ui-demo: replace cosmic-text with cozette bdf
marceline-cramer Dec 13, 2023
cbe5d8c
kindling-flycam: add initial service
marceline-cramer Dec 13, 2023
f1c4986
kindling-flycam: raycast cube world
marceline-cramer Dec 14, 2023
30d6a3b
Merge branch 'main' into dev-flycam
airidaceae Dec 15, 2023
ded16d7
kindling-flycam: use kindling-host api
airidaceae Dec 15, 2023
4b645aa
Merge branch 'main' into ui-dev
airidaceae Dec 15, 2023
7c634d2
kindling-ui-dev: update to use kindling-host
airidaceae Dec 16, 2023
e376bf7
kindling-ui-demo: hacky layout
marceline-cramer Dec 17, 2023
8a55039
kindling-flycam: allow cursor unlocking with tab
airidaceae Dec 27, 2023
780efe6
kindling-ui-demo: add Xilem-style architecture
marceline-cramer Dec 30, 2023
26eb9a7
kindling-ui-demo: add button widget and view
airidaceae Dec 30, 2023
f68dea9
kindling-ui-demo: fix flow relayout bug
marceline-cramer Dec 31, 2023
8bc0635
kindling-ui-demo: center flow children on cross axis
marceline-cramer Dec 31, 2023
5e1fd7e
kindling-ui-demo: relayout on draw
marceline-cramer Dec 31, 2023
4252d92
kindling-ui-demo: fix rebuild() not diffing bug
marceline-cramer Dec 31, 2023
90275e8
kindling-ui-demo: text layout + label + demo
marceline-cramer Dec 31, 2023
c3c0ab9
kindling: workspace glam dep
marceline-cramer Jan 26, 2024
deb3e04
kindling-schema: add WIP panel protocol
marceline-cramer Jan 26, 2024
2a039c1
kindling: add initial panel-manager
marceline-cramer Jan 26, 2024
5b1c752
Merge branch 'main' into dev-flycam
marceline-cramer Jan 26, 2024
ecbae12
kindling-flycam: update API
marceline-cramer Jan 26, 2024
c70cffe
kindling-flycam: remove .cargo
marceline-cramer Jan 26, 2024
4a83278
Merge branch 'dev-flycam' into panel-manager
marceline-cramer Jan 26, 2024
44fefc3
kindling-terminal-demo: don't set camera
marceline-cramer Jan 26, 2024
340b736
kindling-flycam: replace rapier with panel manager service
marceline-cramer Jan 26, 2024
3543b6b
kindling-panel-manager: fix raycast math mistake
marceline-cramer Jan 26, 2024
0aba2c6
kindling-terminal-demo: terminal panels with dynamic opacity
marceline-cramer Jan 26, 2024
98b4ae3
kindling-schema: add select state to CursorEventKind::Entered
marceline-cramer Jan 27, 2024
c561aa7
kindling-panel-manager: implement cursor events
marceline-cramer Jan 27, 2024
be325f8
Merge branch 'main' into dev-ui
marceline-cramer Jan 27, 2024
b25533f
kindling-ui-demo: update APIs
marceline-cramer Jan 27, 2024
dfea397
Merge branch 'dev-ui' into panel-manager
marceline-cramer Jan 27, 2024
317be30
kindling-schema: add panel redraw messages
marceline-cramer Jan 27, 2024
96bf2e9
kindling-panel-manager: redraw + bugfixes
marceline-cramer Jan 27, 2024
8588329
kindling-flycam: panel redraw and selection
marceline-cramer Jan 27, 2024
d276ba3
kindling-ui-demo: switch from direct window to panel manager
marceline-cramer Jan 27, 2024
a65e727
kindling-schema: add TODO note for one-sided panel input
marceline-cramer Jan 27, 2024
2155d5d
guest: add Message::parse()
marceline-cramer Jan 31, 2024
cc41be7
kindling-panel-manager: remove downed panels
marceline-cramer Jan 31, 2024
bc88325
kindling-schema: add one-sided panel config
marceline-cramer Jan 31, 2024
4cb414b
kindling-panel-manager: implement one-sided panels
marceline-cramer Jan 31, 2024
7f63bca
kindling-terminal-demo: make terminals one-sided
marceline-cramer Jan 31, 2024
0efec9d
kindling-ui-demo: make UI one-sided
marceline-cramer Jan 31, 2024
bf1a725
Merge branch 'main' into panel-manager
marceline-cramer Feb 1, 2024
71f8ab6
Merge branch 'main' into panel-manager
marceline-cramer Mar 18, 2024
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
8 changes: 8 additions & 0 deletions guest/rust/hearth-guest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,14 @@ impl Message {

Self { data, caps }
}

/// Parses this JSON-encoded message into a given data type.
///
/// Panics if decoding fails.
pub fn parse<T: for<'a> Deserialize<'a>>(self) -> (T, Vec<Capability>) {
let data = serde_json::from_slice(&self.data).unwrap();
(data, self.caps)
}
}

/// A loaded lump.
Expand Down
1 change: 1 addition & 0 deletions kindling/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ members = ["init", "services/*", "host", "utils", "schema"]
exclude = ["build"]

[workspace.dependencies]
glam = "0.20"
hearth-guest = { path = "../guest/rust/hearth-guest"}
kindling-host = { path = "host"}
kindling-schema = { path = "schema" }
Expand Down
2 changes: 1 addition & 1 deletion kindling/host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"
license = "AGPL-3.0-or-later"

[dependencies]
glam = "0.20"
glam.workspace = true
hearth-guest.workspace = true
lazy_static.workspace = true
serde.workspace = true
Expand Down
1 change: 1 addition & 0 deletions kindling/schema/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ edition = "2021"
license = "AGPL-3.0-or-later"

[dependencies]
glam.workspace = true
hearth-guest.workspace = true
serde.workspace = true
2 changes: 2 additions & 0 deletions kindling/schema/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
//
// You should have received a copy of the GNU Affero General Public License
// along with Hearth. If not, see <https://www.gnu.org/licenses/>.

pub mod panel;
118 changes: 118 additions & 0 deletions kindling/schema/src/panel.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
// Copyright (c) 2024 Marceline Cramer
// SPDX-License-Identifier: AGPL-3.0-or-later
//
// This file is part of Hearth.
//
// Hearth is free software: you can redistribute it and/or modify it under the
// terms of the GNU Affero General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option)
// any later version.
//
// Hearth is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
// details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Hearth. If not, see <https://www.gnu.org/licenses/>.

use glam::{Quat, Vec2, Vec3};
use serde::{Deserialize, Serialize};

/// A request to the panel manager.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum PanelManagerRequest {
/// Create a panel.
///
/// Provide one capability to receive the panel's [PanelEvents][PanelEvent].
CreatePanel {
/// The panel's initial transform.
transform: PanelTransform,

/// If true, this panel cannot be interacted with from behind.
one_sided: bool,
},

/// Enable and update the global cursor.
UpdateCursor(Cursor),

/// Disable the global cursor.
DisableCursor,

/// Redraw all panels.
Redraw,
}

/// A cursor's current state.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Cursor {
/// The cursor's origin.
pub origin: Vec3,

/// The cursor's direction.
pub dir: Vec3,

/// Whether the cursor's select button is clicked.
pub select: bool,
}

/// An event occurring on a panel.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum PanelEvent {
/// Redraw this panel.
///
/// Contains the time (in seconds) since the last redraw.
Redraw(f32),

/// The panel has moved to the provided transform.
Move(PanelTransform),

/// The panel has gained focus.
FocusGained,

/// The panel has lost focus.
FocusLost,

/// The panel has received a cursor event.
CursorEvent {
/// The position of the cursor on this panel.
at: Vec2,

/// The kind of event.
kind: CursorEventKind,
},
}

/// A panel's location information in space.
#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
pub struct PanelTransform {
/// The panel's center position.
pub position: Vec3,

/// The panel's orientation.
pub orientation: Quat,

/// The panel's half-size.
pub half_size: Vec2,
}

/// A kind of cursor event. See [PanelEvent::CursorEvent].
#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
pub enum CursorEventKind {
/// The cursor has entered this panel.
///
/// Carries the current state of the select button.
Entered(bool),

/// The cursor has left this panel.
Left,

/// The cursor has moved on the panel.
Move,

/// The cursor has pressed its select button.
ClickDown,

/// The cursor has released its select button.
ClickUp,
}
19 changes: 19 additions & 0 deletions kindling/services/flycam/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "kindling-flycam"
version = "0.1.0"
edition = "2021"
description = "A simple flycam implementation"

[package.metadata.service]
name = "rs.hearth.kindling.Flycam"
targets = []
dependencies.need = ["hearth.Window", "rs.hearth.kindling.PanelManager"]

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

[dependencies]
bitflags = "2.4.1"
kindling-host.workspace = true
kindling-schema.workspace = true
hearth-guest.workspace = true
Loading
Loading