Removed test code.
This commit is contained in:
parent
d740fbd016
commit
e6681db319
|
@ -13,63 +13,3 @@
|
|||
* Focus moving twice when cycling from one of the icons
|
||||
* The priority of keyboard focus should be high when highlighting and low when not?
|
||||
* `move_focus` changes highlight to true when scrolling with arrow keys
|
||||
|
||||
```rust
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
use zero_ui::prelude::*;
|
||||
use zero_ui_view_prebuilt as zero_ui_view;
|
||||
|
||||
fn main() {
|
||||
examples_util::print_info();
|
||||
zero_ui_view::init();
|
||||
|
||||
// let rec = examples_util::record_profile("profile-_test.json.gz", &[("example", &"_test")], |_| true);
|
||||
|
||||
app_main();
|
||||
|
||||
// rec.finish();
|
||||
}
|
||||
|
||||
fn app_main() {
|
||||
App::default().run_window(|_| {
|
||||
window! {
|
||||
content_align = Align::CENTER;
|
||||
// zero_ui::widgets::inspector::show_center_points = true;
|
||||
content = v_stack! {
|
||||
focusable = true;
|
||||
background_color = colors::DARK_RED;
|
||||
when self.is_focused {
|
||||
background_color = colors::GREEN;
|
||||
}
|
||||
|
||||
padding = 10;
|
||||
// padding = (20, 10, 10, 10);
|
||||
|
||||
spacing = 10;
|
||||
items = widgets![
|
||||
focusable_item(),
|
||||
focusable_item(),
|
||||
// focusable_item(),
|
||||
focusable_item(),
|
||||
focusable_item(),
|
||||
]
|
||||
};
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn focusable_item() -> impl Widget {
|
||||
text! {
|
||||
focusable = true;
|
||||
padding = 10;
|
||||
font_size = 20;
|
||||
background_color = colors::DARK_RED;
|
||||
when self.is_focused {
|
||||
background_color = colors::GREEN;
|
||||
}
|
||||
|
||||
text = "Focusable Item";
|
||||
}
|
||||
}
|
||||
```
|
|
@ -367,7 +367,7 @@ fn nested_focusable(g: char, column: u8, row: u8) -> impl Widget {
|
|||
margin = 5;
|
||||
};
|
||||
v_stack! {
|
||||
id = formatx!("focusable{g}-{column}-{row}");
|
||||
id = formatx!("focusable-{g}-{column}-{row}");
|
||||
padding = 2;
|
||||
|
||||
items = if row == 5 {
|
||||
|
|
|
@ -1017,14 +1017,9 @@ impl<'a> WidgetFocusInfo<'a> {
|
|||
a + b
|
||||
};
|
||||
|
||||
let self_bounds = self.info.inner_bounds();
|
||||
|
||||
let mut candidate_dist = i32::MAX;
|
||||
let mut candidate_overlap = Px::MAX;
|
||||
let mut candidate = None;
|
||||
|
||||
println!("!!: SEARCH =========");
|
||||
|
||||
for w in scope.descendants_skip_directional(if skip_descendants { Some(self) } else { None }) {
|
||||
if w.info.widget_id() != skip_id {
|
||||
let candidate_bounds = w.info.inner_bounds();
|
||||
|
@ -1051,11 +1046,8 @@ impl<'a> WidgetFocusInfo<'a> {
|
|||
|
||||
if is_in_direction {
|
||||
let dist = distance(candidate_center);
|
||||
let overlap = candidate_bounds.intersection(&self_bounds).map(|r| r.area()).unwrap_or(Px(0));
|
||||
println!("!!: opt {:?}", (overlap, dist));
|
||||
if overlap <= candidate_overlap && dist <= candidate_dist {
|
||||
if dist <= candidate_dist {
|
||||
candidate = Some(w);
|
||||
candidate_overlap = overlap;
|
||||
candidate_dist = dist;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue