Skip to content

Commit

Permalink
Fixed|Updater|libappfw: Showing the Updater notification icon
Browse files Browse the repository at this point in the history
ProgressWidget in mini mode uses a zero color for the label's image,
so the Updater notification must use a separate label (it's cleaner
like this, anyway).
  • Loading branch information
skyjake committed Mar 23, 2014
1 parent fa2dba3 commit ff4ff06
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
25 changes: 21 additions & 4 deletions doomsday/client/src/updater/updater.cpp
Expand Up @@ -122,6 +122,13 @@ class UpdaterStatusWidget : public ProgressWidget
setShadowColor(""); // no shadow, please
setSizePolicy(ui::Expand, ui::Expand);

_icon = new LabelWidget;
_icon->setImage(ClientApp::windowSystem().style().images().image("updater"));
_icon->setOverrideImageSize(overrideImageSize());
_icon->rule().setRect(rule());
add(_icon);
hideIcon();

// The notification has a hidden button that can be clicked.
_clickable = new ButtonWidget;
_clickable->setOpacity(0); // not drawn
Expand All @@ -131,7 +138,18 @@ class UpdaterStatusWidget : public ProgressWidget
add(_clickable);
}

void showIcon(DotPath const &path)
{
_icon->setImageColor(ClientApp::windowSystem().style().colors().colorf(path));
}

void hideIcon()
{
_icon->setImageColor(Vector4f());
}

private:
LabelWidget *_icon;
ButtonWidget *_clickable;
};

Expand Down Expand Up @@ -271,21 +289,20 @@ DENG2_OBSERVES(App, StartupComplete)
{
status->setRange(Rangei(0, 1));
status->setProgress(0, 0);
status->setImage(ClientApp::windowSystem().style().images().image("updater"));
status->setImageColor(ClientApp::windowSystem().style().colors().colorf("text"));
status->showIcon("text");
showNotification(true);
}

void showUpdateAvailableNotification()
{
showCheckingNotification();
status->setImageColor(ClientApp::windowSystem().style().colors().colorf("accent"));
status->showIcon("accent");
}

void showDownloadNotification()
{
status->setMode(ProgressWidget::Indefinite);
status->setImage(Image());
status->hideIcon();
showNotification(true);
}

Expand Down
2 changes: 2 additions & 0 deletions doomsday/libappfw/include/de/widgets/labelwidget.h
Expand Up @@ -162,6 +162,8 @@ class LIBAPPFW_PUBLIC LabelWidget : public GuiWidget, public AssetGroup
*/
void setOverrideImageSize(Vector2f const &size);

Vector2f overrideImageSize() const;

void setOverrideImageSize(float widthAndHeight);

void setImageScale(float scaleFactor);
Expand Down
5 changes: 5 additions & 0 deletions doomsday/libappfw/src/widgets/labelwidget.cpp
Expand Up @@ -655,6 +655,11 @@ void LabelWidget::setOverrideImageSize(Vector2f const &size)
d->overrideImageSize = size;
}

Vector2f LabelWidget::overrideImageSize() const
{
return d->overrideImageSize;
}

void LabelWidget::setOverrideImageSize(float widthAndHeight)
{
d->overrideImageSize = Vector2f(widthAndHeight, widthAndHeight);
Expand Down

0 comments on commit ff4ff06

Please sign in to comment.