[go: nahoru, domu]

blob: 69155bb45c0321b80afd18798ab0eec578774181 [file] [log] [blame]
Yulun Wu9310ee32020-02-26 01:49:001// Copyright 2020 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef ASH_SHELF_CONTEXTUAL_NUDGE_H_
6#define ASH_SHELF_CONTEXTUAL_NUDGE_H_
7
8#include "ash/ash_export.h"
Toni Barzic0f6eb8cc2020-03-11 16:39:029#include "base/callback.h"
Yulun Wu9310ee32020-02-26 01:49:0010#include "ui/views/bubble/bubble_dialog_delegate_view.h"
11#include "ui/views/controls/label.h"
12
13namespace views {
14class View;
15} // namespace views
16
17namespace ash {
18
19// The implementation of contextual nudge tooltip bubbles.
20class ASH_EXPORT ContextualNudge : public views::BubbleDialogDelegateView {
21 public:
Toni Barzic1a51c142020-02-26 22:04:5422 // Indicates whether the nudge should be shown below or above the anchor.
23 enum class Position { kBottom, kTop };
24
25 // |anchor| - The view to which the nudge bubble should be anchored. May be
26 // nullptr, in which case anchor bounds should be provided using
27 // UpdateAnchorRect().
28 // |parent_window| - if set, the window that should parent the nudge native
29 // window. If not set, the shelf container in the anchor view's root
30 // window will be used.
Toni Barzic1a51c142020-02-26 22:04:5431 // |position| - The nudge position relative to the anchor rectangle.
Toni Barzic4ebccb502020-02-28 16:00:4032 // |margins| - The margins added to the nudge bubble.
33 // |text| - The nudge text.
34 // |text_color| - The nudge text label foreground color.
Toni Barzic0f6eb8cc2020-03-11 16:39:0235 // |tap_callback| - If set, the callback called when the user taps the nuge.
Toni Barzic1a51c142020-02-26 22:04:5436 ContextualNudge(views::View* anchor,
37 aura::Window* parent_window,
Toni Barzic4ebccb502020-02-28 16:00:4038 Position position,
39 const gfx::Insets& margins,
Jan Wilken Dörrie85285b02021-03-11 23:38:4740 const std::u16string& text,
Toni Barzic0f6eb8cc2020-03-11 16:39:0241 SkColor text_color,
42 const base::RepeatingClosure& tap_callback);
Yulun Wu9310ee32020-02-26 01:49:0043 ~ContextualNudge() override;
44
45 ContextualNudge(const ContextualNudge&) = delete;
46 ContextualNudge& operator=(const ContextualNudge&) = delete;
47
48 views::Label* label() { return label_; }
49
Toni Barzic1a51c142020-02-26 22:04:5450 // Sets the nudge bubble anchor rect - should be used to set the anchor rect
51 // if no valid anchor was passed to the nudge bubble.
52 void UpdateAnchorRect(const gfx::Rect& rect);
53
Yulun Wu9310ee32020-02-26 01:49:0054 // BubbleDialogDelegateView:
Yulun Wu9310ee32020-02-26 01:49:0055 ui::LayerType GetLayerType() const override;
Toni Barzic0f6eb8cc2020-03-11 16:39:0256 void OnGestureEvent(ui::GestureEvent* event) override;
Yulun Wu9310ee32020-02-26 01:49:0057
58 private:
Toni Barzic0f6eb8cc2020-03-11 16:39:0259 base::RepeatingClosure tap_callback_;
60
Yulun Wu9310ee32020-02-26 01:49:0061 views::Label* label_;
62};
63
64} // namespace ash
65
66#endif // ASH_SHELF_CONTEXTUAL_NUDGE_H_