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

Side by Side Diff: chrome/browser/ui/views/desktop_media_picker_views.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
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 "chrome/browser/media/desktop_media_picker.h" 5 #include "chrome/browser/media/desktop_media_picker.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "chrome/browser/media/desktop_media_list.h" 8 #include "chrome/browser/media/desktop_media_list.h"
9 #include "chrome/browser/media/desktop_media_list_observer.h" 9 #include "chrome/browser/media/desktop_media_list_observer.h"
10 #include "chrome/browser/ui/ash/ash_util.h" 10 #include "chrome/browser/ui/ash/ash_util.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // Called by DesktopMediaSourceView when selection has changed. 119 // Called by DesktopMediaSourceView when selection has changed.
120 void OnSelectionChanged(); 120 void OnSelectionChanged();
121 121
122 // Called by DesktopMediaSourceView when a source has been double-clicked. 122 // Called by DesktopMediaSourceView when a source has been double-clicked.
123 void OnDoubleClick(); 123 void OnDoubleClick();
124 124
125 // Returns currently selected source. 125 // Returns currently selected source.
126 DesktopMediaSourceView* GetSelection(); 126 DesktopMediaSourceView* GetSelection();
127 127
128 // views::View overrides. 128 // views::View overrides.
129 virtual gfx::Size GetPreferredSize() OVERRIDE; 129 virtual gfx::Size GetPreferredSize() const OVERRIDE;
130 virtual void Layout() OVERRIDE; 130 virtual void Layout() OVERRIDE;
131 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; 131 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE;
132 132
133 private: 133 private:
134 // DesktopMediaList::Observer interface 134 // DesktopMediaList::Observer interface
135 virtual void OnSourceAdded(int index) OVERRIDE; 135 virtual void OnSourceAdded(int index) OVERRIDE;
136 virtual void OnSourceRemoved(int index) OVERRIDE; 136 virtual void OnSourceRemoved(int index) OVERRIDE;
137 virtual void OnSourceMoved(int old_index, int new_index) OVERRIDE; 137 virtual void OnSourceMoved(int old_index, int new_index) OVERRIDE;
138 virtual void OnSourceNameChanged(int index) OVERRIDE; 138 virtual void OnSourceNameChanged(int index) OVERRIDE;
139 virtual void OnSourceThumbnailChanged(int index) OVERRIDE; 139 virtual void OnSourceThumbnailChanged(int index) OVERRIDE;
(...skipping 16 matching lines...) Expand all
156 virtual ~DesktopMediaPickerDialogView(); 156 virtual ~DesktopMediaPickerDialogView();
157 157
158 // Called by parent (DesktopMediaPickerViews) when it's destroyed. 158 // Called by parent (DesktopMediaPickerViews) when it's destroyed.
159 void DetachParent(); 159 void DetachParent();
160 160
161 // Called by DesktopMediaListView. 161 // Called by DesktopMediaListView.
162 void OnSelectionChanged(); 162 void OnSelectionChanged();
163 void OnDoubleClick(); 163 void OnDoubleClick();
164 164
165 // views::View overrides. 165 // views::View overrides.
166 virtual gfx::Size GetPreferredSize() OVERRIDE; 166 virtual gfx::Size GetPreferredSize() const OVERRIDE;
167 virtual void Layout() OVERRIDE; 167 virtual void Layout() OVERRIDE;
168 168
169 // views::DialogDelegateView overrides. 169 // views::DialogDelegateView overrides.
170 virtual base::string16 GetWindowTitle() const OVERRIDE; 170 virtual base::string16 GetWindowTitle() const OVERRIDE;
171 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE; 171 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE;
172 virtual base::string16 GetDialogButtonLabel( 172 virtual base::string16 GetDialogButtonLabel(
173 ui::DialogButton button) const OVERRIDE; 173 ui::DialogButton button) const OVERRIDE;
174 virtual bool Accept() OVERRIDE; 174 virtual bool Accept() OVERRIDE;
175 virtual void DeleteDelegate() OVERRIDE; 175 virtual void DeleteDelegate() OVERRIDE;
176 176
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 for (int i = 0; i < child_count(); ++i) { 357 for (int i = 0; i < child_count(); ++i) {
358 DesktopMediaSourceView* source_view = 358 DesktopMediaSourceView* source_view =
359 static_cast<DesktopMediaSourceView*>(child_at(i)); 359 static_cast<DesktopMediaSourceView*>(child_at(i));
360 DCHECK_EQ(source_view->GetClassName(), kDesktopMediaSourceViewClassName); 360 DCHECK_EQ(source_view->GetClassName(), kDesktopMediaSourceViewClassName);
361 if (source_view->is_selected()) 361 if (source_view->is_selected())
362 return source_view; 362 return source_view;
363 } 363 }
364 return NULL; 364 return NULL;
365 } 365 }
366 366
367 gfx::Size DesktopMediaListView::GetPreferredSize() { 367 gfx::Size DesktopMediaListView::GetPreferredSize() const {
368 int total_rows = (child_count() + kListColumns - 1) / kListColumns; 368 int total_rows = (child_count() + kListColumns - 1) / kListColumns;
369 return gfx::Size(kTotalListWidth, kListItemHeight * total_rows); 369 return gfx::Size(kTotalListWidth, kListItemHeight * total_rows);
370 } 370 }
371 371
372 void DesktopMediaListView::Layout() { 372 void DesktopMediaListView::Layout() {
373 int x = 0; 373 int x = 0;
374 int y = 0; 374 int y = 0;
375 375
376 for (int i = 0; i < child_count(); ++i) { 376 for (int i = 0; i < child_count(); ++i) {
377 if (x + kListItemWidth > kTotalListWidth) { 377 if (x + kListItemWidth > kTotalListWidth) {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 533
534 GetWidget()->Show(); 534 GetWidget()->Show();
535 } 535 }
536 536
537 DesktopMediaPickerDialogView::~DesktopMediaPickerDialogView() {} 537 DesktopMediaPickerDialogView::~DesktopMediaPickerDialogView() {}
538 538
539 void DesktopMediaPickerDialogView::DetachParent() { 539 void DesktopMediaPickerDialogView::DetachParent() {
540 parent_ = NULL; 540 parent_ = NULL;
541 } 541 }
542 542
543 gfx::Size DesktopMediaPickerDialogView::GetPreferredSize() { 543 gfx::Size DesktopMediaPickerDialogView::GetPreferredSize() const {
544 return gfx::Size(600, 500); 544 return gfx::Size(600, 500);
545 } 545 }
546 546
547 void DesktopMediaPickerDialogView::Layout() { 547 void DesktopMediaPickerDialogView::Layout() {
548 gfx::Rect rect = GetLocalBounds(); 548 gfx::Rect rect = GetLocalBounds();
549 rect.Inset(views::kPanelHorizMargin, views::kPanelVertMargin); 549 rect.Inset(views::kPanelHorizMargin, views::kPanelVertMargin);
550 550
551 gfx::Rect label_rect(rect.x(), rect.y(), rect.width(), 551 gfx::Rect label_rect(rect.x(), rect.y(), rect.width(),
552 label_->GetHeightForWidth(rect.width())); 552 label_->GetHeightForWidth(rect.width()));
553 label_->SetBoundsRect(label_rect); 553 label_->SetBoundsRect(label_rect);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 base::Bind(callback_, source)); 645 base::Bind(callback_, source));
646 callback_.Reset(); 646 callback_.Reset();
647 } 647 }
648 648
649 } // namespace 649 } // namespace
650 650
651 // static 651 // static
652 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { 652 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() {
653 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); 653 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews());
654 } 654 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/create_application_shortcut_view.cc ('k') | chrome/browser/ui/views/download/download_item_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698