diff --git a/examples/restricted_input.rs b/examples/restricted_input.rs index a5b8bd8d9586c5dad4ada415cf25627c3fbeb452..65b93fc8dd771558cbe51a529d6fe2b6c6bc158b 100644 --- a/examples/restricted_input.rs +++ b/examples/restricted_input.rs @@ -25,12 +25,13 @@ fn setup(mut commands: Commands, windows: Query<&Window, With<PrimaryWindow>>) { line_height: 16., scale_factor: primary_window.scale_factor() as f32, }, - max_chars: CosmicMaxChars(15), + max_chars: CosmicMaxChars(23), max_lines: CosmicMaxLines(1), text: CosmicText::OneStyle( - "1 line 15 chars! But this\n is longer\n than is\n allowed by\n the limits.\n" + "1 line 25 chars! But this a b c d e f g\n is longer\n than is\n allowed by\n the limits.\n" .into(), ), + text_position: CosmicTextPosition::Left { padding: 20 }, ..default() }) .id(); diff --git a/src/lib.rs b/src/lib.rs index 1bacfb67c9ba05a8d3a86b884ffe932d6b8fa643..a1b1d43e4f4377a56dba14f9b94d9d56dbb832ec 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,7 +36,12 @@ impl Default for CosmicText { pub enum CosmicTextPosition { #[default] Center, - TopLeft, + TopLeft { + padding: i32, + }, + Left { + padding: i32, + }, } #[derive(Event, Debug)] @@ -1014,7 +1019,8 @@ fn cosmic_edit_bevy_events( get_x_offset(editor.0.buffer()), get_y_offset(editor.0.buffer()), ), - CosmicTextPosition::TopLeft => (0, 0), + CosmicTextPosition::TopLeft { padding } => (*padding, *padding), + CosmicTextPosition::Left { padding } => (*padding, get_y_offset(editor.0.buffer())), }; let point = |node_cursor_pos: (f32, f32)| { ( @@ -1209,7 +1215,8 @@ fn redraw_buffer_common( CosmicTextPosition::Center => { (get_y_offset(editor.buffer()), get_x_offset(editor.buffer())) } - CosmicTextPosition::TopLeft => (0, 0), + CosmicTextPosition::TopLeft { padding } => (*padding, *padding), + CosmicTextPosition::Left { padding } => (get_y_offset(editor.buffer()), *padding), }; editor.draw(