veloren_voxygen/ui/widgets/
ghost_image.rs1use conrod_core::{
2 Widget, WidgetCommon, image,
3 widget::{
4 self,
5 image::{State, Style},
6 },
7};
8
9#[derive(WidgetCommon)]
12pub struct GhostImage {
13 #[conrod(common_builder)]
14 common: widget::CommonBuilder,
15 image_id: image::Id,
16 style: Style,
17}
18
19impl GhostImage {
20 pub fn new(image_id: image::Id) -> Self {
21 Self {
22 common: widget::CommonBuilder::default(),
23 image_id,
24 style: Style::default(),
25 }
26 }
27}
28
29impl Widget for GhostImage {
30 type Event = ();
31 type State = State;
32 type Style = Style;
33
34 fn init_state(&self, _: widget::id::Generator) -> Self::State {
35 State {
36 src_rect: None,
37 image_id: self.image_id,
38 }
39 }
40
41 fn style(&self) -> Self::Style { self.style }
42
43 fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
44 let widget::UpdateArgs { state, .. } = args;
45
46 if state.image_id != self.image_id {
47 state.update(|state| state.image_id = self.image_id)
48 }
49 }
50
51 fn is_over(&self) -> widget::IsOverFn { |_, _, _| widget::IsOver::Bool(false) }
53}