-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
borealis: Add a "beta" label to the borealis installer
This label indicates to the user that "Steam for Chromebook" is still in beta. Bug: b:276392572 Change-Id: If0456fe9f21641f4f5fac066879e8437113070ed Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4564895 Reviewed-by: Chloe Pelling <cpelling@google.com> Commit-Queue: Nic Hollingum <hollingum@google.com> Cr-Commit-Position: refs/heads/main@{#1150364}
- Loading branch information
Nicholas Hollingum
authored and
Chromium LUCI CQ
committed
May 30, 2023
1 parent
9693298
commit ea75b74
Showing
7 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
chrome/app/chromeos_strings_grdp/IDS_BOREALIS_BETA_BADGE.png.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3d7f342ba8c692eabf5a899c6fc824fd6f34e1f6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chrome/browser/ui/views/borealis/borealis_beta_badge.h" | ||
|
||
#include <string> | ||
|
||
#include "base/i18n/rtl.h" | ||
#include "cc/paint/paint_flags.h" | ||
#include "chrome/grit/generated_resources.h" | ||
#include "ui/base/l10n/l10n_util.h" | ||
#include "ui/base/metadata/metadata_impl_macros.h" | ||
#include "ui/chromeos/styles/cros_tokens_color_mappings.h" | ||
#include "ui/color/color_id.h" | ||
#include "ui/color/color_provider.h" | ||
#include "ui/gfx/canvas.h" | ||
#include "ui/gfx/font_list.h" | ||
#include "ui/gfx/geometry/outsets.h" | ||
#include "ui/gfx/geometry/point.h" | ||
#include "ui/gfx/geometry/rect.h" | ||
#include "ui/gfx/geometry/size.h" | ||
#include "ui/gfx/text_utils.h" | ||
|
||
namespace views { | ||
|
||
namespace { | ||
// Padding that appears around the "Beta" label. | ||
gfx::Outsets kInternalPadding = gfx::Outsets::VH(4, 10); | ||
|
||
// The corners of the label are rounded, | ||
int kCornerRadius = 10; | ||
|
||
// Colors used by the badge. | ||
ui::ColorId kTextColor = cros_tokens::LegacySemanticColorIds::kColorSelection; | ||
ui::ColorId kBackgroundColor = | ||
cros_tokens::LegacySemanticColorIds::kHighlightColor; | ||
|
||
gfx::FontList GetFont() { | ||
// TODO(b/284389804): Use TypographyToken::kCrosButton1 | ||
return gfx::FontList({"Google Sans", "Roboto"}, gfx::Font::NORMAL, 14, | ||
gfx::Font::Weight::MEDIUM); | ||
} | ||
|
||
} // namespace | ||
|
||
BorealisBetaBadge::BorealisBetaBadge() = default; | ||
|
||
BorealisBetaBadge::~BorealisBetaBadge() = default; | ||
|
||
std::u16string BorealisBetaBadge::GetText() const { | ||
return l10n_util::GetStringUTF16(IDS_BOREALIS_BETA_BADGE); | ||
} | ||
|
||
gfx::Size BorealisBetaBadge::CalculatePreferredSize() const { | ||
gfx::Rect preferred(gfx::GetStringSize(GetText(), GetFont())); | ||
preferred.Outset(kInternalPadding); | ||
return preferred.size(); | ||
} | ||
|
||
void BorealisBetaBadge::OnPaint(gfx::Canvas* canvas) { | ||
gfx::Size text_size = gfx::GetStringSize(GetText(), GetFont()); | ||
// The text is offset from the top-left corner by the inset amount | ||
gfx::Rect badge_text_bounds{ | ||
gfx::Point(kInternalPadding.left(), kInternalPadding.top()), text_size}; | ||
// ...depending on the side text is written on. | ||
if (base::i18n::IsRTL()) { | ||
badge_text_bounds.set_x(GetMirroredXForRect(badge_text_bounds)); | ||
} | ||
|
||
const ui::ColorProvider* color_provider = GetColorProvider(); | ||
|
||
// Render the badge itself. | ||
gfx::Rect surrounding(badge_text_bounds); | ||
surrounding.Outset(kInternalPadding); | ||
cc::PaintFlags flags; | ||
flags.setColor(color_provider->GetColor(kBackgroundColor)); | ||
canvas->DrawRoundRect(surrounding, kCornerRadius, flags); | ||
|
||
// Render the badge text. | ||
canvas->DrawStringRect(GetText(), GetFont(), | ||
color_provider->GetColor(kTextColor), | ||
badge_text_bounds); | ||
} | ||
|
||
BEGIN_METADATA(BorealisBetaBadge, View) | ||
ADD_READONLY_PROPERTY_METADATA(std::u16string, Text) | ||
END_METADATA | ||
|
||
} // namespace views |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef CHROME_BROWSER_UI_VIEWS_BOREALIS_BOREALIS_BETA_BADGE_H_ | ||
#define CHROME_BROWSER_UI_VIEWS_BOREALIS_BOREALIS_BETA_BADGE_H_ | ||
|
||
#include <string> | ||
|
||
#include "ui/views/view.h" | ||
#include "ui/views/views_export.h" | ||
|
||
namespace views { | ||
|
||
// Badge used to signify borealis' beta-ness on various UI surfaces. | ||
class VIEWS_EXPORT BorealisBetaBadge : public View { | ||
public: | ||
METADATA_HEADER(BorealisBetaBadge); | ||
|
||
BorealisBetaBadge(); | ||
~BorealisBetaBadge() override; | ||
|
||
// Not copyable or movable. | ||
BorealisBetaBadge(const BorealisBetaBadge&) = delete; | ||
BorealisBetaBadge& operator=(const BorealisBetaBadge&) = delete; | ||
|
||
std::u16string GetText() const; | ||
|
||
// View overrides. | ||
gfx::Size CalculatePreferredSize() const override; | ||
void OnPaint(gfx::Canvas* canvas) override; | ||
}; | ||
|
||
} // namespace views | ||
|
||
#endif // CHROME_BROWSER_UI_VIEWS_BOREALIS_BOREALIS_BETA_BADGE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters