mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Improve naming of checkbox images related methods
This commit is contained in:
parent
f27a7853a3
commit
80190c408d
@ -4,7 +4,7 @@ use super::super::super::widget::image;
|
|||||||
struct Background {
|
struct Background {
|
||||||
default: image::Handle,
|
default: image::Handle,
|
||||||
hover: image::Handle,
|
hover: image::Handle,
|
||||||
press: image::Handle,
|
checked: image::Handle,
|
||||||
hover_checked: image::Handle,
|
hover_checked: image::Handle,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ impl Background {
|
|||||||
Self {
|
Self {
|
||||||
default: image,
|
default: image,
|
||||||
hover: image,
|
hover: image,
|
||||||
press: image,
|
checked: image,
|
||||||
hover_checked: image,
|
hover_checked: image,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -22,18 +22,18 @@ impl Background {
|
|||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct Style {
|
pub struct Style {
|
||||||
background: Option<Background>,
|
background: Option<Background>,
|
||||||
checked: Option<image::Handle>,
|
check: Option<image::Handle>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Style {
|
impl Style {
|
||||||
pub fn new(image: image::Handle, checked: image::Handle) -> Self {
|
pub fn new(image: image::Handle, check: image::Handle) -> Self {
|
||||||
Self {
|
Self {
|
||||||
background: Some(Background::new(image)),
|
background: Some(Background::new(image)),
|
||||||
checked: Some(checked),
|
check: Some(check),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn hover_image(mut self, image: image::Handle) -> Self {
|
pub fn bg_hover_image(mut self, image: image::Handle) -> Self {
|
||||||
self.background = Some(match self.background {
|
self.background = Some(match self.background {
|
||||||
Some(mut background) => {
|
Some(mut background) => {
|
||||||
background.hover = image;
|
background.hover = image;
|
||||||
@ -44,10 +44,10 @@ impl Style {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn press_image(mut self, image: image::Handle) -> Self {
|
pub fn bg_checked_image(mut self, image: image::Handle) -> Self {
|
||||||
self.background = Some(match self.background {
|
self.background = Some(match self.background {
|
||||||
Some(mut background) => {
|
Some(mut background) => {
|
||||||
background.press = image;
|
background.checked = image;
|
||||||
background
|
background
|
||||||
},
|
},
|
||||||
None => Background::new(image),
|
None => Background::new(image),
|
||||||
@ -55,7 +55,7 @@ impl Style {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn hover_checked_image(mut self, image: image::Handle) -> Self {
|
pub fn bg_hover_checked_image(mut self, image: image::Handle) -> Self {
|
||||||
self.background = Some(match self.background {
|
self.background = Some(match self.background {
|
||||||
Some(mut background) => {
|
Some(mut background) => {
|
||||||
background.hover_checked = image;
|
background.hover_checked = image;
|
||||||
@ -66,13 +66,15 @@ impl Style {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn checked(&self) -> Option<image::Handle> { self.checked }
|
pub fn check(&self) -> Option<image::Handle> { self.check }
|
||||||
|
|
||||||
pub fn bg_check(&self) -> Option<image::Handle> { self.background.as_ref().map(|b| b.press) }
|
pub fn bg_checked(&self) -> Option<image::Handle> {
|
||||||
|
self.background.as_ref().map(|b| b.checked)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn bg_hover(&self) -> Option<image::Handle> { self.background.as_ref().map(|b| b.hover) }
|
pub fn bg_hover(&self) -> Option<image::Handle> { self.background.as_ref().map(|b| b.hover) }
|
||||||
|
|
||||||
pub fn bg_hover_check(&self) -> Option<image::Handle> {
|
pub fn bg_hover_checked(&self) -> Option<image::Handle> {
|
||||||
self.background.as_ref().map(|b| b.hover_checked)
|
self.background.as_ref().map(|b| b.hover_checked)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +87,7 @@ impl Default for Style {
|
|||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
background: None,
|
background: None,
|
||||||
checked: None,
|
check: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,8 @@ impl checkbox::Renderer for IcedRenderer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let background_image = match (is_checked, is_mouse_over) {
|
let background_image = match (is_checked, is_mouse_over) {
|
||||||
(true, true) => style.bg_hover_check(),
|
(true, true) => style.bg_hover_checked(),
|
||||||
(true, false) => style.bg_check(),
|
(true, false) => style.bg_checked(),
|
||||||
(false, true) => style.bg_hover(),
|
(false, true) => style.bg_hover(),
|
||||||
(false, false) => style.bg_default(),
|
(false, false) => style.bg_default(),
|
||||||
};
|
};
|
||||||
@ -41,7 +41,7 @@ impl checkbox::Renderer for IcedRenderer {
|
|||||||
Primitive::Group {
|
Primitive::Group {
|
||||||
primitives: if is_checked {
|
primitives: if is_checked {
|
||||||
let check = style
|
let check = style
|
||||||
.checked()
|
.check()
|
||||||
.map(|image| Primitive::Image {
|
.map(|image| Primitive::Image {
|
||||||
handle: (image, Rotation::None),
|
handle: (image, Rotation::None),
|
||||||
bounds,
|
bounds,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user