painted_scrollbar_layer_impl.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // Copyright 2013 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef CC_LAYERS_PAINTED_SCROLLBAR_LAYER_IMPL_H_
  5. #define CC_LAYERS_PAINTED_SCROLLBAR_LAYER_IMPL_H_
  6. #include <memory>
  7. #include "cc/cc_export.h"
  8. #include "cc/input/scrollbar.h"
  9. #include "cc/layers/scrollbar_layer_impl_base.h"
  10. #include "cc/resources/ui_resource_client.h"
  11. namespace cc {
  12. class LayerTreeImpl;
  13. class CC_EXPORT PaintedScrollbarLayerImpl : public ScrollbarLayerImplBase {
  14. public:
  15. static std::unique_ptr<PaintedScrollbarLayerImpl> Create(
  16. LayerTreeImpl* tree_impl,
  17. int id,
  18. ScrollbarOrientation orientation,
  19. bool is_left_side_vertical_scrollbar,
  20. bool is_overlay);
  21. PaintedScrollbarLayerImpl(const PaintedScrollbarLayerImpl&) = delete;
  22. ~PaintedScrollbarLayerImpl() override;
  23. PaintedScrollbarLayerImpl& operator=(const PaintedScrollbarLayerImpl&) =
  24. delete;
  25. // LayerImpl implementation.
  26. std::unique_ptr<LayerImpl> CreateLayerImpl(
  27. LayerTreeImpl* tree_impl) const override;
  28. void PushPropertiesTo(LayerImpl* layer) override;
  29. bool WillDraw(DrawMode draw_mode,
  30. viz::ClientResourceProvider* resource_provider) override;
  31. void AppendQuads(viz::CompositorRenderPass* render_pass,
  32. AppendQuadsData* append_quads_data) override;
  33. gfx::Rect GetEnclosingVisibleRectInTargetSpace() const override;
  34. void SetJumpOnTrackClick(bool jump_on_track_click);
  35. void SetSupportsDragSnapBack(bool supports_drag_snap_back);
  36. void SetBackButtonRect(gfx::Rect back_button_rect);
  37. void SetForwardButtonRect(gfx::Rect forward_button_rect);
  38. void SetThumbThickness(int thumb_thickness);
  39. void SetThumbLength(int thumb_length);
  40. void SetTrackRect(gfx::Rect track_rect);
  41. void SetScrollbarPaintedOpacity(float opacity);
  42. void set_track_ui_resource_id(UIResourceId uid) {
  43. track_ui_resource_id_ = uid;
  44. }
  45. void set_thumb_ui_resource_id(UIResourceId uid) {
  46. thumb_ui_resource_id_ = uid;
  47. }
  48. float OverlayScrollbarOpacity() const override;
  49. void set_internal_contents_scale_and_bounds(float content_scale,
  50. const gfx::Size& content_bounds) {
  51. internal_contents_scale_ = content_scale;
  52. internal_content_bounds_ = content_bounds;
  53. }
  54. bool JumpOnTrackClick() const override;
  55. bool SupportsDragSnapBack() const override;
  56. gfx::Rect BackButtonRect() const override;
  57. gfx::Rect ForwardButtonRect() const override;
  58. gfx::Rect BackTrackRect() const override;
  59. gfx::Rect ForwardTrackRect() const override;
  60. int ThumbThickness() const override;
  61. LayerTreeSettings::ScrollbarAnimator GetScrollbarAnimator() const override;
  62. protected:
  63. PaintedScrollbarLayerImpl(LayerTreeImpl* tree_impl,
  64. int id,
  65. ScrollbarOrientation orientation,
  66. bool is_left_side_vertical_scrollbar,
  67. bool is_overlay);
  68. // ScrollbarLayerImplBase implementation.
  69. int ThumbLength() const override;
  70. float TrackLength() const override;
  71. int TrackStart() const override;
  72. bool IsThumbResizable() const override;
  73. private:
  74. const char* LayerTypeAsString() const override;
  75. UIResourceId track_ui_resource_id_;
  76. UIResourceId thumb_ui_resource_id_;
  77. // This is relevant in case of Mac overlay scrollbars because they fade out by
  78. // animating the opacity via Blink paint.
  79. float painted_opacity_;
  80. float internal_contents_scale_;
  81. gfx::Size internal_content_bounds_;
  82. bool jump_on_track_click_;
  83. bool supports_drag_snap_back_;
  84. int thumb_thickness_;
  85. int thumb_length_;
  86. gfx::Rect back_button_rect_;
  87. gfx::Rect forward_button_rect_;
  88. gfx::Rect track_rect_;
  89. };
  90. } // namespace cc
  91. #endif // CC_LAYERS_PAINTED_SCROLLBAR_LAYER_IMPL_H_