Skip to content

Commit

Permalink
Merge branch 'emilk:master' into patch2
Browse files Browse the repository at this point in the history
  • Loading branch information
rustbasic authored Jul 4, 2024
2 parents 67bc9ae + b31d02d commit 0a9d65f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Changes since the last release can be found at <https://github.com/emilk/egui/co
* `Ui::new` and `ui.child_ui` now takes a new parameter for the `UiStack` ([#4588](https://github.com/emilk/egui/pull/4588))
* The `extra_asserts` and `extra_debug_asserts` feature flags have been removed ([#4478](https://github.com/emilk/egui/pull/4478))
* Remove `Event::Scroll` and handle it in egui. Use `Event::MouseWheel` instead ([#4524](https://github.com/emilk/egui/pull/4524))
* `Event::Zoom` is no longer emitted on ctrl+scroll. Use `InputState::smooth_scroll_delta` instead ([#4524](https://github.com/emilk/egui/pull/4524))
* `ui.set_enabled` and `set_visbile` have been deprecated ([#4614](https://github.com/emilk/egui/pull/4614))
* `DragValue::clamp_range` renamed to `range` (([#4728](https://github.com/emilk/egui/pull/4728))

Expand Down
8 changes: 5 additions & 3 deletions crates/egui/src/containers/panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ impl TopBottomPanel {
}

/// The initial height of the [`TopBottomPanel`], including margins.
/// Defaults to [`style::Spacing::interact_size`].y.
/// Defaults to [`style::Spacing::interact_size`].y, plus frame margins.
#[inline]
pub fn default_height(mut self, default_height: f32) -> Self {
self.default_height = Some(default_height);
Expand Down Expand Up @@ -712,13 +712,16 @@ impl TopBottomPanel {
height_range,
} = self;

let frame = frame.unwrap_or_else(|| Frame::side_top_panel(ui.style()));

let available_rect = ui.available_rect_before_wrap();
let mut panel_rect = available_rect;

let mut height = if let Some(state) = PanelState::load(ui.ctx(), id) {
state.rect.height()
} else {
default_height.unwrap_or_else(|| ui.style().spacing.interact_size.y)
default_height
.unwrap_or_else(|| ui.style().spacing.interact_size.y + frame.inner_margin.sum().y)
};
{
height = clamp_to_range(height, height_range).at_most(available_rect.height());
Expand Down Expand Up @@ -759,7 +762,6 @@ impl TopBottomPanel {
panel_ui.expand_to_include_rect(panel_rect);
panel_ui.set_clip_rect(panel_rect); // If we overflow, don't do so visibly (#4475)

let frame = frame.unwrap_or_else(|| Frame::side_top_panel(ui.style()));
let inner_response = frame.show(&mut panel_ui, |ui| {
ui.set_min_width(ui.max_rect().width()); // Make the frame fill full width
ui.set_min_height((height_range.min - frame.inner_margin.sum().y).at_least(0.0));
Expand Down
8 changes: 7 additions & 1 deletion crates/egui/src/data/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,16 @@ pub enum Event {
/// On touch-up first send `PointerButton{pressed: false, …}` followed by `PointerLeft`.
PointerGone,

/// Zoom scale factor this frame (e.g. from ctrl-scroll or pinch gesture).
/// Zoom scale factor this frame (e.g. from a pinch gesture).
///
/// * `zoom = 1`: no change.
/// * `zoom < 1`: pinch together
/// * `zoom > 1`: pinch spread
///
/// Note that egui also implement zooming by holding `Ctrl` and scrolling the mouse wheel,
/// so integration need NOT emit this `Zoom` event in those cases, just [`Self::MouseWheel`].
///
/// As a user, check [`crate::InputState::smooth_scroll_delta`] to see if the user did any zooming this frame.
Zoom(f32),

/// IME Event
Expand Down
2 changes: 2 additions & 0 deletions crates/egui/src/input_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const MAX_DOUBLE_CLICK_DELAY: f64 = 0.3; // TODO(emilk): move to settings

/// Input state that egui updates each frame.
///
/// You can access this with [`crate::Context::input`].
///
/// You can check if `egui` is using the inputs using
/// [`crate::Context::wants_pointer_input`] and [`crate::Context::wants_keyboard_input`].
#[derive(Clone, Debug)]
Expand Down

0 comments on commit 0a9d65f

Please sign in to comment.