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

Side by Side Diff: ash/wm/caption_buttons/frame_caption_button_container_view.cc

Issue 24048003: [Refactor] Cache the views::Widget* that the FrameMaximizeButton acts on (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nits per jamescook@ Created 7 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ash/wm/caption_buttons/frame_caption_button_container_view.h" 5 #include "ash/wm/caption_buttons/frame_caption_button_container_view.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/shell_delegate.h" 9 #include "ash/shell_delegate.h"
10 #include "ash/wm/caption_buttons/alternate_frame_caption_button.h" 10 #include "ash/wm/caption_buttons/alternate_frame_caption_button.h"
11 #include "ash/wm/caption_buttons/frame_maximize_button.h" 11 #include "ash/wm/caption_buttons/frame_maximize_button.h"
12 #include "ash/wm/window_settings.h" 12 #include "ash/wm/window_settings.h"
13 #include "grit/ash_resources.h" 13 #include "grit/ash_resources.h"
14 #include "grit/ui_strings.h" // Accessibility names 14 #include "grit/ui_strings.h" // Accessibility names
15 #include "ui/base/hit_test.h" 15 #include "ui/base/hit_test.h"
16 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/base/resource/resource_bundle.h" 17 #include "ui/base/resource/resource_bundle.h"
18 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 18 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
19 #include "ui/gfx/canvas.h" 19 #include "ui/gfx/canvas.h"
20 #include "ui/views/border.h" 20 #include "ui/views/border.h"
21 #include "ui/views/controls/button/image_button.h" 21 #include "ui/views/controls/button/image_button.h"
22 #include "ui/views/widget/widget.h" 22 #include "ui/views/widget/widget.h"
23 #include "ui/views/widget/widget_delegate.h" 23 #include "ui/views/widget/widget_delegate.h"
24 #include "ui/views/window/non_client_view.h"
25 24
26 namespace ash { 25 namespace ash {
27 26
28 namespace { 27 namespace {
29 28
30 // Constants for normal button style ------------------------------------------- 29 // Constants for normal button style -------------------------------------------
31 30
32 // The distance between buttons. AlternateFrameCaptionButton::GetXOverlap() is 31 // The distance between buttons. AlternateFrameCaptionButton::GetXOverlap() is
33 // used to compute the distance between buttons for the alternate button style. 32 // used to compute the distance between buttons for the alternate button style.
34 const int kDistanceBetweenButtons = -1; 33 const int kDistanceBetweenButtons = -1;
(...skipping 23 matching lines...) Expand all
58 return dst->HitTestPoint(converted); 57 return dst->HitTestPoint(converted);
59 } 58 }
60 59
61 } // namespace 60 } // namespace
62 61
63 // static 62 // static
64 const char FrameCaptionButtonContainerView::kViewClassName[] = 63 const char FrameCaptionButtonContainerView::kViewClassName[] =
65 "FrameCaptionButtonContainerView"; 64 "FrameCaptionButtonContainerView";
66 65
67 FrameCaptionButtonContainerView::FrameCaptionButtonContainerView( 66 FrameCaptionButtonContainerView::FrameCaptionButtonContainerView(
68 views::NonClientFrameView* frame_view,
69 views::Widget* frame, 67 views::Widget* frame,
70 MinimizeAllowed minimize_allowed) 68 MinimizeAllowed minimize_allowed)
71 : frame_(frame), 69 : frame_(frame),
72 header_style_(HEADER_STYLE_SHORT), 70 header_style_(HEADER_STYLE_SHORT),
73 minimize_button_(NULL), 71 minimize_button_(NULL),
74 size_button_(NULL), 72 size_button_(NULL),
75 close_button_(NULL) { 73 close_button_(NULL) {
76 bool alternate_style = switches::UseAlternateFrameCaptionButtonStyle(); 74 bool alternate_style = switches::UseAlternateFrameCaptionButtonStyle();
77 75
78 // Insert the buttons left to right. 76 // Insert the buttons left to right.
79 if (alternate_style) { 77 if (alternate_style) {
80 minimize_button_ = new AlternateFrameCaptionButton(this, 78 minimize_button_ = new AlternateFrameCaptionButton(this,
81 AlternateFrameCaptionButton::ACTION_MINIMIZE); 79 AlternateFrameCaptionButton::ACTION_MINIMIZE);
82 size_button_ = new AlternateFrameCaptionButton(this, 80 size_button_ = new AlternateFrameCaptionButton(this,
83 AlternateFrameCaptionButton::ACTION_MAXIMIZE_RESTORE); 81 AlternateFrameCaptionButton::ACTION_MAXIMIZE_RESTORE);
84 close_button_ = new AlternateFrameCaptionButton(this, 82 close_button_ = new AlternateFrameCaptionButton(this,
85 AlternateFrameCaptionButton::ACTION_CLOSE); 83 AlternateFrameCaptionButton::ACTION_CLOSE);
86 } else { 84 } else {
87 minimize_button_ = new views::ImageButton(this); 85 minimize_button_ = new views::ImageButton(this);
88 size_button_ = new FrameMaximizeButton(this, frame_view); 86 size_button_ = new FrameMaximizeButton(this, frame);
89 close_button_ = new views::ImageButton(this); 87 close_button_ = new views::ImageButton(this);
90 } 88 }
91 89
92 minimize_button_->SetAccessibleName( 90 minimize_button_->SetAccessibleName(
93 l10n_util::GetStringUTF16(IDS_APP_ACCNAME_MINIMIZE)); 91 l10n_util::GetStringUTF16(IDS_APP_ACCNAME_MINIMIZE));
94 // Hide |minimize_button_| when using the non-alternate button style because 92 // Hide |minimize_button_| when using the non-alternate button style because
95 // |size_button_| is capable of minimizing in this case. 93 // |size_button_| is capable of minimizing in this case.
96 // TODO(pkotwicz): We should probably show the minimize button when in 94 // TODO(pkotwicz): We should probably show the minimize button when in
97 // "always maximized" mode. 95 // "always maximized" mode.
98 minimize_button_->SetVisible( 96 minimize_button_->SetVisible(
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 ui::ResourceBundle& resource_bundle = ui::ResourceBundle::GetSharedInstance(); 347 ui::ResourceBundle& resource_bundle = ui::ResourceBundle::GetSharedInstance();
350 image_button->SetImage(views::CustomButton::STATE_NORMAL, 348 image_button->SetImage(views::CustomButton::STATE_NORMAL,
351 resource_bundle.GetImageSkiaNamed(normal_image_id)); 349 resource_bundle.GetImageSkiaNamed(normal_image_id));
352 image_button->SetImage(views::CustomButton::STATE_HOVERED, 350 image_button->SetImage(views::CustomButton::STATE_HOVERED,
353 resource_bundle.GetImageSkiaNamed(hot_image_id)); 351 resource_bundle.GetImageSkiaNamed(hot_image_id));
354 image_button->SetImage(views::CustomButton::STATE_PRESSED, 352 image_button->SetImage(views::CustomButton::STATE_PRESSED,
355 resource_bundle.GetImageSkiaNamed(pushed_image_id)); 353 resource_bundle.GetImageSkiaNamed(pushed_image_id));
356 } 354 }
357 355
358 } // namespace ash 356 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698