Rebrand to Galaxy, major improvements to Bedrock support, still needs some TLC though

This commit is contained in:
Ryan Ward
2026-05-07 11:29:34 -05:00
parent f4e2475c60
commit a41cbd8cc7
2433 changed files with 14208 additions and 9409 deletions
@@ -0,0 +1,34 @@
use anyhow::{anyhow, Result};
use root_view::RootView;
use std::borrow::Cow;
pub mod root_view;
extern crate galaxyui;
use rust_embed::RustEmbed;
use galaxyui::{platform, AssetProvider};
#[derive(Clone, Copy, RustEmbed)]
#[folder = "examples/assets"]
pub struct Assets;
// The static assets we need to load in app.
pub static ASSETS: Assets = Assets;
// Implement the AssetProvider trait here (required by App::new).
impl AssetProvider for Assets {
fn get(&self, path: &str) -> Result<Cow<'_, [u8]>> {
<Assets as RustEmbed>::get(path)
.map(|f| f.data)
.ok_or_else(|| anyhow!("no asset exists at path {}", path))
}
}
fn main() -> Result<()> {
let app_builder =
platform::AppBuilder::new(platform::AppCallbacks::default(), Box::new(ASSETS), None);
let _ = app_builder.run(move |ctx| {
ctx.add_window(galaxyui::AddWindowOptions::default(), |_| RootView::new());
});
Ok(())
}
@@ -0,0 +1,99 @@
use instant::Instant;
use galaxyui::{
assets::asset_cache::AssetSource,
elements::{
CacheOption, ConstrainedBox, CrossAxisAlignment, Flex, Image, ParentElement, Shrinkable,
Stack,
},
AppContext, Element, Entity, TypedActionView, View,
};
pub struct RootView {
animation_start_time: Instant,
}
impl RootView {
pub fn new() -> Self {
println!(
"WARN: This example is slow to start up due to the huge GIF. Compiling with --release \
helps."
);
RootView {
animation_start_time: Instant::now(),
}
}
}
impl Default for RootView {
fn default() -> Self {
Self::new()
}
}
impl Entity for RootView {
type Event = ();
}
impl View for RootView {
fn ui_name() -> &'static str {
"RootView"
}
fn render(&self, _: &AppContext) -> Box<dyn Element> {
Stack::new()
.with_child(
Shrinkable::new(
1.,
Image::new(
AssetSource::Bundled {
path: "rustyrain.gif",
},
CacheOption::Original,
)
.enable_animation_with_start_time(self.animation_start_time)
.cover()
.finish(),
)
.finish(),
)
.with_child(
Flex::row()
.with_cross_axis_alignment(CrossAxisAlignment::Center)
.with_child(
ConstrainedBox::new(
Image::new(
AssetSource::Bundled {
path: "numbers-1000ms.gif",
},
CacheOption::BySize,
)
.enable_animation_with_start_time(self.animation_start_time)
.finish(),
)
.with_height(350.)
.with_width(350.)
.finish(),
)
.with_child(
ConstrainedBox::new(
Image::new(
AssetSource::Bundled {
path: "numbers-750ms.gif",
},
CacheOption::BySize,
)
.enable_animation_with_start_time(self.animation_start_time)
.finish(),
)
.with_height(350.)
.with_width(350.)
.finish(),
)
.finish(),
)
.finish()
}
}
impl TypedActionView for RootView {
type Action = ();
}