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

Side by Side Diff: chrome/browser/ui/views/desktop_capture/desktop_media_source_view.cc

Issue 2480813003: Reduce views::Border creation verbosity by promoting factory functions (Closed)
Patch Set: fix bad merge Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/views/desktop_capture/desktop_media_source_view.h" 5 #include "chrome/browser/ui/views/desktop_capture/desktop_media_source_view.h"
6 6
7 #include "chrome/browser/media/webrtc/desktop_media_list.h" 7 #include "chrome/browser/media/webrtc/desktop_media_list.h"
8 #include "chrome/browser/ui/views/desktop_capture/desktop_media_list_view.h" 8 #include "chrome/browser/ui/views/desktop_capture/desktop_media_list_view.h"
9 #include "chrome/browser/ui/views/desktop_capture/desktop_media_picker_views.h" 9 #include "chrome/browser/ui/views/desktop_capture/desktop_media_picker_views.h"
10 #include "ui/accessibility/ax_node_data.h" 10 #include "ui/accessibility/ax_node_data.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 DCHECK_EQ((*i)->GetClassName(), 88 DCHECK_EQ((*i)->GetClassName(),
89 DesktopMediaSourceView::kDesktopMediaSourceViewClassName); 89 DesktopMediaSourceView::kDesktopMediaSourceViewClassName);
90 DesktopMediaSourceView* source_view = 90 DesktopMediaSourceView* source_view =
91 static_cast<DesktopMediaSourceView*>(*i); 91 static_cast<DesktopMediaSourceView*>(*i);
92 source_view->SetSelected(false); 92 source_view->SetSelected(false);
93 } 93 }
94 } 94 }
95 95
96 const SkColor border_color = GetNativeTheme()->GetSystemColor( 96 const SkColor border_color = GetNativeTheme()->GetSystemColor(
97 ui::NativeTheme::kColorId_FocusedBorderColor); 97 ui::NativeTheme::kColorId_FocusedBorderColor);
98 image_view_->SetBorder(views::Border::CreateSolidBorder( 98 image_view_->SetBorder(views::CreateSolidBorder(
99 style_.selection_border_thickness, border_color)); 99 style_.selection_border_thickness, border_color));
100 label_->SetFontList(label_->font_list().Derive(0, gfx::Font::NORMAL, 100 label_->SetFontList(label_->font_list().Derive(0, gfx::Font::NORMAL,
101 gfx::Font::Weight::BOLD)); 101 gfx::Font::Weight::BOLD));
102 parent_->OnSelectionChanged(); 102 parent_->OnSelectionChanged();
103 } else { 103 } else {
104 image_view_->SetBorder(views::Border::NullBorder()); 104 image_view_->SetBorder(views::NullBorder());
105 label_->SetFontList(label_->font_list().Derive(0, gfx::Font::NORMAL, 105 label_->SetFontList(label_->font_list().Derive(0, gfx::Font::NORMAL,
106 gfx::Font::Weight::NORMAL)); 106 gfx::Font::Weight::NORMAL));
107 } 107 }
108 108
109 SchedulePaint(); 109 SchedulePaint();
110 } 110 }
111 111
112 const char* DesktopMediaSourceView::GetClassName() const { 112 const char* DesktopMediaSourceView::GetClassName() const {
113 return DesktopMediaSourceView::kDesktopMediaSourceViewClassName; 113 return DesktopMediaSourceView::kDesktopMediaSourceViewClassName;
114 } 114 }
115 115
116 void DesktopMediaSourceView::SetStyle(DesktopMediaSourceViewStyle style) { 116 void DesktopMediaSourceView::SetStyle(DesktopMediaSourceViewStyle style) {
117 style_ = style; 117 style_ = style;
118 image_view_->SetBoundsRect(style_.image_rect); 118 image_view_->SetBoundsRect(style_.image_rect);
119 if (selected_) { 119 if (selected_) {
120 const SkColor border_color = GetNativeTheme()->GetSystemColor( 120 const SkColor border_color = GetNativeTheme()->GetSystemColor(
121 ui::NativeTheme::kColorId_FocusedBorderColor); 121 ui::NativeTheme::kColorId_FocusedBorderColor);
122 image_view_->SetBorder(views::Border::CreateSolidBorder( 122 image_view_->SetBorder(views::CreateSolidBorder(
123 style_.selection_border_thickness, border_color)); 123 style_.selection_border_thickness, border_color));
124 } 124 }
125 icon_view_->SetBoundsRect(style_.icon_rect); 125 icon_view_->SetBoundsRect(style_.icon_rect);
126 icon_view_->SetImageSize(style_.icon_rect.size()); 126 icon_view_->SetImageSize(style_.icon_rect.size());
127 label_->SetBoundsRect(style_.label_rect); 127 label_->SetBoundsRect(style_.label_rect);
128 label_->SetHorizontalAlignment(style_.text_alignment); 128 label_->SetHorizontalAlignment(style_.text_alignment);
129 } 129 }
130 130
131 views::View* DesktopMediaSourceView::GetSelectedViewForGroup(int group) { 131 views::View* DesktopMediaSourceView::GetSelectedViewForGroup(int group) {
132 Views neighbours; 132 Views neighbours;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { 196 if (event->type() == ui::ET_GESTURE_TAP_DOWN) {
197 RequestFocus(); 197 RequestFocus();
198 event->SetHandled(); 198 event->SetHandled();
199 } 199 }
200 } 200 }
201 201
202 void DesktopMediaSourceView::GetAccessibleNodeData(ui::AXNodeData* node_data) { 202 void DesktopMediaSourceView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
203 node_data->role = ui::AX_ROLE_BUTTON; 203 node_data->role = ui::AX_ROLE_BUTTON;
204 node_data->SetName(label_->text()); 204 node_data->SetName(label_->text());
205 } 205 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/cookie_info_view.cc ('k') | chrome/browser/ui/views/download/download_item_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698