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(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 set_style(DesktopMediaSourceViewStyle style) { style_ = 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; | 67 void Layout() override; |
| 39 views::View* GetSelectedViewForGroup(int group) override; | 68 views::View* GetSelectedViewForGroup(int group) override; |
| 40 bool IsGroupFocusTraversable() const override; | 69 bool IsGroupFocusTraversable() const override; |
| 41 void OnPaint(gfx::Canvas* canvas) override; | 70 void OnPaint(gfx::Canvas* canvas) override; |
| 42 void OnFocus() override; | 71 void OnFocus() override; |
| 43 void OnBlur() override; | 72 void OnBlur() override; |
| 44 bool OnMousePressed(const ui::MouseEvent& event) override; | 73 bool OnMousePressed(const ui::MouseEvent& event) override; |
| 74 void OnMouseEntered(const ui::MouseEvent& event) override; | |
| 75 void OnMouseExited(const ui::MouseEvent& event) override; | |
| 45 void OnGestureEvent(ui::GestureEvent* event) override; | 76 void OnGestureEvent(ui::GestureEvent* event) override; |
| 46 | 77 |
| 47 static const char* kDesktopMediaSourceViewClassName; | 78 static const char* kDesktopMediaSourceViewClassName; |
| 48 | 79 |
| 49 private: | 80 private: |
| 50 // Updates selection state of the element. If |selected| is true then also | 81 // 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 | 82 // calls SetSelected(false) for the source view that was selected before that |
| 52 // (if any). | 83 // (if any). |
| 53 void SetSelected(bool selected); | 84 void SetSelected(bool selected); |
| 54 | 85 |
| 86 // Updates hover state of the element, and the appearance. | |
| 87 void SetHovered(bool hovered); | |
| 88 | |
| 55 DesktopMediaListView* parent_; | 89 DesktopMediaListView* parent_; |
| 56 content::DesktopMediaID source_id_; | 90 content::DesktopMediaID source_id_; |
| 57 | 91 |
| 92 DesktopMediaSourceViewStyle style_; | |
| 58 views::ImageView* image_view_; | 93 views::ImageView* image_view_; |
| 59 views::Label* label_; | 94 views::Label* label_; |
| 60 | 95 |
| 61 bool selected_; | 96 bool selected_; |
| 97 bool hovered_; | |
|
msw
2016/05/25 17:22:13
Remove |hovered_| now that it's unused.
qiangchen
2016/05/25 20:27:30
Done.
| |
| 62 | 98 |
| 63 DISALLOW_COPY_AND_ASSIGN(DesktopMediaSourceView); | 99 DISALLOW_COPY_AND_ASSIGN(DesktopMediaSourceView); |
| 64 }; | 100 }; |
| 65 | 101 |
| 66 #endif // CHROME_BROWSER_UI_VIEWS_DESKTOP_CAPTURE_DESKTOP_MEDIA_SOURCE_VIEW_H_ | 102 #endif // CHROME_BROWSER_UI_VIEWS_DESKTOP_CAPTURE_DESKTOP_MEDIA_SOURCE_VIEW_H_ |
| OLD | NEW |