# Bubble View
To find the bubble view specific logic, let's check the bubble view related codes.
## BubbleFrameView
[BubbleFrameView](https://source.chromium.org/chromium/chromium/src/+/main:ui/views/bubble/bubble_frame_view.h;l=58;drc=0a4425227929ec9a290aa09d2dbf41870cab4f6d) is one of the view with bubble style.
It's derived from NonClientFrameView.
Bubble view consists of multiple views such as HeaderView, TitleView, DialogClientView...
The followings are the example.
```
+- BubbleFrameView ------------------+
| +- ProgressBar ------------------+ |
| +-----------------------(-)-(x)-+ |
| | HeaderView | |
| +-------------------------------+ |
| +-------------------------------+ |
| | TitleView | |
| +-------------------------------+ |
| +-- DialogClientView------------+ |
| | <<Dialog Contents View>> | |
| | <<OK and Cancel Buttons>> | |
| | <<...>> | |
| +-------------------------------+ |
| +-------------------------------+ |
| | FootnoteView | |
| +-------------------------------+ |
+------------------------------------+
```
These views are optional.
The below are the list of views stored in BubbleFrameView.
```cpp=
raw_ptr<BubbleBorder> bubble_border_ = nullptr;
raw_ptr<ImageView> title_icon_ = nullptr;
raw_ptr<ImageView> main_image_ = nullptr;
raw_ptr<BoxLayoutView> title_container_ = nullptr;
raw_ptr<Label, DanglingUntriaged> default_title_ = nullptr;
raw_ptr<View, DanglingUntriaged> custom_title_ = nullptr;
raw_ptr<Label> subtitle_ = nullptr;
raw_ptr<Button> minimize_ = nullptr;
raw_ptr<Button> close_ = nullptr;
raw_ptr<ProgressBar> progress_indicator_ = nullptr;
raw_ptr<View, DanglingUntriaged> header_view_ = nullptr;
raw_ptr<FootnoteContainerView, DanglingUntriaged> footnote_container_ = nullptr;
```
Each caption buttons (minimize window, close window...) are stored.
[GetAvilableScreenBounds](https://source.chromium.org/chromium/chromium/src/+/main:ui/views/bubble/bubble_frame_view.cc;l=854;drc=88d87ae50728261cfdbf77ae493a8d506eaf42e6) and [GetAvailableAnchorWindowBounds](https://source.chromium.org/chromium/chromium/src/+/main:ui/views/bubble/bubble_frame_view.cc;l=862;drc=88d87ae50728261cfdbf77ae493a8d506eaf42e6) returns a window and screen area that the bubble view can be shown.
This is used from [GetUpdatedWindowBounds](https://source.chromium.org/chromium/chromium/src/+/main:ui/views/bubble/bubble_frame_view.cc;l=785;drc=88d87ae50728261cfdbf77ae493a8d506eaf42e6) to calculate the position.
[MirrorArrowIfOutOfBounds](https://source.chromium.org/chromium/chromium/src/+/main:ui/views/bubble/bubble_frame_view.cc;l=913;drc=88d87ae50728261cfdbf77ae493a8d506eaf42e6) adjusts the bubble view position to fit in the screen. When the window is placed at the buttom of the screen, bubble view may need to be placed above to fit inside the screen. This calculation is "MirrorArrow".
After calculating the bounds, it triggeds [SchedulePaint](https://source.chromium.org/chromium/chromium/src/+/main:ui/views/view.cc;l=1163;drc=88d87ae50728261cfdbf77ae493a8d506eaf42e6) to paint.
At this point, the view is not yet clipped even if the bubble view is out side of the window.
## BubbleDialogDelegate
All views inside BubbleFrameView is optional except for [BubbleDialogDelegte](https://source.chromium.org/chromium/chromium/src/+/main:ui/views/bubble/bubble_dialog_delegate_view.h;l=43;drc=9ada743e25e1693ce25f64e3d8447df579beaa0e).
[DialogDelegate](https://source.chromium.org/chromium/chromium/src/+/main:ui/views/window/dialog_delegate.h;l=45;drc=88d87ae50728261cfdbf77ae493a8d506eaf42e6) is an interface implemented by objects to show dialog box. BubbleDialogDelegate is one implementation of it.
It holds a [Param](https://source.chromium.org/chromium/chromium/src/+/main:ui/views/window/dialog_delegate.h;l=47;drc=88d87ae50728261cfdbf77ae493a8d506eaf42e6) to represents the property of the window.
[`draggable`](https://source.chromium.org/chromium/chromium/src/+/main:ui/views/window/dialog_delegate.h;l=54;drc=88d87ae50728261cfdbf77ae493a8d506eaf42e6) can take true if the bubble view is draggable.
[PaintVisibleArrow](https://source.chromium.org/chromium/chromium/src/+/main:ui/views/bubble/bubble_border.cc;l=692;drc=76586edae653236ea8b2e8eef1ef7632bb4b5765) clips the bubble view by the arrow bounds via [Canvas::ClipRect](https://source.chromium.org/chromium/chromium/src/+/main:ui/views/bubble/bubble_border.cc;l=706;drc=76586edae653236ea8b2e8eef1ef7632bb4b5765) in BubbleBorder.