Chromium Code Reviews| Index: ash/shelf/shelf_tooltip_manager.cc |
| diff --git a/ash/shelf/shelf_tooltip_manager.cc b/ash/shelf/shelf_tooltip_manager.cc |
| index b97747511b3020a87babe05667ca2d7416401f4a..7847581931836f5ec20c653884ce26288fec94fa 100644 |
| --- a/ash/shelf/shelf_tooltip_manager.cc |
| +++ b/ash/shelf/shelf_tooltip_manager.cc |
| @@ -4,6 +4,8 @@ |
| #include "ash/shelf/shelf_tooltip_manager.h" |
| +#include "ash/common/material_design/material_design_controller.h" |
| +#include "ash/common/shelf/shelf_constants.h" |
| #include "ash/common/shell_window_ids.h" |
| #include "ash/shelf/shelf.h" |
| #include "ash/shelf/shelf_layout_manager.h" |
| @@ -27,22 +29,9 @@ |
| namespace ash { |
| namespace { |
| -const int kTooltipTopBottomMargin = 3; |
| -const int kTooltipLeftRightMargin = 10; |
| const int kTooltipAppearanceDelay = 1000; // msec |
| -const int kTooltipMinHeight = 29 - 2 * kTooltipTopBottomMargin; |
| const SkColor kTooltipTextColor = SkColorSetRGB(0x22, 0x22, 0x22); |
| -// The maximum width of the tooltip bubble. Borrowed the value from |
| -// ash/tooltip/tooltip_controller.cc |
| -const int kTooltipMaxWidth = 250; |
| - |
| -// The offset for the tooltip bubble - making sure that the bubble is flush |
| -// with the shelf. The offset includes the arrow size in pixels as well as |
| -// the activation bar and other spacing elements. |
| -const int kArrowOffsetLeftRight = 11; |
| -const int kArrowOffsetTopBottom = 7; |
| - |
| } // namespace |
| // The implementation of tooltip of the launcher. |
| @@ -54,7 +43,8 @@ class ShelfTooltipManager::ShelfTooltipBubble |
| const base::string16& text) |
| : views::BubbleDialogDelegateView(anchor, arrow) { |
| gfx::Insets insets = |
| - gfx::Insets(kArrowOffsetTopBottom, kArrowOffsetLeftRight); |
| + gfx::Insets(GetShelfConstant(TOOLTIP_ARROW_TOP_BOTTOM_OFFSET), |
| + GetShelfConstant(TOOLTIP_ARROW_LEFT_RIGHT_OFFSET)); |
| // Adjust the anchor location for asymmetrical borders of shelf item. |
| if (anchor->border()) |
| insets += anchor->border()->GetInsets(); |
| @@ -63,8 +53,11 @@ class ShelfTooltipManager::ShelfTooltipBubble |
| set_close_on_deactivate(false); |
| set_can_activate(false); |
| set_accept_events(false); |
| - set_margins(gfx::Insets(kTooltipTopBottomMargin, kTooltipLeftRightMargin)); |
| - set_shadow(views::BubbleBorder::SMALL_SHADOW); |
| + set_margins(gfx::Insets(GetShelfConstant(TOOLTIP_TOP_BOTTOM_MARGIN), |
| + GetShelfConstant(TOOLTIP_LEFT_RIGHT_MARGIN))); |
| + const bool material = ash::MaterialDesignController::IsTooltipMaterial(); |
| + set_shadow(material ? views::BubbleBorder::NO_ASSETS_TOOLTIP |
|
msw
2016/07/22 16:51:06
driveby: Can you use the existing NO_ASSETS settin
varkha
2016/07/22 22:03:56
views::BubbleBorder::NO_ASSETS results in huge ver
msw
2016/07/22 22:14:52
There's only one user; SubtleNotificationView. Per
msw
2016/07/22 22:16:25
Oops, there are multiple users; but the same thoug
varkha
2016/07/23 01:09:42
Yes, the margins that are settable with set_margin
|
| + : views::BubbleBorder::SMALL_SHADOW); |
| SetLayoutManager(new views::FillLayout()); |
| // The anchor may not have the widget in tests. |
| if (anchor->GetWidget() && anchor->GetWidget()->GetNativeWindow()) { |
| @@ -74,15 +67,35 @@ class ShelfTooltipManager::ShelfTooltipBubble |
| } |
| views::Label* label = new views::Label(text); |
| label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| - label->SetEnabledColor(kTooltipTextColor); |
| + ui::NativeTheme* theme = anchor->GetWidget()->GetNativeTheme(); |
| + SkColor text_color = |
| + material ? theme->GetSystemColor(ui::NativeTheme::kColorId_TooltipText) |
| + : kTooltipTextColor; |
| + label->SetEnabledColor(text_color); |
| + if (material) { |
| + SkColor background_color = |
| + theme->GetSystemColor(ui::NativeTheme::kColorId_TooltipBackground); |
| + set_color(background_color); |
| + label->SetBackgroundColor(background_color); |
| + } |
| AddChildView(label); |
| views::BubbleDialogDelegateView::CreateBubble(this); |
| + // The bubble border has its own background so the background created by the |
| + // BubbleDialogDelegateView is redundant and would cause extra opacity. |
| + if (material) |
| + set_background(nullptr); |
| + SetArrowPaintType(material ? views::BubbleBorder::PAINT_TRANSPARENT |
| + : views::BubbleBorder::PAINT_NORMAL); |
| } |
| private: |
| // BubbleDialogDelegateView overrides: |
| gfx::Size GetPreferredSize() const override { |
| const gfx::Size size = BubbleDialogDelegateView::GetPreferredSize(); |
| + const int kTooltipMinHeight = |
| + GetShelfConstant(TOOLTIP_HEIGHT) - |
| + 2 * GetShelfConstant(TOOLTIP_TOP_BOTTOM_MARGIN); |
| + const int kTooltipMaxWidth = GetShelfConstant(TOOLTIP_MAX_WIDTH); |
| return gfx::Size(std::min(size.width(), kTooltipMaxWidth), |
| std::max(size.height(), kTooltipMinHeight)); |
| } |