diff options
Diffstat (limited to 'dw/image.cc')
-rw-r--r-- | dw/image.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/dw/image.cc b/dw/image.cc index 44a1ff45..603f2964 100644 --- a/dw/image.cc +++ b/dw/image.cc @@ -402,6 +402,22 @@ void Image::sizeRequestSimpl (core::Requisition *requisition) DBG_OBJ_LEAVE (); } +void Image::setReqWidth(core::Requisition *requisition, int width) +{ + /* If we have the image buffer, try to set the height to preserve the image + * ratio */ + if (buffer) { + int w = buffer->getRootWidth(); + int h = buffer->getRootHeight(); + float ratio = (float) h / (float) w; + int height = (float) width * ratio; + /* Preserve descent */ + requisition->ascent = height - requisition->descent; + } + + requisition->width = width; +} + void Image::getExtremesSimpl (core::Extremes *extremes) { int contentWidth; |