aboutsummaryrefslogtreecommitdiff
path: root/dw/image.cc
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2014-08-02 13:05:54 +0200
committerSebastian Geerken <devnull@localhost>2014-08-02 13:05:54 +0200
commit23a4ad7919ee6246edc59b97a947168600fab9b1 (patch)
treef71ddd6f56b566e77fa8f5e2acbfe30e61f2daec /dw/image.cc
parentc4143d5106b2c5f47fa431c0eb0a4291591af292 (diff)
Image aspect ratio is preserved.
Diffstat (limited to 'dw/image.cc')
-rw-r--r--dw/image.cc13
1 files changed, 9 insertions, 4 deletions
diff --git a/dw/image.cc b/dw/image.cc
index d302d362..d753a0f2 100644
--- a/dw/image.cc
+++ b/dw/image.cc
@@ -199,14 +199,19 @@ void Image::sizeRequestImpl (core::Requisition *requisition)
// TODO Check again possible overflows. (Aren't buffer
// dimensions limited to 2^15?)
- if (getStyle()->width == core::style::LENGTH_AUTO &&
- getStyle()->height != core::style::LENGTH_AUTO) {
+ bool widthSpecified = getStyle()->width != core::style::LENGTH_AUTO ||
+ getStyle()->minWidth != core::style::LENGTH_AUTO ||
+ getStyle()->maxWidth != core::style::LENGTH_AUTO;
+ bool heightSpecified = getStyle()->height != core::style::LENGTH_AUTO ||
+ getStyle()->minHeight != core::style::LENGTH_AUTO ||
+ getStyle()->maxHeight != core::style::LENGTH_AUTO;
+
+ if (!widthSpecified && heightSpecified)
requisition->width =
(requisition->ascent + requisition->descent - boxDiffHeight ())
* buffer->getRootWidth () / buffer->getRootHeight ()
+ boxDiffWidth ();
- } else if (getStyle()->width != core::style::LENGTH_AUTO &&
- getStyle()->height == core::style::LENGTH_AUTO) {
+ else if (widthSpecified && !heightSpecified) {
requisition->ascent = (requisition->width + boxDiffWidth ())
* buffer->getRootHeight () / buffer->getRootWidth ()
+ boxOffsetY ();