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