Table resize (#1438)
* Let 1D strips fill up parent width/height * Add Strip + Table + DatePicker to egui_extras changelog * Expose some dragging- and pointer related context/memory methods * Make tables resizable
This commit is contained in:
@@ -201,7 +201,7 @@ impl SidePanel {
|
||||
let mut is_resizing = false;
|
||||
if resizable {
|
||||
let resize_id = id.with("__resize");
|
||||
if let Some(pointer) = ui.ctx().latest_pointer_pos() {
|
||||
if let Some(pointer) = ui.ctx().pointer_latest_pos() {
|
||||
let we_are_on_top = ui
|
||||
.ctx()
|
||||
.layer_id_at(pointer)
|
||||
@@ -217,9 +217,9 @@ impl SidePanel {
|
||||
&& ui.input().pointer.any_down()
|
||||
&& mouse_over_resize_line
|
||||
{
|
||||
ui.memory().interaction.drag_id = Some(resize_id);
|
||||
ui.memory().set_dragged_id(resize_id);
|
||||
}
|
||||
is_resizing = ui.memory().interaction.drag_id == Some(resize_id);
|
||||
is_resizing = ui.memory().is_being_dragged(resize_id);
|
||||
if is_resizing {
|
||||
let width = (pointer.x - side.side_x(panel_rect)).abs();
|
||||
let width =
|
||||
|
||||
+1
-1
@@ -885,7 +885,7 @@ impl Context {
|
||||
/// Latest reported pointer position.
|
||||
/// When tapping a touch screen, this will be `None`.
|
||||
#[inline(always)]
|
||||
pub(crate) fn latest_pointer_pos(&self) -> Option<Pos2> {
|
||||
pub fn pointer_latest_pos(&self) -> Option<Pos2> {
|
||||
self.input().pointer.latest_pos()
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ pub(crate) fn font_texture_ui(ui: &mut Ui, [width, height]: [usize; 2]) -> Respo
|
||||
response
|
||||
.on_hover_cursor(CursorIcon::ZoomIn)
|
||||
.on_hover_ui_at_pointer(|ui| {
|
||||
if let Some(pos) = ui.ctx().latest_pointer_pos() {
|
||||
if let Some(pos) = ui.ctx().pointer_latest_pos() {
|
||||
let (_id, zoom_rect) = ui.allocate_space(vec2(128.0, 128.0));
|
||||
let u = remap_clamp(pos.x, rect.x_range(), 0.0..=tex_w);
|
||||
let v = remap_clamp(pos.y, rect.y_range(), 0.0..=tex_h);
|
||||
|
||||
@@ -418,6 +418,11 @@ impl Memory {
|
||||
self.interaction.drag_id == Some(id)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn set_dragged_id(&mut self, id: Id) {
|
||||
self.interaction.drag_id = Some(id);
|
||||
}
|
||||
|
||||
/// Forget window positions, sizes etc.
|
||||
/// Can be used to auto-layout windows.
|
||||
pub fn reset_areas(&mut self) {
|
||||
|
||||
Reference in New Issue
Block a user