Skip to content

Commit

Permalink
TextArea: override SetAnimPicture
Browse files Browse the repository at this point in the history
this fixes an issue where UpdateScrollbar would miscalculate due to the pending shrinkage of the TextContainer
  • Loading branch information
bradallred committed Oct 14, 2014
1 parent db0f4d5 commit 6c7831b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
2 changes: 1 addition & 1 deletion gemrb/core/GUI/Control.h
Expand Up @@ -163,7 +163,7 @@ class GEM_EXPORT Control {
}
virtual const String& QueryText() const { static String s; return s; }
/** Sets the animation picture ref */
void SetAnimPicture(Sprite2D* Picture);
virtual void SetAnimPicture(Sprite2D* Picture);
/** Sets the Scroll Bar Pointer */
int SetScrollBar(Control* ptr);

Expand Down
43 changes: 27 additions & 16 deletions gemrb/core/GUI/TextArea.cpp
Expand Up @@ -106,26 +106,12 @@ bool TextArea::NeedsDraw()

void TextArea::DrawInternal(Region& clip)
{
// apply padding to the clip
if (sb) {
clip.w -= EDGE_PADDING;
} else {
clip.w -= EDGE_PADDING * 2;
}
clip.x += EDGE_PADDING;

if (AnimPicture) {
// speaker portrait
// dont clip the portrait, the original draws slightly outside the TA bounds
core->GetVideoDriver()->BlitSprite(AnimPicture, clip.x - EDGE_PADDING, clip.y + EDGE_PADDING, true);
int offset = AnimPicture->Width + EDGE_PADDING;
// FIXME: in the original dialog is always indented (even without portrait), I doubt we care, but mentioning it here.
clip.x += offset;
clip.w -= offset;
core->GetVideoDriver()->BlitSprite(AnimPicture, clip.x, clip.y + EDGE_PADDING, true);
clip.x += AnimPicture->Width + (EDGE_PADDING * 2);
}
// FIXME: content containers should support the "flexible" idiom so we can resize children by resizing parent
textContainer->SetFrame(Region(Point(), Size(clip.w, 0)));
contentWrapper.SetFrame(Region(Point(), Size(clip.w, 0)));

if (Flags&IE_GUI_TEXTAREA_SMOOTHSCROLL) {
unsigned long thisTime = GetTickCount();
Expand All @@ -145,6 +131,31 @@ void TextArea::DrawInternal(Region& clip)
}
}

void TextArea::SetAnimPicture(Sprite2D* pic)
{
if (pic == AnimPicture) return;

Size frame(Width, 0);
// apply padding to the clip
frame.w -= (sb) ? EDGE_PADDING : EDGE_PADDING * 2;

if (pic) {
int offset = pic->Width + EDGE_PADDING;
// FIXME: in the original dialog is always indented (even without portrait), I doubt we care, but mentioning it here.
frame.w -= offset;
}
// FIXME: content containers should support the "flexible" idiom so we can resize children by resizing parent
textContainer->SetFrame(Region(Point(), frame));
contentWrapper.SetFrame(Region(Point(), frame));

if (contentWrapper.ContentFrame().w != frame.w) {
// FIXME: content containers should support the "flexible" idiom so we can resize children by resizing parent
textContainer->SetFrame(Region(Point(), frame));
contentWrapper.SetFrame(Region(Point(), frame));
}
Control::SetAnimPicture(pic);
}

void TextArea::UpdateScrollbar()
{
if (sb == NULL) return;
Expand Down
1 change: 1 addition & 0 deletions gemrb/core/GUI/TextArea.h
Expand Up @@ -88,6 +88,7 @@ class GEM_EXPORT TextArea : public Control {
void SetRow(int row);
/** Set Selectable */
void SetSelectable(bool val);
void SetAnimPicture(Sprite2D* Picture);

/** Returns the selected text */
const String& QueryText() const;
Expand Down

0 comments on commit 6c7831b

Please sign in to comment.