edit: Scale cropping selection area with image
This commit is contained in:
parent
6867e0b13f
commit
5b184e6be9
8 changed files with 133 additions and 56 deletions
|
|
@ -29,6 +29,19 @@ impl imp::LpImage {
|
|||
}
|
||||
}
|
||||
|
||||
/// Image width with current zoom factor and rotation
|
||||
///
|
||||
/// During rotation it is an interpolated size that does not
|
||||
/// represent the actual size. The size returned might well be
|
||||
/// larger than what can actually be displayed within the widget.
|
||||
pub fn image_displayed_width(&self) -> f64 {
|
||||
self.image_width(self.applicable_zoom())
|
||||
}
|
||||
|
||||
pub fn image_displayed_height(&self) -> f64 {
|
||||
self.image_height(self.applicable_zoom())
|
||||
}
|
||||
|
||||
pub fn image_width(&self, zoom: f64) -> f64 {
|
||||
let (width, height) = self.original_dimensions();
|
||||
|
||||
|
|
@ -94,19 +107,4 @@ impl LpImage {
|
|||
self.imp().original_dimensions()
|
||||
}
|
||||
}
|
||||
|
||||
/// Image width with current zoom factor and rotation
|
||||
///
|
||||
/// During rotation it is an interpolated size that does not
|
||||
/// represent the actual size. The size returned might well be
|
||||
/// larger than what can actually be displayed within the widget.
|
||||
pub fn image_displayed_width(&self) -> f64 {
|
||||
let imp = self.imp();
|
||||
imp.image_width(imp.applicable_zoom())
|
||||
}
|
||||
|
||||
pub fn image_displayed_height(&self) -> f64 {
|
||||
let imp = self.imp();
|
||||
imp.image_height(imp.applicable_zoom())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,8 +60,8 @@ impl WidgetImpl for imp::LpImage {
|
|||
let obj = self.obj();
|
||||
let widget_width = self.widget_width();
|
||||
let widget_height = self.widget_height();
|
||||
let display_width = obj.image_displayed_width();
|
||||
let display_height = obj.image_displayed_height();
|
||||
let display_width = self.image_displayed_width();
|
||||
let display_height = self.image_displayed_height();
|
||||
|
||||
let applicable_zoom = self.applicable_zoom();
|
||||
|
||||
|
|
@ -338,14 +338,24 @@ impl LpImage {
|
|||
pub fn image_rendering_x(&self) -> f64 {
|
||||
let imp = self.imp();
|
||||
let widget_width = imp.widget_width();
|
||||
let display_width = self.image_displayed_width();
|
||||
let display_width = imp.image_displayed_width();
|
||||
imp.round_f64(f64::max((widget_width - display_width) / 2.0, 0.))
|
||||
}
|
||||
|
||||
pub fn image_rendering_y(&self) -> f64 {
|
||||
let imp = self.imp();
|
||||
let widget_height = imp.widget_height();
|
||||
let display_height = self.image_displayed_height();
|
||||
let display_height = imp.image_displayed_height();
|
||||
imp.round_f64(f64::max((widget_height - display_height) / 2.0, 0.))
|
||||
}
|
||||
|
||||
pub fn image_rendering_width(&self) -> f64 {
|
||||
let imp = self.imp();
|
||||
imp.round_f64(imp.image_displayed_width())
|
||||
}
|
||||
|
||||
pub fn image_rendering_height(&self) -> f64 {
|
||||
let imp = self.imp();
|
||||
imp.round_f64(imp.image_displayed_height())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ impl imp::LpImage {
|
|||
|
||||
let hadjustment = obj.hadj();
|
||||
// round to application pixels to avoid tiny rounding errors from zoom
|
||||
let content_width = self.round_f64(obj.image_displayed_width());
|
||||
let content_width = self.round_f64(self.image_displayed_width());
|
||||
let widget_width = self.widget_width();
|
||||
|
||||
hadjustment.configure(
|
||||
|
|
@ -93,7 +93,7 @@ impl imp::LpImage {
|
|||
|
||||
let vadjustment = obj.vadj();
|
||||
// round to application pixels to avoid tiny rounding errors from zoom
|
||||
let content_height = self.round_f64(obj.image_displayed_height());
|
||||
let content_height = self.round_f64(self.image_displayed_height());
|
||||
let widget_height = self.widget_height();
|
||||
|
||||
vadjustment.configure(
|
||||
|
|
@ -132,13 +132,11 @@ impl imp::LpImage {
|
|||
}
|
||||
|
||||
pub fn max_hadjustment_value(&self) -> f64 {
|
||||
let obj = self.obj();
|
||||
f64::max(obj.image_displayed_width() - self.widget_width(), 0.)
|
||||
f64::max(self.image_displayed_width() - self.widget_width(), 0.)
|
||||
}
|
||||
|
||||
pub fn max_vadjustment_value(&self) -> f64 {
|
||||
let obj = self.obj();
|
||||
f64::max(obj.image_displayed_height() - self.widget_height(), 0.)
|
||||
f64::max(self.image_displayed_height() - self.widget_height(), 0.)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -104,15 +104,16 @@ impl imp::LpImage {
|
|||
}
|
||||
|
||||
fn horizontal_bar(&self) -> f64 {
|
||||
let obj = self.obj();
|
||||
f64::max(0., (self.widget_width() - obj.image_displayed_width()) / 2.)
|
||||
f64::max(
|
||||
0.,
|
||||
(self.widget_width() - self.image_displayed_width()) / 2.,
|
||||
)
|
||||
}
|
||||
|
||||
fn vertical_bar(&self) -> f64 {
|
||||
let obj = self.obj();
|
||||
f64::max(
|
||||
0.,
|
||||
(self.widget_height() - obj.image_displayed_height()) / 2.,
|
||||
(self.widget_height() - self.image_displayed_height()) / 2.,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue