Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/bubble/bubble_frame_view.h" | 5 #include "ui/views/bubble/bubble_frame_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "grit/ui_resources.h" | 9 #include "grit/ui_resources.h" |
| 10 #include "ui/base/hit_test.h" | 10 #include "ui/base/hit_test.h" |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 return std::max(0, monitor_bounds.y() - window_bounds.y()) + | 40 return std::max(0, monitor_bounds.y() - window_bounds.y()) + |
| 41 std::max(0, window_bounds.bottom() - monitor_bounds.bottom()); | 41 std::max(0, window_bounds.bottom() - monitor_bounds.bottom()); |
| 42 return std::max(0, monitor_bounds.x() - window_bounds.x()) + | 42 return std::max(0, monitor_bounds.x() - window_bounds.x()) + |
| 43 std::max(0, window_bounds.right() - monitor_bounds.right()); | 43 std::max(0, window_bounds.right() - monitor_bounds.right()); |
| 44 } | 44 } |
| 45 | 45 |
| 46 } // namespace | 46 } // namespace |
| 47 | 47 |
| 48 namespace views { | 48 namespace views { |
| 49 | 49 |
| 50 // static | |
| 51 const char BubbleFrameView::kViewClassName[] = | |
| 52 "ui/views/bubble/BubbleFrameView"; | |
| 53 | |
| 50 BubbleFrameView::BubbleFrameView(const gfx::Insets& content_margins) | 54 BubbleFrameView::BubbleFrameView(const gfx::Insets& content_margins) |
| 51 : bubble_border_(NULL), | 55 : bubble_border_(NULL), |
| 52 content_margins_(content_margins), | 56 content_margins_(content_margins), |
| 53 title_(NULL), | 57 title_(NULL), |
| 54 close_(NULL), | 58 close_(NULL), |
| 55 titlebar_extra_view_(NULL), | 59 titlebar_extra_view_(NULL), |
| 56 can_drag_(false) { | 60 can_drag_(false) { |
| 57 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 61 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 58 title_ = new Label(string16(), rb.GetFont(ui::ResourceBundle::MediumFont)); | 62 title_ = new Label(string16(), rb.GetFont(ui::ResourceBundle::MediumFont)); |
| 59 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 63 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 bounds.right() - size.width(), | 141 bounds.right() - size.width(), |
| 138 title_bounds.y(), | 142 title_bounds.y(), |
| 139 size.width(), | 143 size.width(), |
| 140 title_bounds.height()); | 144 title_bounds.height()); |
| 141 titlebar_extra_view_bounds.Subtract(title_bounds); | 145 titlebar_extra_view_bounds.Subtract(title_bounds); |
| 142 titlebar_extra_view_->SetBoundsRect(titlebar_extra_view_bounds); | 146 titlebar_extra_view_->SetBoundsRect(titlebar_extra_view_bounds); |
| 143 } | 147 } |
| 144 } | 148 } |
| 145 | 149 |
| 146 std::string BubbleFrameView::GetClassName() const { | 150 std::string BubbleFrameView::GetClassName() const { |
| 147 return "ui/views/BubbleFrameView"; | 151 return kViewClassName; |
|
tfarina
2013/04/18 22:15:17
could you keep "ui/views/bubble/BubbleFrameView" h
simonhong_
2013/04/18 22:20:58
Done.
| |
| 148 } | 152 } |
| 149 | 153 |
| 150 void BubbleFrameView::ButtonPressed(Button* sender, const ui::Event& event) { | 154 void BubbleFrameView::ButtonPressed(Button* sender, const ui::Event& event) { |
| 151 if (sender == close_) | 155 if (sender == close_) |
| 152 GetWidget()->Close(); | 156 GetWidget()->Close(); |
| 153 } | 157 } |
| 154 | 158 |
| 155 void BubbleFrameView::SetBubbleBorder(BubbleBorder* border) { | 159 void BubbleFrameView::SetBubbleBorder(BubbleBorder* border) { |
| 156 bubble_border_ = border; | 160 bubble_border_ = border; |
| 157 set_border(bubble_border_); | 161 set_border(bubble_border_); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 263 // |offscreen_adjust|, e.g. positive |offscreen_adjust| means bubble | 267 // |offscreen_adjust|, e.g. positive |offscreen_adjust| means bubble |
| 264 // window needs to be moved to the right and that means we need to move arrow | 268 // window needs to be moved to the right and that means we need to move arrow |
| 265 // to the left, and that means negative offset. | 269 // to the left, and that means negative offset. |
| 266 bubble_border_->set_arrow_offset( | 270 bubble_border_->set_arrow_offset( |
| 267 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust); | 271 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust); |
| 268 if (offscreen_adjust) | 272 if (offscreen_adjust) |
| 269 SchedulePaint(); | 273 SchedulePaint(); |
| 270 } | 274 } |
| 271 | 275 |
| 272 } // namespace views | 276 } // namespace views |
| OLD | NEW |