mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-02 03:58:33 +08:00
improve text selector
This commit is contained in:
parent
97e3b13d69
commit
d59496036f
@ -3,6 +3,7 @@
|
||||
2022/10/21
|
||||
* 完善line number高亮行(方便awblock用于显示断点)
|
||||
* 完善fscript array的文档(感谢雨欣提供补丁)
|
||||
* 修复text\_selector勾选loop\_options时无法跳转到指定选项的问题(感谢雨欣提供补丁)
|
||||
|
||||
2022/10/20
|
||||
* 增加tk\_object\_to\_json函数。
|
||||
|
@ -551,23 +551,17 @@ static int32_t text_selector_get_yoffset_for_selected_index(text_selector_t* tex
|
||||
int32_t yoffset = 0;
|
||||
if (text_selector->loop_options) {
|
||||
int32_t options_nr = text_selector_count_options(WIDGET(text_selector));
|
||||
int32_t n = options_nr >> 1;
|
||||
int32_t d =
|
||||
n - tk_abs(tk_abs(text_selector->selected_index - text_selector->last_selected_index) - n);
|
||||
float_t middle = (float_t)options_nr / 2.0f;
|
||||
float_t d_nr = tk_abs((float_t)text_selector->selected_index -
|
||||
(float_t)text_selector->last_selected_index);
|
||||
int32_t move_nr = middle - tk_abs(d_nr - middle);
|
||||
yoffset = text_selector->yoffset;
|
||||
if (text_selector->selected_index > text_selector->last_selected_index) {
|
||||
if (text_selector->selected_index - d == text_selector->last_selected_index) {
|
||||
yoffset += (d * item_height);
|
||||
} else {
|
||||
yoffset -= (d * item_height);
|
||||
}
|
||||
|
||||
if ((text_selector->last_selected_index + move_nr) % options_nr ==
|
||||
text_selector->selected_index) {
|
||||
yoffset += (move_nr * item_height);
|
||||
} else {
|
||||
if ((text_selector->last_selected_index + d + 1) % options_nr ==
|
||||
text_selector->selected_index) {
|
||||
yoffset += ((d + 1) * item_height);
|
||||
} else {
|
||||
yoffset -= (d * item_height);
|
||||
}
|
||||
yoffset -= (move_nr * item_height);
|
||||
}
|
||||
} else {
|
||||
yoffset = (text_selector->selected_index - mid_index) * item_height;
|
||||
|
Loading…
Reference in New Issue
Block a user