Skip to content

Commit

Permalink
Fixed|UI|Automap: Clipping of the automap when sidebar is open
Browse files Browse the repository at this point in the history
The normalized coordinates should be agnostic of the game widget’s
size and position, so normalize against the widget instead of
the full view.
  • Loading branch information
skyjake committed Dec 21, 2013
1 parent c692f12 commit 3b4ad3d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
12 changes: 12 additions & 0 deletions doomsday/client/include/ui/framework/guiwidget.h
Expand Up @@ -306,6 +306,18 @@ class GuiWidget : public QObject, public de::Widget

bool isInitialized() const;

public:
/**
* Normalize a rectangle within a container rectangle.
*
* @param rect Rectangle to normalize.
* @param containerRect Container rectangle to normalize in.
*
* @return Normalized rectangle.
*/
static de::Rectanglef normalizedRect(de::Rectanglei const &rect,
de::Rectanglei const &containerRect);

protected:
/**
* Called by GuiWidget::update() the first time an update is being carried
Expand Down
7 changes: 5 additions & 2 deletions doomsday/client/src/gl/dgl_common.cpp
Expand Up @@ -373,10 +373,13 @@ DENG_EXTERN_C void DGL_SetScissor(RectRaw const *rect)
DENG_ASSERT_IN_MAIN_THREAD();
DENG_ASSERT_GL_CONTEXT_ACTIVE();

GameWidget &game = ClientWindow::main().game();

GLState::current().setNormalizedScissor(
ClientWindow::main().game().normalizedRect(
game.normalizedRect(
Rectanglei(rect->origin.x, rect->origin.y,
rect->size.width, rect->size.height))).apply();
rect->size.width, rect->size.height),
game.rule().recti())).apply();
}

#undef DGL_SetScissor2
Expand Down
26 changes: 15 additions & 11 deletions doomsday/client/src/ui/framework/guiwidget.cpp
Expand Up @@ -369,23 +369,27 @@ ui::Margins const &GuiWidget::margins() const
return d->margins;
}

Rectanglef GuiWidget::normalizedRect(de::Rectanglei const &rect,
de::Rectanglei const &containerRect) // static
{
Rectanglef const rectf = rect.moved(-containerRect.topLeft);
Vector2f const contSize = containerRect.size();
return Rectanglef(Vector2f(rectf.left() / contSize.x,
rectf.top() / contSize.y),
Vector2f(rectf.right() / contSize.x,
rectf.bottom() / contSize.y));
}

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

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)));
return GuiWidget::normalizedRect(viewSpaceRect,
Rectanglei::fromSize(root().viewSize()));
}

Rectanglef GuiWidget::normalizedContentRect() const
Expand Down

0 comments on commit 3b4ad3d

Please sign in to comment.