Base accessibility API.
This commit is contained in:
@ -43,12 +43,51 @@ PackedStringArray Range::get_configuration_warnings() const {
|
||||
void Range::_value_changed(double p_value) {
|
||||
GDVIRTUAL_CALL(_value_changed, p_value);
|
||||
}
|
||||
|
||||
void Range::_value_changed_notify() {
|
||||
_value_changed(shared->val);
|
||||
emit_signal(SceneStringName(value_changed), shared->val);
|
||||
queue_accessibility_update();
|
||||
queue_redraw();
|
||||
}
|
||||
|
||||
void Range::_accessibility_action_inc(const Variant &p_data) {
|
||||
double step = ((shared->step > 0) ? shared->step : 1);
|
||||
set_value(shared->val + step);
|
||||
}
|
||||
|
||||
void Range::_accessibility_action_dec(const Variant &p_data) {
|
||||
double step = ((shared->step > 0) ? shared->step : 1);
|
||||
set_value(shared->val - step);
|
||||
}
|
||||
|
||||
void Range::_accessibility_action_set_value(const Variant &p_data) {
|
||||
double new_val = p_data;
|
||||
set_value(new_val);
|
||||
}
|
||||
|
||||
void Range::_notification(int p_what) {
|
||||
ERR_MAIN_THREAD_GUARD;
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ACCESSIBILITY_UPDATE: {
|
||||
RID ae = get_accessibility_element();
|
||||
ERR_FAIL_COND(ae.is_null());
|
||||
|
||||
DisplayServer::get_singleton()->accessibility_update_set_role(ae, DisplayServer::AccessibilityRole::ROLE_SPIN_BUTTON);
|
||||
DisplayServer::get_singleton()->accessibility_update_set_num_value(ae, shared->val);
|
||||
DisplayServer::get_singleton()->accessibility_update_set_num_range(ae, shared->min, shared->max);
|
||||
if (shared->step > 0) {
|
||||
DisplayServer::get_singleton()->accessibility_update_set_num_step(ae, shared->step);
|
||||
} else {
|
||||
DisplayServer::get_singleton()->accessibility_update_set_num_step(ae, 1);
|
||||
}
|
||||
DisplayServer::get_singleton()->accessibility_update_add_action(ae, DisplayServer::AccessibilityAction::ACTION_DECREMENT, callable_mp(this, &Range::_accessibility_action_dec));
|
||||
DisplayServer::get_singleton()->accessibility_update_add_action(ae, DisplayServer::AccessibilityAction::ACTION_INCREMENT, callable_mp(this, &Range::_accessibility_action_inc));
|
||||
DisplayServer::get_singleton()->accessibility_update_add_action(ae, DisplayServer::AccessibilityAction::ACTION_SET_VALUE, callable_mp(this, &Range::_accessibility_action_set_value));
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void Range::Shared::emit_value_changed() {
|
||||
for (Range *E : owners) {
|
||||
Range *r = E;
|
||||
@ -80,6 +119,7 @@ void Range::Shared::redraw_owners() {
|
||||
if (!r->is_inside_tree()) {
|
||||
continue;
|
||||
}
|
||||
r->queue_accessibility_update();
|
||||
r->queue_redraw();
|
||||
}
|
||||
}
|
||||
@ -91,6 +131,7 @@ void Range::set_value(double p_val) {
|
||||
if (shared->val != prev_val) {
|
||||
shared->emit_value_changed();
|
||||
}
|
||||
queue_accessibility_update();
|
||||
}
|
||||
|
||||
void Range::_set_value_no_signal(double p_val) {
|
||||
@ -143,6 +184,8 @@ void Range::set_min(double p_min) {
|
||||
shared->emit_changed("min");
|
||||
|
||||
update_configuration_warnings();
|
||||
|
||||
queue_accessibility_update();
|
||||
}
|
||||
|
||||
void Range::set_max(double p_max) {
|
||||
@ -156,6 +199,8 @@ void Range::set_max(double p_max) {
|
||||
set_value(shared->val);
|
||||
|
||||
shared->emit_changed("max");
|
||||
|
||||
queue_accessibility_update();
|
||||
}
|
||||
|
||||
void Range::set_step(double p_step) {
|
||||
@ -165,6 +210,8 @@ void Range::set_step(double p_step) {
|
||||
|
||||
shared->step = p_step;
|
||||
shared->emit_changed("step");
|
||||
|
||||
queue_accessibility_update();
|
||||
}
|
||||
|
||||
void Range::set_page(double p_page) {
|
||||
@ -177,6 +224,8 @@ void Range::set_page(double p_page) {
|
||||
set_value(shared->val);
|
||||
|
||||
shared->emit_changed("page");
|
||||
|
||||
queue_accessibility_update();
|
||||
}
|
||||
|
||||
double Range::get_value() const {
|
||||
@ -264,6 +313,7 @@ void Range::unshare() {
|
||||
nshared->allow_lesser = shared->allow_lesser;
|
||||
_unref_shared();
|
||||
_ref_shared(nshared);
|
||||
queue_accessibility_update();
|
||||
}
|
||||
|
||||
void Range::_ref_shared(Shared *p_shared) {
|
||||
|
||||
Reference in New Issue
Block a user