Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Side by Side Diff: chrome/browser/ui/panels/panel_browser_frame_view.cc

Issue 7633034: Use Titlebar instead of TitleBar consistently in panels code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/extensions/extension_service.h" 7 #include "chrome/browser/extensions/extension_service.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/themes/theme_service.h" 9 #include "chrome/browser/themes/theme_service.h"
10 #include "chrome/browser/ui/panels/panel.h" 10 #include "chrome/browser/ui/panels/panel.h"
(...skipping 19 matching lines...) Expand all
30 #include "views/widget/widget_delegate.h" 30 #include "views/widget/widget_delegate.h"
31 #include "views/window/window_shape.h" 31 #include "views/window/window_shape.h"
32 32
33 #if !defined(OS_WIN) 33 #if !defined(OS_WIN)
34 #include "views/window/hit_test.h" 34 #include "views/window/hit_test.h"
35 #endif 35 #endif
36 36
37 namespace { 37 namespace {
38 38
39 // The height in pixels of the title bar. 39 // The height in pixels of the title bar.
40 const int kTitleBarHeight = 24; 40 const int kTitlebarHeight = 24;
41 41
42 // The thickness in pixels of the frame border. 42 // The thickness in pixels of the frame border.
43 const int kFrameBorderThickness = 1; 43 const int kFrameBorderThickness = 1;
44 44
45 // The spacing in pixels between the icon and the border/text. 45 // The spacing in pixels between the icon and the border/text.
46 const int kIconSpacing = 4; 46 const int kIconSpacing = 4;
47 47
48 // The height and width in pixels of the icon. 48 // The height and width in pixels of the icon.
49 const int kIconSize = 16; 49 const int kIconSize = 16;
50 50
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 gfx::Size PanelBrowserFrameView::GetMinimumSize() { 350 gfx::Size PanelBrowserFrameView::GetMinimumSize() {
351 // This makes the panel be able to shrink to very small, like 3-pixel lines. 351 // This makes the panel be able to shrink to very small, like 3-pixel lines.
352 // Since the panel cannot be resized by the user, we do not need to enforce 352 // Since the panel cannot be resized by the user, we do not need to enforce
353 // the minimum size. 353 // the minimum size.
354 return gfx::Size(); 354 return gfx::Size();
355 } 355 }
356 356
357 void PanelBrowserFrameView::Layout() { 357 void PanelBrowserFrameView::Layout() {
358 // If the panel height is smaller than the title-bar height, as in minimized 358 // If the panel height is smaller than the title-bar height, as in minimized
359 // case, we hide all controls. 359 // case, we hide all controls.
360 bool is_control_visible = height() >= kTitleBarHeight; 360 bool is_control_visible = height() >= kTitlebarHeight;
361 close_button_->SetVisible(is_control_visible); 361 close_button_->SetVisible(is_control_visible);
362 settings_button_->SetVisible( 362 settings_button_->SetVisible(
363 is_control_visible && is_settings_button_visible_); 363 is_control_visible && is_settings_button_visible_);
364 title_icon_->SetVisible(is_control_visible); 364 title_icon_->SetVisible(is_control_visible);
365 title_label_->SetVisible(is_control_visible); 365 title_label_->SetVisible(is_control_visible);
366 366
367 // Layout the close button. 367 // Layout the close button.
368 gfx::Size close_button_size = close_button_->GetPreferredSize(); 368 gfx::Size close_button_size = close_button_->GetPreferredSize();
369 close_button_->SetBounds( 369 close_button_->SetBounds(
370 width() - kFrameBorderThickness - kButtonSpacing - 370 width() - kFrameBorderThickness - kButtonSpacing -
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 std::max(0, width() - (2 * border_thickness)), 407 std::max(0, width() - (2 * border_thickness)),
408 std::max(0, height() - top_height - border_thickness)); 408 std::max(0, height() - top_height - border_thickness));
409 } 409 }
410 410
411 void PanelBrowserFrameView::GetAccessibleState(ui::AccessibleViewState* state) { 411 void PanelBrowserFrameView::GetAccessibleState(ui::AccessibleViewState* state) {
412 state->role = ui::AccessibilityTypes::ROLE_TITLEBAR; 412 state->role = ui::AccessibilityTypes::ROLE_TITLEBAR;
413 } 413 }
414 414
415 bool PanelBrowserFrameView::OnMousePressed(const views::MouseEvent& event) { 415 bool PanelBrowserFrameView::OnMousePressed(const views::MouseEvent& event) {
416 if (event.IsOnlyLeftMouseButton() && 416 if (event.IsOnlyLeftMouseButton() &&
417 browser_view_->OnTitleBarMousePressed(event.location())) { 417 browser_view_->OnTitlebarMousePressed(event.location())) {
418 return true; 418 return true;
419 } 419 }
420 return BrowserNonClientFrameView::OnMousePressed(event); 420 return BrowserNonClientFrameView::OnMousePressed(event);
421 } 421 }
422 422
423 bool PanelBrowserFrameView::OnMouseDragged(const views::MouseEvent& event) { 423 bool PanelBrowserFrameView::OnMouseDragged(const views::MouseEvent& event) {
424 if (browser_view_->OnTitleBarMouseDragged(event.location())) 424 if (browser_view_->OnTitlebarMouseDragged(event.location()))
425 return true; 425 return true;
426 return BrowserNonClientFrameView::OnMouseDragged(event); 426 return BrowserNonClientFrameView::OnMouseDragged(event);
427 } 427 }
428 428
429 void PanelBrowserFrameView::OnMouseReleased(const views::MouseEvent& event) { 429 void PanelBrowserFrameView::OnMouseReleased(const views::MouseEvent& event) {
430 if (browser_view_->OnTitleBarMouseReleased()) 430 if (browser_view_->OnTitlebarMouseReleased())
431 return; 431 return;
432 BrowserNonClientFrameView::OnMouseReleased(event); 432 BrowserNonClientFrameView::OnMouseReleased(event);
433 } 433 }
434 434
435 void PanelBrowserFrameView::OnMouseCaptureLost() { 435 void PanelBrowserFrameView::OnMouseCaptureLost() {
436 if (browser_view_->OnTitleBarMouseCaptureLost()) 436 if (browser_view_->OnTitlebarMouseCaptureLost())
437 return; 437 return;
438 BrowserNonClientFrameView::OnMouseCaptureLost(); 438 BrowserNonClientFrameView::OnMouseCaptureLost();
439 } 439 }
440 440
441 void PanelBrowserFrameView::ButtonPressed(views::Button* sender, 441 void PanelBrowserFrameView::ButtonPressed(views::Button* sender,
442 const views::Event& event) { 442 const views::Event& event) {
443 if (sender == close_button_) 443 if (sender == close_button_)
444 frame_->Close(); 444 frame_->Close();
445 } 445 }
446 446
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 } 551 }
552 552
553 void PanelBrowserFrameView::ExtensionDialogCanceled() { 553 void PanelBrowserFrameView::ExtensionDialogCanceled() {
554 } 554 }
555 555
556 int PanelBrowserFrameView::NonClientBorderThickness() const { 556 int PanelBrowserFrameView::NonClientBorderThickness() const {
557 return kFrameBorderThickness + kClientEdgeThickness; 557 return kFrameBorderThickness + kClientEdgeThickness;
558 } 558 }
559 559
560 int PanelBrowserFrameView::NonClientTopBorderHeight() const { 560 int PanelBrowserFrameView::NonClientTopBorderHeight() const {
561 return kFrameBorderThickness + kTitleBarHeight + kClientEdgeThickness; 561 return kFrameBorderThickness + kTitlebarHeight + kClientEdgeThickness;
562 } 562 }
563 563
564 SkColor PanelBrowserFrameView::GetTitleColor(PaintState paint_state) const { 564 SkColor PanelBrowserFrameView::GetTitleColor(PaintState paint_state) const {
565 switch (paint_state) { 565 switch (paint_state) {
566 case PAINT_AS_INACTIVE: 566 case PAINT_AS_INACTIVE:
567 return GetThemeProvider()->GetColor( 567 return GetThemeProvider()->GetColor(
568 ThemeService::COLOR_BACKGROUND_TAB_TEXT); 568 ThemeService::COLOR_BACKGROUND_TAB_TEXT);
569 case PAINT_AS_ACTIVE: 569 case PAINT_AS_ACTIVE:
570 return GetThemeProvider()->GetColor(ThemeService::COLOR_TAB_TEXT); 570 return GetThemeProvider()->GetColor(ThemeService::COLOR_TAB_TEXT);
571 case PAINT_FOR_ATTENTION: 571 case PAINT_FOR_ATTENTION:
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 settings_menu_contents_.AddItem( 750 settings_menu_contents_.AddItem(
751 COMMAND_DISABLE, l10n_util::GetStringUTF16(IDS_EXTENSIONS_DISABLE)); 751 COMMAND_DISABLE, l10n_util::GetStringUTF16(IDS_EXTENSIONS_DISABLE));
752 settings_menu_contents_.AddItem( 752 settings_menu_contents_.AddItem(
753 COMMAND_UNINSTALL, l10n_util::GetStringUTF16(IDS_EXTENSIONS_UNINSTALL)); 753 COMMAND_UNINSTALL, l10n_util::GetStringUTF16(IDS_EXTENSIONS_UNINSTALL));
754 settings_menu_contents_.AddSeparator(); 754 settings_menu_contents_.AddSeparator();
755 settings_menu_contents_.AddItem( 755 settings_menu_contents_.AddItem(
756 COMMAND_MANAGE, l10n_util::GetStringUTF16(IDS_MANAGE_EXTENSIONS)); 756 COMMAND_MANAGE, l10n_util::GetStringUTF16(IDS_MANAGE_EXTENSIONS));
757 757
758 settings_menu_adapter_.BuildMenu(&settings_menu_); 758 settings_menu_adapter_.BuildMenu(&settings_menu_);
759 } 759 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698