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