Chromium Code Reviews| 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/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(); | |
|
msw
2016/05/20 23:26:37
Can we remove the default constructor?
qiangchen
2016/05/24 00:03:37
Done.
| |
| 22 DesktopMediaSourceViewStyle(const DesktopMediaSourceViewStyle& style); | |
|
msw
2016/05/20 23:26:37
Can we use the default copy ctor? "... = default;"
qiangchen
2016/05/24 00:03:38
Done.
| |
| 23 DesktopMediaSourceViewStyle(int columns, | |
| 24 const gfx::Size& item_size, | |
| 25 const gfx::Rect& label_position, | |
| 26 gfx::HorizontalAlignment text_alignment, | |
| 27 const gfx::Rect& image_position, | |
| 28 int selection_border_thickness, | |
| 29 int paint_inset_horizontal, | |
| 30 int paint_inset_vertical); | |
| 31 | |
| 32 int columns; | |
| 33 | |
| 34 gfx::Size item_size; | |
| 35 | |
| 36 gfx::Rect label_position; | |
|
msw
2016/05/20 23:26:37
nit: |label_rect| for position *and size* data pas
qiangchen
2016/05/24 00:03:38
Done.
| |
| 37 gfx::HorizontalAlignment text_alignment; | |
| 38 | |
| 39 gfx::Rect image_position; | |
|
msw
2016/05/20 23:26:37
nit: |image_rect| for position *and size* data pas
qiangchen
2016/05/24 00:03:38
Done.
| |
| 40 int selection_border_thickness; | |
|
msw
2016/05/20 23:26:37
|selection_border_thickness| is 2 for everything e
qiangchen
2016/05/24 00:03:38
I think it is better to make it a variable.
Now I
| |
| 41 | |
| 42 int paint_inset_horizontal; | |
|
msw
2016/05/20 23:26:37
Your horizontal and vertical values always match,
qiangchen
2016/05/24 00:03:38
Done.
| |
| 43 int paint_inset_vertical; | |
| 44 }; | |
| 45 | |
| 18 // View used for each item in DesktopMediaListView. Shows a single desktop media | 46 // View used for each item in DesktopMediaListView. Shows a single desktop media |
| 19 // source as a thumbnail with the title under it. | 47 // source as a thumbnail with the title under it. |
| 20 class DesktopMediaSourceView : public views::View { | 48 class DesktopMediaSourceView : public views::View { |
| 21 public: | 49 public: |
| 22 DesktopMediaSourceView(DesktopMediaListView* parent, | 50 DesktopMediaSourceView(DesktopMediaListView* parent, |
| 23 content::DesktopMediaID source_id); | 51 content::DesktopMediaID source_id, |
| 52 DesktopMediaSourceViewStyle style); | |
| 24 ~DesktopMediaSourceView() override; | 53 ~DesktopMediaSourceView() override; |
| 25 | 54 |
| 55 // Update style. | |
|
msw
2016/05/20 23:26:37
nit: Used to update the style when the number of a
qiangchen
2016/05/24 00:03:38
Done.
| |
| 56 void SetStyle(DesktopMediaSourceViewStyle style); | |
|
msw
2016/05/20 23:26:37
I hope we won't need this function! (if single==ge
qiangchen
2016/05/24 00:03:38
N/A as that is controlled on the list level.
Now t
| |
| 57 | |
| 26 // Updates thumbnail and title from |source|. | 58 // Updates thumbnail and title from |source|. |
| 27 void SetName(const base::string16& name); | 59 void SetName(const base::string16& name); |
| 28 void SetThumbnail(const gfx::ImageSkia& thumbnail); | 60 void SetThumbnail(const gfx::ImageSkia& thumbnail); |
| 29 | 61 |
| 30 // Id for the source shown by this View. | 62 // Id for the source shown by this View. |
| 31 const content::DesktopMediaID& source_id() const { return source_id_; } | 63 const content::DesktopMediaID& source_id() const { return source_id_; } |
| 32 | 64 |
| 33 // Returns true if the source is selected. | 65 // Returns true if the source is selected. |
| 34 bool is_selected() const { return selected_; } | 66 bool is_selected() const { return selected_; } |
| 35 | 67 |
| 36 // views::View interface. | 68 // views::View interface. |
| 37 const char* GetClassName() const override; | 69 const char* GetClassName() const override; |
| 38 void Layout() override; | 70 void Layout() override; |
| 39 views::View* GetSelectedViewForGroup(int group) override; | 71 views::View* GetSelectedViewForGroup(int group) override; |
| 40 bool IsGroupFocusTraversable() const override; | 72 bool IsGroupFocusTraversable() const override; |
| 41 void OnPaint(gfx::Canvas* canvas) override; | 73 void OnPaint(gfx::Canvas* canvas) override; |
| 42 void OnFocus() override; | 74 void OnFocus() override; |
| 43 void OnBlur() override; | 75 void OnBlur() override; |
| 44 bool OnMousePressed(const ui::MouseEvent& event) override; | 76 bool OnMousePressed(const ui::MouseEvent& event) override; |
| 77 void OnMouseEntered(const ui::MouseEvent& event) override; | |
| 78 void OnMouseExited(const ui::MouseEvent& event) override; | |
| 45 void OnGestureEvent(ui::GestureEvent* event) override; | 79 void OnGestureEvent(ui::GestureEvent* event) override; |
| 46 | 80 |
| 47 static const char* kDesktopMediaSourceViewClassName; | 81 static const char* kDesktopMediaSourceViewClassName; |
| 48 | 82 |
| 49 private: | 83 private: |
| 50 // Updates selection state of the element. If |selected| is true then also | 84 // 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 | 85 // calls SetSelected(false) for the source view that was selected before that |
| 52 // (if any). | 86 // (if any). |
| 53 void SetSelected(bool selected); | 87 void SetSelected(bool selected); |
| 54 | 88 |
| 89 // Updates hover state of the element, and the appearance. | |
| 90 void SetHovered(bool hovered); | |
| 91 | |
| 55 DesktopMediaListView* parent_; | 92 DesktopMediaListView* parent_; |
| 56 content::DesktopMediaID source_id_; | 93 content::DesktopMediaID source_id_; |
| 57 | 94 |
| 95 DesktopMediaSourceViewStyle style_; | |
| 58 views::ImageView* image_view_; | 96 views::ImageView* image_view_; |
| 59 views::Label* label_; | 97 views::Label* label_; |
| 60 | 98 |
| 61 bool selected_; | 99 bool selected_; |
| 100 bool hovered_; | |
| 62 | 101 |
| 63 DISALLOW_COPY_AND_ASSIGN(DesktopMediaSourceView); | 102 DISALLOW_COPY_AND_ASSIGN(DesktopMediaSourceView); |
| 64 }; | 103 }; |
| 65 | 104 |
| 66 #endif // CHROME_BROWSER_UI_VIEWS_DESKTOP_CAPTURE_DESKTOP_MEDIA_SOURCE_VIEW_H_ | 105 #endif // CHROME_BROWSER_UI_VIEWS_DESKTOP_CAPTURE_DESKTOP_MEDIA_SOURCE_VIEW_H_ |
| OLD | NEW |