Skip to content

Commit

Permalink
refactor!: Rename the StaticText role to Label (#434)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwcampbell authored Jun 16, 2024
1 parent acd7810 commit 7086bc0
Show file tree
Hide file tree
Showing 15 changed files with 70 additions and 84 deletions.
2 changes: 1 addition & 1 deletion bindings/c/examples/sdl/hello_world.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ accesskit_node *build_button(accesskit_node_id id, const char *name) {

accesskit_node *build_announcement(const char *text) {
accesskit_node_builder *builder =
accesskit_node_builder_new(ACCESSKIT_ROLE_STATIC_TEXT);
accesskit_node_builder_new(ACCESSKIT_ROLE_LABEL);
accesskit_node_builder_set_name(builder, text);
accesskit_node_builder_set_live(builder, ACCESSKIT_LIVE_POLITE);
return accesskit_node_builder_build(builder);
Expand Down
2 changes: 1 addition & 1 deletion bindings/c/examples/windows/hello_world.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ accesskit_node *build_button(accesskit_node_id id, const char *name) {

accesskit_node *build_announcement(const char *text) {
accesskit_node_builder *builder =
accesskit_node_builder_new(ACCESSKIT_ROLE_STATIC_TEXT);
accesskit_node_builder_new(ACCESSKIT_ROLE_LABEL);
accesskit_node_builder_set_name(builder, text);
accesskit_node_builder_set_live(builder, ACCESSKIT_LIVE_POLITE);
return accesskit_node_builder_build(builder);
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/examples/pygame/hello_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def build_button(id, name):


def build_announcement(text):
builder = accesskit.NodeBuilder(accesskit.Role.STATIC_TEXT)
builder = accesskit.NodeBuilder(accesskit.Role.LABEL)
builder.set_name(text)
builder.set_live(accesskit.Live.POLITE)
return builder.build()
Expand Down
2 changes: 1 addition & 1 deletion common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub enum Role {
Unknown,
InlineTextBox,
Cell,
StaticText,
Label,
Image,
Link,
Row,
Expand Down
42 changes: 16 additions & 26 deletions consumer/src/iterators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,12 +630,7 @@ mod tests {
.next()
.is_none());
assert_eq!(
[
STATIC_TEXT_1_1_ID,
PARAGRAPH_2_ID,
STATIC_TEXT_3_1_0_ID,
BUTTON_3_2_ID
],
[LABEL_1_1_ID, PARAGRAPH_2_ID, LABEL_3_1_0_ID, BUTTON_3_2_ID],
tree.state()
.node_by_id(PARAGRAPH_0_ID)
.unwrap()
Expand All @@ -646,7 +641,7 @@ mod tests {
assert_eq!(
[BUTTON_3_2_ID],
tree.state()
.node_by_id(STATIC_TEXT_3_1_0_ID)
.node_by_id(LABEL_3_1_0_ID)
.unwrap()
.following_filtered_siblings(test_tree_filter)
.map(|node| node.id())
Expand All @@ -671,12 +666,7 @@ mod tests {
.next_back()
.is_none());
assert_eq!(
[
BUTTON_3_2_ID,
STATIC_TEXT_3_1_0_ID,
PARAGRAPH_2_ID,
STATIC_TEXT_1_1_ID
],
[BUTTON_3_2_ID, LABEL_3_1_0_ID, PARAGRAPH_2_ID, LABEL_1_1_ID],
tree.state()
.node_by_id(PARAGRAPH_0_ID)
.unwrap()
Expand All @@ -688,7 +678,7 @@ mod tests {
assert_eq!(
[BUTTON_3_2_ID,],
tree.state()
.node_by_id(STATIC_TEXT_3_1_0_ID)
.node_by_id(LABEL_3_1_0_ID)
.unwrap()
.following_filtered_siblings(test_tree_filter)
.rev()
Expand All @@ -714,7 +704,7 @@ mod tests {
.next()
.is_none());
assert_eq!(
[PARAGRAPH_2_ID, STATIC_TEXT_1_1_ID, PARAGRAPH_0_ID],
[PARAGRAPH_2_ID, LABEL_1_1_ID, PARAGRAPH_0_ID],
tree.state()
.node_by_id(PARAGRAPH_3_IGNORED_ID)
.unwrap()
Expand All @@ -723,9 +713,9 @@ mod tests {
.collect::<Vec<NodeId>>()[..]
);
assert_eq!(
[PARAGRAPH_2_ID, STATIC_TEXT_1_1_ID, PARAGRAPH_0_ID],
[PARAGRAPH_2_ID, LABEL_1_1_ID, PARAGRAPH_0_ID],
tree.state()
.node_by_id(STATIC_TEXT_3_1_0_ID)
.node_by_id(LABEL_3_1_0_ID)
.unwrap()
.preceding_filtered_siblings(test_tree_filter)
.map(|node| node.id())
Expand All @@ -750,7 +740,7 @@ mod tests {
.next_back()
.is_none());
assert_eq!(
[PARAGRAPH_0_ID, STATIC_TEXT_1_1_ID, PARAGRAPH_2_ID],
[PARAGRAPH_0_ID, LABEL_1_1_ID, PARAGRAPH_2_ID],
tree.state()
.node_by_id(PARAGRAPH_3_IGNORED_ID)
.unwrap()
Expand All @@ -760,9 +750,9 @@ mod tests {
.collect::<Vec<NodeId>>()[..]
);
assert_eq!(
[PARAGRAPH_0_ID, STATIC_TEXT_1_1_ID, PARAGRAPH_2_ID],
[PARAGRAPH_0_ID, LABEL_1_1_ID, PARAGRAPH_2_ID],
tree.state()
.node_by_id(STATIC_TEXT_3_1_0_ID)
.node_by_id(LABEL_3_1_0_ID)
.unwrap()
.preceding_filtered_siblings(test_tree_filter)
.rev()
Expand All @@ -784,9 +774,9 @@ mod tests {
assert_eq!(
[
PARAGRAPH_0_ID,
STATIC_TEXT_1_1_ID,
LABEL_1_1_ID,
PARAGRAPH_2_ID,
STATIC_TEXT_3_1_0_ID,
LABEL_3_1_0_ID,
BUTTON_3_2_ID
],
tree.state()
Expand All @@ -804,7 +794,7 @@ mod tests {
.is_none());
assert!(tree
.state()
.node_by_id(STATIC_TEXT_0_0_IGNORED_ID)
.node_by_id(LABEL_0_0_IGNORED_ID)
.unwrap()
.filtered_children(test_tree_filter)
.next()
Expand All @@ -817,9 +807,9 @@ mod tests {
assert_eq!(
[
BUTTON_3_2_ID,
STATIC_TEXT_3_1_0_ID,
LABEL_3_1_0_ID,
PARAGRAPH_2_ID,
STATIC_TEXT_1_1_ID,
LABEL_1_1_ID,
PARAGRAPH_0_ID
],
tree.state()
Expand All @@ -838,7 +828,7 @@ mod tests {
.is_none());
assert!(tree
.state()
.node_by_id(STATIC_TEXT_0_0_IGNORED_ID)
.node_by_id(LABEL_0_0_IGNORED_ID)
.unwrap()
.filtered_children(test_tree_filter)
.next_back()
Expand Down
50 changes: 25 additions & 25 deletions consumer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ mod tests {

pub const ROOT_ID: NodeId = NodeId(0);
pub const PARAGRAPH_0_ID: NodeId = NodeId(1);
pub const STATIC_TEXT_0_0_IGNORED_ID: NodeId = NodeId(2);
pub const LABEL_0_0_IGNORED_ID: NodeId = NodeId(2);
pub const PARAGRAPH_1_IGNORED_ID: NodeId = NodeId(3);
pub const BUTTON_1_0_HIDDEN_ID: NodeId = NodeId(4);
pub const CONTAINER_1_0_0_HIDDEN_ID: NodeId = NodeId(5);
pub const STATIC_TEXT_1_1_ID: NodeId = NodeId(6);
pub const LABEL_1_1_ID: NodeId = NodeId(6);
pub const BUTTON_1_2_HIDDEN_ID: NodeId = NodeId(7);
pub const CONTAINER_1_2_0_HIDDEN_ID: NodeId = NodeId(8);
pub const PARAGRAPH_2_ID: NodeId = NodeId(9);
pub const STATIC_TEXT_2_0_ID: NodeId = NodeId(10);
pub const LABEL_2_0_ID: NodeId = NodeId(10);
pub const PARAGRAPH_3_IGNORED_ID: NodeId = NodeId(11);
pub const EMPTY_CONTAINER_3_0_IGNORED_ID: NodeId = NodeId(12);
pub const LINK_3_1_IGNORED_ID: NodeId = NodeId(13);
pub const STATIC_TEXT_3_1_0_ID: NodeId = NodeId(14);
pub const LABEL_3_1_0_ID: NodeId = NodeId(14);
pub const BUTTON_3_2_ID: NodeId = NodeId(15);
pub const EMPTY_CONTAINER_3_3_IGNORED_ID: NodeId = NodeId(16);

Expand All @@ -57,12 +57,12 @@ mod tests {
};
let paragraph_0 = {
let mut builder = NodeBuilder::new(Role::Paragraph);
builder.set_children(vec![STATIC_TEXT_0_0_IGNORED_ID]);
builder.set_children(vec![LABEL_0_0_IGNORED_ID]);
builder.build()
};
let static_text_0_0_ignored = {
let mut builder = NodeBuilder::new(Role::StaticText);
builder.set_name("static_text_0_0_ignored");
let label_0_0_ignored = {
let mut builder = NodeBuilder::new(Role::Label);
builder.set_name("label_0_0_ignored");
builder.build()
};
let paragraph_1_ignored = {
Expand All @@ -76,7 +76,7 @@ mod tests {
});
builder.set_children(vec![
BUTTON_1_0_HIDDEN_ID,
STATIC_TEXT_1_1_ID,
LABEL_1_1_ID,
BUTTON_1_2_HIDDEN_ID,
]);
builder.build()
Expand All @@ -93,15 +93,15 @@ mod tests {
builder.set_hidden();
builder.build()
};
let static_text_1_1 = {
let mut builder = NodeBuilder::new(Role::StaticText);
let label_1_1 = {
let mut builder = NodeBuilder::new(Role::Label);
builder.set_bounds(Rect {
x0: 10.0,
y0: 10.0,
x1: 90.0,
y1: 30.0,
});
builder.set_name("static_text_1_1");
builder.set_name("label_1_1");
builder.build()
};
let button_1_2_hidden = {
Expand All @@ -118,12 +118,12 @@ mod tests {
};
let paragraph_2 = {
let mut builder = NodeBuilder::new(Role::Paragraph);
builder.set_children(vec![STATIC_TEXT_2_0_ID]);
builder.set_children(vec![LABEL_2_0_ID]);
builder.build()
};
let static_text_2_0 = {
let mut builder = NodeBuilder::new(Role::StaticText);
builder.set_name("static_text_2_0");
let label_2_0 = {
let mut builder = NodeBuilder::new(Role::Label);
builder.set_name("label_2_0");
builder.build()
};
let paragraph_3_ignored = {
Expand All @@ -139,13 +139,13 @@ mod tests {
let empty_container_3_0_ignored = NodeBuilder::new(Role::GenericContainer).build();
let link_3_1_ignored = {
let mut builder = NodeBuilder::new(Role::Link);
builder.set_children(vec![STATIC_TEXT_3_1_0_ID]);
builder.set_children(vec![LABEL_3_1_0_ID]);
builder.set_linked();
builder.build()
};
let static_text_3_1_0 = {
let mut builder = NodeBuilder::new(Role::StaticText);
builder.set_name("static_text_3_1_0");
let label_3_1_0 = {
let mut builder = NodeBuilder::new(Role::Label);
builder.set_name("label_3_1_0");
builder.build()
};
let button_3_2 = {
Expand All @@ -158,19 +158,19 @@ mod tests {
nodes: vec![
(ROOT_ID, root),
(PARAGRAPH_0_ID, paragraph_0),
(STATIC_TEXT_0_0_IGNORED_ID, static_text_0_0_ignored),
(LABEL_0_0_IGNORED_ID, label_0_0_ignored),
(PARAGRAPH_1_IGNORED_ID, paragraph_1_ignored),
(BUTTON_1_0_HIDDEN_ID, button_1_0_hidden),
(CONTAINER_1_0_0_HIDDEN_ID, container_1_0_0_hidden),
(STATIC_TEXT_1_1_ID, static_text_1_1),
(LABEL_1_1_ID, label_1_1),
(BUTTON_1_2_HIDDEN_ID, button_1_2_hidden),
(CONTAINER_1_2_0_HIDDEN_ID, container_1_2_0_hidden),
(PARAGRAPH_2_ID, paragraph_2),
(STATIC_TEXT_2_0_ID, static_text_2_0),
(LABEL_2_0_ID, label_2_0),
(PARAGRAPH_3_IGNORED_ID, paragraph_3_ignored),
(EMPTY_CONTAINER_3_0_IGNORED_ID, empty_container_3_0_ignored),
(LINK_3_1_IGNORED_ID, link_3_1_ignored),
(STATIC_TEXT_3_1_0_ID, static_text_3_1_0),
(LABEL_3_1_0_ID, label_3_1_0),
(BUTTON_3_2_ID, button_3_2),
(EMPTY_CONTAINER_3_3_IGNORED_ID, empty_container_3_3_ignored),
],
Expand All @@ -184,7 +184,7 @@ mod tests {
let id = node.id();
if node.is_hidden() {
FilterResult::ExcludeSubtree
} else if id == STATIC_TEXT_0_0_IGNORED_ID
} else if id == LABEL_0_0_IGNORED_ID
|| id == PARAGRAPH_1_IGNORED_ID
|| id == PARAGRAPH_3_IGNORED_ID
|| id == EMPTY_CONTAINER_3_0_IGNORED_ID
Expand Down
Loading

0 comments on commit 7086bc0

Please sign in to comment.