Skip to content

Commit

Permalink
UI|Client: Minor widget tweaks and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Aug 21, 2013
1 parent 06ded03 commit f839796
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
8 changes: 7 additions & 1 deletion doomsday/client/src/ui/widgets/dialogwidget.cpp
Expand Up @@ -19,6 +19,7 @@
#include "ui/widgets/dialogwidget.h"
#include "ui/widgets/guirootwidget.h"
#include "ui/widgets/togglewidget.h"
#include "ui/widgets/choicewidget.h"
#include "ui/signalaction.h"
#include "dd_main.h"

Expand Down Expand Up @@ -288,6 +289,9 @@ MenuWidget &DialogWidget::buttons()

int DialogWidget::exec(GuiRootWidget &root)
{
/// @todo Non-modal dialogs shouldn't be run with a subloop.
DENG2_ASSERT(modality() == Modal);

// The widget is added to the root temporarily (as top child).
DENG2_ASSERT(!hasRoot());
root.add(this);
Expand Down Expand Up @@ -343,7 +347,9 @@ bool DialogWidget::handleEvent(Event const &event)
{
// The event should already have been handled by the children.
if(event.isKeyDown() ||
(event.type() == Event::MouseButton && !hitTest(event.as<MouseEvent>().pos())))
(event.type() == Event::MouseButton &&
event.as<MouseEvent>().state() == MouseEvent::Pressed &&
!hitTest(event.as<MouseEvent>().pos())))
{
d->startBorderFlash();
}
Expand Down
20 changes: 11 additions & 9 deletions doomsday/client/src/ui/widgets/notificationwidget.cpp
Expand Up @@ -71,7 +71,8 @@ DENG2_OBSERVES(Widget, ChildRemoval)

void updateStyle()
{
self.set(Background(self.style().colors().colorf("background")));
//self.
//self.set(Background(self.style().colors().colorf("background")));
}

void glInit()
Expand Down Expand Up @@ -111,15 +112,13 @@ DENG2_OBSERVES(Widget, ChildRemoval)
foreach(Widget *child, self.childWidgets())
{
GuiWidget &w = child->as<GuiWidget>();
if(first)
if(!first)
{
layout << w;
first = false;
}
else
{
layout.append(w, gap);
layout << gap;
}
first = false;

layout << w;
}

// Update the total size of the notification area.
Expand Down Expand Up @@ -164,8 +163,11 @@ DENG2_OBSERVES(Widget, ChildRemoval)
pendingDismiss.clear();
}

void widgetChildAdded(Widget &)
void widgetChildAdded(Widget &child)
{
// Set a background for all notifications.
child.as<GuiWidget>().set(Background(self.style().colors().colorf("background")));

updateChildLayout();
self.show();
}
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/ui/widgets/popupwidget.cpp
Expand Up @@ -440,6 +440,8 @@ void PopupWidget::glMakeGeometry(DefaultVertexBuf::Builder &verts)
{
GuiWidget::glMakeGeometry(verts);

if(d->dir == ui::NoDirection) return;

// Anchor triangle.
DefaultVertexBuf::Builder tri;
DefaultVertexBuf::Type v;
Expand All @@ -451,8 +453,6 @@ void PopupWidget::glMakeGeometry(DefaultVertexBuf::Builder &verts)

Vector2i anchorPos(d->anchorX->valuei(), d->anchorY->valuei());

/// @todo Other directions are missing: this is just for the popup that opens upwards.

if(d->dir == ui::Up)
{
// Can't put the anchor too close to the edges.
Expand Down
5 changes: 3 additions & 2 deletions doomsday/client/src/ui/widgets/togglewidget.cpp
Expand Up @@ -64,6 +64,7 @@ DENG2_OBSERVES(ButtonWidget, Press)
float p = _pos;

ColorBank::Colorf const &accentColor = style().colors().colorf("accent");
ColorBank::Colorf const &textColor = style().colors().colorf("text");

// Clamp the position to non-fractional coordinates.
Rectanglei const recti(rect.topLeft.toVector2i(), rect.bottomRight.toVector2i());
Expand All @@ -72,13 +73,13 @@ DENG2_OBSERVES(ButtonWidget, Press)
ColorBank::Colorf bgColor = style().colors().colorf("background");
bgColor.w = 1;
float c = (.3f + .33f * p);
verts.makeQuad(recti, accentColor * Vector4f(c, c, c, 1),
verts.makeQuad(recti, (accentColor * p + textColor * (1-p)) * Vector4f(c, c, c, 1),
atlas().imageRectf(_owner.root().solidWhitePixel()).middle());

Id onOff = _owner.root().toggleOnOff();

// The on/off graphic.
verts.makeQuad(recti, accentColor * (5 + p) / 6, atlas().imageRectf(onOff));
verts.makeQuad(recti, accentColor * p + textColor * (1-p) * .8f, atlas().imageRectf(onOff));

// The flipper.
int flipWidth = size().x - size().y + 2;
Expand Down

0 comments on commit f839796

Please sign in to comment.