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

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

Issue 8664021: Update Panel UI looks on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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
« no previous file with comments | « chrome/browser/ui/panels/panel_browser_frame_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/themes/theme_service.h" 10 #include "chrome/browser/themes/theme_service.h"
11 #include "chrome/browser/themes/theme_service_factory.h"
11 #include "chrome/browser/ui/panels/panel.h" 12 #include "chrome/browser/ui/panels/panel.h"
12 #include "chrome/browser/ui/panels/panel_browser_view.h" 13 #include "chrome/browser/ui/panels/panel_browser_view.h"
13 #include "chrome/browser/ui/panels/panel_manager.h" 14 #include "chrome/browser/ui/panels/panel_manager.h"
14 #include "chrome/browser/ui/panels/panel_settings_menu_model.h" 15 #include "chrome/browser/ui/panels/panel_settings_menu_model.h"
15 #include "chrome/common/extensions/extension.h" 16 #include "chrome/common/extensions/extension.h"
16 #include "content/browser/tab_contents/tab_contents.h" 17 #include "content/browser/tab_contents/tab_contents.h"
17 #include "grit/generated_resources.h" 18 #include "grit/generated_resources.h"
18 #include "grit/theme_resources.h" 19 #include "grit/theme_resources.h"
19 #include "grit/theme_resources_standard.h" 20 #include "grit/theme_resources_standard.h"
20 #include "grit/ui_resources.h" 21 #include "grit/ui_resources.h"
21 #include "third_party/skia/include/effects/SkGradientShader.h" 22 #include "third_party/skia/include/effects/SkGradientShader.h"
22 #include "ui/base/accessibility/accessible_view_state.h" 23 #include "ui/base/accessibility/accessible_view_state.h"
23 #include "ui/base/animation/slide_animation.h" 24 #include "ui/base/animation/slide_animation.h"
24 #include "ui/base/hit_test.h" 25 #include "ui/base/hit_test.h"
25 #include "ui/base/l10n/l10n_util.h" 26 #include "ui/base/l10n/l10n_util.h"
26 #include "ui/base/resource/resource_bundle.h" 27 #include "ui/base/resource/resource_bundle.h"
27 #include "ui/gfx/canvas_skia.h" 28 #include "ui/gfx/canvas_skia.h"
28 #include "ui/gfx/path.h" 29 #include "ui/gfx/path.h"
29 #include "ui/gfx/screen.h" 30 #include "ui/gfx/screen.h"
31 #include "ui/gfx/skia_util.h"
30 #include "ui/views/widget/widget_delegate.h" 32 #include "ui/views/widget/widget_delegate.h"
31 #include "views/controls/button/image_button.h" 33 #include "views/controls/button/image_button.h"
32 #include "views/controls/button/menu_button.h" 34 #include "views/controls/button/menu_button.h"
33 #include "views/controls/label.h" 35 #include "views/controls/label.h"
34 #include "views/controls/menu/menu_item_view.h" 36 #include "views/controls/menu/menu_item_view.h"
35 #include "views/controls/menu/menu_model_adapter.h" 37 #include "views/controls/menu/menu_model_adapter.h"
36 #include "views/controls/menu/menu_runner.h" 38 #include "views/controls/menu/menu_runner.h"
37 #include "views/painter.h" 39 #include "views/painter.h"
38 40
39 namespace { 41 namespace {
40 42
41 // The height in pixels of the titlebar. 43 // The height in pixels of the titlebar.
42 const int kTitlebarHeight = 24; 44 const int kTitlebarHeight = 24;
43 45
44 // The thickness in pixels of the frame border. 46 // The thickness in pixels of the border.
45 const int kFrameBorderThickness = 1; 47 const int kBorderThickness = 1;
46 48
47 // The spacing in pixels between the icon and the border/text. 49 // No client edge is present.
48 const int kIconSpacing = 4; 50 const int kPanelClientEdgeThickness = 0;
51
52 // The spacing in pixels between the icon and the left border.
53 const int kIconAndBorderSpacing = 4;
49 54
50 // The height and width in pixels of the icon. 55 // The height and width in pixels of the icon.
51 const int kIconSize = 16; 56 const int kIconSize = 16;
52 57
53 // The spacing in pixels between buttons or the button and the adjacent control. 58 // The spacing in pixels between the title and the icon on the left, or the
54 const int kButtonSpacing = 6; 59 // button on the right.
60 const int kTitleSpacing = 8;
61
62 // The spacing in pixels between the close button and the right border.
63 const int kCloseButtonAndBorderSpacing = 8;
64
65 // The spacing in pixels between the close button and the settings button.
66 const int kSettingsButtonAndCloseButtonSpacing = 8;
55 67
56 // This value is experimental and subjective. 68 // This value is experimental and subjective.
57 const int kUpdateSettingsVisibilityAnimationMs = 120; 69 const int kUpdateSettingsVisibilityAnimationMs = 120;
58 70
59 // Colors used in painting the titlebar for drawing attention. 71 // Colors used to draw active titlebar under default theme.
60 const SkColor kBackgroundColorForAttention = 0xfffa983a; 72 const SkColor kActiveTitleTextDefaultColor = SK_ColorBLACK;
61 const SkColor kTitleTextColorForAttention = SK_ColorWHITE; 73 const SkColor kActiveBackgroundDefaultColorStart = 0xfff0f8fa;
74 const SkColor kActiveBackgroundDefaultColorEnd = 0xffd1e2ed;
75
76 // Colors used to draw inactive titlebar under default theme.
77 const SkColor kInactiveTitleTextDefaultColor = 0xc0000000;
78 const SkColor kInactiveBackgroundDefaultColorStart = 0xffffffff;
79 const SkColor kInactiveBackgroundDefaultColorEnd = 0xffe7edf1;
80
81 // Alpha value used in drawing inactive titlebar under default theme.
82 const U8CPU kInactiveAlphaBlending = 0xc0;
83
84 // Colors used to draw titlebar for drawing attention regardless of the theme.
85 const SkColor kAttentionTitleTextColor = SK_ColorWHITE;
86 const SkColor kAttentionBackgroundColorStart = 0xffffab57;
87 const SkColor kAttentionBackgroundColorEnd = 0xfff59338;
88
89 // Color used to draw the border.
90 const SkColor kBorderColor = 0xc0000000;
91
92 // Color used to draw the divider line between the titlebar and the client area.
93 const SkColor kDividerColor = 0xffb5b5b5;
62 94
63 struct ButtonResources { 95 struct ButtonResources {
64 SkBitmap* normal_image; 96 SkBitmap* normal_image;
65 SkBitmap* mask_image; 97 SkBitmap* mask_image;
66 SkBitmap* hover_image; 98 SkBitmap* hover_image;
67 SkBitmap* pushed_image; 99 SkBitmap* pushed_image;
68 100
69 void SetResources(int normal_image_id, int mask_image_id, int hover_image_id, 101 void SetResources(int normal_image_id, int mask_image_id, int hover_image_id,
70 int pushed_image_id) { 102 int pushed_image_id) {
71 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 103 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
(...skipping 25 matching lines...) Expand all
97 bottom_right = rb.GetBitmapNamed(bottom_right_id); 129 bottom_right = rb.GetBitmapNamed(bottom_right_id);
98 bottom = rb.GetBitmapNamed(bottom_id); 130 bottom = rb.GetBitmapNamed(bottom_id);
99 bottom_left = rb.GetBitmapNamed(bottom_left_id); 131 bottom_left = rb.GetBitmapNamed(bottom_left_id);
100 left = rb.GetBitmapNamed(left_id); 132 left = rb.GetBitmapNamed(left_id);
101 } 133 }
102 }; 134 };
103 135
104 ButtonResources settings_button_resources; 136 ButtonResources settings_button_resources;
105 ButtonResources close_button_resources; 137 ButtonResources close_button_resources;
106 EdgeResources frame_edges; 138 EdgeResources frame_edges;
107 EdgeResources client_edges;
108 gfx::Font* title_font = NULL; 139 gfx::Font* title_font = NULL;
109 SkBitmap* background_bitmap_for_attention = NULL; 140 SkPaint active_background_default_paint;
Dmitry Titov 2011/11/29 04:04:03 I wonder if this is a good thing to have objects w
jianli 2011/11/29 19:30:15 Done.
141 SkPaint inactive_background_default_paint;
142 SkPaint attention_background_paint;
143
144 void InitializeGradientPaint(SkPaint* paint,
Dmitry Titov 2011/11/29 04:04:03 why not return the SkPaint*, especially if statics
jianli 2011/11/29 19:30:15 I still need this to do the delay initialization w
145 SkColor start_color,
146 SkColor end_color) {
147 SkShader* shader = gfx::CreateGradientShader(
148 0, kTitlebarHeight, start_color, end_color);
149 paint->setStyle(SkPaint::kFill_Style);
150 paint->setAntiAlias(true);
151 paint->setShader(shader);
152 shader->unref();
153 }
110 154
111 void LoadImageResources() { 155 void LoadImageResources() {
112 settings_button_resources.SetResources( 156 settings_button_resources.SetResources(
113 IDR_BALLOON_WRENCH, 0, IDR_BALLOON_WRENCH_H, IDR_BALLOON_WRENCH_P); 157 IDR_BALLOON_WRENCH, 0, IDR_BALLOON_WRENCH_H, IDR_BALLOON_WRENCH_P);
114 158
115 close_button_resources.SetResources( 159 close_button_resources.SetResources(
116 IDR_TAB_CLOSE, IDR_TAB_CLOSE_MASK, IDR_TAB_CLOSE_H, IDR_TAB_CLOSE_P); 160 IDR_TAB_CLOSE, IDR_TAB_CLOSE_MASK, IDR_TAB_CLOSE_H, IDR_TAB_CLOSE_P);
117 161
118 frame_edges.SetResources( 162 frame_edges.SetResources(
119 IDR_WINDOW_TOP_LEFT_CORNER, IDR_WINDOW_TOP_CENTER, 163 IDR_WINDOW_TOP_LEFT_CORNER, IDR_WINDOW_TOP_CENTER,
120 IDR_WINDOW_TOP_RIGHT_CORNER, IDR_WINDOW_RIGHT_SIDE, 164 IDR_WINDOW_TOP_RIGHT_CORNER, IDR_WINDOW_RIGHT_SIDE,
121 IDR_PANEL_BOTTOM_RIGHT_CORNER, IDR_WINDOW_BOTTOM_CENTER, 165 IDR_PANEL_BOTTOM_RIGHT_CORNER, IDR_WINDOW_BOTTOM_CENTER,
122 IDR_PANEL_BOTTOM_LEFT_CORNER, IDR_WINDOW_LEFT_SIDE); 166 IDR_PANEL_BOTTOM_LEFT_CORNER, IDR_WINDOW_LEFT_SIDE);
123
124 client_edges.SetResources(
125 IDR_APP_TOP_LEFT, IDR_APP_TOP_CENTER,
126 IDR_APP_TOP_RIGHT, IDR_CONTENT_RIGHT_SIDE,
127 IDR_CONTENT_BOTTOM_RIGHT_CORNER, IDR_CONTENT_BOTTOM_CENTER,
128 IDR_CONTENT_BOTTOM_LEFT_CORNER, IDR_CONTENT_LEFT_SIDE);
129 } 167 }
130 168
131 void EnsureResourcesInitialized() { 169 void EnsureResourcesInitialized() {
132 static bool resources_initialized = false; 170 static bool resources_initialized = false;
133 if (resources_initialized) 171 if (resources_initialized)
134 return; 172 return;
135 resources_initialized = true; 173 resources_initialized = true;
136 174
137 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 175 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
138 title_font = new gfx::Font(rb.GetFont(ResourceBundle::BaseFont)); 176 title_font = new gfx::Font(rb.GetFont(ResourceBundle::BoldFont));
139 177
140 // Creates a bitmap of the specified color. 178 InitializeGradientPaint(&active_background_default_paint,
141 background_bitmap_for_attention = new SkBitmap(); 179 kActiveBackgroundDefaultColorStart,
142 background_bitmap_for_attention->setConfig( 180 kActiveBackgroundDefaultColorEnd);
143 SkBitmap::kARGB_8888_Config, 16, 16); 181 InitializeGradientPaint(&inactive_background_default_paint,
144 background_bitmap_for_attention->allocPixels(); 182 kInactiveBackgroundDefaultColorStart,
145 background_bitmap_for_attention->eraseColor(kBackgroundColorForAttention); 183 kInactiveBackgroundDefaultColorEnd);
184 InitializeGradientPaint(&attention_background_paint,
185 kAttentionBackgroundColorStart,
186 kAttentionBackgroundColorEnd);
146 187
147 LoadImageResources(); 188 LoadImageResources();
148 } 189 }
149 190
150 } // namespace 191 } // namespace
151 192
152 // PanelBrowserFrameView::MouseWatcher ----------------------------------------- 193 // PanelBrowserFrameView::MouseWatcher -----------------------------------------
153 194
154 PanelBrowserFrameView::MouseWatcher::MouseWatcher(PanelBrowserFrameView* view) 195 PanelBrowserFrameView::MouseWatcher::MouseWatcher(PanelBrowserFrameView* view)
155 : view_(view), 196 : view_(view),
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 int window_component = GetHTComponentForFrame(point, 374 int window_component = GetHTComponentForFrame(point,
334 NonClientBorderThickness(), NonClientBorderThickness(), 375 NonClientBorderThickness(), NonClientBorderThickness(),
335 0, 0, 376 0, 0,
336 frame()->widget_delegate()->CanResize()); 377 frame()->widget_delegate()->CanResize());
337 // Fall back to the caption if no other component matches. 378 // Fall back to the caption if no other component matches.
338 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; 379 return (window_component == HTNOWHERE) ? HTCAPTION : window_component;
339 } 380 }
340 381
341 void PanelBrowserFrameView::GetWindowMask(const gfx::Size& size, 382 void PanelBrowserFrameView::GetWindowMask(const gfx::Size& size,
342 gfx::Path* window_mask) { 383 gfx::Path* window_mask) {
343 // For panel, the window shape is rectangle with top-left and top-right 384 window_mask->moveTo(0, 3);
344 // corners rounded. 385 window_mask->lineTo(1, 2);
345 if (size.height() <= Panel::kMinimizedPanelHeight) { 386 window_mask->lineTo(1, 1);
346 // For minimize panel, we need to produce the window mask applicable to 387 window_mask->lineTo(2, 1);
347 // the 3-pixel lines. 388 window_mask->lineTo(3, 0);
348 window_mask->moveTo(0, SkIntToScalar(size.height())); 389 window_mask->lineTo(SkIntToScalar(size.width() - 3), 0);
349 window_mask->lineTo(0, 1); 390 window_mask->lineTo(SkIntToScalar(size.width() - 2), 1);
350 window_mask->lineTo(1, 0); 391 window_mask->lineTo(SkIntToScalar(size.width() - 1), 1);
351 window_mask->lineTo(SkIntToScalar(size.width()) - 1, 0); 392 window_mask->lineTo(SkIntToScalar(size.width() - 1), 2);
352 window_mask->lineTo(SkIntToScalar(size.width()), 1); 393 window_mask->lineTo(SkIntToScalar(size.width() - 1), 3);
353 window_mask->lineTo(SkIntToScalar(size.width()), 394 window_mask->lineTo(SkIntToScalar(size.width()),
354 SkIntToScalar(size.height())); 395 SkIntToScalar(size.height()));
355 } else { 396 window_mask->lineTo(0, SkIntToScalar(size.height()));
356 window_mask->moveTo(0, 3);
357 window_mask->lineTo(1, 2);
358 window_mask->lineTo(1, 1);
359 window_mask->lineTo(2, 1);
360 window_mask->lineTo(3, 0);
361 window_mask->lineTo(SkIntToScalar(size.width() - 3), 0);
362 window_mask->lineTo(SkIntToScalar(size.width() - 2), 1);
363 window_mask->lineTo(SkIntToScalar(size.width() - 1), 1);
364 window_mask->lineTo(SkIntToScalar(size.width() - 1), 2);
365 window_mask->lineTo(SkIntToScalar(size.width()), 3);
366 window_mask->lineTo(SkIntToScalar(size.width()),
367 SkIntToScalar(size.height()));
368 window_mask->lineTo(0, SkIntToScalar(size.height()));
369 }
370 window_mask->close(); 397 window_mask->close();
371 } 398 }
372 399
373 void PanelBrowserFrameView::ResetWindowControls() { 400 void PanelBrowserFrameView::ResetWindowControls() {
374 // The close button isn't affected by this constraint. 401 // The close button isn't affected by this constraint.
375 } 402 }
376 403
377 void PanelBrowserFrameView::UpdateWindowIcon() { 404 void PanelBrowserFrameView::UpdateWindowIcon() {
378 title_icon_->SchedulePaint(); 405 title_icon_->SchedulePaint();
379 } 406 }
380 407
381 void PanelBrowserFrameView::OnPaint(gfx::Canvas* canvas) { 408 void PanelBrowserFrameView::OnPaint(gfx::Canvas* canvas) {
382 // The font and color need to be updated depending on the panel's state. 409 // The font and color need to be updated depending on the panel's state.
383 PaintState paint_state; 410 PaintState paint_state;
384 if (panel_browser_view_->panel()->IsDrawingAttention()) 411 if (panel_browser_view_->panel()->IsDrawingAttention())
385 paint_state = PAINT_FOR_ATTENTION; 412 paint_state = PAINT_FOR_ATTENTION;
386 else if (panel_browser_view_->focused()) 413 else if (panel_browser_view_->focused())
387 paint_state = PAINT_AS_ACTIVE; 414 paint_state = PAINT_AS_ACTIVE;
388 else 415 else
389 paint_state = PAINT_AS_INACTIVE; 416 paint_state = PAINT_AS_INACTIVE;
390 417
391 UpdateControlStyles(paint_state); 418 UpdateControlStyles(paint_state);
392 PaintFrameBorder(canvas); 419 PaintFrameBorder(canvas);
393 PaintClientEdge(canvas);
394 } 420 }
395 421
396 void PanelBrowserFrameView::OnThemeChanged() { 422 void PanelBrowserFrameView::OnThemeChanged() {
397 LoadImageResources(); 423 LoadImageResources();
398 } 424 }
399 425
400 gfx::Size PanelBrowserFrameView::GetMinimumSize() { 426 gfx::Size PanelBrowserFrameView::GetMinimumSize() {
401 // This makes the panel be able to shrink to very small, like 3-pixel lines. 427 // This makes the panel be able to shrink to very small, like 4-pixel lines.
402 // Since the panel cannot be resized by the user, we do not need to enforce 428 // Since the panel cannot be resized by the user, we do not need to enforce
403 // the minimum size. 429 // the minimum size.
404 return gfx::Size(); 430 return gfx::Size();
405 } 431 }
406 432
407 void PanelBrowserFrameView::Layout() { 433 void PanelBrowserFrameView::Layout() {
408 // Cancel the settings button animation if the layout of titlebar is being 434 // Cancel the settings button animation if the layout of titlebar is being
409 // updated. 435 // updated.
410 if (settings_button_animator_.get() && settings_button_animator_->IsShowing()) 436 if (settings_button_animator_.get() && settings_button_animator_->IsShowing())
411 settings_button_animator_->Reset(); 437 settings_button_animator_->Reset();
412 438
413 // Layout the close button. 439 // Layout the close button.
414 gfx::Size close_button_size = close_button_->GetPreferredSize(); 440 gfx::Size close_button_size = close_button_->GetPreferredSize();
415 close_button_->SetBounds( 441 close_button_->SetBounds(
416 width() - kFrameBorderThickness - kButtonSpacing - 442 width() - kBorderThickness - kCloseButtonAndBorderSpacing -
417 close_button_size.width(), 443 close_button_size.width(),
418 (NonClientTopBorderHeight() - close_button_size.height()) / 2, 444 (NonClientTopBorderHeight() - close_button_size.height()) / 2,
419 close_button_size.width(), 445 close_button_size.width(),
420 close_button_size.height()); 446 close_button_size.height());
421 447
422 // Layout the settings button. 448 // Layout the settings button.
423 gfx::Size settings_button_size = settings_button_->GetPreferredSize(); 449 gfx::Size settings_button_size = settings_button_->GetPreferredSize();
424 settings_button_->SetBounds( 450 settings_button_->SetBounds(
425 close_button_->x() - kButtonSpacing - settings_button_size.width(), 451 close_button_->x() - kSettingsButtonAndCloseButtonSpacing -
452 settings_button_size.width(),
426 (NonClientTopBorderHeight() - settings_button_size.height()) / 2, 453 (NonClientTopBorderHeight() - settings_button_size.height()) / 2,
427 settings_button_size.width(), 454 settings_button_size.width(),
428 settings_button_size.height()); 455 settings_button_size.height());
429 456
430 // Trace the full bounds and zero-size bounds for animation purpose. 457 // Trace the full bounds and zero-size bounds for animation purpose.
431 settings_button_full_bounds_ = settings_button_->bounds(); 458 settings_button_full_bounds_ = settings_button_->bounds();
432 settings_button_zero_bounds_.SetRect( 459 settings_button_zero_bounds_.SetRect(
433 settings_button_full_bounds_.x() + 460 settings_button_full_bounds_.x() +
434 settings_button_full_bounds_.width() / 2, 461 settings_button_full_bounds_.width() / 2,
435 settings_button_full_bounds_.y() + 462 settings_button_full_bounds_.y() +
436 settings_button_full_bounds_.height() / 2, 463 settings_button_full_bounds_.height() / 2,
437 0, 464 0,
438 0); 465 0);
439 466
440 // Layout the icon. 467 // Layout the icon.
441 int icon_y = (NonClientTopBorderHeight() - kIconSize) / 2; 468 int icon_y = (NonClientTopBorderHeight() - kIconSize) / 2;
442 title_icon_->SetBounds( 469 title_icon_->SetBounds(
443 kFrameBorderThickness + kIconSpacing, 470 kBorderThickness + kIconAndBorderSpacing,
444 icon_y, 471 icon_y,
445 kIconSize, 472 kIconSize,
446 kIconSize); 473 kIconSize);
447 474
448 // Layout the title. 475 // Layout the title.
449 int title_x = title_icon_->bounds().right() + kIconSpacing; 476 int title_x = title_icon_->bounds().right() + kTitleSpacing;
450 int title_height = BrowserFrame::GetTitleFont().GetHeight(); 477 int title_height = BrowserFrame::GetTitleFont().GetHeight();
451 title_label_->SetBounds( 478 title_label_->SetBounds(
452 title_x, 479 title_x,
453 icon_y + ((kIconSize - title_height - 1) / 2), 480 icon_y + ((kIconSize - title_height - 1) / 2),
454 std::max(0, settings_button_->x() - kButtonSpacing - title_x), 481 std::max(0, settings_button_->x() - kTitleSpacing - title_x),
455 title_height); 482 title_height);
456 483
457 // Calculate the client area bounds. 484 // Calculate the client area bounds.
458 int top_height = NonClientTopBorderHeight(); 485 int top_height = NonClientTopBorderHeight();
459 int border_thickness = NonClientBorderThickness(); 486 int border_thickness = NonClientBorderThickness();
460 client_view_bounds_.SetRect( 487 client_view_bounds_.SetRect(
461 border_thickness, 488 border_thickness,
462 top_height, 489 top_height,
463 std::max(0, width() - (2 * border_thickness)), 490 std::max(0, width() - (2 * border_thickness)),
464 std::max(0, height() - top_height - border_thickness)); 491 std::max(0, height() - top_height - border_thickness));
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 AnimationEnded(animation); 573 AnimationEnded(animation);
547 else 574 else
548 settings_button_->SetBoundsRect(new_bounds); 575 settings_button_->SetBoundsRect(new_bounds);
549 } 576 }
550 577
551 void PanelBrowserFrameView::AnimationCanceled(const ui::Animation* animation) { 578 void PanelBrowserFrameView::AnimationCanceled(const ui::Animation* animation) {
552 AnimationEnded(animation); 579 AnimationEnded(animation);
553 } 580 }
554 581
555 int PanelBrowserFrameView::NonClientBorderThickness() const { 582 int PanelBrowserFrameView::NonClientBorderThickness() const {
556 return kFrameBorderThickness + kClientEdgeThickness; 583 return kBorderThickness + kPanelClientEdgeThickness;
557 } 584 }
558 585
559 int PanelBrowserFrameView::NonClientTopBorderHeight() const { 586 int PanelBrowserFrameView::NonClientTopBorderHeight() const {
560 return kFrameBorderThickness + kTitlebarHeight + kClientEdgeThickness; 587 return kBorderThickness + kTitlebarHeight + kPanelClientEdgeThickness;
561 } 588 }
562 589
563 gfx::Size PanelBrowserFrameView::NonClientAreaSize() const { 590 gfx::Size PanelBrowserFrameView::NonClientAreaSize() const {
564 return gfx::Size(NonClientBorderThickness() * 2, 591 return gfx::Size(NonClientBorderThickness() * 2,
565 NonClientTopBorderHeight() + NonClientBorderThickness()); 592 NonClientTopBorderHeight() + NonClientBorderThickness());
566 } 593 }
567 594
595 bool PanelBrowserFrameView::UsingDefaultTheme() const {
596 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(
597 panel_browser_view_->panel()->browser()->profile());
598 return theme_service->UsingDefaultTheme();
599 }
600
601 SkColor PanelBrowserFrameView::GetDefaultTitleColor(
602 PaintState paint_state) const {
603 switch (paint_state) {
604 case PAINT_AS_INACTIVE:
605 return kActiveTitleTextDefaultColor;
606 case PAINT_AS_ACTIVE:
607 return kInactiveTitleTextDefaultColor;
608 case PAINT_FOR_ATTENTION:
609 return kAttentionTitleTextColor;
610 default:
611 NOTREACHED();
612 return SkColor();
613 }
614 }
615
568 SkColor PanelBrowserFrameView::GetTitleColor(PaintState paint_state) const { 616 SkColor PanelBrowserFrameView::GetTitleColor(PaintState paint_state) const {
569 switch (paint_state) { 617 switch (paint_state) {
570 case PAINT_AS_INACTIVE: 618 case PAINT_AS_INACTIVE:
571 return GetThemeProvider()->GetColor( 619 return SkColorSetA(
572 ThemeService::COLOR_BACKGROUND_TAB_TEXT); 620 GetThemeProvider()->GetColor(ThemeService::COLOR_BACKGROUND_TAB_TEXT),
621 kInactiveAlphaBlending);
573 case PAINT_AS_ACTIVE: 622 case PAINT_AS_ACTIVE:
574 return GetThemeProvider()->GetColor(ThemeService::COLOR_TAB_TEXT); 623 return GetThemeProvider()->GetColor(ThemeService::COLOR_TAB_TEXT);
575 case PAINT_FOR_ATTENTION: 624 case PAINT_FOR_ATTENTION:
576 return kTitleTextColorForAttention; 625 return kAttentionTitleTextColor;
577 default: 626 default:
578 NOTREACHED(); 627 NOTREACHED();
579 return SkColor(); 628 return SkColor();
580 } 629 }
581 } 630 }
582 631
583 gfx::Font* PanelBrowserFrameView::GetTitleFont() const { 632 gfx::Font* PanelBrowserFrameView::GetTitleFont() const {
584 return title_font; 633 return title_font;
585 } 634 }
586 635
636 SkPaint* PanelBrowserFrameView::GetDefaultFrameTheme(
637 PaintState paint_state) const {
638 switch (paint_state) {
639 case PAINT_AS_INACTIVE:
640 return &inactive_background_default_paint;
641 case PAINT_AS_ACTIVE:
642 return &active_background_default_paint;
643 case PAINT_FOR_ATTENTION:
644 return &attention_background_paint;
645 default:
646 NOTREACHED();
647 return NULL;
648 }
649 }
650
587 SkBitmap* PanelBrowserFrameView::GetFrameTheme(PaintState paint_state) const { 651 SkBitmap* PanelBrowserFrameView::GetFrameTheme(PaintState paint_state) const {
588 switch (paint_state) { 652 switch (paint_state) {
589 case PAINT_AS_INACTIVE: 653 case PAINT_AS_INACTIVE:
590 return GetThemeProvider()->GetBitmapNamed(IDR_THEME_TAB_BACKGROUND); 654 return GetThemeProvider()->GetBitmapNamed(IDR_THEME_TAB_BACKGROUND);
591 case PAINT_AS_ACTIVE: 655 case PAINT_AS_ACTIVE:
592 return GetThemeProvider()->GetBitmapNamed(IDR_THEME_TOOLBAR); 656 return GetThemeProvider()->GetBitmapNamed(IDR_THEME_TOOLBAR);
593 case PAINT_FOR_ATTENTION: 657 case PAINT_FOR_ATTENTION:
594 return background_bitmap_for_attention; 658 // Background color for drawing attention is same regardless of the
659 // theme. GetDefaultFrameTheme should be used.
595 default: 660 default:
596 NOTREACHED(); 661 NOTREACHED();
597 return NULL; 662 return NULL;
598 } 663 }
599 } 664 }
600 665
601 void PanelBrowserFrameView::UpdateControlStyles(PaintState paint_state) { 666 void PanelBrowserFrameView::UpdateControlStyles(PaintState paint_state) {
602 DCHECK(paint_state != NOT_PAINTED); 667 DCHECK(paint_state != NOT_PAINTED);
603 668
604 if (paint_state == paint_state_) 669 if (paint_state == paint_state_)
605 return; 670 return;
606 paint_state_ = paint_state; 671 paint_state_ = paint_state;
607 672
608 SkColor title_color = GetTitleColor(paint_state_); 673 SkColor title_color = GetTitleColor(paint_state_);
609 title_label_->SetEnabledColor(title_color); 674 title_label_->SetEnabledColor(title_color);
610 title_label_->SetFont(*GetTitleFont()); 675 title_label_->SetFont(*GetTitleFont());
611 676
612 close_button_->SetBackground(title_color, 677 close_button_->SetBackground(title_color,
613 close_button_resources.normal_image, 678 close_button_resources.normal_image,
614 close_button_resources.mask_image); 679 close_button_resources.mask_image);
615 } 680 }
616 681
617 void PanelBrowserFrameView::PaintFrameBorder(gfx::Canvas* canvas) { 682 void PanelBrowserFrameView::PaintFrameBorder(gfx::Canvas* canvas) {
618 SkBitmap* theme_frame = GetFrameTheme(paint_state_); 683 // Paint the background.
619 684 if (paint_state_ == PAINT_FOR_ATTENTION || UsingDefaultTheme()) {
620 // Draw the theme frame. 685 SkPaint* paint = GetDefaultFrameTheme(paint_state_);
621 canvas->TileImageInt(*theme_frame, 0, 0, width(), height()); 686 canvas->DrawRectInt(0, 0, width(), kTitlebarHeight, *paint);
622 687 } else {
623 // No need to paint other stuff if panel is minimized. 688 SkBitmap* bitmap = GetFrameTheme(paint_state_);
624 if (height() <= Panel::kMinimizedPanelHeight) 689 canvas->TileImageInt(*bitmap, 0, 0, width(), kTitlebarHeight);
625 return; 690 }
626 691
627 // Draw the top border. 692 // Draw the top border.
628 canvas->DrawBitmapInt(*(frame_edges.top_left), 0, 0); 693 canvas->DrawBitmapInt(*(frame_edges.top_left), 0, 0);
629 canvas->TileImageInt( 694 canvas->TileImageInt(
630 *(frame_edges.top), frame_edges.top_left->width(), 0, 695 *(frame_edges.top), frame_edges.top_left->width(), 0,
631 width() - frame_edges.top_right->width(), frame_edges.top->height()); 696 width() - frame_edges.top_right->width(), frame_edges.top->height());
632 canvas->DrawBitmapInt( 697 canvas->DrawBitmapInt(
633 *(frame_edges.top_right), 698 *(frame_edges.top_right),
634 width() - frame_edges.top_right->width(), 0); 699 width() - frame_edges.top_right->width(), 0);
635 700
(...skipping 18 matching lines...) Expand all
654 canvas->DrawBitmapInt( 719 canvas->DrawBitmapInt(
655 *(frame_edges.bottom_left), 0, 720 *(frame_edges.bottom_left), 0,
656 height() - frame_edges.bottom_left->height()); 721 height() - frame_edges.bottom_left->height());
657 722
658 // Draw the left border. 723 // Draw the left border.
659 canvas->TileImageInt( 724 canvas->TileImageInt(
660 *(frame_edges.left), 0, frame_edges.top_left->height(), 725 *(frame_edges.left), 0, frame_edges.top_left->height(),
661 frame_edges.left->width(), 726 frame_edges.left->width(),
662 height() - frame_edges.top_left->height() - 727 height() - frame_edges.top_left->height() -
663 frame_edges.bottom_left->height()); 728 frame_edges.bottom_left->height());
664 }
665 729
666 void PanelBrowserFrameView::PaintClientEdge(gfx::Canvas* canvas) { 730 // Draw the divider between the titlebar and the client area.
667 int client_area_top = client_view_bounds_.y(); 731 if (height() > kTitlebarHeight) {
668 732 canvas->DrawRectInt(kDividerColor, kBorderThickness, kTitlebarHeight,
669 // No need to paint other stuff if panel is minimized. 733 width() - 1 - 2 * kBorderThickness, kBorderThickness);
670 if (height() <= Panel::kMinimizedPanelHeight) 734 }
671 return;
672
673 // Draw the top edge.
674 int top_edge_y = client_area_top - client_edges.top->height();
675 canvas->DrawBitmapInt(
676 *(client_edges.top_left),
677 client_view_bounds_.x() - client_edges.top_left->width(),
678 top_edge_y);
679 canvas->TileImageInt(
680 *(client_edges.top), client_view_bounds_.x(), top_edge_y,
681 client_view_bounds_.width(), client_edges.top->height());
682 canvas->DrawBitmapInt(
683 *(client_edges.top_right), client_view_bounds_.right(), top_edge_y);
684
685 // Draw the right edge.
686 int client_area_bottom =
687 std::max(client_area_top, client_view_bounds_.bottom());
688 int client_area_height = client_area_bottom - client_area_top;
689 canvas->TileImageInt(
690 *(client_edges.right), client_view_bounds_.right(), client_area_top,
691 client_edges.right->width(), client_area_height);
692
693 // Draw the bottom edge.
694 canvas->DrawBitmapInt(
695 *(client_edges.bottom_right), client_view_bounds_.right(),
696 client_area_bottom);
697 canvas->TileImageInt(
698 *(client_edges.bottom), client_view_bounds_.x(), client_area_bottom,
699 client_view_bounds_.width(), client_edges.bottom_right->height());
700 canvas->DrawBitmapInt(
701 *(client_edges.bottom_left),
702 client_view_bounds_.x() - client_edges.bottom_left->width(),
703 client_area_bottom);
704
705 // Draw the left edge.
706 canvas->TileImageInt(
707 *(client_edges.left),
708 client_view_bounds_.x() - client_edges.left->width(),
709 client_area_top, client_edges.left->width(), client_area_height);
710 } 735 }
711 736
712 string16 PanelBrowserFrameView::GetTitleText() const { 737 string16 PanelBrowserFrameView::GetTitleText() const {
713 return frame()->widget_delegate()->GetWindowTitle(); 738 return frame()->widget_delegate()->GetWindowTitle();
714 } 739 }
715 740
716 void PanelBrowserFrameView::UpdateTitleBar() { 741 void PanelBrowserFrameView::UpdateTitleBar() {
717 title_label_->SetText(GetTitleText()); 742 title_label_->SetText(GetTitleText());
718 } 743 }
719 744
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 790
766 settings_menu_model_.reset( 791 settings_menu_model_.reset(
767 new PanelSettingsMenuModel(panel_browser_view_->panel())); 792 new PanelSettingsMenuModel(panel_browser_view_->panel()));
768 settings_menu_adapter_.reset( 793 settings_menu_adapter_.reset(
769 new views::MenuModelAdapter(settings_menu_model_.get())); 794 new views::MenuModelAdapter(settings_menu_model_.get()));
770 settings_menu_ = new views::MenuItemView(settings_menu_adapter_.get()); 795 settings_menu_ = new views::MenuItemView(settings_menu_adapter_.get());
771 settings_menu_adapter_->BuildMenu(settings_menu_); 796 settings_menu_adapter_->BuildMenu(settings_menu_);
772 settings_menu_runner_.reset(new views::MenuRunner(settings_menu_)); 797 settings_menu_runner_.reset(new views::MenuRunner(settings_menu_));
773 return true; 798 return true;
774 } 799 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_browser_frame_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698