Skip to content

Commit

Permalink
Remove unused changes
Browse files Browse the repository at this point in the history
  • Loading branch information
yachtcaptain23 committed Aug 27, 2020
1 parent 83e78db commit 43af083
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 271 deletions.
2 changes: 0 additions & 2 deletions ui/brave_custom_notification/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ source_set("brave_custom_notification") {
"notification_view_factory.h",
"padded_button.cc",
"padded_button.h",
"proportional_image_view.cc",
"proportional_image_view.h",
]
deps += [
"//ui/compositor",
Expand Down
108 changes: 0 additions & 108 deletions ui/brave_custom_notification/ad_notification_view_md.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "brave/ui/brave_custom_notification/notification_control_buttons_view.h"
#include "brave/ui/brave_custom_notification/notification_header_view.h"
#include "brave/ui/brave_custom_notification/padded_button.h"
#include "brave/ui/brave_custom_notification/proportional_image_view.h"
#include "brave/ui/brave_custom_notification/public/cpp/constants.h"
#include "brave/ui/brave_custom_notification/public/cpp/notification.h"
#include "build/build_config.h"
Expand Down Expand Up @@ -71,14 +70,9 @@ namespace {
// Dimensions.
constexpr gfx::Insets kContentRowPadding(0, 12, 16, 12);
constexpr gfx::Size kIconViewSize(36, 36);
constexpr gfx::Insets kLargeImageContainerPadding(0, 16, 16, 16);
constexpr gfx::Size kLargeImageMinSize(328, 0);
constexpr gfx::Size kLargeImageMaxSize(328, 218);
constexpr gfx::Insets kLeftContentPadding(2, 4, 0, 4);
constexpr gfx::Insets kLeftContentPaddingWithIcon(2, 4, 0, 12);

// Background color of the large image.
constexpr SkColor kLargeImageBackgroundColor = SkColorSetRGB(0xf5, 0xf5, 0xf5);
// Background color of the inline settings.
constexpr SkColor kInlineSettingsBackgroundColor =
SkColorSetRGB(0xEE, 0xEE, 0xEE);
Expand Down Expand Up @@ -147,65 +141,6 @@ class ClickActivator : public ui::EventHandler {

} // anonymous namespace

// LargeImageView //////////////////////////////////////////////////////////////

LargeImageView::LargeImageView() {
SetBackground(views::CreateSolidBackground(kLargeImageBackgroundColor));
}

LargeImageView::~LargeImageView() = default;

void LargeImageView::SetImage(const gfx::ImageSkia& image) {
image_ = image;
gfx::Size preferred_size = GetResizedImageSize();
preferred_size.SetToMax(kLargeImageMinSize);
preferred_size.SetToMin(kLargeImageMaxSize);
SetPreferredSize(preferred_size);
SchedulePaint();
Layout();
}

void LargeImageView::OnPaint(gfx::Canvas* canvas) {
views::View::OnPaint(canvas);

gfx::Size resized_size = GetResizedImageSize();
gfx::Size drawn_size = resized_size;
drawn_size.SetToMin(kLargeImageMaxSize);
gfx::Rect drawn_bounds = GetContentsBounds();
drawn_bounds.ClampToCenteredSize(drawn_size);

gfx::ImageSkia resized_image = gfx::ImageSkiaOperations::CreateResizedImage(
image_, skia::ImageOperations::RESIZE_BEST, resized_size);

// Cut off the overflown part.
gfx::ImageSkia drawn_image = gfx::ImageSkiaOperations::ExtractSubset(
resized_image, gfx::Rect(drawn_size));

canvas->DrawImageInt(drawn_image, drawn_bounds.x(), drawn_bounds.y());
}

const char* LargeImageView::GetClassName() const {
return "LargeImageView";
}

// Returns expected size of the image right after resizing.
// The GetResizedImageSize().width() <= kLargeImageMaxSize.width() holds, but
// GetResizedImageSize().height() may be larger than kLargeImageMaxSize.height()
// In this case, the overflown part will be just cutted off from the view.
gfx::Size LargeImageView::GetResizedImageSize() {
return kLargeImageMaxSize;
gfx::Size original_size = image_.size();
if (original_size.width() <= kLargeImageMaxSize.width())
return image_.size();

const double proportion =
original_size.height() / static_cast<double>(original_size.width());
gfx::Size resized_size;
resized_size.SetSize(kLargeImageMaxSize.width(),
kLargeImageMaxSize.width() * proportion);
return resized_size;
}

// NotificationInkDropImpl /////////////////////////////////////////////////////

class NotificationInkDropImpl : public views::InkDropImpl {
Expand Down Expand Up @@ -267,7 +202,6 @@ void AdNotificationViewMD::CreateOrUpdateViews(const Notification& notification)
CreateOrUpdateTitleView(notification);
CreateOrUpdateNotificationView(notification);
CreateOrUpdateSmallIconView(notification);
CreateOrUpdateImageView(notification);
UpdateViewForExpandedState(expanded_);
}

Expand Down Expand Up @@ -494,7 +428,6 @@ void AdNotificationViewMD::CreateOrUpdateContextTitleView(
header_row_->SetAccentColor(SK_ColorTRANSPARENT);
header_row_->SetBackgroundColor(kNotificationBackgroundColor);
header_row_->SetAppNameElideBehavior(gfx::ELIDE_TAIL);
header_row_->SetSummaryText(base::string16());

base::string16 app_name;
if (notification.UseOriginAsContextMessage()) {
Expand Down Expand Up @@ -582,41 +515,6 @@ void AdNotificationViewMD::CreateOrUpdateSmallIconView(
}
}

void AdNotificationViewMD::CreateOrUpdateImageView(
const Notification& notification) {
if (notification.image().IsEmpty()) {
if (image_container_view_) {
DCHECK(Contains(image_container_view_));
delete image_container_view_;
image_container_view_ = nullptr;
}
return;
}

if (!image_container_view_) {
image_container_view_ = new views::View();

gfx::Size preferred_size = kLargeImageMaxSize;
SetPreferredSize(preferred_size);


image_container_view_->SetLayoutManager(
std::make_unique<views::FillLayout>());
image_container_view_->SetBorder(
views::CreateEmptyBorder(kLargeImageContainerPadding));
image_container_view_->SetBackground(
views::CreateSolidBackground(kImageBackgroundColor));
image_container_view_->AddChildView(new LargeImageView());

// Insert the created image container just after the |content_row_|.
image_container_view_->SetSize(kLargeImageMaxSize);
AddChildViewAt(image_container_view_, GetIndexOf(content_row_) + 1);
}

static_cast<LargeImageView*>(image_container_view_->children().front())
->SetImage(notification.image().AsImageSkia());
}

bool AdNotificationViewMD::IsExpandable() {
return false;
}
Expand All @@ -626,10 +524,6 @@ void AdNotificationViewMD::UpdateViewForExpandedState(bool expanded) {
message_view_->SetMaxLines(expanded ? kMaxLinesForExpandedNotificationView
: kMaxLinesForNotificationView);
}
if (image_container_view_) {
image_container_view_->SetSize(kLargeImageMaxSize);
image_container_view_->SetVisible(expanded);
}

for (size_t i = kMaxLinesForNotificationView; i < item_views_.size(); ++i) {
item_views_[i]->SetVisible(expanded);
Expand All @@ -640,8 +534,6 @@ void AdNotificationViewMD::UpdateViewForExpandedState(bool expanded) {
int max_items = expanded ? item_views_.size() : kMaxLinesForNotificationView;
if (list_items_count_ > max_items)
header_row_->SetOverflowIndicator(list_items_count_ - max_items);
else if (!item_views_.empty())
header_row_->SetSummaryText(base::string16());

right_content_->SetVisible(true);
left_content_->SetBorder(views::CreateEmptyBorder(kLeftContentPadding));
Expand Down
19 changes: 0 additions & 19 deletions ui/brave_custom_notification/ad_notification_view_md.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,6 @@ class Textfield;
namespace brave_custom_notification {

class NotificationHeaderView;
class ProportionalImageView;

class LargeImageView : public views::View {
public:
LargeImageView();
~LargeImageView() override;

void SetImage(const gfx::ImageSkia& image);

void OnPaint(gfx::Canvas* canvas) override;
const char* GetClassName() const override;

private:
gfx::Size GetResizedImageSize();

gfx::ImageSkia image_;

DISALLOW_COPY_AND_ASSIGN(LargeImageView);
};

// View that displays all current types of notification (web, basic, image, and
// list) except the custom notification. Future notification types may be
Expand Down
11 changes: 8 additions & 3 deletions ui/brave_custom_notification/message_popup_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
namespace brave_custom_notification {
namespace {
static std::map<std::string, MessagePopupView*> g_notifications_;
static const int kPopupX = 30;
static const int kPopupY = 30;
static const int kPopupBaseWidth = 300;
static const int kPopupBaseHeight = 100;
static const int kBodyPixelLineHeight = 10;
static const int kBodyCharactersPerLine = 40;
}

// static
Expand Down Expand Up @@ -57,7 +63,7 @@ MessagePopupView::MessagePopupView(const Notification& notification) :
views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS;
params.z_order = ui::ZOrderLevel::kFloatingWindow;
params.bounds = { 30, 30, 300, 100 + GetBodyHeight(notification.message())};
params.bounds = { kPopupX, kPopupY, kPopupBaseWidth, kPopupBaseHeight + GetBodyHeight(notification.message())};
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
// Make the widget explicitly activatable as TYPE_POPUP is not activatable by
// default but we need focus for the inline reply textarea.
Expand Down Expand Up @@ -85,7 +91,6 @@ MessagePopupView::MessagePopupView(const Notification& notification) :
NotificationView* message_view_ = NotificationViewFactory::Create(notification);
popup_window_->SetContentsView(message_view_);
set_notify_enter_exit_on_child(true);
// g_message_popup_view = this;
}

MessagePopupView::~MessagePopupView() {}
Expand Down Expand Up @@ -143,7 +148,7 @@ bool MessagePopupView::IsWidgetValid() const {
}

int MessagePopupView::GetBodyHeight(const base::string16& message) {
return (10 * (message.size() / 40)) + 10;
return (kBodyPixelLineHeight * (message.size() / kBodyCharactersPerLine));
}

} // namespace brave_custom_notification
5 changes: 0 additions & 5 deletions ui/brave_custom_notification/notification_header_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,6 @@ void NotificationHeaderView::SetAppNameElideBehavior(
app_name_view_->SetElideBehavior(elide_behavior);
}

void NotificationHeaderView::SetSummaryText(const base::string16& text) {
summary_text_view_->SetText(text);
UpdateSummaryTextVisibility();
}

void NotificationHeaderView::SetOverflowIndicator(int count) {
summary_text_view_->SetText(l10n_util::GetStringFUTF16Int(
IDS_MESSAGE_CENTER_LIST_NOTIFICATION_HEADER_OVERFLOW_INDICATOR, count));
Expand Down
4 changes: 0 additions & 4 deletions ui/brave_custom_notification/notification_header_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ class NotificationHeaderView : public views::Button {
void SetAppIcon(const gfx::ImageSkia& img);
void SetAppName(const base::string16& name);
void SetAppNameElideBehavior(gfx::ElideBehavior elide_behavior);

// Summary and overflow indicator are all the same UI element so are
// mutually exclusive.
void SetSummaryText(const base::string16& text);
void SetOverflowIndicator(int count);

// Set the unified theme color used among the app icon, app name, and expand
Expand Down
5 changes: 4 additions & 1 deletion ui/brave_custom_notification/notification_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ namespace brave_custom_notification {

namespace {

static const int kWindowsShadowElevation = 2;
static const int kWindowsShadowRadius = 0;

bool ShouldShowAeroShadowBorder() {
#if defined(OS_WIN)
return ui::win::IsAeroGlassEnabled();
Expand Down Expand Up @@ -77,7 +80,7 @@ NotificationView::NotificationView(const Notification& notification) : notificat

// If Aero is enabled, set shadow border.
if (ShouldShowAeroShadowBorder()) {
const auto& shadow = gfx::ShadowDetails::Get(2, 0);
const auto& shadow = gfx::ShadowDetails::Get(kWindowsShadowElevation, kWindowsShadowRadius);
gfx::Insets ninebox_insets = gfx::ShadowValue::GetBlurRegion(shadow.values);
SetBorder(views::CreateBorderPainter(
views::Painter::CreateImagePainter(shadow.ninebox_image,
Expand Down
80 changes: 0 additions & 80 deletions ui/brave_custom_notification/proportional_image_view.cc

This file was deleted.

Loading

0 comments on commit 43af083

Please sign in to comment.