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

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

Issue 2323913002: Desktop Capture Picker: More Clear Selection (Closed)
Patch Set: Created 4 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
« no previous file with comments | « chrome/browser/ui/views/desktop_capture/desktop_media_source_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/desktop_media_list.h" 7 #include "chrome/browser/media/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_view_state.h" 10 #include "ui/accessibility/ax_view_state.h"
11 #include "ui/gfx/canvas.h" 11 #include "ui/gfx/canvas.h"
12 #include "ui/native_theme/native_theme.h" 12 #include "ui/native_theme/native_theme.h"
13 #include "ui/views/background.h" 13 #include "ui/views/background.h"
msw 2016/09/10 00:07:41 nit: remove
qiangchen 2016/09/12 16:49:56 Done.
14 #include "ui/views/border.h" 14 #include "ui/views/border.h"
15 #include "ui/views/controls/image_view.h" 15 #include "ui/views/controls/image_view.h"
16 #include "ui/views/controls/label.h" 16 #include "ui/views/controls/label.h"
17 17
18 using content::DesktopMediaID; 18 using content::DesktopMediaID;
19 19
20 DesktopMediaSourceViewStyle::DesktopMediaSourceViewStyle( 20 DesktopMediaSourceViewStyle::DesktopMediaSourceViewStyle(
21 const DesktopMediaSourceViewStyle& style) = default; 21 const DesktopMediaSourceViewStyle& style) = default;
22 22
23 DesktopMediaSourceViewStyle::DesktopMediaSourceViewStyle( 23 DesktopMediaSourceViewStyle::DesktopMediaSourceViewStyle(
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 if (*i != this) { 88 if (*i != this) {
89 DCHECK_EQ((*i)->GetClassName(), 89 DCHECK_EQ((*i)->GetClassName(),
90 DesktopMediaSourceView::kDesktopMediaSourceViewClassName); 90 DesktopMediaSourceView::kDesktopMediaSourceViewClassName);
91 DesktopMediaSourceView* source_view = 91 DesktopMediaSourceView* source_view =
92 static_cast<DesktopMediaSourceView*>(*i); 92 static_cast<DesktopMediaSourceView*>(*i);
93 source_view->SetSelected(false); 93 source_view->SetSelected(false);
94 } 94 }
95 } 95 }
96 96
97 const SkColor border_color = GetNativeTheme()->GetSystemColor( 97 const SkColor border_color = GetNativeTheme()->GetSystemColor(
98 ui::NativeTheme::kColorId_FocusedMenuItemBackgroundColor); 98 ui::NativeTheme::kColorId_FocusedBorderColor);
99 image_view_->SetBorder(views::Border::CreateSolidBorder( 99 image_view_->SetBorder(views::Border::CreateSolidBorder(
100 style_.selection_border_thickness, border_color)); 100 style_.selection_border_thickness, border_color));
101 label_->SetFontList(label_->font_list().Derive(0, gfx::Font::NORMAL, 101 label_->SetFontList(label_->font_list().Derive(0, gfx::Font::NORMAL,
102 gfx::Font::Weight::BOLD)); 102 gfx::Font::Weight::BOLD));
103 parent_->OnSelectionChanged(); 103 parent_->OnSelectionChanged();
104 } else { 104 } else {
105 image_view_->SetBorder(views::Border::NullBorder()); 105 image_view_->SetBorder(views::Border::NullBorder());
106 label_->SetFontList(label_->font_list().Derive(0, gfx::Font::NORMAL, 106 label_->SetFontList(label_->font_list().Derive(0, gfx::Font::NORMAL,
107 gfx::Font::Weight::NORMAL)); 107 gfx::Font::Weight::NORMAL));
108 } 108 }
109 109
110 SchedulePaint(); 110 SchedulePaint();
111 } 111 }
112 112
113 void DesktopMediaSourceView::SetHovered(bool hovered) {
114 if (hovered) {
115 // Use background color to show mouse hover.
116 const SkColor bg_color = GetNativeTheme()->GetSystemColor(
117 ui::NativeTheme::kColorId_HoverMenuItemBackgroundColor);
118 set_background(views::Background::CreateSolidBackground(bg_color));
119 } else {
120 set_background(nullptr);
121 }
122
123 SchedulePaint();
124 }
125
126 const char* DesktopMediaSourceView::GetClassName() const { 113 const char* DesktopMediaSourceView::GetClassName() const {
127 return DesktopMediaSourceView::kDesktopMediaSourceViewClassName; 114 return DesktopMediaSourceView::kDesktopMediaSourceViewClassName;
128 } 115 }
129 116
130 void DesktopMediaSourceView::SetStyle(DesktopMediaSourceViewStyle style) { 117 void DesktopMediaSourceView::SetStyle(DesktopMediaSourceViewStyle style) {
131 style_ = style; 118 style_ = style;
132 image_view_->SetBoundsRect(style_.image_rect); 119 image_view_->SetBoundsRect(style_.image_rect);
133 if (selected_) { 120 if (selected_) {
134 const SkColor border_color = GetNativeTheme()->GetSystemColor( 121 const SkColor border_color = GetNativeTheme()->GetSystemColor(
135 ui::NativeTheme::kColorId_FocusedMenuItemBackgroundColor); 122 ui::NativeTheme::kColorId_FocusedBorderColor);
136 image_view_->SetBorder(views::Border::CreateSolidBorder( 123 image_view_->SetBorder(views::Border::CreateSolidBorder(
137 style_.selection_border_thickness, border_color)); 124 style_.selection_border_thickness, border_color));
138 } 125 }
139 icon_view_->SetBoundsRect(style_.icon_rect); 126 icon_view_->SetBoundsRect(style_.icon_rect);
140 icon_view_->SetImageSize(style_.icon_rect.size()); 127 icon_view_->SetImageSize(style_.icon_rect.size());
141 label_->SetBoundsRect(style_.label_rect); 128 label_->SetBoundsRect(style_.label_rect);
142 label_->SetHorizontalAlignment(style_.text_alignment); 129 label_->SetHorizontalAlignment(style_.text_alignment);
143 } 130 }
144 131
145 views::View* DesktopMediaSourceView::GetSelectedViewForGroup(int group) { 132 views::View* DesktopMediaSourceView::GetSelectedViewForGroup(int group) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 bool DesktopMediaSourceView::OnMousePressed(const ui::MouseEvent& event) { 176 bool DesktopMediaSourceView::OnMousePressed(const ui::MouseEvent& event) {
190 if (event.GetClickCount() == 1) { 177 if (event.GetClickCount() == 1) {
191 RequestFocus(); 178 RequestFocus();
192 } else if (event.GetClickCount() == 2) { 179 } else if (event.GetClickCount() == 2) {
193 RequestFocus(); 180 RequestFocus();
194 parent_->OnDoubleClick(); 181 parent_->OnDoubleClick();
195 } 182 }
196 return true; 183 return true;
197 } 184 }
198 185
199 void DesktopMediaSourceView::OnMouseEntered(const ui::MouseEvent& event) {
200 SetHovered(true);
201 }
202
203 void DesktopMediaSourceView::OnMouseExited(const ui::MouseEvent& event) {
204 SetHovered(false);
205 }
206
207 void DesktopMediaSourceView::OnGestureEvent(ui::GestureEvent* event) { 186 void DesktopMediaSourceView::OnGestureEvent(ui::GestureEvent* event) {
208 if (event->type() == ui::ET_GESTURE_TAP && 187 if (event->type() == ui::ET_GESTURE_TAP &&
209 event->details().tap_count() == 2) { 188 event->details().tap_count() == 2) {
210 RequestFocus(); 189 RequestFocus();
211 parent_->OnDoubleClick(); 190 parent_->OnDoubleClick();
212 event->SetHandled(); 191 event->SetHandled();
213 return; 192 return;
214 } 193 }
215 194
216 // Detect tap gesture using ET_GESTURE_TAP_DOWN so the view also gets focused 195 // Detect tap gesture using ET_GESTURE_TAP_DOWN so the view also gets focused
217 // on the long tap (when the tap gesture starts). 196 // on the long tap (when the tap gesture starts).
218 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { 197 if (event->type() == ui::ET_GESTURE_TAP_DOWN) {
219 RequestFocus(); 198 RequestFocus();
220 event->SetHandled(); 199 event->SetHandled();
221 } 200 }
222 } 201 }
223 202
224 void DesktopMediaSourceView::GetAccessibleState(ui::AXViewState* state) { 203 void DesktopMediaSourceView::GetAccessibleState(ui::AXViewState* state) {
225 state->role = ui::AX_ROLE_BUTTON; 204 state->role = ui::AX_ROLE_BUTTON;
226 state->name = label_->text(); 205 state->name = label_->text();
227 } 206 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/desktop_capture/desktop_media_source_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698