image/scrollable: Add non-nullable adj getters
Somehow they are not automatically generated anymore with new gtk-rs version.
This commit is contained in:
parent
0ed7036098
commit
6a4c1c61d7
3 changed files with 16 additions and 16 deletions
|
|
@ -33,10 +33,10 @@ impl LpImage {
|
||||||
|
|
||||||
let (adjustment, max) = match direction {
|
let (adjustment, max) = match direction {
|
||||||
gtk::PanDirection::Left | gtk::PanDirection::Right => {
|
gtk::PanDirection::Left | gtk::PanDirection::Right => {
|
||||||
(self.hadjustment(), imp.max_hadjustment_value())
|
(self.hadj(), imp.max_hadjustment_value())
|
||||||
}
|
}
|
||||||
gtk::PanDirection::Up | gtk::PanDirection::Down => {
|
gtk::PanDirection::Up | gtk::PanDirection::Down => {
|
||||||
(self.vadjustment(), imp.max_vadjustment_value())
|
(self.vadj(), imp.max_vadjustment_value())
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
log::error!("Unknown pan direction {direction:?}");
|
log::error!("Unknown pan direction {direction:?}");
|
||||||
|
|
|
||||||
|
|
@ -99,11 +99,11 @@ impl WidgetImpl for imp::LpImage {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Apply the scrolling position to the image
|
// Apply the scrolling position to the image
|
||||||
let hadj: gtk::Adjustment = obj.hadjustment();
|
let hadj: gtk::Adjustment = obj.hadj();
|
||||||
let x = -(hadj.value() - (hadj.upper() - display_width) / 2.);
|
let x = -(hadj.value() - (hadj.upper() - display_width) / 2.);
|
||||||
snapshot.translate(&graphene::Point::new(self.round_f64(x) as f32, 0.));
|
snapshot.translate(&graphene::Point::new(self.round_f64(x) as f32, 0.));
|
||||||
|
|
||||||
let vadj = obj.vadjustment();
|
let vadj = obj.vadj();
|
||||||
let y = -(vadj.value() - (vadj.upper() - display_height) / 2.);
|
let y = -(vadj.value() - (vadj.upper() - display_height) / 2.);
|
||||||
snapshot.translate(&graphene::Point::new(0., self.round_f64(y) as f32));
|
snapshot.translate(&graphene::Point::new(0., self.round_f64(y) as f32));
|
||||||
|
|
||||||
|
|
@ -257,8 +257,8 @@ impl imp::LpImage {
|
||||||
let obj = self.obj();
|
let obj = self.obj();
|
||||||
|
|
||||||
let scaling = self.scaling() as f32;
|
let scaling = self.scaling() as f32;
|
||||||
let x = obj.hadjustment().value() as f32 * scaling;
|
let x = obj.hadj().value() as f32 * scaling;
|
||||||
let y = obj.vadjustment().value() as f32 * scaling;
|
let y = obj.vadj().value() as f32 * scaling;
|
||||||
let width = self.widget_width() as f32 * scaling;
|
let width = self.widget_width() as f32 * scaling;
|
||||||
let height = self.widget_height() as f32 * scaling;
|
let height = self.widget_height() as f32 * scaling;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ impl imp::LpImage {
|
||||||
pub(super) fn configure_adjustments(&self) {
|
pub(super) fn configure_adjustments(&self) {
|
||||||
let obj = self.obj();
|
let obj = self.obj();
|
||||||
|
|
||||||
let hadjustment = obj.hadjustment();
|
let hadjustment = obj.hadj();
|
||||||
// round to application pixels to avoid tiny rounding errors from zoom
|
// round to application pixels to avoid tiny rounding errors from zoom
|
||||||
let content_width = self.round_f64(self.image_displayed_width());
|
let content_width = self.round_f64(self.image_displayed_width());
|
||||||
let widget_width = self.widget_width();
|
let widget_width = self.widget_width();
|
||||||
|
|
@ -83,7 +83,7 @@ impl imp::LpImage {
|
||||||
f64::min(widget_width, content_width),
|
f64::min(widget_width, content_width),
|
||||||
);
|
);
|
||||||
|
|
||||||
let vadjustment = obj.vadjustment();
|
let vadjustment = obj.vadj();
|
||||||
// round to application pixels to avoid tiny rounding errors from zoom
|
// round to application pixels to avoid tiny rounding errors from zoom
|
||||||
let content_height = self.round_f64(self.image_displayed_height());
|
let content_height = self.round_f64(self.image_displayed_height());
|
||||||
let widget_height = self.widget_height();
|
let widget_height = self.widget_height();
|
||||||
|
|
@ -104,23 +104,23 @@ impl imp::LpImage {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_hadj_value(&self, value: f64) {
|
pub fn set_hadj_value(&self, value: f64) {
|
||||||
let hadjustment = self.obj().hadjustment();
|
let hadjustment = self.obj().hadj();
|
||||||
let value = value.clamp(0., hadjustment.upper() - hadjustment.page_size());
|
let value = value.clamp(0., hadjustment.upper() - hadjustment.page_size());
|
||||||
hadjustment.set_value(value);
|
hadjustment.set_value(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_vadj_value(&self, value: f64) {
|
pub fn set_vadj_value(&self, value: f64) {
|
||||||
let vadjustment = self.obj().vadjustment();
|
let vadjustment = self.obj().vadj();
|
||||||
let value = value.clamp(0., vadjustment.upper() - vadjustment.page_size());
|
let value = value.clamp(0., vadjustment.upper() - vadjustment.page_size());
|
||||||
vadjustment.set_value(value);
|
vadjustment.set_value(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn hadj_value(&self) -> f64 {
|
pub fn hadj_value(&self) -> f64 {
|
||||||
self.obj().hadjustment().value()
|
self.obj().hadj().value()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn vadj_value(&self) -> f64 {
|
pub fn vadj_value(&self) -> f64 {
|
||||||
self.obj().vadjustment().value()
|
self.obj().vadj().value()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn max_hadjustment_value(&self) -> f64 {
|
pub fn max_hadjustment_value(&self) -> f64 {
|
||||||
|
|
@ -141,11 +141,11 @@ impl LpImage {
|
||||||
self.imp().max_vadjustment_value() != 0.
|
self.imp().max_vadjustment_value() != 0.
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn hadjustment(&self) -> gtk::Adjustment {
|
pub fn hadj(&self) -> gtk::Adjustment {
|
||||||
todo!()
|
self.imp().hadjustment.borrow().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn vadjustment(&self) -> gtk::Adjustment {
|
pub fn vadj(&self) -> gtk::Adjustment {
|
||||||
todo!()
|
self.imp().vadjustment.borrow().clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue