OLD | NEW |
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/gfx/text_constants.h" |
10 #include "ui/views/view.h" | 10 #include "ui/views/view.h" |
11 | 11 |
12 namespace views { | 12 namespace views { |
13 class ImageView; | 13 class ImageView; |
14 class Label; | 14 class Label; |
15 } // namespace views | 15 } // namespace views |
16 | 16 |
17 class DesktopMediaListView; | 17 class DesktopMediaListView; |
18 | 18 |
19 // Controls the appearance of DesktopMediaSourceView. | 19 // Controls the appearance of DesktopMediaSourceView. |
20 struct DesktopMediaSourceViewStyle { | 20 struct DesktopMediaSourceViewStyle { |
21 DesktopMediaSourceViewStyle(const DesktopMediaSourceViewStyle& style); | 21 DesktopMediaSourceViewStyle(const DesktopMediaSourceViewStyle& style); |
22 DesktopMediaSourceViewStyle(int columns, | 22 DesktopMediaSourceViewStyle(int columns, |
23 const gfx::Size& item_size, | 23 const gfx::Size& item_size, |
| 24 const gfx::Rect& icon_rect, |
24 const gfx::Rect& label_rect, | 25 const gfx::Rect& label_rect, |
25 gfx::HorizontalAlignment text_alignment, | 26 gfx::HorizontalAlignment text_alignment, |
26 const gfx::Rect& image_rect, | 27 const gfx::Rect& image_rect, |
27 int selection_border_thickness, | 28 int selection_border_thickness, |
28 int focus_rectangle_inset); | 29 int focus_rectangle_inset); |
29 | 30 |
| 31 // This parameter controls how many source items can be displayed in a row. |
| 32 // Source items are instances of DesktopMediaSourceView. |
30 int columns; | 33 int columns; |
31 | 34 |
| 35 // The size of a single source item. |
32 gfx::Size item_size; | 36 gfx::Size item_size; |
33 | 37 |
| 38 // The relative position to display icon, label and preview image in the |
| 39 // source item. |
| 40 gfx::Rect icon_rect; |
34 gfx::Rect label_rect; | 41 gfx::Rect label_rect; |
35 gfx::HorizontalAlignment text_alignment; | 42 gfx::HorizontalAlignment text_alignment; |
| 43 gfx::Rect image_rect; |
36 | 44 |
37 gfx::Rect image_rect; | 45 // When a source item is selected, we paint the border to show it. This |
| 46 // parameter controls how thick the border would be. |
38 int selection_border_thickness; | 47 int selection_border_thickness; |
39 | 48 |
| 49 // When a source item is focused, we paint dotted line. This parameter |
| 50 // controls the distance between dotted line and the source view boundary. |
40 int focus_rectangle_inset; | 51 int focus_rectangle_inset; |
41 }; | 52 }; |
42 | 53 |
43 // View used for each item in DesktopMediaListView. Shows a single desktop media | 54 // View used for each item in DesktopMediaListView. Shows a single desktop media |
44 // source as a thumbnail with the title under it. | 55 // source as a thumbnail with the title under it. |
45 class DesktopMediaSourceView : public views::View { | 56 class DesktopMediaSourceView : public views::View { |
46 public: | 57 public: |
47 DesktopMediaSourceView(DesktopMediaListView* parent, | 58 DesktopMediaSourceView(DesktopMediaListView* parent, |
48 content::DesktopMediaID source_id, | 59 content::DesktopMediaID source_id, |
49 DesktopMediaSourceViewStyle style); | 60 DesktopMediaSourceViewStyle style); |
50 ~DesktopMediaSourceView() override; | 61 ~DesktopMediaSourceView() override; |
51 | 62 |
52 // Used to update the style when the number of available items changes. | 63 // Used to update the style when the number of available items changes. |
53 void SetStyle(DesktopMediaSourceViewStyle style); | 64 void SetStyle(DesktopMediaSourceViewStyle style); |
54 | 65 |
55 // Updates thumbnail and title from |source|. | 66 // Updates thumbnail and title from |source|. |
56 void SetName(const base::string16& name); | 67 void SetName(const base::string16& name); |
57 void SetThumbnail(const gfx::ImageSkia& thumbnail); | 68 void SetThumbnail(const gfx::ImageSkia& thumbnail); |
| 69 void SetIcon(const gfx::ImageSkia& icon); |
58 | 70 |
59 // Id for the source shown by this View. | 71 // Id for the source shown by this View. |
60 const content::DesktopMediaID& source_id() const { return source_id_; } | 72 const content::DesktopMediaID& source_id() const { return source_id_; } |
61 | 73 |
62 // Returns true if the source is selected. | 74 // Returns true if the source is selected. |
63 bool is_selected() const { return selected_; } | 75 bool is_selected() const { return selected_; } |
64 | 76 |
65 // views::View interface. | 77 // views::View interface. |
66 const char* GetClassName() const override; | 78 const char* GetClassName() const override; |
67 views::View* GetSelectedViewForGroup(int group) override; | 79 views::View* GetSelectedViewForGroup(int group) override; |
(...skipping 14 matching lines...) Expand all Loading... |
82 // (if any). | 94 // (if any). |
83 void SetSelected(bool selected); | 95 void SetSelected(bool selected); |
84 | 96 |
85 // Updates hover state of the element, and the appearance. | 97 // Updates hover state of the element, and the appearance. |
86 void SetHovered(bool hovered); | 98 void SetHovered(bool hovered); |
87 | 99 |
88 DesktopMediaListView* parent_; | 100 DesktopMediaListView* parent_; |
89 content::DesktopMediaID source_id_; | 101 content::DesktopMediaID source_id_; |
90 | 102 |
91 DesktopMediaSourceViewStyle style_; | 103 DesktopMediaSourceViewStyle style_; |
| 104 views::ImageView* icon_view_; |
92 views::ImageView* image_view_; | 105 views::ImageView* image_view_; |
93 views::Label* label_; | 106 views::Label* label_; |
94 | 107 |
95 bool selected_; | 108 bool selected_; |
96 | 109 |
97 DISALLOW_COPY_AND_ASSIGN(DesktopMediaSourceView); | 110 DISALLOW_COPY_AND_ASSIGN(DesktopMediaSourceView); |
98 }; | 111 }; |
99 | 112 |
100 #endif // CHROME_BROWSER_UI_VIEWS_DESKTOP_CAPTURE_DESKTOP_MEDIA_SOURCE_VIEW_H_ | 113 #endif // CHROME_BROWSER_UI_VIEWS_DESKTOP_CAPTURE_DESKTOP_MEDIA_SOURCE_VIEW_H_ |
OLD | NEW |