Commit 4e905039 authored by calamity's avatar calamity Committed by Commit Bot

Revert "Adds AssistantNotificationView."

This reverts commit 9a0ad6e5.

Reason for revert:
Compile failure on linux-chromeos-rel
https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/linux-chromeos-rel/19683

Original change's description:
> Adds AssistantNotificationView.
> 
> This view provides the UI for in-Assistant notifications. Currently the
> labels/buttons for this view are stubbed in but a follow up CL will wire
> this view up to actual mojom::AssistantNotifications.
> 
> Screenshot: http://shortn/_MYjBlqDoku
> 
> Bug: b:118654460
> Change-Id: I1a436c33466aff9db0c92595a988170c99456e0f
> Reviewed-on: https://chromium-review.googlesource.com/c/1453547
> Commit-Queue: David Black <dmblack@google.com>
> Reviewed-by: Xiaohui Chen <xiaohuic@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#630144}

TBR=xiaohuic@chromium.org,dmblack@google.com

Change-Id: I90a8a9b28ff2414e504806d92a30fb58d51daea7
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: b:118654460
Reviewed-on: https://chromium-review.googlesource.com/c/1460204Reviewed-by: default avatarcalamity <calamity@chromium.org>
Commit-Queue: calamity <calamity@chromium.org>
Cr-Commit-Position: refs/heads/master@{#630146}
parent 6f2fb119
......@@ -40,8 +40,6 @@ component("ui") {
"assistant_mini_view.h",
"assistant_notification_overlay.cc",
"assistant_notification_overlay.h",
"assistant_notification_view.cc",
"assistant_notification_view.h",
"assistant_overlay.h",
"assistant_view_delegate.h",
"assistant_web_view.cc",
......
......@@ -70,7 +70,7 @@ class AssistantContainerClientView : public views::ClientView,
int left = layout_params.margins.left();
int top = layout_params.margins.top();
int width = std::min(preferred_size.width(), this->width());
int width = preferred_size.width();
int height = preferred_size.height();
// Gravity::kBottom.
......@@ -79,10 +79,8 @@ class AssistantContainerClientView : public views::ClientView,
top = this->height() - height - layout_params.margins.bottom();
// Gravity::kCenterHorizontal.
if ((layout_params.gravity & Gravity::kCenterHorizontal) != 0) {
width = std::min(width, this->width() - layout_params.margins.width());
left = (this->width() - width) / 2;
}
if ((layout_params.gravity & Gravity::kCenterHorizontal) != 0)
left = (this->width() - width) / 2 - layout_params.margins.left();
overlay->SetBounds(left, top, width, height);
}
......
......@@ -4,10 +4,7 @@
#include "ash/assistant/ui/assistant_notification_overlay.h"
#include <memory>
#include "ash/assistant/ui/assistant_notification_view.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/gfx/canvas.h"
namespace ash {
......@@ -15,7 +12,8 @@ namespace {
// Appearance.
constexpr int kMarginBottomDip = 64;
constexpr int kMarginHorizontalDip = 32;
constexpr int kPreferredHeightDip = 60;
constexpr int kPreferredWidthDip = 576;
} // namespace
......@@ -29,24 +27,31 @@ const char* AssistantNotificationOverlay::GetClassName() const {
return "AssistantNotificationOverlay";
}
gfx::Size AssistantNotificationOverlay::CalculatePreferredSize() const {
return gfx::Size(kPreferredWidthDip, GetHeightForWidth(kPreferredWidthDip));
}
int AssistantNotificationOverlay::GetHeightForWidth(int width) const {
return kPreferredHeightDip;
}
AssistantOverlay::LayoutParams AssistantNotificationOverlay::GetLayoutParams()
const {
using Gravity = AssistantOverlay::LayoutParams::Gravity;
AssistantOverlay::LayoutParams layout_params;
layout_params.gravity = Gravity::kBottom | Gravity::kCenterHorizontal;
layout_params.margins = gfx::Insets(0, kMarginHorizontalDip, kMarginBottomDip,
kMarginHorizontalDip);
layout_params.margins = gfx::Insets(0, 0, kMarginBottomDip, 0);
return layout_params;
}
void AssistantNotificationOverlay::InitLayout() {
SetLayoutManager(std::make_unique<views::FillLayout>());
// TODO(dmblack): Remove when notification views have been implemented.
void AssistantNotificationOverlay::OnPaintBackground(gfx::Canvas* canvas) {
canvas->DrawColor(0x20000000);
}
void AssistantNotificationOverlay::InitLayout() {
SetPaintToLayer();
layer()->SetFillsBoundsOpaquely(false);
// TODO(dmblack): Wire up to actual notifications.
AddChildView(new AssistantNotificationView());
}
}; // namespace ash
......@@ -21,7 +21,10 @@ class COMPONENT_EXPORT(ASSISTANT_UI) AssistantNotificationOverlay
// AssistantOverlay:
const char* GetClassName() const override;
gfx::Size CalculatePreferredSize() const override;
int GetHeightForWidth(int width) const override;
LayoutParams GetLayoutParams() const override;
void OnPaintBackground(gfx::Canvas* canvas) override;
private:
void InitLayout();
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/assistant/ui/assistant_notification_view.h"
#include <string>
#include "ash/assistant/ui/assistant_ui_constants.h"
#include "ash/assistant/ui/main_stage/suggestion_chip_view.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/views/animation/ink_drop_painted_layer_delegates.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/fill_layout.h"
namespace ash {
namespace {
// Appearance.
constexpr int kLineHeightDip = 20;
constexpr int kPaddingLeftDip = 16;
constexpr int kPaddingRightDip = 8;
constexpr int kPreferredHeightDip = 48;
constexpr int kShadowElevationDip = 6;
// Helpers ---------------------------------------------------------------------
views::View* CreateButton(const std::string& label) {
SuggestionChipView::Params params;
params.text = base::UTF8ToUTF16(label);
return new SuggestionChipView(params, /*listener=*/nullptr);
}
} // namespace
AssistantNotificationView::AssistantNotificationView() {
InitLayout();
}
AssistantNotificationView::~AssistantNotificationView() = default;
const char* AssistantNotificationView::GetClassName() const {
return "AssistantNotificationView";
}
gfx::Size AssistantNotificationView::CalculatePreferredSize() const {
return gfx::Size(INT_MAX, GetHeightForWidth(INT_MAX));
}
int AssistantNotificationView::GetHeightForWidth(int width) const {
return kPreferredHeightDip;
}
void AssistantNotificationView::OnBoundsChanged(
const gfx::Rect& previous_bounds) {
UpdateBackground();
}
void AssistantNotificationView::InitLayout() {
SetLayoutManager(std::make_unique<views::FillLayout>());
SetPaintToLayer();
layer()->SetFillsBoundsOpaquely(false);
// Background/shadow.
background_layer_.SetFillsBoundsOpaquely(false);
layer()->Add(&background_layer_);
// Container.
views::View* container = new views::View();
container->SetPreferredSize(gfx::Size(INT_MAX, INT_MAX));
container->SetPaintToLayer();
container->layer()->SetFillsBoundsOpaquely(false);
AddChildView(container);
auto* layout_manager =
container->SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kHorizontal,
gfx::Insets(0, kPaddingLeftDip, 0, kPaddingRightDip), kSpacingDip));
layout_manager->set_cross_axis_alignment(
views::BoxLayout::CrossAxisAlignment::CROSS_AXIS_ALIGNMENT_CENTER);
gfx::FontList font_list =
assistant::ui::GetDefaultFontList().DeriveWithSizeDelta(1);
// Title.
auto* title = new views::Label(base::UTF8ToUTF16("Placeholder Title"));
title->SetAutoColorReadabilityEnabled(false);
title->SetEnabledColor(kTextColorPrimary);
title->SetFontList(font_list.DeriveWithWeight(gfx::Font::Weight::MEDIUM));
title->SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_LEFT);
title->SetLineHeight(kLineHeightDip);
container->AddChildView(title);
// Message.
auto* message = new views::Label(base::UTF8ToUTF16("Placeholder Message"));
message->SetAutoColorReadabilityEnabled(false);
message->SetEnabledColor(kTextColorSecondary);
message->SetFontList(font_list);
message->SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_LEFT);
message->SetLineHeight(kLineHeightDip);
container->AddChildView(message);
layout_manager->SetFlexForView(message, 1);
// Buttons.
container->AddChildView(CreateButton("Placeholder Button 1"));
container->AddChildView(CreateButton("Placeholder Button 2"));
}
void AssistantNotificationView::UpdateBackground() {
gfx::ShadowValues shadow_values =
gfx::ShadowValue::MakeMdShadowValues(kShadowElevationDip);
shadow_delegate_ = std::make_unique<views::BorderShadowLayerDelegate>(
shadow_values, GetLocalBounds(),
/*fill_color=*/SK_ColorWHITE,
/*corner_radius=*/height() / 2);
background_layer_.set_delegate(shadow_delegate_.get());
background_layer_.SetBounds(
gfx::ToEnclosingRect(shadow_delegate_->GetPaintedBounds()));
}
} // namespace ash
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_ASSISTANT_UI_ASSISTANT_NOTIFICATION_VIEW_H_
#define ASH_ASSISTANT_UI_ASSISTANT_NOTIFICATION_VIEW_H_
#include <memory>
#include "base/component_export.h"
#include "base/macros.h"
#include "ui/compositor/layer.h"
#include "ui/views/view.h"
namespace views {
class BorderShadowLayerDelegate;
} // namespace views
namespace ash {
// AssistantNotificationView is the view for a mojom::AssistantNotification
// which appears in Assistant UI. Its parent is AssistantNotificationOverlay.
class COMPONENT_EXPORT(ASSISTANT_UI) AssistantNotificationView
: public views::View {
public:
AssistantNotificationView();
~AssistantNotificationView() override;
// views::View:
const char* GetClassName() const override;
gfx::Size CalculatePreferredSize() const override;
int GetHeightForWidth(int width) const override;
void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
private:
void InitLayout();
void UpdateBackground();
// Background/shadow.
ui::Layer background_layer_;
std::unique_ptr<views::BorderShadowLayerDelegate> shadow_delegate_;
DISALLOW_COPY_AND_ASSIGN(AssistantNotificationView);
};
} // namespace ash
#endif // ASH_ASSISTANT_UI_ASSISTANT_NOTIFICATION_VIEW_H_
......@@ -25,8 +25,8 @@ constexpr int kMarginDip = 8;
constexpr int kUiElementHorizontalMarginDip = 32;
// Typography.
constexpr SkColor kTextColorHint = gfx::kGoogleGrey700;
constexpr SkColor kTextColorPrimary = gfx::kGoogleGrey900;
constexpr SkColor kTextColorSecondary = gfx::kGoogleGrey700;
// TODO(dmblack): Move the other constants into ash::assistant::ui.
namespace assistant {
......
......@@ -327,7 +327,7 @@ void DialogPlate::InitKeyboardLayoutContainer() {
l10n_util::GetStringUTF16(IDS_ASH_ASSISTANT_DIALOG_PLATE_HINT);
textfield_->set_placeholder_text(textfield_hint);
textfield_->SetAccessibleName(textfield_hint);
textfield_->set_placeholder_text_color(kTextColorSecondary);
textfield_->set_placeholder_text_color(kTextColorHint);
textfield_->SetTextColor(kTextColorPrimary);
keyboard_layout_container_->AddChildView(textfield_);
......
......@@ -128,7 +128,7 @@ void AssistantQueryView::SetText(const std::string& high_confidence_text,
label_->AddStyleRange(gfx::Range(high_confidence_text_16.length(),
high_confidence_text_16.length() +
low_confidence_text_16.length()),
CreateStyleInfo(kTextColorSecondary));
CreateStyleInfo(kTextColorHint));
}
}
label_->SizeToFit(width());
......
......@@ -18,7 +18,6 @@ class Label;
namespace ash {
// TODO(dmblack): Move to /ash/assistant/ui/base/.
// View representing a suggestion chip.
class COMPONENT_EXPORT(ASSISTANT_UI) SuggestionChipView : public views::Button {
public:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment