From 09d32f225b531e42416e31199aefcc256cf7ee50 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Mon, 27 Aug 2012 18:21:34 +0100 Subject: Ensure previewview comment box resizing is triggered. diff --git a/src/interface/Label.cpp b/src/interface/Label.cpp index d4bd82e..e19b6b8 100644 --- a/src/interface/Label.cpp +++ b/src/interface/Label.cpp @@ -59,6 +59,14 @@ void Label::SetText(std::string text) } } +void Label::AutoHeight() +{ + bool oldAH = autoHeight; + autoHeight = true; + updateMultiline(); + autoHeight = oldAH; +} + void Label::updateMultiline() { int lines = 1; diff --git a/src/interface/Label.h b/src/interface/Label.h index f701580..f5fa1a7 100644 --- a/src/interface/Label.h +++ b/src/interface/Label.h @@ -55,6 +55,7 @@ namespace ui virtual bool HasSelection(); virtual void ClearSelection(); + virtual void AutoHeight(); void SetTextColour(Colour textColour) { this->textColour = textColour; } diff --git a/src/preview/PreviewView.cpp b/src/preview/PreviewView.cpp index 00683fc..2e3d1fa 100644 --- a/src/preview/PreviewView.cpp +++ b/src/preview/PreviewView.cpp @@ -199,16 +199,21 @@ void PreviewView::commentBoxAutoHeight() if(!addCommentBox) return; int textWidth = Graphics::textwidth(addCommentBox->GetText().c_str()); - if(textWidth+10 > Size.X-(XRES/2)-48) + if(textWidth+15 > Size.X-(XRES/2)-48) { - commentBoxHeight = 59; addCommentBox->SetMultiline(true); addCommentBox->Appearance.VerticalAlign = ui::Appearance::AlignTop; + int oldSize = addCommentBox->Size.Y; + addCommentBox->AutoHeight(); + int newSize = addCommentBox->Size.Y+5; + addCommentBox->Size.Y = oldSize; + + commentBoxHeight = newSize+22; commentBoxPositionX = (XRES/2)+4; - commentBoxPositionY = Size.Y-58; + commentBoxPositionY = Size.Y-(newSize+21); commentBoxSizeX = Size.X-(XRES/2)-8; - commentBoxSizeY = 37; + commentBoxSizeY = newSize; } else { -- cgit v0.9.2-21-gd62e