OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/panels/panel_browser_frame_view.h" | 5 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" |
6 | 6 |
7 #include "chrome/browser/themes/theme_service.h" | 7 #include "chrome/browser/themes/theme_service.h" |
8 #include "chrome/browser/ui/panels/panel.h" | 8 #include "chrome/browser/ui/panels/panel.h" |
9 #include "chrome/browser/ui/panels/panel_browser_view.h" | 9 #include "chrome/browser/ui/panels/panel_browser_view.h" |
10 #include "chrome/browser/ui/panels/panel_manager.h" | 10 #include "chrome/browser/ui/panels/panel_manager.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 PanelBrowserView* browser_view) | 134 PanelBrowserView* browser_view) |
135 : BrowserNonClientFrameView(), | 135 : BrowserNonClientFrameView(), |
136 frame_(frame), | 136 frame_(frame), |
137 browser_view_(browser_view), | 137 browser_view_(browser_view), |
138 paint_state_(NOT_PAINTED), | 138 paint_state_(NOT_PAINTED), |
139 options_button_(NULL), | 139 options_button_(NULL), |
140 close_button_(NULL), | 140 close_button_(NULL), |
141 title_icon_(NULL), | 141 title_icon_(NULL), |
142 title_label_(NULL) { | 142 title_label_(NULL) { |
143 EnsureResourcesInitialized(); | 143 EnsureResourcesInitialized(); |
144 frame_->set_frame_type(views::Window::FRAME_TYPE_FORCE_CUSTOM); | |
145 | 144 |
146 options_button_ = new views::MenuButton(NULL, std::wstring(), this, false); | 145 options_button_ = new views::MenuButton(NULL, std::wstring(), this, false); |
147 options_button_->SetIcon(*(options_button_resources.normal_image)); | 146 options_button_->SetIcon(*(options_button_resources.normal_image)); |
148 options_button_->SetHoverIcon(*(options_button_resources.hover_image)); | 147 options_button_->SetHoverIcon(*(options_button_resources.hover_image)); |
149 options_button_->SetPushedIcon(*(options_button_resources.pushed_image)); | 148 options_button_->SetPushedIcon(*(options_button_resources.pushed_image)); |
150 options_button_->set_alignment(views::TextButton::ALIGN_CENTER); | 149 options_button_->set_alignment(views::TextButton::ALIGN_CENTER); |
151 options_button_->set_border(NULL); | 150 options_button_->set_border(NULL); |
152 // TODO(jianli): Hide options button by default and show it when mouse is over | 151 // TODO(jianli): Hide options button by default and show it when mouse is over |
153 // panel. | 152 // panel. |
154 // options_button_->SetVisible(false); | 153 // options_button_->SetVisible(false); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 void PanelBrowserFrameView::UpdateThrobber(bool running) { | 194 void PanelBrowserFrameView::UpdateThrobber(bool running) { |
196 // Tells the title icon to update the throbber when we need to show the | 195 // Tells the title icon to update the throbber when we need to show the |
197 // animation to indicate we're still loading. | 196 // animation to indicate we're still loading. |
198 title_icon_->Update(); | 197 title_icon_->Update(); |
199 } | 198 } |
200 | 199 |
201 gfx::Rect PanelBrowserFrameView::GetBoundsForClientView() const { | 200 gfx::Rect PanelBrowserFrameView::GetBoundsForClientView() const { |
202 return client_view_bounds_; | 201 return client_view_bounds_; |
203 } | 202 } |
204 | 203 |
| 204 bool PanelBrowserFrameView::AlwaysUseCustomFrame() const { |
| 205 return true; |
| 206 } |
| 207 |
205 gfx::Rect PanelBrowserFrameView::GetWindowBoundsForClientBounds( | 208 gfx::Rect PanelBrowserFrameView::GetWindowBoundsForClientBounds( |
206 const gfx::Rect& client_bounds) const { | 209 const gfx::Rect& client_bounds) const { |
207 int top_height = NonClientTopBorderHeight(); | 210 int top_height = NonClientTopBorderHeight(); |
208 int border_thickness = NonClientBorderThickness(); | 211 int border_thickness = NonClientBorderThickness(); |
209 return gfx::Rect(std::max(0, client_bounds.x() - border_thickness), | 212 return gfx::Rect(std::max(0, client_bounds.x() - border_thickness), |
210 std::max(0, client_bounds.y() - top_height), | 213 std::max(0, client_bounds.y() - top_height), |
211 client_bounds.width() + (2 * border_thickness), | 214 client_bounds.width() + (2 * border_thickness), |
212 client_bounds.height() + top_height + border_thickness); | 215 client_bounds.height() + top_height + border_thickness); |
213 } | 216 } |
214 | 217 |
| 218 bool PanelBrowserFrameView::AlwaysUseNativeFrame() const { |
| 219 return frame_->AlwaysUseNativeFrame(); |
| 220 } |
| 221 |
215 int PanelBrowserFrameView::NonClientHitTest(const gfx::Point& point) { | 222 int PanelBrowserFrameView::NonClientHitTest(const gfx::Point& point) { |
216 if (!bounds().Contains(point)) | 223 if (!bounds().Contains(point)) |
217 return HTNOWHERE; | 224 return HTNOWHERE; |
218 | 225 |
219 int frame_component = | 226 int frame_component = |
220 frame_->client_view()->NonClientHitTest(point); | 227 frame_->client_view()->NonClientHitTest(point); |
221 if (frame_component != HTNOWHERE) | 228 if (frame_component != HTNOWHERE) |
222 return frame_component; | 229 return frame_component; |
223 | 230 |
224 if (close_button_->IsVisible() && | 231 if (close_button_->IsVisible() && |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 COMMAND_CLOSE_ALL, | 573 COMMAND_CLOSE_ALL, |
567 l10n_util::GetStringUTF16(IDS_PANEL_OPTIONS_MENU_CLOSE_ALL)); | 574 l10n_util::GetStringUTF16(IDS_PANEL_OPTIONS_MENU_CLOSE_ALL)); |
568 options_menu_contents_->AddSeparator(); | 575 options_menu_contents_->AddSeparator(); |
569 } | 576 } |
570 | 577 |
571 options_menu_contents_->AddItem( | 578 options_menu_contents_->AddItem( |
572 COMMAND_ABOUT, l10n_util::GetStringUTF16(IDS_PANEL_OPTIONS_MENU_ABOUT)); | 579 COMMAND_ABOUT, l10n_util::GetStringUTF16(IDS_PANEL_OPTIONS_MENU_ABOUT)); |
573 | 580 |
574 return rebuild_menu; | 581 return rebuild_menu; |
575 } | 582 } |
OLD | NEW |