diff --git a/src/apps/softwareupdater/StripeView.h b/headers/private/shared/StripeView.h similarity index 86% rename from src/apps/softwareupdater/StripeView.h rename to headers/private/shared/StripeView.h index d2a6ebbcd2..e6b037201f 100644 --- a/src/apps/softwareupdater/StripeView.h +++ b/headers/private/shared/StripeView.h @@ -16,9 +16,12 @@ #include -class StripeView : public BView { +namespace BPrivate { + + +class BStripeView : public BView { public: - StripeView(BBitmap& icon); + BStripeView(BBitmap& icon); virtual void Draw(BRect updateRect); virtual BSize PreferredSize(); @@ -40,4 +43,10 @@ icon_layout_scale() } +}; + + +using namespace BPrivate; + + #endif /* _STRIPE_VIEW_H */ diff --git a/src/apps/softwareupdater/Jamfile b/src/apps/softwareupdater/Jamfile index 45a9b236c5..2df569d7c7 100644 --- a/src/apps/softwareupdater/Jamfile +++ b/src/apps/softwareupdater/Jamfile @@ -7,7 +7,6 @@ SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src servers package ] ; Application SoftwareUpdater : SoftwareUpdaterApp.cpp SoftwareUpdaterWindow.cpp - StripeView.cpp UpdateAction.cpp UpdateManager.cpp CheckAction.cpp @@ -17,7 +16,7 @@ Application SoftwareUpdater : # package_daemon ProblemWindow.cpp - : be localestub package translation libbnetapi.so [ TargetLibsupc++ ] + : be localestub package shared translation libbnetapi.so [ TargetLibsupc++ ] : SoftwareUpdater.rdef ; diff --git a/src/apps/softwareupdater/SoftwareUpdaterWindow.cpp b/src/apps/softwareupdater/SoftwareUpdaterWindow.cpp index 46985c096c..9920b12eae 100644 --- a/src/apps/softwareupdater/SoftwareUpdaterWindow.cpp +++ b/src/apps/softwareupdater/SoftwareUpdaterWindow.cpp @@ -55,7 +55,7 @@ SoftwareUpdaterWindow::SoftwareUpdaterWindow() { // Layout BBitmap icon = GetIcon(32 * icon_layout_scale()); - fStripeView = new StripeView(icon); + fStripeView = new BStripeView(icon); fUpdateButton = new BButton(B_TRANSLATE("Update now"), new BMessage(kMsgUpdateConfirmed)); diff --git a/src/apps/softwareupdater/SoftwareUpdaterWindow.h b/src/apps/softwareupdater/SoftwareUpdaterWindow.h index b8a4b7e31f..e37f2aadc1 100644 --- a/src/apps/softwareupdater/SoftwareUpdaterWindow.h +++ b/src/apps/softwareupdater/SoftwareUpdaterWindow.h @@ -175,7 +175,7 @@ private: status_t _ReadSettings(BMessage& settings); BRect fDefaultRect; - StripeView* fStripeView; + BStripeView* fStripeView; BStringView* fHeaderView; BStringView* fDetailView; BButton* fUpdateButton; diff --git a/src/apps/softwareupdater/StripeView.cpp b/src/apps/softwareupdater/StripeView.cpp deleted file mode 100644 index 6256e669d5..0000000000 --- a/src/apps/softwareupdater/StripeView.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2007-2016 Haiku, Inc. - * Distributed under the terms of the MIT License. - * - * Authors: - * Ryan Leavengood - * John Scipione - * Joseph Groover - * Brian Hill - */ - - -#include "StripeView.h" - -#include - - -static const float kTopOffset = 10.0f; -static const int kIconStripeWidth = 30; - - -StripeView::StripeView(BBitmap& icon) - : - BView("StripeView", B_WILL_DRAW), - fIcon(icon), - fIconSize(0.0), - fPreferredWidth(0.0), - fPreferredHeight(0.0) -{ - SetViewUIColor(B_PANEL_BACKGROUND_COLOR); - - if (fIcon.IsValid()) { - fIconSize = fIcon.Bounds().Width(); - // Use the same scaling as a BAlert - int32 scale = icon_layout_scale(); - fPreferredWidth = 18 * scale + fIcon.Bounds().Width(); - fPreferredHeight = 6 * scale + fIcon.Bounds().Height(); - } -} - - -void -StripeView::Draw(BRect updateRect) -{ - if (fIconSize == 0) - return; - - SetHighColor(ViewColor()); - FillRect(updateRect); - - BRect stripeRect = Bounds(); - int32 iconLayoutScale = icon_layout_scale(); - stripeRect.right = kIconStripeWidth * iconLayoutScale; - SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT)); - FillRect(stripeRect); - - SetDrawingMode(B_OP_ALPHA); - SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); - DrawBitmapAsync(&fIcon, BPoint(stripeRect.right - (fIconSize / 2.0), - 6 * iconLayoutScale)); -} - - -BSize -StripeView::PreferredSize() -{ - return BSize(fPreferredWidth, B_SIZE_UNSET); -} - - -void -StripeView::GetPreferredSize(float* _width, float* _height) -{ - if (_width != NULL) - *_width = fPreferredWidth; - - if (_height != NULL) - *_height = fPreferredHeight; -} - - -BSize -StripeView::MaxSize() -{ - return BLayoutUtils::ComposeSize(ExplicitMaxSize(), - BSize(fPreferredWidth, B_SIZE_UNLIMITED)); -} diff --git a/src/kits/shared/Jamfile b/src/kits/shared/Jamfile index e0db3d8f00..60680cab2d 100644 --- a/src/kits/shared/Jamfile +++ b/src/kits/shared/Jamfile @@ -56,6 +56,7 @@ for architectureObject in [ MultiArchSubDirSetup ] { ShakeTrackingFilter.cpp StringForRate.cpp StringForSize.cpp + StripeView.cpp TextTable.cpp Thread.cpp ToolBar.cpp diff --git a/src/servers/keystore/StripeView.cpp b/src/kits/shared/StripeView.cpp similarity index 89% rename from src/servers/keystore/StripeView.cpp rename to src/kits/shared/StripeView.cpp index 41f571496a..00a113aae4 100644 --- a/src/servers/keystore/StripeView.cpp +++ b/src/kits/shared/StripeView.cpp @@ -18,7 +18,7 @@ static const int kIconStripeWidth = 30; -StripeView::StripeView(BBitmap& icon) +BStripeView::BStripeView(BBitmap& icon) : BView("StripeView", B_WILL_DRAW), fIcon(icon), @@ -39,7 +39,7 @@ StripeView::StripeView(BBitmap& icon) void -StripeView::Draw(BRect updateRect) +BStripeView::Draw(BRect updateRect) { if (fIconSize == 0) return; @@ -61,14 +61,14 @@ StripeView::Draw(BRect updateRect) BSize -StripeView::PreferredSize() +BStripeView::PreferredSize() { return BSize(fPreferredWidth, B_SIZE_UNSET); } void -StripeView::GetPreferredSize(float* _width, float* _height) +BStripeView::GetPreferredSize(float* _width, float* _height) { if (_width != NULL) *_width = fPreferredWidth; @@ -79,7 +79,7 @@ StripeView::GetPreferredSize(float* _width, float* _height) BSize -StripeView::MaxSize() +BStripeView::MaxSize() { return BLayoutUtils::ComposeSize(ExplicitMaxSize(), BSize(fPreferredWidth, B_SIZE_UNLIMITED)); diff --git a/src/servers/keystore/AppAccessRequestWindow.cpp b/src/servers/keystore/AppAccessRequestWindow.cpp index 1d5752204b..d63abfbd27 100644 --- a/src/servers/keystore/AppAccessRequestWindow.cpp +++ b/src/servers/keystore/AppAccessRequestWindow.cpp @@ -42,7 +42,7 @@ AppAccessRequestWindow::AppAccessRequestWindow(const char* keyringName, BBitmap icon = GetIcon(32 * icon_layout_scale()); - fStripeView = new StripeView(icon); + fStripeView = new BStripeView(icon); float inset = ceilf(be_plain_font->Size() * 0.7); diff --git a/src/servers/keystore/AppAccessRequestWindow.h b/src/servers/keystore/AppAccessRequestWindow.h index 0d70c1ffd8..ee5521897c 100644 --- a/src/servers/keystore/AppAccessRequestWindow.h +++ b/src/servers/keystore/AppAccessRequestWindow.h @@ -37,7 +37,7 @@ private: BButton* fDisallowButton; BButton* fOnceButton; BButton* fAlwaysButton; - StripeView* fStripeView; + BStripeView* fStripeView; }; diff --git a/src/servers/keystore/Jamfile b/src/servers/keystore/Jamfile index e9eefe88b9..a01613498f 100644 --- a/src/servers/keystore/Jamfile +++ b/src/servers/keystore/Jamfile @@ -1,14 +1,14 @@ SubDir HAIKU_TOP src servers keystore ; UsePrivateHeaders app ; +UsePrivateHeaders shared ; Server keystore_server : AppAccessRequestWindow.cpp KeyRequestWindow.cpp Keyring.cpp KeyStoreServer.cpp - StripeView.cpp - : be localestub [ TargetLibstdc++ ] + : be localestub shared [ TargetLibstdc++ ] : keystore_server.rdef ; diff --git a/src/servers/keystore/StripeView.h b/src/servers/keystore/StripeView.h deleted file mode 100644 index d2a6ebbcd2..0000000000 --- a/src/servers/keystore/StripeView.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2007-2016 Haiku, Inc. - * Distributed under the terms of the MIT License. - * - * Authors: - * Ryan Leavengood - * John Scipione - * Joseph Groover - * Brian Hill - */ -#ifndef _STRIPE_VIEW_H -#define _STRIPE_VIEW_H - - -#include -#include - - -class StripeView : public BView { -public: - StripeView(BBitmap& icon); - - virtual void Draw(BRect updateRect); - virtual BSize PreferredSize(); - virtual void GetPreferredSize(float* _width, float* _height); - virtual BSize MaxSize(); - -private: - BBitmap fIcon; - float fIconSize; - float fPreferredWidth; - float fPreferredHeight; -}; - - -static inline int32 -icon_layout_scale() -{ - return max_c(1, ((int32)be_plain_font->Size() + 15) / 16); -} - - -#endif /* _STRIPE_VIEW_H */