mirror of
https://github.com/griffi-gh/hUI.git
synced 2024-11-29 10:18:56 -06:00
well it somewhat works, build using terrible hacks
This commit is contained in:
parent
c2d7542bb8
commit
6b2d4fbe36
|
@ -41,12 +41,18 @@ ui_main!(
|
||||||
Text::new("-")
|
Text::new("-")
|
||||||
.add_child(ui);
|
.add_child(ui);
|
||||||
})
|
})
|
||||||
.on_click(CounterSignal::Increment)
|
.on_click(CounterSignal::Decrement)
|
||||||
.add_child(ui);
|
.add_child(ui);
|
||||||
|
Container::default()
|
||||||
|
.with_size(size!(20, auto))
|
||||||
|
.with_align(Alignment::Center)
|
||||||
|
.with_children(|ui| {
|
||||||
Text::new(counter.to_string())
|
Text::new(counter.to_string())
|
||||||
.with_color(color::BLACK)
|
.with_color(color::BLACK)
|
||||||
.with_text_size(32)
|
.with_text_size(32)
|
||||||
.add_child(ui);
|
.add_child(ui);
|
||||||
|
})
|
||||||
|
.add_child(ui);
|
||||||
Container::default()
|
Container::default()
|
||||||
.with_padding(10.)
|
.with_padding(10.)
|
||||||
.with_corner_radius(8.)
|
.with_corner_radius(8.)
|
||||||
|
@ -55,7 +61,7 @@ ui_main!(
|
||||||
Text::new("+")
|
Text::new("+")
|
||||||
.add_child(ui);
|
.add_child(ui);
|
||||||
})
|
})
|
||||||
.on_click(CounterSignal::Decrement)
|
.on_click(CounterSignal::Increment)
|
||||||
.add_child(ui);
|
.add_child(ui);
|
||||||
})
|
})
|
||||||
.add_root(ui, size);
|
.add_root(ui, size);
|
||||||
|
|
|
@ -36,7 +36,7 @@ pub struct ProcessContext<'a> {
|
||||||
pub current_font: FontHandle,
|
pub current_font: FontHandle,
|
||||||
pub images: ImageCtx<'a>,
|
pub images: ImageCtx<'a>,
|
||||||
pub input: InputCtx<'a>,
|
pub input: InputCtx<'a>,
|
||||||
//pub signal: SignalCtx<'a>,
|
pub signal: SignalCtx<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait UiElement {
|
pub trait UiElement {
|
||||||
|
|
|
@ -4,11 +4,12 @@ use derive_setters::Setters;
|
||||||
use glam::{Vec2, vec2};
|
use glam::{Vec2, vec2};
|
||||||
use crate::{
|
use crate::{
|
||||||
background::BackgroundColor,
|
background::BackgroundColor,
|
||||||
draw::{RoundedCorners, ImageHandle, UiDrawCommand},
|
draw::{ImageHandle, RoundedCorners, UiDrawCommand},
|
||||||
element::{ElementList, MeasureContext, ProcessContext, UiElement},
|
element::{ElementList, MeasureContext, ProcessContext, UiElement},
|
||||||
layout::{Alignment, Alignment2d, LayoutInfo, Size, Size2d, Direction},
|
layout::{Alignment, Alignment2d, Direction, LayoutInfo, Size, Size2d},
|
||||||
measure::{Hints, Response},
|
measure::{Hints, Response},
|
||||||
rectangle::{Corners, Sides}
|
rectangle::{Corners, Sides},
|
||||||
|
signal::SignalCtx,
|
||||||
};
|
};
|
||||||
|
|
||||||
// pub struct Border {
|
// pub struct Border {
|
||||||
|
@ -453,6 +454,9 @@ impl UiElement for Container {
|
||||||
current_font: ctx.current_font,
|
current_font: ctx.current_font,
|
||||||
images: ctx.images,
|
images: ctx.images,
|
||||||
input: ctx.input,
|
input: ctx.input,
|
||||||
|
//HACK: i have no idea what to do with this
|
||||||
|
//this sucks
|
||||||
|
signal: SignalCtx(ctx.signal.0),
|
||||||
});
|
});
|
||||||
|
|
||||||
//layout
|
//layout
|
||||||
|
|
|
@ -56,7 +56,8 @@ impl<C: UiSignal + 'static> UiElement for Interactable<C> {
|
||||||
//XXX: should we do this AFTER normal process call of wrapped element?
|
//XXX: should we do this AFTER normal process call of wrapped element?
|
||||||
if ctx.input.check_click(rect) {
|
if ctx.input.check_click(rect) {
|
||||||
if let Some(sig) = self.signal.take() {
|
if let Some(sig) = self.signal.take() {
|
||||||
//ctx.signal.push(sig);
|
//HACK: Fucking whatever
|
||||||
|
ctx.signal.0.add(sig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,7 @@ impl UiElement for Transformer {
|
||||||
current_font: ctx.current_font,
|
current_font: ctx.current_font,
|
||||||
images: ctx.images,
|
images: ctx.images,
|
||||||
input: ctx.input,
|
input: ctx.input,
|
||||||
|
signal: ctx.signal,
|
||||||
});
|
});
|
||||||
ctx.draw.add(UiDrawCommand::PopTransform);
|
ctx.draw.add(UiDrawCommand::PopTransform);
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,6 +135,7 @@ impl UiInstance {
|
||||||
current_font: self.text_renderer.current_font(),
|
current_font: self.text_renderer.current_font(),
|
||||||
images: self.atlas.context(),
|
images: self.atlas.context(),
|
||||||
input: self.input.ctx(),
|
input: self.input.ctx(),
|
||||||
|
signal: self.signal.ctx(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ impl SigIntStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct SignalCtx<'a>(&'a mut SigIntStore);
|
pub struct SignalCtx<'a>(pub(crate) &'a mut SigIntStore);
|
||||||
|
|
||||||
impl<'a> SignalCtx<'a> {
|
impl<'a> SignalCtx<'a> {
|
||||||
/// Add a signal to the store
|
/// Add a signal to the store
|
||||||
|
|
Loading…
Reference in a new issue