Rename Output::text_cursor to text_cursor_pos
This commit is contained in:
@@ -24,8 +24,8 @@ pub struct Output {
|
||||
/// Events that may be useful to e.g. a screen reader.
|
||||
pub events: Vec<OutputEvent>,
|
||||
|
||||
/// Position of text widgts' cursor
|
||||
pub text_cursor: Option<crate::Pos2>,
|
||||
/// Position of text edit cursor (used for IME).
|
||||
pub text_cursor_pos: Option<crate::Pos2>,
|
||||
}
|
||||
|
||||
impl Output {
|
||||
|
||||
@@ -152,7 +152,7 @@ impl Button {
|
||||
|
||||
if ui.clip_rect().intersects(rect) {
|
||||
let visuals = ui.style().interact(&response);
|
||||
let text_cursor = ui
|
||||
let text_pos = ui
|
||||
.layout()
|
||||
.align_size_within_rect(galley.size, rect.shrink2(button_padding))
|
||||
.min;
|
||||
@@ -170,7 +170,7 @@ impl Button {
|
||||
let text_color = text_color
|
||||
.or(ui.visuals().override_text_color)
|
||||
.unwrap_or_else(|| visuals.text_color());
|
||||
ui.painter().galley(text_cursor, galley, text_color);
|
||||
ui.painter().galley(text_pos, galley, text_color);
|
||||
}
|
||||
|
||||
response
|
||||
@@ -277,7 +277,7 @@ impl<'a> Widget for Checkbox<'a> {
|
||||
|
||||
// let visuals = ui.style().interact_selectable(&response, *checked); // too colorful
|
||||
let visuals = ui.style().interact(&response);
|
||||
let text_cursor = pos2(
|
||||
let text_pos = pos2(
|
||||
rect.min.x + button_padding.x + icon_width + icon_spacing,
|
||||
rect.center().y - 0.5 * galley.size.y,
|
||||
);
|
||||
@@ -304,7 +304,7 @@ impl<'a> Widget for Checkbox<'a> {
|
||||
let text_color = text_color
|
||||
.or(ui.visuals().override_text_color)
|
||||
.unwrap_or_else(|| visuals.text_color());
|
||||
ui.painter().galley(text_cursor, galley, text_color);
|
||||
ui.painter().galley(text_pos, galley, text_color);
|
||||
response
|
||||
}
|
||||
}
|
||||
@@ -392,7 +392,7 @@ impl Widget for RadioButton {
|
||||
response
|
||||
.widget_info(|| WidgetInfo::selected(WidgetType::RadioButton, checked, &galley.text));
|
||||
|
||||
let text_cursor = pos2(
|
||||
let text_pos = pos2(
|
||||
rect.min.x + button_padding.x + icon_width + icon_spacing,
|
||||
rect.center().y - 0.5 * galley.size.y,
|
||||
);
|
||||
@@ -424,7 +424,7 @@ impl Widget for RadioButton {
|
||||
let text_color = text_color
|
||||
.or(ui.visuals().override_text_color)
|
||||
.unwrap_or_else(|| visuals.text_color());
|
||||
painter.galley(text_cursor, galley, text_color);
|
||||
painter.galley(text_pos, galley, text_color);
|
||||
response
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ impl Widget for SelectableLabel {
|
||||
WidgetInfo::selected(WidgetType::SelectableLabel, selected, &galley.text)
|
||||
});
|
||||
|
||||
let text_cursor = ui
|
||||
let text_pos = ui
|
||||
.layout()
|
||||
.align_size_within_rect(galley.size, rect.shrink2(button_padding))
|
||||
.min;
|
||||
@@ -93,7 +93,7 @@ impl Widget for SelectableLabel {
|
||||
.visuals
|
||||
.override_text_color
|
||||
.unwrap_or_else(|| visuals.text_color());
|
||||
ui.painter().galley(text_cursor, galley, text_color);
|
||||
ui.painter().galley(text_pos, galley, text_color);
|
||||
response
|
||||
}
|
||||
}
|
||||
|
||||
@@ -678,7 +678,7 @@ impl<'t, S: TextBuffer> TextEdit<'t, S> {
|
||||
if ui.memory().has_focus(id) {
|
||||
{
|
||||
let mut output = ui.ctx().output();
|
||||
output.text_cursor = text_cursor.map(|c| {
|
||||
output.text_cursor_pos = text_cursor.map(|c| {
|
||||
galley
|
||||
.pos_from_cursor(&c.primary)
|
||||
.translate(response.rect.min.to_vec2())
|
||||
|
||||
Reference in New Issue
Block a user