clean up code and docs
This commit is contained in:
1 parent
4718668389
commit
d9276bd64c
7 files changed
+55
-105
No files matched your search
@@ -50,7 +50,7 @@ To run our app:
|
|||||||
$ cargo run
|
$ cargo run
|
||||||
```
|
```
|
||||||
|
|
||||||
Press "ctrl-c" to close the app. To switch from "ctrl-c" to just "q" to quit you can launch the app with a Configeration to disable the default quit and use the root TuiContext to quit on your own.
|
Press "ctrl-c" to close the app. To switch from "ctrl-c" to just "q" to quit you can launch the app with a configuration to disable the default quit and use the root TuiContext to quit on your own.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
// main
|
// main
|
||||||
|
|||||||
+15
-15
@@ -398,21 +398,21 @@ pub mod on {
|
|||||||
|
|
||||||
pub type ClipboardEvent = UiEvent<ClipboardData>;
|
pub type ClipboardEvent = UiEvent<ClipboardData>;
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ClipboardData {
|
pub struct ClipboardData {
|
||||||
// DOMDataTransfer clipboardData
|
// DOMDataTransfer clipboardData
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type CompositionEvent = UiEvent<CompositionData>;
|
pub type CompositionEvent = UiEvent<CompositionData>;
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct CompositionData {
|
pub struct CompositionData {
|
||||||
pub data: String,
|
pub data: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type KeyboardEvent = UiEvent<KeyboardData>;
|
pub type KeyboardEvent = UiEvent<KeyboardData>;
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct KeyboardData {
|
pub struct KeyboardData {
|
||||||
pub char_code: u32,
|
pub char_code: u32,
|
||||||
|
|
||||||
@@ -481,12 +481,12 @@ pub mod on {
|
|||||||
|
|
||||||
pub type FocusEvent = UiEvent<FocusData>;
|
pub type FocusEvent = UiEvent<FocusData>;
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct FocusData {/* DOMEventInner: Send + SyncTarget relatedTarget */}
|
pub struct FocusData {/* DOMEventInner: Send + SyncTarget relatedTarget */}
|
||||||
|
|
||||||
pub type FormEvent = UiEvent<FormData>;
|
pub type FormEvent = UiEvent<FormData>;
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct FormData {
|
pub struct FormData {
|
||||||
pub value: String,
|
pub value: String,
|
||||||
pub values: HashMap<String, String>,
|
pub values: HashMap<String, String>,
|
||||||
@@ -495,7 +495,7 @@ pub mod on {
|
|||||||
|
|
||||||
pub type MouseEvent = UiEvent<MouseData>;
|
pub type MouseEvent = UiEvent<MouseData>;
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct MouseData {
|
pub struct MouseData {
|
||||||
pub alt_key: bool,
|
pub alt_key: bool,
|
||||||
pub button: i16,
|
pub button: i16,
|
||||||
@@ -514,7 +514,7 @@ pub mod on {
|
|||||||
|
|
||||||
pub type PointerEvent = UiEvent<PointerData>;
|
pub type PointerEvent = UiEvent<PointerData>;
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct PointerData {
|
pub struct PointerData {
|
||||||
// Mouse only
|
// Mouse only
|
||||||
pub alt_key: bool,
|
pub alt_key: bool,
|
||||||
@@ -544,12 +544,12 @@ pub mod on {
|
|||||||
|
|
||||||
pub type SelectionEvent = UiEvent<SelectionData>;
|
pub type SelectionEvent = UiEvent<SelectionData>;
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct SelectionData {}
|
pub struct SelectionData {}
|
||||||
|
|
||||||
pub type TouchEvent = UiEvent<TouchData>;
|
pub type TouchEvent = UiEvent<TouchData>;
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct TouchData {
|
pub struct TouchData {
|
||||||
pub alt_key: bool,
|
pub alt_key: bool,
|
||||||
pub ctrl_key: bool,
|
pub ctrl_key: bool,
|
||||||
@@ -563,7 +563,7 @@ pub mod on {
|
|||||||
|
|
||||||
pub type WheelEvent = UiEvent<WheelData>;
|
pub type WheelEvent = UiEvent<WheelData>;
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct WheelData {
|
pub struct WheelData {
|
||||||
pub delta_mode: u32,
|
pub delta_mode: u32,
|
||||||
pub delta_x: f64,
|
pub delta_x: f64,
|
||||||
@@ -573,19 +573,19 @@ pub mod on {
|
|||||||
|
|
||||||
pub type MediaEvent = UiEvent<MediaData>;
|
pub type MediaEvent = UiEvent<MediaData>;
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct MediaData {}
|
pub struct MediaData {}
|
||||||
|
|
||||||
pub type ImageEvent = UiEvent<ImageData>;
|
pub type ImageEvent = UiEvent<ImageData>;
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ImageData {
|
pub struct ImageData {
|
||||||
pub load_error: bool,
|
pub load_error: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type AnimationEvent = UiEvent<AnimationData>;
|
pub type AnimationEvent = UiEvent<AnimationData>;
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct AnimationData {
|
pub struct AnimationData {
|
||||||
pub animation_name: String,
|
pub animation_name: String,
|
||||||
pub pseudo_element: String,
|
pub pseudo_element: String,
|
||||||
@@ -594,7 +594,7 @@ pub mod on {
|
|||||||
|
|
||||||
pub type TransitionEvent = UiEvent<TransitionData>;
|
pub type TransitionEvent = UiEvent<TransitionData>;
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct TransitionData {
|
pub struct TransitionData {
|
||||||
pub property_name: String,
|
pub property_name: String,
|
||||||
pub pseudo_element: String,
|
pub pseudo_element: String,
|
||||||
@@ -603,7 +603,7 @@ pub mod on {
|
|||||||
|
|
||||||
pub type ToggleEvent = UiEvent<ToggleData>;
|
pub type ToggleEvent = UiEvent<ToggleData>;
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ToggleData {}
|
pub struct ToggleData {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+18
-63
@@ -30,12 +30,12 @@ use crate::{Dom, Node};
|
|||||||
|
|
||||||
// pub fn mouse(&self) -> Option<MouseData> {
|
// pub fn mouse(&self) -> Option<MouseData> {
|
||||||
// let data = (**self.0).borrow();
|
// let data = (**self.0).borrow();
|
||||||
// data.mouse.as_ref().map(|m| clone_mouse_data(m))
|
// data.mouse.as_ref().map(|m| m.clone())
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// pub fn wheel(&self) -> Option<WheelData> {
|
// pub fn wheel(&self) -> Option<WheelData> {
|
||||||
// let data = (**self.0).borrow();
|
// let data = (**self.0).borrow();
|
||||||
// data.wheel.as_ref().map(|w| clone_wheel_data(w))
|
// data.wheel.as_ref().map(|w| w.clone())
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// pub fn screen(&self) -> Option<(u16, u16)> {
|
// pub fn screen(&self) -> Option<(u16, u16)> {
|
||||||
@@ -47,7 +47,7 @@ use crate::{Dom, Node};
|
|||||||
// let data = (**self.0).borrow();
|
// let data = (**self.0).borrow();
|
||||||
// data.last_key_pressed
|
// data.last_key_pressed
|
||||||
// .as_ref()
|
// .as_ref()
|
||||||
// .map(|k| clone_keyboard_data(&k.0))
|
// .map(|k| &k.0.clone())
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ impl InnerInputState {
|
|||||||
EventData::Mouse(ref mut m) => match &mut self.mouse {
|
EventData::Mouse(ref mut m) => match &mut self.mouse {
|
||||||
Some(state) => {
|
Some(state) => {
|
||||||
let mut buttons = state.0.buttons;
|
let mut buttons = state.0.buttons;
|
||||||
state.0 = clone_mouse_data(m);
|
state.0 = m.clone();
|
||||||
match evt.0 {
|
match evt.0 {
|
||||||
// this code only runs when there are no buttons down
|
// this code only runs when there are no buttons down
|
||||||
"mouseup" => {
|
"mouseup" => {
|
||||||
@@ -135,7 +135,7 @@ impl InnerInputState {
|
|||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
self.mouse = Some((
|
self.mouse = Some((
|
||||||
clone_mouse_data(m),
|
m.clone(),
|
||||||
if m.buttons == 0 {
|
if m.buttons == 0 {
|
||||||
Vec::new()
|
Vec::new()
|
||||||
} else {
|
} else {
|
||||||
@@ -144,7 +144,7 @@ impl InnerInputState {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
EventData::Wheel(ref w) => self.wheel = Some(clone_wheel_data(w)),
|
EventData::Wheel(ref w) => self.wheel = Some(w.clone()),
|
||||||
EventData::Screen(ref s) => self.screen = Some(*s),
|
EventData::Screen(ref s) => self.screen = Some(*s),
|
||||||
EventData::Keyboard(ref mut k) => {
|
EventData::Keyboard(ref mut k) => {
|
||||||
let repeat = self
|
let repeat = self
|
||||||
@@ -153,7 +153,7 @@ impl InnerInputState {
|
|||||||
.filter(|k2| k2.0.key == k.key && k2.1.elapsed() < MAX_REPEAT_TIME)
|
.filter(|k2| k2.0.key == k.key && k2.1.elapsed() < MAX_REPEAT_TIME)
|
||||||
.is_some();
|
.is_some();
|
||||||
k.repeat = repeat;
|
k.repeat = repeat;
|
||||||
let new = clone_keyboard_data(k);
|
let new = k.clone();
|
||||||
self.last_key_pressed = Some((new, Instant::now()));
|
self.last_key_pressed = Some((new, Instant::now()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -166,10 +166,7 @@ impl InnerInputState {
|
|||||||
layout: &Stretch,
|
layout: &Stretch,
|
||||||
dom: &mut Dom,
|
dom: &mut Dom,
|
||||||
) {
|
) {
|
||||||
let previous_mouse = self
|
let previous_mouse = self.mouse.as_ref().map(|m| (m.0.clone(), m.1.clone()));
|
||||||
.mouse
|
|
||||||
.as_ref()
|
|
||||||
.map(|m| (clone_mouse_data(&m.0), m.1.clone()));
|
|
||||||
|
|
||||||
self.wheel = None;
|
self.wheel = None;
|
||||||
|
|
||||||
@@ -269,7 +266,7 @@ impl InnerInputState {
|
|||||||
if currently_contains && previously_contained {
|
if currently_contains && previously_contained {
|
||||||
try_create_event(
|
try_create_event(
|
||||||
"mousemove",
|
"mousemove",
|
||||||
Arc::new(clone_mouse_data(data.mouse_data)),
|
Arc::new(data.mouse_data.clone()),
|
||||||
&mut will_bubble,
|
&mut will_bubble,
|
||||||
resolved_events,
|
resolved_events,
|
||||||
node,
|
node,
|
||||||
@@ -293,7 +290,7 @@ impl InnerInputState {
|
|||||||
if currently_contains && !previously_contained {
|
if currently_contains && !previously_contained {
|
||||||
try_create_event(
|
try_create_event(
|
||||||
"mouseenter",
|
"mouseenter",
|
||||||
Arc::new(clone_mouse_data(data.mouse_data)),
|
Arc::new(data.mouse_data.clone()),
|
||||||
&mut will_bubble,
|
&mut will_bubble,
|
||||||
resolved_events,
|
resolved_events,
|
||||||
node,
|
node,
|
||||||
@@ -317,7 +314,7 @@ impl InnerInputState {
|
|||||||
if currently_contains && !previously_contained {
|
if currently_contains && !previously_contained {
|
||||||
try_create_event(
|
try_create_event(
|
||||||
"mouseover",
|
"mouseover",
|
||||||
Arc::new(clone_mouse_data(data.mouse_data)),
|
Arc::new(data.mouse_data.clone()),
|
||||||
&mut will_bubble,
|
&mut will_bubble,
|
||||||
resolved_events,
|
resolved_events,
|
||||||
node,
|
node,
|
||||||
@@ -337,7 +334,7 @@ impl InnerInputState {
|
|||||||
if currently_contains && data.clicked {
|
if currently_contains && data.clicked {
|
||||||
try_create_event(
|
try_create_event(
|
||||||
"mousedown",
|
"mousedown",
|
||||||
Arc::new(clone_mouse_data(data.mouse_data)),
|
Arc::new(data.mouse_data.clone()),
|
||||||
&mut will_bubble,
|
&mut will_bubble,
|
||||||
resolved_events,
|
resolved_events,
|
||||||
node,
|
node,
|
||||||
@@ -357,7 +354,7 @@ impl InnerInputState {
|
|||||||
if currently_contains && data.released {
|
if currently_contains && data.released {
|
||||||
try_create_event(
|
try_create_event(
|
||||||
"mouseup",
|
"mouseup",
|
||||||
Arc::new(clone_mouse_data(data.mouse_data)),
|
Arc::new(data.mouse_data.clone()),
|
||||||
&mut will_bubble,
|
&mut will_bubble,
|
||||||
resolved_events,
|
resolved_events,
|
||||||
node,
|
node,
|
||||||
@@ -377,7 +374,7 @@ impl InnerInputState {
|
|||||||
if currently_contains && data.released && data.mouse_data.button == 0 {
|
if currently_contains && data.released && data.mouse_data.button == 0 {
|
||||||
try_create_event(
|
try_create_event(
|
||||||
"click",
|
"click",
|
||||||
Arc::new(clone_mouse_data(data.mouse_data)),
|
Arc::new(data.mouse_data.clone()),
|
||||||
&mut will_bubble,
|
&mut will_bubble,
|
||||||
resolved_events,
|
resolved_events,
|
||||||
node,
|
node,
|
||||||
@@ -397,7 +394,7 @@ impl InnerInputState {
|
|||||||
if currently_contains && data.released && data.mouse_data.button == 2 {
|
if currently_contains && data.released && data.mouse_data.button == 2 {
|
||||||
try_create_event(
|
try_create_event(
|
||||||
"contextmenu",
|
"contextmenu",
|
||||||
Arc::new(clone_mouse_data(data.mouse_data)),
|
Arc::new(data.mouse_data.clone()),
|
||||||
&mut will_bubble,
|
&mut will_bubble,
|
||||||
resolved_events,
|
resolved_events,
|
||||||
node,
|
node,
|
||||||
@@ -418,7 +415,7 @@ impl InnerInputState {
|
|||||||
if currently_contains && data.wheel_delta != 0.0 {
|
if currently_contains && data.wheel_delta != 0.0 {
|
||||||
try_create_event(
|
try_create_event(
|
||||||
"wheel",
|
"wheel",
|
||||||
Arc::new(clone_wheel_data(w)),
|
Arc::new(w.clone()),
|
||||||
&mut will_bubble,
|
&mut will_bubble,
|
||||||
resolved_events,
|
resolved_events,
|
||||||
node,
|
node,
|
||||||
@@ -443,7 +440,7 @@ impl InnerInputState {
|
|||||||
if !currently_contains && previously_contained {
|
if !currently_contains && previously_contained {
|
||||||
try_create_event(
|
try_create_event(
|
||||||
"mouseleave",
|
"mouseleave",
|
||||||
Arc::new(clone_mouse_data(data.mouse_data)),
|
Arc::new(data.mouse_data.clone()),
|
||||||
&mut will_bubble,
|
&mut will_bubble,
|
||||||
resolved_events,
|
resolved_events,
|
||||||
node,
|
node,
|
||||||
@@ -467,7 +464,7 @@ impl InnerInputState {
|
|||||||
if !currently_contains && previously_contained {
|
if !currently_contains && previously_contained {
|
||||||
try_create_event(
|
try_create_event(
|
||||||
"mouseout",
|
"mouseout",
|
||||||
Arc::new(clone_mouse_data(data.mouse_data)),
|
Arc::new(data.mouse_data.clone()),
|
||||||
&mut will_bubble,
|
&mut will_bubble,
|
||||||
resolved_events,
|
resolved_events,
|
||||||
node,
|
node,
|
||||||
@@ -786,45 +783,3 @@ fn translate_key_event(event: crossterm::event::KeyEvent) -> Option<EventData> {
|
|||||||
which: Default::default(),
|
which: Default::default(),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clone_mouse_data(m: &MouseData) -> MouseData {
|
|
||||||
MouseData {
|
|
||||||
client_x: m.client_x,
|
|
||||||
client_y: m.client_y,
|
|
||||||
page_x: m.page_x,
|
|
||||||
page_y: m.page_y,
|
|
||||||
screen_x: m.screen_x,
|
|
||||||
screen_y: m.screen_y,
|
|
||||||
alt_key: m.alt_key,
|
|
||||||
ctrl_key: m.ctrl_key,
|
|
||||||
meta_key: m.meta_key,
|
|
||||||
shift_key: m.shift_key,
|
|
||||||
button: m.button,
|
|
||||||
buttons: m.buttons,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn clone_keyboard_data(k: &KeyboardData) -> KeyboardData {
|
|
||||||
KeyboardData {
|
|
||||||
char_code: k.char_code,
|
|
||||||
key: k.key.clone(),
|
|
||||||
key_code: k.key_code,
|
|
||||||
alt_key: k.alt_key,
|
|
||||||
ctrl_key: k.ctrl_key,
|
|
||||||
meta_key: k.meta_key,
|
|
||||||
shift_key: k.shift_key,
|
|
||||||
locale: k.locale.clone(),
|
|
||||||
location: k.location,
|
|
||||||
repeat: k.repeat,
|
|
||||||
which: k.which,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn clone_wheel_data(w: &WheelData) -> WheelData {
|
|
||||||
WheelData {
|
|
||||||
delta_mode: w.delta_mode,
|
|
||||||
delta_x: w.delta_x,
|
|
||||||
delta_y: w.delta_y,
|
|
||||||
delta_z: w.delta_x,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -55,7 +55,7 @@ pub(crate) fn render_vnode(
|
|||||||
|
|
||||||
let label = Label {
|
let label = Label {
|
||||||
text,
|
text,
|
||||||
style: node.state.style.style,
|
style: node.state.style.core,
|
||||||
};
|
};
|
||||||
let area = Rect::new(*x as u16, *y as u16, *width as u16, *height as u16);
|
let area = Rect::new(*x as u16, *y as u16, *width as u16, *height as u16);
|
||||||
|
|
||||||
@@ -264,7 +264,7 @@ impl RinkWidget for &Node {
|
|||||||
for x in area.left()..area.right() {
|
for x in area.left()..area.right() {
|
||||||
for y in area.top()..area.bottom() {
|
for y in area.top()..area.bottom() {
|
||||||
let mut new_cell = RinkCell::default();
|
let mut new_cell = RinkCell::default();
|
||||||
if let Some(c) = self.state.style.style.bg {
|
if let Some(c) = self.state.style.core.bg {
|
||||||
new_cell.bg = c;
|
new_cell.bg = c;
|
||||||
}
|
}
|
||||||
buf.set(x, y, new_cell);
|
buf.set(x, y, new_cell);
|
||||||
@@ -288,7 +288,7 @@ impl RinkWidget for &Node {
|
|||||||
(last_r * RADIUS_MULTIPLIER[0]) as u16,
|
(last_r * RADIUS_MULTIPLIER[0]) as u16,
|
||||||
(last_r * RADIUS_MULTIPLIER[1]) as u16,
|
(last_r * RADIUS_MULTIPLIER[1]) as u16,
|
||||||
];
|
];
|
||||||
let color = current_edge.color.or(self.state.style.style.fg);
|
let color = current_edge.color.or(self.state.style.core.fg);
|
||||||
let mut new_cell = RinkCell::default();
|
let mut new_cell = RinkCell::default();
|
||||||
if let Some(c) = color {
|
if let Some(c) = color {
|
||||||
new_cell.fg = c;
|
new_cell.fg = c;
|
||||||
@@ -323,7 +323,7 @@ impl RinkWidget for &Node {
|
|||||||
(last_r * RADIUS_MULTIPLIER[0]) as u16,
|
(last_r * RADIUS_MULTIPLIER[0]) as u16,
|
||||||
(last_r * RADIUS_MULTIPLIER[1]) as u16,
|
(last_r * RADIUS_MULTIPLIER[1]) as u16,
|
||||||
];
|
];
|
||||||
let color = current_edge.color.or(self.state.style.style.fg);
|
let color = current_edge.color.or(self.state.style.core.fg);
|
||||||
let mut new_cell = RinkCell::default();
|
let mut new_cell = RinkCell::default();
|
||||||
if let Some(c) = color {
|
if let Some(c) = color {
|
||||||
new_cell.fg = c;
|
new_cell.fg = c;
|
||||||
@@ -358,7 +358,7 @@ impl RinkWidget for &Node {
|
|||||||
(last_r * RADIUS_MULTIPLIER[0]) as u16,
|
(last_r * RADIUS_MULTIPLIER[0]) as u16,
|
||||||
(last_r * RADIUS_MULTIPLIER[1]) as u16,
|
(last_r * RADIUS_MULTIPLIER[1]) as u16,
|
||||||
];
|
];
|
||||||
let color = current_edge.color.or(self.state.style.style.fg);
|
let color = current_edge.color.or(self.state.style.core.fg);
|
||||||
let mut new_cell = RinkCell::default();
|
let mut new_cell = RinkCell::default();
|
||||||
if let Some(c) = color {
|
if let Some(c) = color {
|
||||||
new_cell.fg = c;
|
new_cell.fg = c;
|
||||||
@@ -393,7 +393,7 @@ impl RinkWidget for &Node {
|
|||||||
(last_r * RADIUS_MULTIPLIER[0]) as u16,
|
(last_r * RADIUS_MULTIPLIER[0]) as u16,
|
||||||
(last_r * RADIUS_MULTIPLIER[1]) as u16,
|
(last_r * RADIUS_MULTIPLIER[1]) as u16,
|
||||||
];
|
];
|
||||||
let color = current_edge.color.or(self.state.style.style.fg);
|
let color = current_edge.color.or(self.state.style.core.fg);
|
||||||
let mut new_cell = RinkCell::default();
|
let mut new_cell = RinkCell::default();
|
||||||
if let Some(c) = color {
|
if let Some(c) = color {
|
||||||
new_cell.fg = c;
|
new_cell.fg = c;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ use crate::style::{RinkColor, RinkStyle};
|
|||||||
|
|
||||||
#[derive(Default, Clone, PartialEq, Debug)]
|
#[derive(Default, Clone, PartialEq, Debug)]
|
||||||
pub struct StyleModifier {
|
pub struct StyleModifier {
|
||||||
pub style: RinkStyle,
|
pub core: RinkStyle,
|
||||||
pub modifier: TuiModifier,
|
pub modifier: TuiModifier,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ impl ParentDepState for StyleModifier {
|
|||||||
fn reduce(&mut self, node: NodeView, parent: Option<&Self::DepState>, _: &Self::Ctx) -> bool {
|
fn reduce(&mut self, node: NodeView, parent: Option<&Self::DepState>, _: &Self::Ctx) -> bool {
|
||||||
let mut new = StyleModifier::default();
|
let mut new = StyleModifier::default();
|
||||||
if parent.is_some() {
|
if parent.is_some() {
|
||||||
new.style.fg = None;
|
new.core.fg = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle text modifier elements
|
// handle text modifier elements
|
||||||
@@ -84,9 +84,9 @@ impl ParentDepState for StyleModifier {
|
|||||||
|
|
||||||
// keep the text styling from the parent element
|
// keep the text styling from the parent element
|
||||||
if let Some(parent) = parent {
|
if let Some(parent) = parent {
|
||||||
let mut new_style = new.style.merge(parent.style);
|
let mut new_style = new.core.merge(parent.core);
|
||||||
new_style.bg = new.style.bg;
|
new_style.bg = new.core.bg;
|
||||||
new.style = new_style;
|
new.core = new_style;
|
||||||
}
|
}
|
||||||
if &mut new != self {
|
if &mut new != self {
|
||||||
*self = new;
|
*self = new;
|
||||||
@@ -255,7 +255,7 @@ pub fn apply_style_attributes(
|
|||||||
|
|
||||||
"color" => {
|
"color" => {
|
||||||
if let Ok(c) = value.parse() {
|
if let Ok(c) = value.parse() {
|
||||||
style.style.fg.replace(c);
|
style.core.fg.replace(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,7 +324,7 @@ fn apply_background(name: &str, value: &str, style: &mut StyleModifier) {
|
|||||||
match name {
|
match name {
|
||||||
"background-color" => {
|
"background-color" => {
|
||||||
if let Ok(c) = value.parse() {
|
if let Ok(c) = value.parse() {
|
||||||
style.style.bg.replace(c);
|
style.core.bg.replace(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"background" => {}
|
"background" => {}
|
||||||
@@ -546,14 +546,14 @@ fn apply_font(name: &str, value: &str, style: &mut StyleModifier) {
|
|||||||
"font-size-adjust" => (),
|
"font-size-adjust" => (),
|
||||||
"font-stretch" => (),
|
"font-stretch" => (),
|
||||||
"font-style" => match value {
|
"font-style" => match value {
|
||||||
"italic" => style.style = style.style.add_modifier(Modifier::ITALIC),
|
"italic" => style.core = style.core.add_modifier(Modifier::ITALIC),
|
||||||
"oblique" => style.style = style.style.add_modifier(Modifier::ITALIC),
|
"oblique" => style.core = style.core.add_modifier(Modifier::ITALIC),
|
||||||
_ => (),
|
_ => (),
|
||||||
},
|
},
|
||||||
"font-variant" => todo!(),
|
"font-variant" => todo!(),
|
||||||
"font-weight" => match value {
|
"font-weight" => match value {
|
||||||
"bold" => style.style = style.style.add_modifier(Modifier::BOLD),
|
"bold" => style.core = style.core.add_modifier(Modifier::BOLD),
|
||||||
"normal" => style.style = style.style.remove_modifier(Modifier::BOLD),
|
"normal" => style.core = style.core.remove_modifier(Modifier::BOLD),
|
||||||
_ => (),
|
_ => (),
|
||||||
},
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
@@ -569,8 +569,8 @@ fn apply_text(name: &str, value: &str, style: &mut StyleModifier) {
|
|||||||
"text-decoration" | "text-decoration-line" => {
|
"text-decoration" | "text-decoration-line" => {
|
||||||
for v in value.split(' ') {
|
for v in value.split(' ') {
|
||||||
match v {
|
match v {
|
||||||
"line-through" => style.style = style.style.add_modifier(Modifier::CROSSED_OUT),
|
"line-through" => style.core = style.core.add_modifier(Modifier::CROSSED_OUT),
|
||||||
"underline" => style.style = style.style.add_modifier(Modifier::UNDERLINED),
|
"underline" => style.core = style.core.add_modifier(Modifier::UNDERLINED),
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,11 +90,4 @@ fn margin_and_flex_row2() {
|
|||||||
assert_eq!(stretch.layout(node).unwrap().size.height, 100f32);
|
assert_eq!(stretch.layout(node).unwrap().size.height, 100f32);
|
||||||
assert_eq!(stretch.layout(node).unwrap().location.x, 0f32);
|
assert_eq!(stretch.layout(node).unwrap().location.x, 0f32);
|
||||||
assert_eq!(stretch.layout(node).unwrap().location.y, 0f32);
|
assert_eq!(stretch.layout(node).unwrap().location.y, 0f32);
|
||||||
|
|
||||||
dbg!(stretch.layout(node0)).unwrap();
|
|
||||||
|
|
||||||
// assert_eq!(stretch.layout(node0).unwrap().size.width, 80f32);
|
|
||||||
// assert_eq!(stretch.layout(node0).unwrap().size.height, 100f32);
|
|
||||||
// assert_eq!(stretch.layout(node0).unwrap().location.x, 10f32);
|
|
||||||
// assert_eq!(stretch.layout(node0).unwrap().location.y, 0f32);
|
|
||||||
}
|
}
|
||||||
@@ -33,6 +33,8 @@ pub use dioxus_tui as tui;
|
|||||||
|
|
||||||
#[cfg(feature = "native-core")]
|
#[cfg(feature = "native-core")]
|
||||||
pub use dioxus_native_core as native_core;
|
pub use dioxus_native_core as native_core;
|
||||||
|
#[cfg(feature = "native-core")]
|
||||||
|
pub use dioxus_native_core_macro as native_core_macro;
|
||||||
|
|
||||||
#[cfg(feature = "fermi")]
|
#[cfg(feature = "fermi")]
|
||||||
pub use fermi;
|
pub use fermi;
|
||||||
|
|||||||
Reference in new issue
Block a user