Skip to content
Snippets Groups Projects
Commit c4220891 authored by MrGVSV's avatar MrGVSV
Browse files

Updated Todo example with cursor icons

parent 23938a80
No related branches found
No related tags found
No related merge requests found
use kayak_core::CursorIcon;
use kayak_ui::core::{
color::Color,
render_command::RenderCommand,
......@@ -31,11 +32,17 @@ pub fn AddButton(props: AddButtonProps) {
let background_styles = Some(Style {
border_radius: StyleProp::Value((5.0, 5.0, 5.0, 5.0)),
background_color: StyleProp::Value(color),
cursor: CursorIcon::Hand.into(),
padding_left: StyleProp::Value(Units::Pixels(9.0)),
padding_bottom: StyleProp::Value(Units::Pixels(6.0)),
..Style::default()
});
let text_styles = Some(Style {
cursor: StyleProp::Inherit,
..Style::default()
});
let on_event = OnEvent::new(move |_, event| match event.event_type {
EventType::MouseIn(..) => {
set_color(Color::new(0.0791, 0.0998, 0.201, 1.0));
......@@ -48,7 +55,7 @@ pub fn AddButton(props: AddButtonProps) {
rsx! {
<Background styles={background_styles} on_event={Some(on_event)}>
<Text content={"+".to_string()} size={20.0} />
<Text content={"+".to_string()} size={20.0} styles={text_styles} />
</Background>
}
}
use kayak_core::CursorIcon;
use kayak_ui::core::{
color::Color,
render_command::RenderCommand,
......@@ -32,10 +33,16 @@ pub fn DeleteButton(props: DeleteButtonProps) {
let background_styles = Some(Style {
border_radius: StyleProp::Value((5.0, 5.0, 5.0, 5.0)),
background_color: StyleProp::Value(color),
cursor: CursorIcon::Hand.into(),
padding_left: StyleProp::Value(Units::Pixels(8.0)),
..Style::default()
});
let text_styles = Some(Style {
cursor: StyleProp::Inherit,
..Style::default()
});
let on_event = OnEvent::new(move |_, event| match event.event_type {
EventType::MouseIn(..) => {
set_color(Color::new(0.0791, 0.0998, 0.201, 1.0));
......@@ -48,7 +55,7 @@ pub fn DeleteButton(props: DeleteButtonProps) {
rsx! {
<Background styles={background_styles} on_event={Some(on_event)}>
<Text content={"X".to_string()} size={20.0} />
<Text content={"X".to_string()} size={20.0} styles={text_styles} />
</Background>
}
}
......@@ -83,7 +83,7 @@ fn TodoApp(props: TodoAppProps) {
});
rsx! {
<Window position={(415.0, 50.0)} size={(450.0, 600.0)} title={"Todo!".to_string()}>
<Window draggable={true} position={(415.0, 50.0)} size={(450.0, 600.0)} title={"Todo!".to_string()}>
<Element styles={Some(top_area_styles)}>
<TextBox
styles={Some(text_box_styles)}
......
......@@ -565,6 +565,7 @@ impl KayakContext {
self.cursor_icon
}
#[allow(dead_code)]
pub(crate) fn set_cursor_icon(&mut self, icon: CursorIcon) {
self.cursor_icon = icon;
}
......
......@@ -89,10 +89,14 @@ pub fn Window(props: WindowProps) {
..Style::default()
};
let cursor = if is_dragging {
CursorIcon::Grabbing
let cursor = if draggable {
if is_dragging {
CursorIcon::Grabbing
} else {
CursorIcon::Grab
}
} else {
CursorIcon::Grab
CursorIcon::Default
};
let title_background_styles = Style {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment