mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 21:30:03 -04:00
Replace TODO: with TODO(emilk): and update code guidelines
This commit is contained in:
@@ -7,7 +7,7 @@ use std::{fmt::Debug, hash::Hash};
|
||||
use crate::*;
|
||||
|
||||
/// State that is persisted between frames.
|
||||
// TODO: this is not currently stored in `memory().data`, but maybe it should be?
|
||||
// TODO(emilk): this is not currently stored in `memory().data`, but maybe it should be?
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub(crate) struct State {
|
||||
|
||||
@@ -485,7 +485,7 @@ impl CollapsingHeader {
|
||||
show_background,
|
||||
} = self;
|
||||
|
||||
// TODO: horizontal layout, with icon and text as labels. Insert background behind using Frame.
|
||||
// TODO(emilk): horizontal layout, with icon and text as labels. Insert background behind using Frame.
|
||||
|
||||
let id = ui.make_persistent_id(id_source);
|
||||
let button_padding = ui.spacing().button_padding;
|
||||
|
||||
@@ -52,7 +52,7 @@ impl Default for Resize {
|
||||
resizable: true,
|
||||
min_size: Vec2::splat(16.0),
|
||||
max_size: Vec2::splat(f32::INFINITY),
|
||||
default_size: vec2(320.0, 128.0), // TODO: preferred size of [`Resize`] area.
|
||||
default_size: vec2(320.0, 128.0), // TODO(emilk): preferred size of [`Resize`] area.
|
||||
with_stroke: true,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -592,7 +592,7 @@ impl Prepared {
|
||||
- current_bar_use[d]
|
||||
- ui.spacing().item_spacing[d];
|
||||
inner_rect.max[d] = inner_rect.max[d].at_most(max);
|
||||
// TODO: maybe auto-enable horizontal/vertical scrolling if this limit is reached
|
||||
// TODO(emilk): maybe auto-enable horizontal/vertical scrolling if this limit is reached
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -507,7 +507,7 @@ fn interact(
|
||||
|
||||
let new_rect = ctx.constrain_window_rect_to_area(new_rect, area.drag_bounds());
|
||||
|
||||
// TODO: add this to a Window state instead as a command "move here next frame"
|
||||
// TODO(emilk): add this to a Window state instead as a command "move here next frame"
|
||||
area.state_mut().pos = new_rect.min;
|
||||
|
||||
if window_interaction.is_resize() {
|
||||
|
||||
@@ -1227,7 +1227,7 @@ impl Context {
|
||||
continue;
|
||||
}
|
||||
let text = format!("{} - {:?}", layer_id.short_debug_format(), area.rect(),);
|
||||
// TODO: `Sense::hover_highlight()`
|
||||
// TODO(emilk): `Sense::hover_highlight()`
|
||||
if ui
|
||||
.add(Label::new(RichText::new(text).monospace()).sense(Sense::click()))
|
||||
.hovered
|
||||
|
||||
@@ -506,7 +506,7 @@ impl WidgetInfo {
|
||||
text_selection: _,
|
||||
} = self;
|
||||
|
||||
// TODO: localization
|
||||
// TODO(emilk): localization
|
||||
let widget_type = match typ {
|
||||
WidgetType::Link => "link",
|
||||
WidgetType::TextEdit => "text edit",
|
||||
|
||||
@@ -37,7 +37,7 @@ pub(crate) struct FrameState {
|
||||
/// Set to [`InputState::scroll_delta`] on the start of each frame.
|
||||
///
|
||||
/// Cleared by the first [`ScrollArea`] that makes use of it.
|
||||
pub(crate) scroll_delta: Vec2, // TODO: move to a Mutex inside of `InputState` ?
|
||||
pub(crate) scroll_delta: Vec2, // TODO(emilk): move to `InputState` ?
|
||||
|
||||
/// horizontal, vertical
|
||||
pub(crate) scroll_target: [Option<(RangeInclusive<f32>, Option<Align>)>; 2],
|
||||
|
||||
@@ -74,7 +74,7 @@ impl GridLayout {
|
||||
pub(crate) fn new(ui: &Ui, id: Id) -> Self {
|
||||
let prev_state = State::load(ui.ctx(), id).unwrap_or_default();
|
||||
|
||||
// TODO: respect current layout
|
||||
// TODO(emilk): respect current layout
|
||||
|
||||
let initial_available = ui.placer().max_rect().intersect(ui.cursor());
|
||||
crate::egui_assert!(
|
||||
@@ -126,7 +126,7 @@ impl GridLayout {
|
||||
let width = if is_last_column {
|
||||
(self.initial_available.right() - region.cursor.left()).at_most(self.max_cell_size.x)
|
||||
} else if self.max_cell_size.x.is_finite() {
|
||||
// TODO: should probably heed `prev_state` here too
|
||||
// TODO(emilk): should probably heed `prev_state` here too
|
||||
self.max_cell_size.x
|
||||
} else {
|
||||
// If we want to allow width-filling widgets like [`Separator`] in one of the first cells
|
||||
@@ -159,7 +159,7 @@ impl GridLayout {
|
||||
|
||||
#[allow(clippy::unused_self)]
|
||||
pub(crate) fn align_size_within_rect(&self, size: Vec2, frame: Rect) -> Rect {
|
||||
// TODO: allow this alignment to be customized
|
||||
// TODO(emilk): allow this alignment to be customized
|
||||
Align2::LEFT_CENTER.align_size_within_rect(size, frame)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// TODO: have separate types `PositionId` and `UniqueId`. ?
|
||||
// TODO(emilk): have separate types `PositionId` and `UniqueId`. ?
|
||||
|
||||
/// egui tracks widgets frame-to-frame using [`Id`]s.
|
||||
///
|
||||
|
||||
@@ -9,13 +9,13 @@ pub use touch_state::MultiTouchInfo;
|
||||
use touch_state::TouchState;
|
||||
|
||||
/// If the pointer moves more than this, it won't become a click (but it is still a drag)
|
||||
const MAX_CLICK_DIST: f32 = 6.0; // TODO: move to settings
|
||||
const MAX_CLICK_DIST: f32 = 6.0; // TODO(emilk): move to settings
|
||||
|
||||
/// If the pointer is down for longer than this, it won't become a click (but it is still a drag)
|
||||
const MAX_CLICK_DURATION: f64 = 0.6; // TODO: move to settings
|
||||
const MAX_CLICK_DURATION: f64 = 0.6; // TODO(emilk): move to settings
|
||||
|
||||
/// The new pointer press must come within this many seconds from previous pointer release
|
||||
const MAX_DOUBLE_CLICK_DELAY: f64 = 0.3; // TODO: move to settings
|
||||
const MAX_DOUBLE_CLICK_DELAY: f64 = 0.3; // TODO(emilk): move to settings
|
||||
|
||||
/// Input state that egui updates each frame.
|
||||
///
|
||||
@@ -192,7 +192,7 @@ impl InputState {
|
||||
stable_dt,
|
||||
modifiers: new.modifiers,
|
||||
keys_down,
|
||||
events: new.events.clone(), // TODO: remove clone() and use raw.events
|
||||
events: new.events.clone(), // TODO(emilk): remove clone() and use raw.events
|
||||
raw: new,
|
||||
}
|
||||
}
|
||||
@@ -324,7 +324,7 @@ impl InputState {
|
||||
/// Returns imprecision in points.
|
||||
#[inline(always)]
|
||||
pub fn aim_radius(&self) -> f32 {
|
||||
// TODO: multiply by ~3 for touch inputs because fingers are fat
|
||||
// TODO(emilk): multiply by ~3 for touch inputs because fingers are fat
|
||||
self.physical_pixel_size()
|
||||
}
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ pub struct Layout {
|
||||
|
||||
impl Default for Layout {
|
||||
fn default() -> Self {
|
||||
// TODO: Get from `Style` instead.
|
||||
// TODO(emilk): Get from `Style` instead.
|
||||
Self::top_down(Align::LEFT) // This is a very euro-centric default.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,7 +497,7 @@ pub mod special_emojis {
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub enum WidgetType {
|
||||
Label, // TODO: emit Label events
|
||||
Label, // TODO(emilk): emit Label events
|
||||
/// e.g. a hyperlink
|
||||
Link,
|
||||
TextEdit,
|
||||
|
||||
@@ -142,7 +142,7 @@ pub(crate) fn menu_ui<'c, R>(
|
||||
|
||||
Frame::menu(style)
|
||||
.show(ui, |ui| {
|
||||
const DEFAULT_MENU_WIDTH: f32 = 150.0; // TODO: add to ui.spacing
|
||||
const DEFAULT_MENU_WIDTH: f32 = 150.0; // TODO(emilk): add to ui.spacing
|
||||
ui.set_max_width(DEFAULT_MENU_WIDTH);
|
||||
ui.set_menu_state(Some(menu_state_arc.clone()));
|
||||
ui.with_layout(Layout::top_down_justified(Align::LEFT), add_contents)
|
||||
|
||||
@@ -46,7 +46,7 @@ pub struct Response {
|
||||
#[doc(hidden)]
|
||||
pub clicked: [bool; NUM_POINTER_BUTTONS],
|
||||
|
||||
// TODO: `released` for sliders
|
||||
// TODO(emilk): `released` for sliders
|
||||
/// The thing was double-clicked.
|
||||
#[doc(hidden)]
|
||||
pub double_clicked: [bool; NUM_POINTER_BUTTONS],
|
||||
|
||||
@@ -204,7 +204,7 @@ pub struct Style {
|
||||
}
|
||||
|
||||
impl Style {
|
||||
// TODO: rename style.interact() to maybe... `style.interactive` ?
|
||||
// TODO(emilk): rename style.interact() to maybe... `style.interactive` ?
|
||||
/// Use this style for interactive things.
|
||||
/// Note that you must already have a response,
|
||||
/// i.e. you must allocate space and interact BEFORE painting the widget!
|
||||
@@ -258,10 +258,10 @@ pub struct Spacing {
|
||||
/// Minimum size of a [`DragValue`], color picker button, and other small widgets.
|
||||
/// `interact_size.y` is the default height of button, slider, etc.
|
||||
/// Anything clickable should be (at least) this size.
|
||||
pub interact_size: Vec2, // TODO: rename min_interact_size ?
|
||||
pub interact_size: Vec2, // TODO(emilk): rename min_interact_size ?
|
||||
|
||||
/// Default width of a [`Slider`] and [`ComboBox`](crate::ComboBox).
|
||||
pub slider_width: f32, // TODO: rename big_interact_size ?
|
||||
pub slider_width: f32, // TODO(emilk): rename big_interact_size ?
|
||||
|
||||
/// Default width of a [`TextEdit`].
|
||||
pub text_edit_width: f32,
|
||||
@@ -1226,7 +1226,7 @@ impl DebugOptions {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: improve and standardize `slider_vec2`
|
||||
// TODO(emilk): improve and standardize `slider_vec2`
|
||||
fn slider_vec2<'a>(
|
||||
value: &'a mut Vec2,
|
||||
range: std::ops::RangeInclusive<f32>,
|
||||
|
||||
@@ -1037,7 +1037,7 @@ impl Ui {
|
||||
/// # });
|
||||
/// ```
|
||||
pub fn add_sized(&mut self, max_size: impl Into<Vec2>, widget: impl Widget) -> Response {
|
||||
// TODO: configure to overflow to main_dir instead of centered overflow
|
||||
// TODO(emilk): configure to overflow to main_dir instead of centered overflow
|
||||
// to handle the bug mentioned at https://github.com/emilk/egui/discussions/318#discussioncomment-627578
|
||||
// and fixed in https://github.com/emilk/egui/commit/035166276322b3f2324bd8b97ffcedc63fa8419f
|
||||
//
|
||||
@@ -1721,7 +1721,7 @@ impl Ui {
|
||||
/// Create a child ui which is indented to the right.
|
||||
///
|
||||
/// The `id_source` here be anything at all.
|
||||
// TODO: remove `id_source` argument?
|
||||
// TODO(emilk): remove `id_source` argument?
|
||||
#[inline]
|
||||
pub fn indent<R>(
|
||||
&mut self,
|
||||
@@ -2037,7 +2037,7 @@ impl Ui {
|
||||
num_columns: usize,
|
||||
add_contents: Box<dyn FnOnce(&mut [Self]) -> R + 'c>,
|
||||
) -> R {
|
||||
// TODO: ensure there is space
|
||||
// TODO(emilk): ensure there is space
|
||||
let spacing = self.spacing().item_spacing.x;
|
||||
let total_spacing = spacing * (num_columns as f32 - 1.0);
|
||||
let column_width = (self.available_width() - total_spacing) / (num_columns as f32);
|
||||
|
||||
@@ -2,7 +2,7 @@ use epaint::util::hash;
|
||||
|
||||
const FIXED_CACHE_SIZE: usize = 1024; // must be small for web/WASM build (for unknown reason)
|
||||
|
||||
/// Very stupid/simple key-value cache. TODO: improve
|
||||
/// Very stupid/simple key-value cache. TODO(emilk): improve
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct FixedCache<K, V>([Option<(K, V)>; FIXED_CACHE_SIZE]);
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ where
|
||||
|
||||
/// `(time, value)` pairs
|
||||
/// Time difference between values can be zero, but never negative.
|
||||
// TODO: impl IntoIter
|
||||
// TODO(emilk): impl IntoIter
|
||||
pub fn iter(&'_ self) -> impl ExactSizeIterator<Item = (f64, T)> + '_ {
|
||||
self.values.iter().map(|(time, value)| (*time, *value))
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// TODO: it is possible we can simplify `Element` further by
|
||||
// TODO(emilk): it is possible we can simplify `Element` further by
|
||||
// assuming everything is possibly serializable, and by supplying serialize/deserialize functions for them.
|
||||
// For non-serializable types, these simply return `None`.
|
||||
// This will also allow users to pick their own serialization format per type.
|
||||
@@ -292,7 +292,7 @@ fn from_ron_str<T: serde::de::DeserializeOwned>(ron: &str) -> Option<T> {
|
||||
|
||||
use crate::Id;
|
||||
|
||||
// TODO: make IdTypeMap generic over the key (`Id`), and make a library of IdTypeMap.
|
||||
// TODO(emilk): make IdTypeMap generic over the key (`Id`), and make a library of IdTypeMap.
|
||||
/// Stores values identified by an [`Id`] AND a the [`std::any::TypeId`] of the value.
|
||||
///
|
||||
/// In other words, it maps `(Id, TypeId)` to any value you want.
|
||||
|
||||
@@ -203,7 +203,7 @@ impl Widget for Button {
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// TODO: allow checkbox without a text label
|
||||
// TODO(emilk): allow checkbox without a text label
|
||||
/// Boolean on/off control with text label.
|
||||
///
|
||||
/// Usually you'd use [`Ui::checkbox`] instead.
|
||||
|
||||
@@ -350,7 +350,7 @@ pub fn color_edit_button_hsva(ui: &mut Ui, hsva: &mut Hsva, alpha: Alpha) -> Res
|
||||
if button_response.clicked() {
|
||||
ui.memory().toggle_popup(popup_id);
|
||||
}
|
||||
// TODO: make it easier to show a temporary popup that closes when you click outside it
|
||||
// TODO(emilk): make it easier to show a temporary popup that closes when you click outside it
|
||||
if ui.memory().is_popup_open(popup_id) {
|
||||
let area_response = Area::new(popup_id)
|
||||
.order(Order::Foreground)
|
||||
|
||||
@@ -112,7 +112,7 @@ impl<'a> DragValue<'a> {
|
||||
self
|
||||
}
|
||||
|
||||
// TODO: we should also have a "min precision".
|
||||
// TODO(emilk): we should also have a "min precision".
|
||||
/// Set a minimum number of decimals to display.
|
||||
/// Normally you don't need to pick a precision, as the slider will intelligently pick a precision for you.
|
||||
/// Regardless of precision the slider will use "smart aim" to help the user select nice, round values.
|
||||
@@ -121,7 +121,7 @@ impl<'a> DragValue<'a> {
|
||||
self
|
||||
}
|
||||
|
||||
// TODO: we should also have a "max precision".
|
||||
// TODO(emilk): we should also have a "max precision".
|
||||
/// Set a maximum number of decimals to display.
|
||||
/// Values will also be rounded to this number of decimals.
|
||||
/// Normally you don't need to pick a precision, as the slider will intelligently pick a precision for you.
|
||||
@@ -214,7 +214,7 @@ impl<'a> Widget for DragValue<'a> {
|
||||
)
|
||||
.wrap(false)
|
||||
.sense(Sense::click_and_drag())
|
||||
.min_size(ui.spacing().interact_size); // TODO: find some more generic solution to `min_size`
|
||||
.min_size(ui.spacing().interact_size); // TODO(emilk): find some more generic solution to `min_size`
|
||||
|
||||
let response = ui.add(button);
|
||||
let mut response = response.on_hover_cursor(CursorIcon::ResizeHorizontal);
|
||||
@@ -223,7 +223,7 @@ impl<'a> Widget for DragValue<'a> {
|
||||
response = response .on_hover_text(format!(
|
||||
"{}{}{}\nDrag to edit or click to enter a value.\nPress 'Shift' while dragging for better control.",
|
||||
prefix,
|
||||
value as f32, // Show full precision value on-hover. TODO: figure out f64 vs f32
|
||||
value as f32, // Show full precision value on-hover. TODO(emilk): figure out f64 vs f32
|
||||
suffix
|
||||
));
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ impl Image {
|
||||
}
|
||||
|
||||
{
|
||||
// TODO: builder pattern for Mesh
|
||||
// TODO(emilk): builder pattern for Mesh
|
||||
let mut mesh = Mesh::with_texture(*texture_id);
|
||||
mesh.add_rect_with_uv(rect, *uv, *tint);
|
||||
if let Some((rot, origin)) = rotation {
|
||||
|
||||
@@ -135,7 +135,7 @@ impl Label {
|
||||
};
|
||||
|
||||
if ui.is_grid() {
|
||||
// TODO: remove special Grid hacks like these
|
||||
// TODO(emilk): remove special Grid hacks like these
|
||||
text_job.job.halign = Align::LEFT;
|
||||
text_job.job.justify = false;
|
||||
} else {
|
||||
|
||||
@@ -347,7 +347,7 @@ impl ExplicitGenerator {
|
||||
let max_x = *self.x_range.end();
|
||||
let min_y = (self.function)(min_x);
|
||||
let max_y = (self.function)(max_x);
|
||||
// TODO: sample some more points
|
||||
// TODO(emilk): sample some more points
|
||||
PlotBounds {
|
||||
min: [min_x, min_y],
|
||||
max: [max_x, max_y],
|
||||
|
||||
@@ -65,7 +65,7 @@ impl Default for CoordinatesFormatter {
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
const MIN_LINE_SPACING_IN_POINTS: f64 = 6.0; // TODO: large enough for a wide label
|
||||
const MIN_LINE_SPACING_IN_POINTS: f64 = 6.0; // TODO(emilk): large enough for a wide label
|
||||
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[derive(Clone)]
|
||||
@@ -867,7 +867,7 @@ impl PlotUi {
|
||||
self.next_auto_color_idx += 1;
|
||||
let golden_ratio = (5.0_f32.sqrt() - 1.0) / 2.0; // 0.61803398875
|
||||
let h = i as f32 * golden_ratio;
|
||||
Hsva::new(h, 0.85, 0.5, 1.0).into() // TODO: OkLab or some other perspective color space
|
||||
Hsva::new(h, 0.85, 0.5, 1.0).into() // TODO(emilk): OkLab or some other perspective color space
|
||||
}
|
||||
|
||||
pub fn ctx(&self) -> &Context {
|
||||
|
||||
@@ -212,7 +212,7 @@ impl<'a> Slider<'a> {
|
||||
self
|
||||
}
|
||||
|
||||
// TODO: we should also have a "min precision".
|
||||
// TODO(emilk): we should also have a "min precision".
|
||||
/// Set a minimum number of decimals to display.
|
||||
/// Normally you don't need to pick a precision, as the slider will intelligently pick a precision for you.
|
||||
/// Regardless of precision the slider will use "smart aim" to help the user select nice, round values.
|
||||
@@ -221,7 +221,7 @@ impl<'a> Slider<'a> {
|
||||
self
|
||||
}
|
||||
|
||||
// TODO: we should also have a "max precision".
|
||||
// TODO(emilk): we should also have a "max precision".
|
||||
/// Set a maximum number of decimals to display.
|
||||
/// Values will also be rounded to this number of decimals.
|
||||
/// Normally you don't need to pick a precision, as the slider will intelligently pick a precision for you.
|
||||
@@ -485,7 +485,7 @@ impl<'a> Slider<'a> {
|
||||
|
||||
/// delta(value) / delta(points)
|
||||
fn current_gradient(&mut self, position_range: &RangeInclusive<f32>) -> f64 {
|
||||
// TODO: handle clamping
|
||||
// TODO(emilk): handle clamping
|
||||
let value = self.get_value();
|
||||
let value_from_pos =
|
||||
|position: f32| self.value_from_position(position, position_range.clone());
|
||||
|
||||
@@ -312,7 +312,7 @@ impl<'t> TextEdit<'t> {
|
||||
rect: frame_rect,
|
||||
rounding: visuals.rounding,
|
||||
fill: ui.visuals().extreme_bg_color,
|
||||
stroke: visuals.bg_stroke, // TODO: we want to show something here, or a text-edit field doesn't "pop".
|
||||
stroke: visuals.bg_stroke, // TODO(emilk): we want to show something here, or a text-edit field doesn't "pop".
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -323,7 +323,7 @@ impl<'t> TextEdit<'t> {
|
||||
// fill: ui.visuals().extreme_bg_color,
|
||||
// fill: visuals.bg_fill,
|
||||
fill: Color32::TRANSPARENT,
|
||||
stroke: visuals.bg_stroke, // TODO: we want to show something here, or a text-edit field doesn't "pop".
|
||||
stroke: visuals.bg_stroke, // TODO(emilk): we want to show something here, or a text-edit field doesn't "pop".
|
||||
}
|
||||
};
|
||||
|
||||
@@ -388,7 +388,7 @@ impl<'t> TextEdit<'t> {
|
||||
let desired_width = if multiline {
|
||||
galley.size().x.max(wrap_width) // always show everything in multiline
|
||||
} else {
|
||||
wrap_width // visual clipping with scroll in singleline input. TODO: opt-in/out?
|
||||
wrap_width // visual clipping with scroll in singleline input. TODO(emilk): opt-in/out?
|
||||
};
|
||||
let desired_height = (desired_height_rows.at_least(1) as f32) * row_height;
|
||||
let desired_size = vec2(desired_width, galley.size().y.max(desired_height));
|
||||
@@ -430,7 +430,7 @@ impl<'t> TextEdit<'t> {
|
||||
ui.output().mutable_text_under_cursor = true;
|
||||
}
|
||||
|
||||
// TODO: drag selected text to either move or clone (ctrl on windows, alt on mac)
|
||||
// TODO(emilk): drag selected text to either move or clone (ctrl on windows, alt on mac)
|
||||
let singleline_offset = vec2(state.singleline_offset, 0.0);
|
||||
let cursor_at_pointer =
|
||||
galley.cursor_from_pos(pointer_pos - response.rect.min + singleline_offset);
|
||||
@@ -693,7 +693,7 @@ fn events(
|
||||
|
||||
let mut any_change = false;
|
||||
|
||||
let events = ui.input().events.clone(); // avoid dead-lock by cloning. TODO: optimize
|
||||
let events = ui.input().events.clone(); // avoid dead-lock by cloning. TODO(emilk): optimize
|
||||
for event in &events {
|
||||
let did_mutate_text = match event {
|
||||
Event::Copy => {
|
||||
@@ -740,7 +740,7 @@ fn events(
|
||||
if multiline && ui.memory().has_lock_focus(id) {
|
||||
let mut ccursor = delete_selected(text, &cursor_range);
|
||||
if modifiers.shift {
|
||||
// TODO: support removing indentation over a selection?
|
||||
// TODO(emilk): support removing indentation over a selection?
|
||||
decrease_identation(&mut ccursor, text);
|
||||
} else {
|
||||
insert_text(&mut ccursor, text, "\t");
|
||||
@@ -758,7 +758,7 @@ fn events(
|
||||
if multiline {
|
||||
let mut ccursor = delete_selected(text, &cursor_range);
|
||||
insert_text(&mut ccursor, text, "\n");
|
||||
// TODO: if code editor, auto-indent by same leading tabs, + one if the lines end on an opening bracket
|
||||
// TODO(emilk): if code editor, auto-indent by same leading tabs, + one if the lines end on an opening bracket
|
||||
Some(CCursorRange::one(ccursor))
|
||||
} else {
|
||||
ui.memory().surrender_focus(id); // End input with enter
|
||||
@@ -770,7 +770,7 @@ fn events(
|
||||
pressed: true,
|
||||
modifiers,
|
||||
} if modifiers.command && !modifiers.shift => {
|
||||
// TODO: redo
|
||||
// TODO(emilk): redo
|
||||
if let Some((undo_ccursor_range, undo_txt)) = state
|
||||
.undoer
|
||||
.lock()
|
||||
|
||||
@@ -21,4 +21,4 @@ pub struct TextEditOutput {
|
||||
pub cursor_range: Option<super::CursorRange>,
|
||||
}
|
||||
|
||||
// TODO: add `output.paint` and `output.store` and split out that code from `TextEdit::show`.
|
||||
// TODO(emilk): add `output.paint` and `output.store` and split out that code from `TextEdit::show`.
|
||||
|
||||
Reference in New Issue
Block a user