1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69

ash / shelf / shelf_bubble.h [blame]

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_SHELF_SHELF_BUBBLE_H_
#define ASH_SHELF_SHELF_BUBBLE_H_

#include "ash/ash_export.h"
#include "ash/public/cpp/shelf_types.h"
#include "ash/shelf/shelf_background_animator.h"
#include "ash/shelf/shelf_background_animator_observer.h"
#include "ash/shell.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/views/bubble/bubble_dialog_delegate_view.h"

namespace views {
class View;
}  // namespace views

namespace ash {

// A base class for all shelf tooltip bubbles.
class ASH_EXPORT ShelfBubble : public views::BubbleDialogDelegateView,
                               public ShelfBackgroundAnimatorObserver {
  METADATA_HEADER(ShelfBubble, views::BubbleDialogDelegateView)

 public:
  ShelfBubble(views::View* anchor,
              ShelfAlignment alignment,
              bool for_tooltip,
              std::optional<views::BubbleBorder::Arrow> arrow_position);

  ShelfBubble(const ShelfBubble&) = delete;
  ShelfBubble& operator=(const ShelfBubble&) = delete;

  ~ShelfBubble() override;

  // Returns true if we should close when we get a press down event within our
  // bounds.
  virtual bool ShouldCloseOnPressDown() = 0;

  // Returns true if we should disappear when the mouse leaves the anchor's
  // bounds.
  virtual bool ShouldCloseOnMouseExit() = 0;

 protected:
  void set_border_radius(int radius) { border_radius_ = radius; }

  // Performs the actual bubble creation.
  void CreateBubble();

 private:
  // ShelfBackgroundAnimatorObserver:
  void UpdateShelfBackground(SkColor color) override;

  // views::BubbleDialogDelegateView:
  std::unique_ptr<views::NonClientFrameView> CreateNonClientFrameView(
      views::Widget* widget) override;

  int border_radius_ = 0;

  const bool for_tooltip_;

  ShelfBackgroundAnimator background_animator_;
};

}  // namespace ash

#endif  // ASH_SHELF_SHELF_BUBBLE_H_