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

separated tabs from ui crate #269

Merged
merged 5 commits into from
Mar 25, 2024
Merged
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
29 changes: 21 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 11 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,12 @@ repository = "https://github.com/rewin123/space_editor"

[workspace]
members = [
"crates/prefab",
"crates/shared",
"crates/undo",
"crates/persistence",
"crates/editor_core",
"crates/editor_ui",
"crates/*",
"modules/bevy_xpbd_plugin"
]
, "crates/editor_tabs"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is already included in "crates/*"


[workspace.package]
version = "0.5.0"
version = "0.6.0"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥁

edition = "2021"
license = "MIT OR Apache-2.0"
authors = ["rewin <rewin1996@gmail.com>", "Julia Naomi <jnboeira@outlook.com>"]
Expand All @@ -37,12 +32,13 @@ homepage = "https://github.com/rewin123/space_editor"
bevy = "0.13"

# Editor Crates
space_prefab = { version = "0.5.0", path = "crates/prefab" }
space_shared = { version = "0.5.0", path = "crates/shared" }
space_undo = { version = "0.5.0", path = "crates/undo" }
space_persistence = { version = "0.5.0", path = "crates/persistence"}
space_editor_core = { version = "0.5.0", path = "crates/editor_core", features = ["persistence_editor"] }
space_editor_ui = { version = "0.5.0", path = "crates/editor_ui", features = ["persistence_editor"] }
space_prefab = { version = "0.6.0", path = "crates/prefab" }
space_shared = { version = "0.6.0", path = "crates/shared" }
space_undo = { version = "0.6.0", path = "crates/undo" }
space_persistence = { version = "0.6.0", path = "crates/persistence"}
space_editor_core = { version = "0.6.0", path = "crates/editor_core", features = ["persistence_editor"] }
space_editor_ui = { version = "0.6.0", path = "crates/editor_ui", features = ["persistence_editor"] }
space_editor_tabs = { version = "0.6.0", path = "crates/editor_tabs" }

# Crates inner libraries
anyhow = "1.0"
Expand Down Expand Up @@ -74,7 +70,7 @@ ron = "0.8"
serde = "1"

# Community Modules
space_bevy_xpbd_plugin = { version = "0.5.0", path = "modules/bevy_xpbd_plugin"}
space_bevy_xpbd_plugin = { version = "0.6.0", path = "modules/bevy_xpbd_plugin"}

[dependencies]
bevy.workspace = true
Expand Down
3 changes: 0 additions & 3 deletions crates/editor_core/src/gltf_unpack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ impl Plugin for UnpackGltfPlugin {
#[reflect(Component)]
struct GltfHolder(Handle<Gltf>);

#[derive(Component)]
struct NeedUnpackTag;

#[derive(Resource, Default)]
struct GltfSceneQueue(Vec<Handle<Gltf>>);

Expand Down
2 changes: 1 addition & 1 deletion crates/editor_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ pub mod task_storage;
pub mod toast;

pub mod prelude {
pub use super::*;
pub use super::{hotkeys::*, load::*, selected::*, task_storage::*};
pub use crate::*;
pub use space_undo;
}

Expand Down
21 changes: 21 additions & 0 deletions crates/editor_tabs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "space_editor_tabs"
version.workspace = true
edition.workspace = true
license.workspace = true
authors.workspace = true
keywords.workspace = true
categories.workspace = true
repository.workspace = true
homepage.workspace = true

[dependencies]
bevy.workspace = true
bevy_egui.workspace = true
egui_extras.workspace = true
convert_case.workspace = true
egui_dock.workspace = true
bevy-inspector-egui.workspace = true

[lints]
workspace = true
15 changes: 15 additions & 0 deletions crates/editor_tabs/src/colors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/// Colors used in editor
use bevy_egui::egui::{Color32, Stroke};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think color, sizing and typography would live better in the UI crate, as they are ui elements. If this crate is the one responsible for the application ui, maybe call this editor_ui and the other editor_ui_extensions/editor_ui_components?

Copy link
Owner Author

@rewin123 rewin123 Mar 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is undoubtedly better located in editor_ui crate. However, these colours are referenced by editor_tabs. However, the PR is already quite large, so I decided to stop with just shuffling the code for now. And the improvement of the separations will be in multiple PRs


pub fn stroke_default_color() -> Stroke {
Stroke::new(1., STROKE_COLOR)
}

Check warning on line 6 in crates/editor_tabs/src/colors.rs

View check run for this annotation

Codecov / codecov/patch

crates/editor_tabs/src/colors.rs#L4-L6

Added lines #L4 - L6 were not covered by tests
pub const STROKE_COLOR: Color32 = Color32::from_rgb(70, 70, 70);
pub const SPECIAL_BG_COLOR: Color32 = Color32::from_rgb(20, 20, 20);
pub const DEFAULT_BG_COLOR: Color32 = Color32::from_rgb(27, 27, 27);
pub const PLAY_COLOR: Color32 = Color32::from_rgb(0, 194, 149);
pub const ERROR_COLOR: Color32 = Color32::from_rgb(255, 59, 33);
pub const HYPERLINK_COLOR: Color32 = Color32::from_rgb(99, 235, 231);
pub const WARM_COLOR: Color32 = Color32::from_rgb(225, 206, 67);
pub const SELECTED_ITEM_COLOR: Color32 = Color32::from_rgb(76, 93, 235);
pub const TEXT_COLOR: Color32 = Color32::WHITE;
29 changes: 29 additions & 0 deletions crates/editor_tabs/src/editor_tab.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use crate::NewTabBehaviour;
/// This module contains the implementation of the editor tabs
use bevy::prelude::*;
use bevy_egui::egui;

pub const TAB_MODES: [NewTabBehaviour; 3] = [
NewTabBehaviour::Pop,
NewTabBehaviour::SameNode,
NewTabBehaviour::SplitNode,
];

pub trait EditorTab {
fn ui(&mut self, ui: &mut egui::Ui, commands: &mut Commands, world: &mut World);
fn title(&self) -> egui::WidgetText;
}

#[derive(Clone, Hash, PartialEq, Eq, Debug, PartialOrd, Ord)]
pub enum EditorTabName {
CameraView,
EventDispatcher,
GameView,
Hierarchy,
Inspector,
Resource,
RuntimeAssets,
Settings,
ToolBox,
Other(String),
}
Loading
Loading