Skip to content

Commit

Permalink
Bumps winit to 0.29.10.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed May 27, 2024
1 parent a926f01 commit 3a4034a
Show file tree
Hide file tree
Showing 15 changed files with 92 additions and 273 deletions.
65 changes: 0 additions & 65 deletions examples/keymaps/de_macos.txt

This file was deleted.

5 changes: 1 addition & 4 deletions examples/ui/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ use contrast_renderer::{
use geometric_algebra::{ppga2d, ppga3d};

const MSAA_SAMPLE_COUNT: u32 = 4;

const OPEN_SANS_TTF: &[u8] = include_bytes!("../../examples/fonts/OpenSans-Regular.ttf");
const KEYMAP: &str = include_str!("../../examples/keymaps/de_macos.txt");

struct Application {
depth_stencil_texture_view: Option<wgpu::TextureView>,
Expand Down Expand Up @@ -134,8 +132,7 @@ impl application_framework::Application for Application {
"tabs_margin" => Value::Float1(5.0.into()),
"tabs_padding" => Value::Float2([10.0, 10.0].into()),
};
let mut ui_event_translator = contrast_renderer::ui::message::WinitEventTranslator::default();
ui_event_translator.load_keymap(KEYMAP).unwrap();
let ui_event_translator = contrast_renderer::ui::message::WinitEventTranslator::default();

let overlay_container_node_id = ui_node_hierarchy.link_node(Node::new(contrast_renderer::ui::overlay::overlay_container, hash_map! {}), None);

Expand Down
2 changes: 0 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ pub enum Error {
TooManyDashIntervals,
/// The passed [DynamicStrokeOptions](crate::path::DynamicStrokeOptions) index is invalid.
DynamicStrokeOptionsIndexOutOfBounds,
/// The keymap could not be parsed (byte index at which the problem was encountered).
Syntax(usize),
}

/// Used for floating point comparison.
Expand Down
8 changes: 4 additions & 4 deletions src/ui/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ pub fn button(context: &mut NodeMessengerContext, messenger: &Messenger) -> Vec<
}
"ButtonInput" => {
let input_state = match_option!(messenger.get_attribute("input_state"), Value::InputState).unwrap();
let changed_keycode = *match_option!(messenger.get_attribute("changed_keycode"), Value::Character).unwrap();
if !input_state.pressed_keycodes.contains(&changed_keycode) {
let changed_key = *match_option!(messenger.get_attribute("changed_key"), Value::Character).unwrap();
if !input_state.pressed_keys.contains(&changed_key) {
return Vec::new();
}
match changed_keycode {
match changed_key {
'⇥' => {
if messenger.get_attribute("origin") != &Value::Void {
return context.input_focus_self(messenger);
} else if input_state.pressed_keycodes.contains(&'⇧') {
} else if input_state.pressed_keys.contains(&'⇧') {
return vec![context.input_focus_parent_or_child(messenger, None)];
} else {
context.touch_attribute("active");
Expand Down
8 changes: 4 additions & 4 deletions src/ui/checkbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ pub fn checkbox(context: &mut NodeMessengerContext, messenger: &Messenger) -> Ve
}
"ButtonInput" => {
let input_state = match_option!(messenger.get_attribute("input_state"), Value::InputState).unwrap();
let changed_keycode = *match_option!(messenger.get_attribute("changed_keycode"), Value::Character).unwrap();
if !input_state.pressed_keycodes.contains(&changed_keycode) {
let changed_key = *match_option!(messenger.get_attribute("changed_key"), Value::Character).unwrap();
if !input_state.pressed_keys.contains(&changed_key) {
return Vec::new();
}
match changed_keycode {
match changed_key {
'⇥' => {
if messenger.get_attribute("origin") != &Value::Void {
return context.input_focus_self(messenger);
} else if input_state.pressed_keycodes.contains(&'⇧') {
} else if input_state.pressed_keys.contains(&'⇧') {
return vec![context.input_focus_parent_or_child(messenger, None)];
} else {
let is_checked = !match_option!(context.get_attribute("is_checked"), Value::Boolean).unwrap_or(false);
Expand Down
8 changes: 4 additions & 4 deletions src/ui/dropdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,15 @@ pub fn dropdown(context: &mut NodeMessengerContext, messenger: &Messenger) -> Ve
}
"ButtonInput" => {
let input_state = match_option!(messenger.get_attribute("input_state"), Value::InputState).unwrap();
let changed_keycode = *match_option!(messenger.get_attribute("changed_keycode"), Value::Character).unwrap();
if !input_state.pressed_keycodes.contains(&changed_keycode) {
let changed_key = *match_option!(messenger.get_attribute("changed_key"), Value::Character).unwrap();
if !input_state.pressed_keys.contains(&changed_key) {
return Vec::new();
}
match changed_keycode {
match changed_key {
'⇥' => {
if messenger.get_attribute("origin") != &Value::Void {
return context.input_focus_self(messenger);
} else if input_state.pressed_keycodes.contains(&'⇧') {
} else if input_state.pressed_keys.contains(&'⇧') {
return vec![context.input_focus_parent_or_child(messenger, None)];
} else if match_option!(context.get_attribute("enable_interaction"), Value::Boolean).unwrap_or(false) {
return toggle_overlay(context, messenger);
Expand Down
26 changes: 13 additions & 13 deletions src/ui/label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ pub fn text_label(context: &mut NodeMessengerContext, messenger: &Messenger) ->
}
"ButtonInput" => {
let text_interaction = match_option!(context.get_attribute("text_interaction"), Value::TextInteraction).unwrap_or(TextInteraction::None);
if text_interaction == TextInteraction::None || messenger.get_attribute("changed_keycode") == &Value::Void {
if text_interaction == TextInteraction::None || messenger.get_attribute("changed_key") == &Value::Void {
return Vec::new();
}
let input_state = match_option!(messenger.get_attribute("input_state"), Value::InputState).unwrap();
let changed_keycode = *match_option!(messenger.get_attribute("changed_keycode"), Value::Character).unwrap();
if !input_state.pressed_keycodes.contains(&changed_keycode) {
let changed_key = *match_option!(messenger.get_attribute("changed_key"), Value::Character).unwrap();
if !input_state.pressed_keys.contains(&changed_key) {
return Vec::new();
}
let mut text_content = match_option!(context.get_attribute("text_content"), Value::TextString).unwrap_or_else(String::default);
Expand All @@ -185,11 +185,11 @@ pub fn text_label(context: &mut NodeMessengerContext, messenger: &Messenger) ->
&layout!(context),
&text_content,
);
match changed_keycode {
match changed_key {
'⇥' => {
if messenger.get_attribute("origin") != &Value::Void {
return context.input_focus_self(messenger);
} else if input_state.pressed_keycodes.contains(&'⇧') {
} else if input_state.pressed_keys.contains(&'⇧') {
if &context.get_attribute("input_source_entered") == messenger.get_attribute("input_source") {
context.set_attribute("input_source_entered", Value::Void);
if text_interaction != TextInteraction::Editing {
Expand Down Expand Up @@ -218,8 +218,8 @@ pub fn text_label(context: &mut NodeMessengerContext, messenger: &Messenger) ->
'←' | '→' | '↑' | '↓' => {
if &context.get_attribute("input_source_entered") != messenger.get_attribute("input_source") {
vec![context.redirect_input_focus_navigation_to_parent(messenger)]
} else if input_state.pressed_keycodes.contains(&'⇧') {
cursor_a = match changed_keycode {
} else if input_state.pressed_keys.contains(&'⇧') {
cursor_a = match changed_key {
'←' if cursor_a > 0 => cursor_a - 1,
'→' if cursor_a < text_content.chars().count() => cursor_a + 1,
'↑' => text_geometry.advance_char_index_by_line_index(cursor_a, -1),
Expand All @@ -231,7 +231,7 @@ pub fn text_label(context: &mut NodeMessengerContext, messenger: &Messenger) ->
context.set_attribute("cursor_a", Value::Natural1(cursor_a));
Vec::new()
} else {
cursor_a = match changed_keycode {
cursor_a = match changed_key {
'←' if range.start > 0 && range.start == range.end => range.start - 1,
'←' if range.end > range.start && range.start != range.end => range.start,
'→' if range.end < text_content.chars().count() && range.start == range.end => range.end + 1,
Expand All @@ -252,7 +252,7 @@ pub fn text_label(context: &mut NodeMessengerContext, messenger: &Messenger) ->
_ if text_interaction == TextInteraction::Editing
&& &context.get_attribute("input_source_entered") == messenger.get_attribute("input_source") =>
{
if changed_keycode == '⌫' {
if changed_key == '⌫' {
if range.start == range.end && range.start > 0 {
cursor_a = range.start - 1;
cursor_b = cursor_a;
Expand All @@ -268,24 +268,24 @@ pub fn text_label(context: &mut NodeMessengerContext, messenger: &Messenger) ->
return Vec::new();
}
} else {
let changed_keycode = match changed_keycode {
let changed_key = match changed_key {
'␣' => ' ',
'⇥' => '\t',
'⏎' => '\n',
_ => changed_keycode,
_ => changed_key,
};
match range.start {
_ if range.start == range.end => {
cursor_a = range.start + 1;
cursor_b = cursor_a;
text_content.insert(byte_offset_of_char_index(&text_content, range.start), changed_keycode);
text_content.insert(byte_offset_of_char_index(&text_content, range.start), changed_key);
}
_ if range.start < range.end => {
cursor_a = range.start + 1;
cursor_b = cursor_a;
text_content.replace_range(
byte_offset_of_char_index(&text_content, range.start)..byte_offset_of_char_index(&text_content, range.end),
&changed_keycode.to_string(),
&changed_key.to_string(),
);
}
_ => {
Expand Down
10 changes: 5 additions & 5 deletions src/ui/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ pub fn list(context: &mut NodeMessengerContext, messenger: &Messenger) -> Vec<Me
}
"ButtonInput" => {
let input_state = match_option!(messenger.get_attribute("input_state"), Value::InputState).unwrap();
let changed_keycode = *match_option!(messenger.get_attribute("changed_keycode"), Value::Character).unwrap();
if !input_state.pressed_keycodes.contains(&changed_keycode) {
let changed_key = *match_option!(messenger.get_attribute("changed_key"), Value::Character).unwrap();
if !input_state.pressed_keys.contains(&changed_key) {
return Vec::new();
}
match changed_keycode {
match changed_key {
'⇥' => {
let focus_child_id = match messenger.get_attribute("origin") {
Value::NodeOrObservableIdentifier(NodeOrObservableIdentifier::Indexed(_)) => None,
Expand All @@ -172,13 +172,13 @@ pub fn list(context: &mut NodeMessengerContext, messenger: &Messenger) -> Vec<Me
'←' | '→' | '↑' | '↓' => {
if let Value::NodeOrObservableIdentifier(NodeOrObservableIdentifier::Indexed(child_index)) = messenger.get_attribute("origin") {
let direction = if context.get_attribute("orientation") == Value::Orientation(Orientation::Horizontal) {
match changed_keycode {
match changed_key {
'←' => Some(-1),
'→' => Some(1),
_ => None,
}
} else {
match changed_keycode {
match changed_key {
'↑' => Some(1),
'↓' => Some(-1),
_ => None,
Expand Down
Loading

0 comments on commit 3a4034a

Please sign in to comment.