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

Side by Side Diff: ash/system/tray/tray_bar_button_with_title.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 | « ash/system/tray/tray_bar_button_with_title.h ('k') | ash/system/tray/tray_details_view.cc » ('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 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/system/tray/tray_bar_button_with_title.h" 5 #include "ash/system/tray/tray_bar_button_with_title.h"
6 6
7 #include "ash/system/tray/tray_constants.h" 7 #include "ash/system/tray/tray_constants.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "grit/ui_resources.h" 9 #include "grit/ui_resources.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 image_height_ = ui::ResourceBundle::GetSharedInstance().GetImageNamed( 77 image_height_ = ui::ResourceBundle::GetSharedInstance().GetImageNamed(
78 kBarImagesActive[0]).ToImageSkia()->height(); 78 kBarImagesActive[0]).ToImageSkia()->height();
79 } 79 }
80 80
81 TrayBarButtonWithTitle::~TrayBarButtonWithTitle() {} 81 TrayBarButtonWithTitle::~TrayBarButtonWithTitle() {}
82 82
83 void TrayBarButtonWithTitle::UpdateButton(bool control_on) { 83 void TrayBarButtonWithTitle::UpdateButton(bool control_on) {
84 image_->Update(control_on); 84 image_->Update(control_on);
85 } 85 }
86 86
87 gfx::Size TrayBarButtonWithTitle::GetPreferredSize() { 87 gfx::Size TrayBarButtonWithTitle::GetPreferredSize() const {
88 return gfx::Size(width_, kTrayPopupItemHeight); 88 return gfx::Size(width_, kTrayPopupItemHeight);
89 } 89 }
90 90
91 void TrayBarButtonWithTitle::Layout() { 91 void TrayBarButtonWithTitle::Layout() {
92 gfx::Rect rect(GetContentsBounds()); 92 gfx::Rect rect(GetContentsBounds());
93 int bar_image_y = rect.height() / 2 - image_height_ / 2; 93 int bar_image_y = rect.height() / 2 - image_height_ / 2;
94 gfx::Rect bar_image_rect(rect.x(), 94 gfx::Rect bar_image_rect(rect.x(),
95 bar_image_y, 95 bar_image_y,
96 rect.width(), 96 rect.width(),
97 image_height_); 97 image_height_);
98 image_->SetBoundsRect(bar_image_rect); 98 image_->SetBoundsRect(bar_image_rect);
99 if (title_) { 99 if (title_) {
100 // The image_ has some empty space below the bar image, move the title 100 // The image_ has some empty space below the bar image, move the title
101 // a little bit up to look closer to the bar. 101 // a little bit up to look closer to the bar.
102 gfx::Size title_size = title_->GetPreferredSize(); 102 gfx::Size title_size = title_->GetPreferredSize();
103 title_->SetBounds(rect.x(), 103 title_->SetBounds(rect.x(),
104 bar_image_y + image_height_ - 3, 104 bar_image_y + image_height_ - 3,
105 rect.width(), 105 rect.width(),
106 title_size.height()); 106 title_size.height());
107 } 107 }
108 } 108 }
109 109
110 } // namespace ash 110 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/tray_bar_button_with_title.h ('k') | ash/system/tray/tray_details_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698