diff options
author | 2020-02-24 18:03:42 +0100 | |
---|---|---|
committer | 2020-02-24 18:03:42 +0100 | |
commit | c6c8cabdaf03f90b1739be828cf140d8ddb92e65 (patch) | |
tree | 07986c2132fd6f66904170e7f745a9d680fd17a7 /wgpu/src/renderer | |
parent | 190dcef1553efa181b68caa91b109f83fe289412 (diff) | |
download | iced-c6c8cabdaf03f90b1739be828cf140d8ddb92e65.tar.gz iced-c6c8cabdaf03f90b1739be828cf140d8ddb92e65.tar.bz2 iced-c6c8cabdaf03f90b1739be828cf140d8ddb92e65.zip |
moved cursor into own file
moved click tracking as a new State struct to input::mouse
made cursor field of text_input state private
brought back cursor type(Index, Selection) representation with a state enum
cleaned out some stuff (but not enough/all)
TODO: Documentation (sigh)
TODO: Editor struct
TODO: some (hopefully) small improvements here and there
Diffstat (limited to 'wgpu/src/renderer')
-rw-r--r-- | wgpu/src/renderer/widget/text_input.rs | 50 |
1 files changed, 7 insertions, 43 deletions
diff --git a/wgpu/src/renderer/widget/text_input.rs b/wgpu/src/renderer/widget/text_input.rs index 4e0274b8..fa108d68 100644 --- a/wgpu/src/renderer/widget/text_input.rs +++ b/wgpu/src/renderer/widget/text_input.rs @@ -46,7 +46,7 @@ impl text_input::Renderer for Renderer { text_bounds, value, size, - state.cursor.draw_position(value), + state.cursor().cursor_position(value), font, ); @@ -116,20 +116,20 @@ impl text_input::Renderer for Renderer { text_bounds, value, size, - state.cursor.draw_position(value), + state.cursor().cursor_position(value), font, ); - /*let selection = match cursor { - text_input::Cursor::Index(_) => Primitive::None, - text_input::Cursor::Selection { .. } => { + let selection = match state.cursor().selection_position() { + None => Primitive::None, + Some(_) => { let (cursor_left_offset, _) = measure_cursor_and_scroll_offset( self, text_bounds, value, size, - state.cursor.left(), + state.cursor().left(), font, ); let (cursor_right_offset, _) = @@ -138,7 +138,7 @@ impl text_input::Renderer for Renderer { text_bounds, value, size, - state.cursor.right(), + state.cursor().right(), font, ); let width = cursor_right_offset - cursor_left_offset; @@ -157,42 +157,6 @@ impl text_input::Renderer for Renderer { border_color: Color::TRANSPARENT, } } - };*/ - - let selection = if !state.cursor.is_selection() { - Primitive::None - } else { - let (cursor_left_offset, _) = measure_cursor_and_scroll_offset( - self, - text_bounds, - value, - size, - state.cursor.left(), - font, - ); - let (cursor_right_offset, _) = measure_cursor_and_scroll_offset( - self, - text_bounds, - value, - size, - state.cursor.right(), - font, - ); - let width = cursor_right_offset - cursor_left_offset; - Primitive::Quad { - bounds: Rectangle { - x: text_bounds.x + cursor_left_offset, - y: text_bounds.y, - width, - height: text_bounds.height, - }, - background: Background::Color( - style_sheet.selection_color(), - ), - border_radius: 0, - border_width: 0, - border_color: Color::TRANSPARENT, - } }; let cursor = Primitive::Quad { |