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

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

Issue 1990053002: Desktop Capture Picker New UI: Non Mac Appearance Change (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit fixes Created 4 years, 6 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
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 #ifndef CHROME_BROWSER_UI_VIEWS_DESKTOP_CAPTURE_DESKTOP_MEDIA_SOURCE_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_DESKTOP_CAPTURE_DESKTOP_MEDIA_SOURCE_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_DESKTOP_CAPTURE_DESKTOP_MEDIA_SOURCE_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_DESKTOP_CAPTURE_DESKTOP_MEDIA_SOURCE_VIEW_H_
7 7
8 #include "content/public/browser/desktop_media_id.h" 8 #include "content/public/browser/desktop_media_id.h"
9 #include "ui/gfx/text_constants.h"
9 #include "ui/views/view.h" 10 #include "ui/views/view.h"
10 11
11 namespace views { 12 namespace views {
12 class ImageView; 13 class ImageView;
13 class Label; 14 class Label;
14 } // namespace views 15 } // namespace views
15 16
16 class DesktopMediaListView; 17 class DesktopMediaListView;
17 18
19 // Controls the appearance of DesktopMediaSourceView.
20 struct DesktopMediaSourceViewStyle {
21 DesktopMediaSourceViewStyle(const DesktopMediaSourceViewStyle& style);
22 DesktopMediaSourceViewStyle(int columns,
23 const gfx::Size& item_size,
24 const gfx::Rect& label_rect,
25 gfx::HorizontalAlignment text_alignment,
26 const gfx::Rect& image_rect,
27 int selection_border_thickness,
28 int focus_rectangle_inset);
29
30 int columns;
31
32 gfx::Size item_size;
33
34 gfx::Rect label_rect;
35 gfx::HorizontalAlignment text_alignment;
36
37 gfx::Rect image_rect;
38 int selection_border_thickness;
39
40 int focus_rectangle_inset;
41 };
42
18 // View used for each item in DesktopMediaListView. Shows a single desktop media 43 // View used for each item in DesktopMediaListView. Shows a single desktop media
19 // source as a thumbnail with the title under it. 44 // source as a thumbnail with the title under it.
20 class DesktopMediaSourceView : public views::View { 45 class DesktopMediaSourceView : public views::View {
21 public: 46 public:
22 DesktopMediaSourceView(DesktopMediaListView* parent, 47 DesktopMediaSourceView(DesktopMediaListView* parent,
23 content::DesktopMediaID source_id); 48 content::DesktopMediaID source_id,
49 DesktopMediaSourceViewStyle style);
24 ~DesktopMediaSourceView() override; 50 ~DesktopMediaSourceView() override;
25 51
52 // Used to update the style when the number of available items changes.
53 void SetStyle(DesktopMediaSourceViewStyle style);
54
26 // Updates thumbnail and title from |source|. 55 // Updates thumbnail and title from |source|.
27 void SetName(const base::string16& name); 56 void SetName(const base::string16& name);
28 void SetThumbnail(const gfx::ImageSkia& thumbnail); 57 void SetThumbnail(const gfx::ImageSkia& thumbnail);
29 58
30 // Id for the source shown by this View. 59 // Id for the source shown by this View.
31 const content::DesktopMediaID& source_id() const { return source_id_; } 60 const content::DesktopMediaID& source_id() const { return source_id_; }
32 61
33 // Returns true if the source is selected. 62 // Returns true if the source is selected.
34 bool is_selected() const { return selected_; } 63 bool is_selected() const { return selected_; }
35 64
36 // views::View interface. 65 // views::View interface.
37 const char* GetClassName() const override; 66 const char* GetClassName() const override;
38 void Layout() override;
39 views::View* GetSelectedViewForGroup(int group) override; 67 views::View* GetSelectedViewForGroup(int group) override;
40 bool IsGroupFocusTraversable() const override; 68 bool IsGroupFocusTraversable() const override;
41 void OnPaint(gfx::Canvas* canvas) override; 69 void OnPaint(gfx::Canvas* canvas) override;
42 void OnFocus() override; 70 void OnFocus() override;
43 void OnBlur() override; 71 void OnBlur() override;
44 bool OnMousePressed(const ui::MouseEvent& event) override; 72 bool OnMousePressed(const ui::MouseEvent& event) override;
73 void OnMouseEntered(const ui::MouseEvent& event) override;
74 void OnMouseExited(const ui::MouseEvent& event) override;
45 void OnGestureEvent(ui::GestureEvent* event) override; 75 void OnGestureEvent(ui::GestureEvent* event) override;
46 76
47 static const char* kDesktopMediaSourceViewClassName; 77 static const char* kDesktopMediaSourceViewClassName;
48 78
49 private: 79 private:
50 // Updates selection state of the element. If |selected| is true then also 80 // Updates selection state of the element. If |selected| is true then also
51 // calls SetSelected(false) for the source view that was selected before that 81 // calls SetSelected(false) for the source view that was selected before that
52 // (if any). 82 // (if any).
53 void SetSelected(bool selected); 83 void SetSelected(bool selected);
54 84
85 // Updates hover state of the element, and the appearance.
86 void SetHovered(bool hovered);
87
55 DesktopMediaListView* parent_; 88 DesktopMediaListView* parent_;
56 content::DesktopMediaID source_id_; 89 content::DesktopMediaID source_id_;
57 90
91 DesktopMediaSourceViewStyle style_;
58 views::ImageView* image_view_; 92 views::ImageView* image_view_;
59 views::Label* label_; 93 views::Label* label_;
60 94
61 bool selected_; 95 bool selected_;
62 96
63 DISALLOW_COPY_AND_ASSIGN(DesktopMediaSourceView); 97 DISALLOW_COPY_AND_ASSIGN(DesktopMediaSourceView);
64 }; 98 };
65 99
66 #endif // CHROME_BROWSER_UI_VIEWS_DESKTOP_CAPTURE_DESKTOP_MEDIA_SOURCE_VIEW_H_ 100 #endif // CHROME_BROWSER_UI_VIEWS_DESKTOP_CAPTURE_DESKTOP_MEDIA_SOURCE_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698