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

Side by Side Diff: ui/app_list/views/contents_switcher_view.cc

Issue 273223002: views: Make view::Views::GetPreferredSize() const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More compile fix for ToT Created 6 years, 7 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
« no previous file with comments | « ui/app_list/views/contents_switcher_view.h ('k') | ui/app_list/views/contents_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/app_list/views/contents_switcher_view.h" 5 #include "ui/app_list/views/contents_switcher_view.h"
6 6
7 #include "grit/ui_resources.h" 7 #include "grit/ui_resources.h"
8 #include "ui/app_list/app_list_constants.h" 8 #include "ui/app_list/app_list_constants.h"
9 #include "ui/app_list/views/contents_view.h" 9 #include "ui/app_list/views/contents_view.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
(...skipping 24 matching lines...) Expand all
35 35
36 void ContentsSwitcherView::AddSwitcherButton(int resource_id, int tag) { 36 void ContentsSwitcherView::AddSwitcherButton(int resource_id, int tag) {
37 views::ImageButton* button = new views::ImageButton(this); 37 views::ImageButton* button = new views::ImageButton(this);
38 button->SetImage( 38 button->SetImage(
39 views::CustomButton::STATE_NORMAL, 39 views::CustomButton::STATE_NORMAL,
40 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id)); 40 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id));
41 button->set_tag(tag); 41 button->set_tag(tag);
42 buttons_->AddChildView(button); 42 buttons_->AddChildView(button);
43 } 43 }
44 44
45 gfx::Size ContentsSwitcherView::GetPreferredSize() { 45 gfx::Size ContentsSwitcherView::GetPreferredSize() const {
46 return gfx::Size(buttons_->GetPreferredSize().width(), kPreferredHeight); 46 return gfx::Size(buttons_->GetPreferredSize().width(), kPreferredHeight);
47 } 47 }
48 48
49 void ContentsSwitcherView::Layout() { 49 void ContentsSwitcherView::Layout() {
50 gfx::Rect rect(GetContentsBounds()); 50 gfx::Rect rect(GetContentsBounds());
51 51
52 // Makes |buttons_| horizontally center and vertically fill. 52 // Makes |buttons_| horizontally center and vertically fill.
53 gfx::Size buttons_size(buttons_->GetPreferredSize()); 53 gfx::Size buttons_size(buttons_->GetPreferredSize());
54 gfx::Rect buttons_bounds(rect.CenterPoint().x() - buttons_size.width() / 2, 54 gfx::Rect buttons_bounds(rect.CenterPoint().x() - buttons_size.width() / 2,
55 rect.y(), 55 rect.y(),
56 buttons_size.width(), 56 buttons_size.width(),
57 rect.height()); 57 rect.height());
58 buttons_->SetBoundsRect(gfx::IntersectRects(rect, buttons_bounds)); 58 buttons_->SetBoundsRect(gfx::IntersectRects(rect, buttons_bounds));
59 } 59 }
60 60
61 void ContentsSwitcherView::ButtonPressed(views::Button* sender, 61 void ContentsSwitcherView::ButtonPressed(views::Button* sender,
62 const ui::Event& event) { 62 const ui::Event& event) {
63 contents_view_->SetShowState( 63 contents_view_->SetShowState(
64 static_cast<ContentsView::ShowState>(sender->tag())); 64 static_cast<ContentsView::ShowState>(sender->tag()));
65 } 65 }
66 66
67 } // namespace app_list 67 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/views/contents_switcher_view.h ('k') | ui/app_list/views/contents_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698