Skip to content

Commit

Permalink
LogWidget: Use normalized scissor for content clipping
Browse files Browse the repository at this point in the history
Widgets should always use a normalized scissor rather than specifying
the window coordinates manually, as the root widget's size may not be
the same as the window.

Todo: LegacyWidget must use a normalized scissor, too.
  • Loading branch information
skyjake committed Oct 25, 2013
1 parent 99e6418 commit 20cc03c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions doomsday/client/include/ui/framework/guiwidget.h
Expand Up @@ -187,6 +187,7 @@ class GuiWidget : public QObject, public de::Widget
ui::Margins const &margins() const;

de::Rectanglef normalizedRect() const;
de::Rectanglef normalizedRect(de::Rectanglei const &viewSpaceRect) const;

/**
* Normalized content rectangle. Same as normalizedRect() except margins
Expand Down
17 changes: 13 additions & 4 deletions doomsday/client/src/ui/framework/guiwidget.cpp
Expand Up @@ -358,10 +358,19 @@ Rectanglef GuiWidget::normalizedRect() const
{
Rectanglef const rect = rule().rect();
GuiRootWidget::Size const &viewSize = root().viewSize();
return Rectanglef(Vector2f(float(rect.left()) / float(viewSize.x),
float(rect.top()) / float(viewSize.y)),
Vector2f(float(rect.right()) / float(viewSize.x),
float(rect.bottom()) / float(viewSize.y)));
return Rectanglef(Vector2f(rect.left() / float(viewSize.x),
rect.top() / float(viewSize.y)),
Vector2f(rect.right() / float(viewSize.x),
rect.bottom() / float(viewSize.y)));
}

Rectanglef GuiWidget::normalizedRect(Rectanglei const &viewSpaceRect) const
{
GuiRootWidget::Size const &viewSize = root().viewSize();
return Rectanglef(Vector2f(float(viewSpaceRect.left()) / float(viewSize.x),
float(viewSpaceRect.top()) / float(viewSize.y)),
Vector2f(float(viewSpaceRect.right()) / float(viewSize.x),
float(viewSpaceRect.bottom()) / float(viewSize.y)));
}

Rectanglef GuiWidget::normalizedContentRect() const
Expand Down
4 changes: 3 additions & 1 deletion doomsday/client/src/ui/widgets/logwidget.cpp
Expand Up @@ -746,7 +746,9 @@ public Font::RichFormat::IStyle
{
GLState &st = GLState::push();
// Leave room for the indicator in the scissor.
st.setScissor(vp.adjusted(Vector2i(), Vector2i(self.margins().right().valuei(), 0)));
st.setNormalizedScissor(
self.normalizedRect(vp.adjusted(Vector2i(),
Vector2i(self.margins().right().valuei(), 0))));

// First draw the shadow of the text.
uMvpMatrix = projMatrix * Matrix4f::translate(
Expand Down

0 comments on commit 20cc03c

Please sign in to comment.