SoftwareUpdater: Add a fancy looking stripe view
This commit is contained in:
parent
f7d9c0110d
commit
c5867c77cc
@ -5,6 +5,7 @@ UsePrivateHeaders interface shared ;
|
|||||||
Application SoftwareUpdater :
|
Application SoftwareUpdater :
|
||||||
SoftwareUpdaterApp.cpp
|
SoftwareUpdaterApp.cpp
|
||||||
SoftwareUpdaterWindow.cpp
|
SoftwareUpdaterWindow.cpp
|
||||||
|
StripeView.cpp
|
||||||
: be localestub tracker translation [ TargetLibsupc++ ]
|
: be localestub tracker translation [ TargetLibsupc++ ]
|
||||||
: SoftwareUpdater.rdef
|
: SoftwareUpdater.rdef
|
||||||
;
|
;
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#include "SoftwareUpdaterApp.h"
|
#include "SoftwareUpdaterApp.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <AppDefs.h>
|
#include <AppDefs.h>
|
||||||
|
|
||||||
#include "SoftwareUpdaterWindow.h"
|
#include "SoftwareUpdaterWindow.h"
|
||||||
|
@ -10,14 +10,16 @@
|
|||||||
#include "SoftwareUpdaterWindow.h"
|
#include "SoftwareUpdaterWindow.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <AppDefs.h>
|
#include <AppDefs.h>
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
#include <GroupLayout.h>
|
#include <GroupLayout.h>
|
||||||
#include <GroupLayoutBuilder.h>
|
#include <GroupLayoutBuilder.h>
|
||||||
|
#include <NodeInfo.h>
|
||||||
#include <LayoutBuilder.h>
|
#include <LayoutBuilder.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
|
#include <Resources.h>
|
||||||
|
#include <SeparatorView.h>
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
|
|
||||||
|
|
||||||
@ -31,19 +33,41 @@ const uint32 UPDATE_MESSAGE = 'iUPD';
|
|||||||
SoftwareUpdaterWindow::SoftwareUpdaterWindow()
|
SoftwareUpdaterWindow::SoftwareUpdaterWindow()
|
||||||
:
|
:
|
||||||
BWindow(BRect(0, 0, 500, 300), "Software Update",
|
BWindow(BRect(0, 0, 500, 300), "Software Update",
|
||||||
B_TITLED_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS | B_NOT_ZOOMABLE)
|
B_TITLED_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS | B_NOT_ZOOMABLE),
|
||||||
|
fStripeView(NULL)
|
||||||
{
|
{
|
||||||
|
BBitmap* icon = new BBitmap(BRect(0, 0, 31, 31), 0, B_RGBA32);
|
||||||
|
|
||||||
|
team_info teamInfo;
|
||||||
|
get_team_info(B_CURRENT_TEAM, &teamInfo);
|
||||||
|
app_info appInfo;
|
||||||
|
be_roster->GetRunningAppInfo(teamInfo.team, &appInfo);
|
||||||
|
BNodeInfo::GetTrackerIcon(&appInfo.ref, icon, B_LARGE_ICON);
|
||||||
|
|
||||||
|
fStripeView = new StripeView(icon);
|
||||||
BStringView* introText = new BStringView("intro",
|
BStringView* introText = new BStringView("intro",
|
||||||
"Software updates are available.", B_WILL_DRAW);
|
"Software updates are available.", B_WILL_DRAW);
|
||||||
|
BFont font;
|
||||||
|
introText->GetFont(&font);
|
||||||
|
font.SetFace(B_BOLD_FACE);
|
||||||
|
font.SetSize(font.Size() * 1.5);
|
||||||
|
introText->SetFont(&font, B_FONT_FAMILY_AND_STYLE | B_FONT_SIZE
|
||||||
|
| B_FONT_FLAGS);
|
||||||
|
|
||||||
BButton* updateButton = new BButton("Apply Updates",
|
BButton* updateButton = new BButton("Apply Updates",
|
||||||
new BMessage(UPDATE_MESSAGE));
|
new BMessage(UPDATE_MESSAGE));
|
||||||
|
|
||||||
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
|
BLayoutBuilder::Group<>(this, B_HORIZONTAL, 0)
|
||||||
.AddGroup(B_VERTICAL, B_USE_ITEM_SPACING)
|
.Add(fStripeView)
|
||||||
.SetInsets(B_USE_WINDOW_SPACING)
|
.AddGroup(B_VERTICAL, B_USE_SMALL_SPACING)
|
||||||
|
.SetInsets(0, B_USE_DEFAULT_SPACING,
|
||||||
|
B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
|
||||||
|
//.SetInsets(B_USE_WINDOW_SPACING)
|
||||||
.Add(introText)
|
.Add(introText)
|
||||||
.Add(updateButton)
|
.Add(updateButton)
|
||||||
|
.End()
|
||||||
|
.AddGlue()
|
||||||
|
//.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
|
||||||
;
|
;
|
||||||
CenterOnScreen();
|
CenterOnScreen();
|
||||||
Show();
|
Show();
|
||||||
|
@ -9,14 +9,22 @@
|
|||||||
#define _SOFTWARE_UPDATER_WINDOW_H
|
#define _SOFTWARE_UPDATER_WINDOW_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <Roster.h>
|
||||||
|
#include <StatusBar.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
|
#include "StripeView.h"
|
||||||
|
|
||||||
|
|
||||||
class SoftwareUpdaterWindow : public BWindow {
|
class SoftwareUpdaterWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
SoftwareUpdaterWindow();
|
SoftwareUpdaterWindow();
|
||||||
~SoftwareUpdaterWindow();
|
~SoftwareUpdaterWindow();
|
||||||
bool QuitRequested();
|
bool QuitRequested();
|
||||||
|
|
||||||
|
private:
|
||||||
|
StripeView* fStripeView;
|
||||||
|
app_info* fAppInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
73
src/apps/softwareupdater/StripeView.cpp
Normal file
73
src/apps/softwareupdater/StripeView.cpp
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2007-2016 Haiku, Inc.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Ryan Leavengood <leavengood@gmail.com>
|
||||||
|
* John Scipione <jscipione@gmail.com>
|
||||||
|
* Joseph Groover <looncraz@looncraz.net>
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "StripeView.h"
|
||||||
|
|
||||||
|
|
||||||
|
static const float kStripeWidth = 30.0;
|
||||||
|
|
||||||
|
|
||||||
|
StripeView::StripeView(BBitmap* icon)
|
||||||
|
:
|
||||||
|
BView("StripeView", B_WILL_DRAW),
|
||||||
|
fIcon(icon)
|
||||||
|
{
|
||||||
|
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
|
||||||
|
|
||||||
|
float width = 0.0f;
|
||||||
|
if (icon != NULL)
|
||||||
|
width += icon->Bounds().Width() + 32.0f;
|
||||||
|
|
||||||
|
SetExplicitMinSize(BSize(width, B_SIZE_UNSET));
|
||||||
|
SetExplicitPreferredSize(BSize(width, B_SIZE_UNLIMITED));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
StripeView::~StripeView()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
StripeView::Draw(BRect updateRect)
|
||||||
|
{
|
||||||
|
if (fIcon == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
SetHighColor(ViewColor());
|
||||||
|
FillRect(updateRect);
|
||||||
|
|
||||||
|
BRect stripeRect = Bounds();
|
||||||
|
stripeRect.right = kStripeWidth;
|
||||||
|
SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
|
||||||
|
FillRect(stripeRect);
|
||||||
|
|
||||||
|
SetDrawingMode(B_OP_ALPHA);
|
||||||
|
SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
|
||||||
|
DrawBitmapAsync(fIcon, BPoint(15.0f, 10.0f));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
StripeView::SetIcon(BBitmap* icon)
|
||||||
|
{
|
||||||
|
if (fIcon != NULL)
|
||||||
|
delete fIcon;
|
||||||
|
|
||||||
|
fIcon = icon;
|
||||||
|
|
||||||
|
float width = 0.0f;
|
||||||
|
if (icon != NULL)
|
||||||
|
width += icon->Bounds().Width() + 32.0f;
|
||||||
|
|
||||||
|
SetExplicitMinSize(BSize(width, B_SIZE_UNSET));
|
||||||
|
SetExplicitPreferredSize(BSize(width, B_SIZE_UNLIMITED));
|
||||||
|
}
|
33
src/apps/softwareupdater/StripeView.h
Normal file
33
src/apps/softwareupdater/StripeView.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2007-2016 Haiku, Inc.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Ryan Leavengood <leavengood@gmail.com>
|
||||||
|
* John Scipione <jscipione@gmail.com>
|
||||||
|
* Joseph Groover <looncraz@looncraz.net>
|
||||||
|
*/
|
||||||
|
#ifndef _STRIPE_VIEW_H
|
||||||
|
#define _STRIPE_VIEW_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <Bitmap.h>
|
||||||
|
#include <View.h>
|
||||||
|
|
||||||
|
|
||||||
|
class StripeView : public BView {
|
||||||
|
public:
|
||||||
|
StripeView(BBitmap* icon);
|
||||||
|
~StripeView();
|
||||||
|
|
||||||
|
virtual void Draw(BRect updateRect);
|
||||||
|
|
||||||
|
BBitmap* Icon() const { return fIcon; };
|
||||||
|
void SetIcon(BBitmap* icon);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BBitmap* fIcon;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* _STRIPE_VIEW_H */
|
Loading…
Reference in New Issue
Block a user