Skip to content

Commit 8d67426

Browse files
committed
Move azul-widgets into azul-dll, debug hit tester
1 parent 60c00fb commit 8d67426

File tree

21 files changed

+578
-492
lines changed

21 files changed

+578
-492
lines changed

Cargo.lock

-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ members = [
99
"azul-core",
1010
"azul-layout",
1111
"azul-text-layout",
12-
"azul-widgets",
1312
"azul-css-parser",
1413
"examples",
1514
]

api.json

+97-64
Original file line numberDiff line numberDiff line change
@@ -2020,70 +2020,6 @@
20202020
}
20212021
}
20222022
},
2023-
"menu": {
2024-
"classes": {
2025-
"Menu": {
2026-
"doc": "Menu struct (application / window menu, dropdown menu, context menu). Modeled after the Windows API",
2027-
"external": "azul_impl::window::Menu",
2028-
"struct_fields": [
2029-
{"items": {"type": "MenuItemVec", "doc": "Items in this menu"}}
2030-
]
2031-
},
2032-
"MenuItem": {
2033-
"doc": "Item entry in a menu or menu bar",
2034-
"external": "azul_impl::window::MenuItem",
2035-
"enum_fields": [
2036-
{"Label": {"type": "StringMenuItem", "doc": "Regular \"labeled\" menu item"}},
2037-
{"Separator": {"doc": "Line separator, usually only rendered in vertical menus"}},
2038-
{"BreakLine": {"doc": "Breaks items in a menu onto separate lines, usually only rendered in horizontal menu bars"}}
2039-
]
2040-
},
2041-
"StringMenuItem": {
2042-
"doc": "Regular labeled menu item",
2043-
"external": "azul_impl::window::StringMenuItem",
2044-
"struct_fields": [
2045-
{"label": {"type": "String", "doc": "Label of the menu entry"}},
2046-
{"accelerator": {"type": "OptionVirtualKeyCodeCombo", "doc": "Optional accelerator combination, (ex. \"CTRL + X\" = [VirtualKeyCode::Ctrl, VirtualKeyCode::X]) for keyboard shortcut"}},
2047-
{"callback": {"type": "OptionMenuCallback", "doc": "Optional callback to call when the item is activated"}},
2048-
{"state": {"type": "MenuItemState", "doc": "State of the menu entry (normal, greyed, disabled)"}},
2049-
{"icon": {"type": "OptionMenuItemIcon", "doc": "Optional icon (checkbox or custom image) of the menu entry"}},
2050-
{"children": {"type": "MenuItemVec", "doc": "Sub-menus of the window (empty by default)"}}
2051-
]
2052-
},
2053-
"VirtualKeyCodeCombo": {
2054-
"doc": "Combination of virtual key codes that have to be pressed together",
2055-
"external": "azul_impl::window::VirtualKeyCodeCombo",
2056-
"struct_fields": [
2057-
{"keys": {"type": "VirtualKeyCodeVec"}}
2058-
]
2059-
},
2060-
"MenuCallback": {
2061-
"doc": "Similar to `dom.CallbackData`, stores some data + a callback to call when the menu is activated",
2062-
"external": "azul_impl::window::MenuCallback",
2063-
"struct_fields": [
2064-
{"callback": {"type": "Callback", "doc": "Callback to be called when the menu item is clicked"}},
2065-
{"data": {"type": "RefAny", "doc": "Data of the callback to be called on"}}
2066-
]
2067-
},
2068-
"MenuItemIcon": {
2069-
"doc": "Icon of a menu entry",
2070-
"external": "azul_impl::window::MenuItemIcon",
2071-
"enum_fields": [
2072-
{"Checkbox": {"type": "bool", "doc": "Menu item shows a checkbox (either checked or not)"}},
2073-
{"Image": {"type": "ImageRef", "doc": "Menu item shows a custom image, usually in 16x16 format"}}
2074-
]
2075-
},
2076-
"MenuItemState": {
2077-
"doc": "Describes the state of a menu item",
2078-
"external": "azul_impl::window::MenuItemState",
2079-
"enum_fields": [
2080-
{"Normal": {"doc": "Normal menu item (default)"}},
2081-
{"Greyed": {"doc": "Menu item is greyed out and clicking it does nothing"}},
2082-
{"Disabled": {"doc": "Menu item is disabled, clicking it does nothing - but NOT greyed out"}}
2083-
]
2084-
}
2085-
}
2086-
},
20872023
"dom": {
20882024
"doc": "`Dom` construction and configuration",
20892025
"classes": {
@@ -2959,6 +2895,70 @@
29592895
}
29602896
}
29612897
},
2898+
"menu": {
2899+
"classes": {
2900+
"Menu": {
2901+
"doc": "Menu struct (application / window menu, dropdown menu, context menu). Modeled after the Windows API",
2902+
"external": "azul_impl::window::Menu",
2903+
"struct_fields": [
2904+
{"items": {"type": "MenuItemVec", "doc": "Items in this menu"}}
2905+
]
2906+
},
2907+
"MenuItem": {
2908+
"doc": "Item entry in a menu or menu bar",
2909+
"external": "azul_impl::window::MenuItem",
2910+
"enum_fields": [
2911+
{"Label": {"type": "StringMenuItem", "doc": "Regular \"labeled\" menu item"}},
2912+
{"Separator": {"doc": "Line separator, usually only rendered in vertical menus"}},
2913+
{"BreakLine": {"doc": "Breaks items in a menu onto separate lines, usually only rendered in horizontal menu bars"}}
2914+
]
2915+
},
2916+
"StringMenuItem": {
2917+
"doc": "Regular labeled menu item",
2918+
"external": "azul_impl::window::StringMenuItem",
2919+
"struct_fields": [
2920+
{"label": {"type": "String", "doc": "Label of the menu entry"}},
2921+
{"accelerator": {"type": "OptionVirtualKeyCodeCombo", "doc": "Optional accelerator combination, (ex. \"CTRL + X\" = [VirtualKeyCode::Ctrl, VirtualKeyCode::X]) for keyboard shortcut"}},
2922+
{"callback": {"type": "OptionMenuCallback", "doc": "Optional callback to call when the item is activated"}},
2923+
{"state": {"type": "MenuItemState", "doc": "State of the menu entry (normal, greyed, disabled)"}},
2924+
{"icon": {"type": "OptionMenuItemIcon", "doc": "Optional icon (checkbox or custom image) of the menu entry"}},
2925+
{"children": {"type": "MenuItemVec", "doc": "Sub-menus of the window (empty by default)"}}
2926+
]
2927+
},
2928+
"VirtualKeyCodeCombo": {
2929+
"doc": "Combination of virtual key codes that have to be pressed together",
2930+
"external": "azul_impl::window::VirtualKeyCodeCombo",
2931+
"struct_fields": [
2932+
{"keys": {"type": "VirtualKeyCodeVec"}}
2933+
]
2934+
},
2935+
"MenuCallback": {
2936+
"doc": "Similar to `dom.CallbackData`, stores some data + a callback to call when the menu is activated",
2937+
"external": "azul_impl::window::MenuCallback",
2938+
"struct_fields": [
2939+
{"callback": {"type": "Callback", "doc": "Callback to be called when the menu item is clicked"}},
2940+
{"data": {"type": "RefAny", "doc": "Data of the callback to be called on"}}
2941+
]
2942+
},
2943+
"MenuItemIcon": {
2944+
"doc": "Icon of a menu entry",
2945+
"external": "azul_impl::window::MenuItemIcon",
2946+
"enum_fields": [
2947+
{"Checkbox": {"type": "bool", "doc": "Menu item shows a checkbox (either checked or not)"}},
2948+
{"Image": {"type": "ImageRef", "doc": "Menu item shows a custom image, usually in 16x16 format"}}
2949+
]
2950+
},
2951+
"MenuItemState": {
2952+
"doc": "Describes the state of a menu item",
2953+
"external": "azul_impl::window::MenuItemState",
2954+
"enum_fields": [
2955+
{"Normal": {"doc": "Normal menu item (default)"}},
2956+
{"Greyed": {"doc": "Menu item is greyed out and clicking it does nothing"}},
2957+
{"Disabled": {"doc": "Menu item is disabled, clicking it does nothing - but NOT greyed out"}}
2958+
]
2959+
}
2960+
}
2961+
},
29622962
"css": {
29632963
"doc": "`Css` parsing module",
29642964
"classes": {
@@ -4909,6 +4909,39 @@
49094909
}
49104910
}
49114911
},
4912+
"widgets": {
4913+
"doc": "Default, built-in widgets (button, label, textinput, etc.)",
4914+
"classes": {
4915+
"Button": {
4916+
"external": "crate::widgets::button::Button",
4917+
4918+
},
4919+
"CheckBox": {
4920+
"external": "crate::widgets::check_box::CheckBox",
4921+
4922+
},
4923+
"Label": {
4924+
"external": "crate::widgets::label::Label",
4925+
4926+
},
4927+
"TextInput": {
4928+
"external": "crate::widgets::text_input::TextInput",
4929+
4930+
},
4931+
"NumberInput": {
4932+
"external": "crate::widgets::number_input::NumberInput",
4933+
4934+
},
4935+
"ColorInput": {
4936+
"external": "crate::widgets::color_input::ColorInput",
4937+
4938+
},
4939+
"Spreadsheet": {
4940+
"external": "crate::widgets::table_view::TableView",
4941+
4942+
},
4943+
}
4944+
},
49124945
"style": {
49134946
"doc": "DOM to CSS cascading and styling module",
49144947
"classes": {

azul-core/src/dom.rs

-12
Original file line numberDiff line numberDiff line change
@@ -1411,20 +1411,8 @@ fn convert_dom_into_compact_dom(mut dom: Dom) -> CompactDom {
14111411
last_child: if dom.children.is_empty() { None } else { Some(root_node_id + dom.estimated_total_children) },
14121412
};
14131413

1414-
println!("converting DOM into compact DOM:
1415-
1416-
dom: {:#?}
1417-
node_hierarchy: {:#?}
1418-
node_data: {:#?}
1419-
root_node_id: {:#?}
1420-
root_node: {:#?}
1421-
cur_node_id: {:#?}
1422-
", dom, node_hierarchy, node_data, root_node_id, root_node, cur_node_id);
1423-
14241414
convert_dom_into_compact_dom_internal(&mut dom, &mut node_hierarchy, &mut node_data, root_node_id, root_node, &mut cur_node_id);
14251415

1426-
println!("ok: converted: {:?}, {:?}", node_hierarchy, node_data);
1427-
14281416
CompactDom {
14291417
node_hierarchy: NodeHierarchy { internal: node_hierarchy },
14301418
node_data: NodeDataContainer { internal: node_data },

azul-core/src/window.rs

-32
Original file line numberDiff line numberDiff line change
@@ -478,44 +478,19 @@ impl ScrollStates {
478478
.set(scroll_position.x, scroll_position.y, &node.child_rect);
479479
}
480480

481-
/// NOTE: This has to be a getter, because we need to update
482-
#[must_use = "function marks the scroll ID as dirty, therefore the function is must_use"]
483-
pub fn get_scroll_position_and_mark_as_used(&mut self, scroll_id: &ExternalScrollId) -> Option<LogicalPosition> {
484-
let entry = self.0.get_mut(&scroll_id)?;
485-
Some(entry.get_and_mark_as_used())
486-
}
487-
488481
/// Updating (add to) the existing scroll amount does not update the `entry.used_this_frame`,
489482
/// since that is only relevant when we are actually querying the renderer.
490483
pub fn scroll_node(&mut self, node: &OverflowingScrollNode, scroll_by_x: f32, scroll_by_y: f32) {
491484
self.0.entry(node.parent_external_scroll_id)
492485
.or_insert_with(|| ScrollState::default())
493486
.add(scroll_by_x, scroll_by_y, &node.child_rect);
494487
}
495-
496-
/// Removes all scroll states that weren't used in the last frame
497-
pub fn remove_unused_scroll_states(&mut self) {
498-
// NOTE: originally this code used retain(), but retain() is not available on no_std
499-
let mut scroll_states_to_remove = Vec::new();
500-
501-
for (key, state) in self.0.iter_mut() {
502-
if !state.used_this_frame {
503-
scroll_states_to_remove.push(*key);
504-
}
505-
}
506-
507-
for key in scroll_states_to_remove {
508-
self.0.remove(&key);
509-
}
510-
}
511488
}
512489

513490
#[derive(Debug, Copy, Clone, PartialEq, PartialOrd)]
514491
pub struct ScrollState {
515492
/// Amount in pixel that the current node is scrolled
516493
pub scroll_position: LogicalPosition,
517-
/// Was the scroll amount used in this frame?
518-
pub used_this_frame: bool,
519494
}
520495

521496
impl ScrollState {
@@ -536,19 +511,12 @@ impl ScrollState {
536511
self.scroll_position.x = x.max(0.0).min(child_rect.size.width);
537512
self.scroll_position.y = y.max(0.0).min(child_rect.size.height);
538513
}
539-
540-
/// Returns the scroll position and also set the "used_this_frame" flag
541-
pub fn get_and_mark_as_used(&mut self) -> LogicalPosition {
542-
self.used_this_frame = true;
543-
self.scroll_position
544-
}
545514
}
546515

547516
impl Default for ScrollState {
548517
fn default() -> Self {
549518
ScrollState {
550519
scroll_position: LogicalPosition::zero(),
551-
used_this_frame: true,
552520
}
553521
}
554522
}

azul-desktop/src/app.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,13 @@ fn run_inner(app: App) -> ! {
500500
window.regenerate_styled_dom(&mut data, &image_cache, &mut resource_updates, &mut fc_cache);
501501
window.rebuild_display_list(&mut transaction, &image_cache, resource_updates);
502502
window.render_async(transaction, /* display list was rebuilt */ true);
503+
window.force_synchronize_hit_tester_during();
504+
505+
// do the same thing again, but this time after the hit_tester has been updated
506+
let mut resource_updates = Vec::new();
507+
let mut transaction = WrTransaction::new();
508+
window.rebuild_display_list(&mut transaction, &image_cache, resource_updates);
509+
window.render_async(transaction, /* display list was rebuilt */ true);
503510
hit_tester_request = Some((*window_id, window.render_api.request_hit_tester(
504511
wr_translate_document_id(window.internal.document_id)))
505512
);
@@ -775,9 +782,7 @@ fn run_inner(app: App) -> ! {
775782
loop {
776783
let events = Events::new(&window.internal.current_window_state, &window.internal.previous_window_state);
777784
let layout_callback_changed = window.internal.current_window_state.layout_callback_changed(&window.internal.previous_window_state);
778-
let hit_test = if !events.needs_hit_test() {
779-
FullHitTest::empty(window.internal.current_window_state.focused_node)
780-
} else {
785+
let hit_test = {
781786
let ht = crate::wr_translate::fullhittest_new_webrender(
782787
&*window.hit_tester,
783788
window.internal.document_id,
@@ -1199,12 +1204,14 @@ fn run_inner(app: App) -> ! {
11991204
}
12001205
}
12011206

1207+
/*
12021208
// resolve the hit-testing scene
12031209
if let Some((window_id, new_hit_test_results)) = hit_tester_request {
12041210
if let Some(w) = active_windows.get_mut(&window_id) {
12051211
w.hit_tester = new_hit_test_results.resolve();
12061212
}
12071213
}
1214+
*/
12081215

12091216
// end: handle control flow and app shutdown
12101217
let new_control_flow = if !active_windows.is_empty() {
@@ -1528,7 +1535,7 @@ fn create_window(
15281535
}
15291536

15301537
let timer = Timer::new(data.clone(), hot_reload_timer, config.system_callbacks.get_system_time_fn)
1531-
.with_interval(StdDuration::from_millis(200).into());
1538+
.with_interval(StdDuration::from_millis(800).into());
15321539

15331540
timers
15341541
.entry(glutin_window_id)

0 commit comments

Comments
 (0)