Skip to content

Instantly share code, notes, and snippets.

View PsichiX's full-sized avatar
👨‍🔬
For the Symmetry!

Patryk Budzyński PsichiX

👨‍🔬
For the Symmetry!
View GitHub Profile
@PsichiX
PsichiX / test.rs
Last active March 15, 2024 02:55
Intuicio - Name and Text framework
use intuicio_core::prelude::*;
use intuicio_data::prelude::*;
use intuicio_derive::*;
use intuicio_framework_text::{Name, Text};
use std::collections::HashMap;
#[derive(IntuicioStruct, Debug, Default)]
#[intuicio(module_name = "test")]
struct Loc {
#[intuicio(ignore)]
@PsichiX
PsichiX / ecs.rs
Created February 24, 2024 00:06
Intuicio with hecs example
use hecs::World;
use intuicio_core::prelude::*;
use intuicio_data::{
lifetime::Lifetime,
managed::{ManagedRef, ManagedRefMut},
};
use intuicio_derive::*;
#[derive(IntuicioStruct, Default)]
struct Health {
@PsichiX
PsichiX / immediate_mode_access_and_tests.rs
Last active October 23, 2023 23:53
RAUI's immediate mode `use_access` allows GUI testing with mock data
#[allow(unused_imports)]
use raui_app::prelude::*;
use raui_immediate::*;
mod gui {
use raui_immediate::*;
use raui_immediate_widgets::prelude::*;
pub fn app() {
nav_content_box((), || {
@PsichiX
PsichiX / immediate_mode_states_and_effects.rs
Created October 15, 2023 01:31
RAUI immediate mode - states and effects
// Make sure you have seen `immediate_mode` code example first, because this is a continuation of that.
use raui_immediate::{make_widgets, ImmediateContext};
use raui_quick_start::RauiQuickStartBuilder;
const FONT: &str = "./demos/hello-world/resources/verdana.ttf";
mod gui {
use raui_immediate::*;
use raui_immediate_widgets::prelude::*;
@PsichiX
PsichiX / immediate_mode.rs
Last active October 14, 2023 21:41
RAUI immediate mode experiments
// Example of immediate mode UI on top of RAUI.
// It's goal is to bring more ergonomics to RAUI by hiding
// declarative interface under simple nested function calls.
// As with retained mode, immediate mode UI can be mixed with
// declarative mode and retained mode widgets.
use raui_immediate::{make_widgets, ImmediateContext};
use raui_quick_start::RauiQuickStartBuilder;
const FONT: &str = "./demos/hello-world/resources/verdana.ttf";
@PsichiX
PsichiX / retained_mode.rs
Last active October 12, 2023 23:52
RAUI retained mode experiments
// Example of retained mode UI on top of RAUI.
// It's goals are very similar to Unreal's UMG on top of Slate.
// Evolution of this approach allows to use retained mode views
// within declarative mode widgets and vice versa - they
// interleave quite seamingly.
use raui::prelude::*;
use raui_quick_start::RauiQuickStartBuilder;
use raui_retained::*;
use std::any::Any;
@PsichiX
PsichiX / retained_mode.rs
Created October 12, 2023 02:26
RAUI retained mode experiments
use raui::prelude::*;
use raui_quick_start::RauiQuickStartBuilder;
use std::any::Any;
#[derive(Default)]
struct AppView {
pub icons: View<ListView<IconView>>,
}
impl ViewState for AppView {
@PsichiX
PsichiX / raui_view_model_example.rs
Last active October 9, 2023 23:46
RAUI view-model example
use raui::prelude::*;
use raui_quick_start::{
tetra::{input::Key, Event},
RauiQuickStartBuilder,
};
// Name of View-Model instance.
const DATA: &str = "data";
// Name of View-Model property notification.
const COUNTER: &str = "counter";
@PsichiX
PsichiX / test_view_model.rs
Created October 9, 2023 17:19
View-Model usage test
const FOO_VIEW_MODEL: &str = "foo";
const COUNTER_PROPERTY: &str = "counter";
const FLAG_PROPERTY: &str = "flag";
// view-model data type
struct Foo {
// can hold view-model value wrapper that implicitly notifies on mutation.
counter: ViewModelValue<usize>,
// or can hold raw notifiers to explicitly notify.
flag: bool,
@PsichiX
PsichiX / intuicio_gc_integration_test.rs
Last active October 7, 2023 21:38
Intuicio + GC integration test
use gc::{Finalize as GcFinalize, Gc, Trace as GcTrace};
use intuicio_core::prelude::*;
use intuicio_derive::*;
#[intuicio_function(module_name = "test")]
fn add(a: Gc<i32>, b: Gc<i32>) -> Gc<i32> {
let c = *a + *b;
println!("add | {} + {} = {}", *a, *b, c);
Gc::new(c)
}