Merge remote-tracking branch 'origin/master' into tui_focus
This commit is contained in:
commit
bd105c9bc6
6 files changed
+95
-78
No files matched your search
@@ -38,7 +38,7 @@ jobs:
|
|||||||
override: true
|
override: true
|
||||||
- uses: Swatinem/rust-cache@v1
|
- uses: Swatinem/rust-cache@v1
|
||||||
- run: sudo apt-get update
|
- run: sudo apt-get update
|
||||||
- run: sudo apt install libwebkit2gtk-4.0-dev libappindicator3-dev libgtk-3-dev
|
- run: sudo apt install libwebkit2gtk-4.0-dev libgtk-3-dev libayatana-appindicator3-dev
|
||||||
- uses: actions-rs/cargo@v1
|
- uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: check
|
command: check
|
||||||
@@ -56,7 +56,7 @@ jobs:
|
|||||||
override: true
|
override: true
|
||||||
- uses: Swatinem/rust-cache@v1
|
- uses: Swatinem/rust-cache@v1
|
||||||
- run: sudo apt-get update
|
- run: sudo apt-get update
|
||||||
- run: sudo apt install libwebkit2gtk-4.0-dev libappindicator3-dev libgtk-3-dev
|
- run: sudo apt install libwebkit2gtk-4.0-dev libgtk-3-dev libayatana-appindicator3-dev
|
||||||
- uses: davidB/rust-cargo-make@v1
|
- uses: davidB/rust-cargo-make@v1
|
||||||
- uses: browser-actions/setup-firefox@latest
|
- uses: browser-actions/setup-firefox@latest
|
||||||
- uses: jetli/wasm-pack-action@v0.3.0
|
- uses: jetli/wasm-pack-action@v0.3.0
|
||||||
@@ -96,7 +96,7 @@ jobs:
|
|||||||
override: true
|
override: true
|
||||||
- uses: Swatinem/rust-cache@v1
|
- uses: Swatinem/rust-cache@v1
|
||||||
- run: sudo apt-get update
|
- run: sudo apt-get update
|
||||||
- run: sudo apt install libwebkit2gtk-4.0-dev libappindicator3-dev libgtk-3-dev
|
- run: sudo apt install libwebkit2gtk-4.0-dev libgtk-3-dev libayatana-appindicator3-dev
|
||||||
- run: rustup component add clippy
|
- run: rustup component add clippy
|
||||||
- uses: actions-rs/cargo@v1
|
- uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
@@ -117,7 +117,7 @@ jobs:
|
|||||||
# run: |
|
# run: |
|
||||||
# apt-get update &&\
|
# apt-get update &&\
|
||||||
# apt-get install build-essential &&\
|
# apt-get install build-essential &&\
|
||||||
# apt install libwebkit2gtk-4.0-dev libappindicator3-dev libgtk-3-dev -y &&\
|
# apt install libwebkit2gtk-4.0-dev libgtk-3-dev libayatana-appindicator3-dev -y &&\
|
||||||
# cargo +nightly tarpaulin --verbose --all-features --workspace --timeout 120 --out Xml
|
# cargo +nightly tarpaulin --verbose --all-features --workspace --timeout 120 --out Xml
|
||||||
# - name: Upload to codecov.io
|
# - name: Upload to codecov.io
|
||||||
# uses: codecov/codecov-action@v2
|
# uses: codecov/codecov-action@v2
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
use std::fmt::Formatter;
|
use std::fmt::Formatter;
|
||||||
|
|
||||||
|
/// Possible values for an attribute
|
||||||
// trying to keep values at 3 bytes
|
// trying to keep values at 3 bytes
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||||
|
#[cfg_attr(feature = "serialize", serde(untagged))]
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
|
#[allow(missing_docs)]
|
||||||
pub enum AttributeValue<'a> {
|
pub enum AttributeValue<'a> {
|
||||||
Text(&'a str),
|
Text(&'a str),
|
||||||
Float32(f32),
|
Float32(f32),
|
||||||
@@ -25,6 +28,8 @@ pub enum AttributeValue<'a> {
|
|||||||
Any(ArbitraryAttributeValue<'a>),
|
Any(ArbitraryAttributeValue<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo
|
||||||
|
#[allow(missing_docs)]
|
||||||
impl<'a> AttributeValue<'a> {
|
impl<'a> AttributeValue<'a> {
|
||||||
pub fn is_truthy(&self) -> bool {
|
pub fn is_truthy(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
@@ -112,6 +117,8 @@ impl<'de, 'a> serde::Deserialize<'de> for ArbitraryAttributeValue<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo
|
||||||
|
#[allow(missing_docs)]
|
||||||
impl<'a> AttributeValue<'a> {
|
impl<'a> AttributeValue<'a> {
|
||||||
pub fn as_text(&self) -> Option<&'a str> {
|
pub fn as_text(&self) -> Option<&'a str> {
|
||||||
match self {
|
match self {
|
||||||
|
|||||||
@@ -73,10 +73,10 @@ pub(crate) mod innerlude {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub use crate::innerlude::{
|
pub use crate::innerlude::{
|
||||||
AnyEvent, Attribute, Component, DioxusElement, DomEdit, Element, ElementId, ElementIdIterator,
|
AnyEvent, Attribute, AttributeValue, Component, DioxusElement, DomEdit, Element, ElementId,
|
||||||
EventHandler, EventPriority, IntoVNode, LazyNodes, Listener, Mutations, NodeFactory,
|
ElementIdIterator, EventHandler, EventPriority, IntoVNode, LazyNodes, Listener, Mutations,
|
||||||
Properties, SchedulerMsg, Scope, ScopeId, ScopeState, TaskId, UiEvent, UserEvent, VComponent,
|
NodeFactory, Properties, SchedulerMsg, Scope, ScopeId, ScopeState, TaskId, UiEvent, UserEvent,
|
||||||
VElement, VFragment, VNode, VPlaceholder, VText, VirtualDom,
|
VComponent, VElement, VFragment, VNode, VPlaceholder, VText, VirtualDom,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The purpose of this module is to alleviate imports of many common types
|
/// The purpose of this module is to alleviate imports of many common types
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use anymap::AnyMap;
|
use anymap::AnyMap;
|
||||||
|
use dioxus_core::AttributeValue;
|
||||||
use dioxus_core::VNode;
|
use dioxus_core::VNode;
|
||||||
use dioxus_core::*;
|
use dioxus_core::*;
|
||||||
use dioxus_core_macro::*;
|
use dioxus_core_macro::*;
|
||||||
@@ -347,7 +348,7 @@ fn state_reduce_parent_called_minimally_on_update() {
|
|||||||
edits: vec![DomEdit::SetAttribute {
|
edits: vec![DomEdit::SetAttribute {
|
||||||
root: 1,
|
root: 1,
|
||||||
field: "width",
|
field: "width",
|
||||||
value: "99%",
|
value: AttributeValue::Text("99%"),
|
||||||
ns: Some("style"),
|
ns: Some("style"),
|
||||||
}],
|
}],
|
||||||
dirty_scopes: fxhash::FxHashSet::default(),
|
dirty_scopes: fxhash::FxHashSet::default(),
|
||||||
@@ -416,7 +417,7 @@ fn state_reduce_child_called_minimally_on_update() {
|
|||||||
edits: vec![DomEdit::SetAttribute {
|
edits: vec![DomEdit::SetAttribute {
|
||||||
root: 4,
|
root: 4,
|
||||||
field: "width",
|
field: "width",
|
||||||
value: "99%",
|
value: AttributeValue::Text("99%"),
|
||||||
ns: Some("style"),
|
ns: Some("style"),
|
||||||
}],
|
}],
|
||||||
dirty_scopes: fxhash::FxHashSet::default(),
|
dirty_scopes: fxhash::FxHashSet::default(),
|
||||||
|
|||||||
+75
-66
@@ -376,78 +376,18 @@ impl InnerInputState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// mouseup
|
{
|
||||||
if released {
|
// mouseup
|
||||||
let mut will_bubble = FxHashSet::default();
|
if released {
|
||||||
for node in dom.get_listening_sorted("mouseup") {
|
|
||||||
let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
|
||||||
let currently_contains = layout_contains_point(node_layout, new_pos);
|
|
||||||
|
|
||||||
if currently_contains {
|
|
||||||
try_create_event(
|
|
||||||
"mouseup",
|
|
||||||
Arc::new(prepare_mouse_data(mouse_data, node_layout)),
|
|
||||||
&mut will_bubble,
|
|
||||||
resolved_events,
|
|
||||||
node,
|
|
||||||
dom,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// click
|
|
||||||
if released && mouse_data.button == 0 {
|
|
||||||
let mut will_bubble = FxHashSet::default();
|
|
||||||
for node in dom.get_listening_sorted("click") {
|
|
||||||
let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
|
||||||
let currently_contains = layout_contains_point(node_layout, new_pos);
|
|
||||||
|
|
||||||
if currently_contains {
|
|
||||||
try_create_event(
|
|
||||||
"click",
|
|
||||||
Arc::new(prepare_mouse_data(mouse_data, node_layout)),
|
|
||||||
&mut will_bubble,
|
|
||||||
resolved_events,
|
|
||||||
node,
|
|
||||||
dom,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// contextmenu
|
|
||||||
if released && mouse_data.button == 2 {
|
|
||||||
let mut will_bubble = FxHashSet::default();
|
|
||||||
for node in dom.get_listening_sorted("contextmenu") {
|
|
||||||
let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
|
||||||
let currently_contains = layout_contains_point(node_layout, new_pos);
|
|
||||||
|
|
||||||
if currently_contains {
|
|
||||||
try_create_event(
|
|
||||||
"contextmenu",
|
|
||||||
Arc::new(prepare_mouse_data(mouse_data, node_layout)),
|
|
||||||
&mut will_bubble,
|
|
||||||
resolved_events,
|
|
||||||
node,
|
|
||||||
dom,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// wheel
|
|
||||||
if let Some(w) = wheel_data {
|
|
||||||
if wheel_delta != 0.0 {
|
|
||||||
let mut will_bubble = FxHashSet::default();
|
let mut will_bubble = FxHashSet::default();
|
||||||
for node in dom.get_listening_sorted("wheel") {
|
for node in dom.get_listening_sorted("mouseup") {
|
||||||
let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
||||||
let currently_contains = layout_contains_point(node_layout, new_pos);
|
let currently_contains = layout_contains_point(node_layout, new_pos);
|
||||||
|
|
||||||
if currently_contains {
|
if currently_contains {
|
||||||
try_create_event(
|
try_create_event(
|
||||||
"wheel",
|
"mouseup",
|
||||||
Arc::new(w.clone()),
|
Arc::new(prepare_mouse_data(mouse_data, node_layout)),
|
||||||
&mut will_bubble,
|
&mut will_bubble,
|
||||||
resolved_events,
|
resolved_events,
|
||||||
node,
|
node,
|
||||||
@@ -458,6 +398,75 @@ impl InnerInputState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// click
|
||||||
|
if mouse_data.button == 0 && released {
|
||||||
|
let mut will_bubble = FxHashSet::default();
|
||||||
|
for node in dom.get_listening_sorted("click") {
|
||||||
|
let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
||||||
|
let currently_contains = layout_contains_point(node_layout, new_pos);
|
||||||
|
|
||||||
|
if currently_contains {
|
||||||
|
try_create_event(
|
||||||
|
"click",
|
||||||
|
Arc::new(prepare_mouse_data(mouse_data, node_layout)),
|
||||||
|
&mut will_bubble,
|
||||||
|
resolved_events,
|
||||||
|
node,
|
||||||
|
dom,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// contextmenu
|
||||||
|
if mouse_data.button == 2 && released {
|
||||||
|
let mut will_bubble = FxHashSet::default();
|
||||||
|
for node in dom.get_listening_sorted("contextmenu") {
|
||||||
|
let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
||||||
|
let currently_contains = layout_contains_point(node_layout, new_pos);
|
||||||
|
|
||||||
|
if currently_contains {
|
||||||
|
try_create_event(
|
||||||
|
"contextmenu",
|
||||||
|
Arc::new(prepare_mouse_data(mouse_data, node_layout)),
|
||||||
|
&mut will_bubble,
|
||||||
|
resolved_events,
|
||||||
|
node,
|
||||||
|
dom,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// wheel
|
||||||
|
if let Some(w) = wheel_data {
|
||||||
|
if wheel_delta != 0.0 {
|
||||||
|
let mut will_bubble = FxHashSet::default();
|
||||||
|
for node in dom.get_listening_sorted("wheel") {
|
||||||
|
let node_layout =
|
||||||
|
layout.layout(node.state.layout.node.unwrap()).unwrap();
|
||||||
|
let currently_contains = layout_contains_point(node_layout, new_pos);
|
||||||
|
|
||||||
|
if currently_contains {
|
||||||
|
try_create_event(
|
||||||
|
"wheel",
|
||||||
|
Arc::new(w.clone()),
|
||||||
|
&mut will_bubble,
|
||||||
|
resolved_events,
|
||||||
|
node,
|
||||||
|
dom,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// mouseleave
|
// mouseleave
|
||||||
let mut will_bubble = FxHashSet::default();
|
let mut will_bubble = FxHashSet::default();
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ fn render_vdom(
|
|||||||
terminal.clear().unwrap();
|
terminal.clear().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
let to_rerender: fxhash::FxHashSet<usize> = vec![0].into_iter().collect();
|
let mut to_rerender: fxhash::FxHashSet<usize> = vec![0].into_iter().collect();
|
||||||
let mut updated = true;
|
let mut updated = true;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
@@ -221,7 +221,7 @@ fn render_vdom(
|
|||||||
// update the style and layout
|
// update the style and layout
|
||||||
let mut any_map = AnyMap::new();
|
let mut any_map = AnyMap::new();
|
||||||
any_map.insert(stretch.clone());
|
any_map.insert(stretch.clone());
|
||||||
let _to_rerender = rdom.update_state(vdom, to_update, any_map).unwrap();
|
to_rerender = rdom.update_state(vdom, to_update, any_map).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user