| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 CC_LAYERS_SCROLLBAR_LAYER_IMPL_H_ | 5 #ifndef CC_LAYERS_SCROLLBAR_LAYER_IMPL_H_ |
| 6 #define CC_LAYERS_SCROLLBAR_LAYER_IMPL_H_ | 6 #define CC_LAYERS_SCROLLBAR_LAYER_IMPL_H_ |
| 7 | 7 |
| 8 #include "cc/base/cc_export.h" | 8 #include "cc/base/cc_export.h" |
| 9 #include "cc/input/scrollbar.h" | 9 #include "cc/input/scrollbar.h" |
| 10 #include "cc/layers/layer_impl.h" | 10 #include "cc/layers/layer_impl.h" |
| 11 #include "cc/resources/ui_resource_client.h" |
| 11 | 12 |
| 12 namespace cc { | 13 namespace cc { |
| 13 | 14 |
| 14 class LayerTreeImpl; | 15 class LayerTreeImpl; |
| 15 class ScrollView; | 16 class ScrollView; |
| 16 | 17 |
| 17 class CC_EXPORT ScrollbarLayerImpl : public LayerImpl { | 18 class CC_EXPORT ScrollbarLayerImpl : public LayerImpl { |
| 18 public: | 19 public: |
| 19 static scoped_ptr<ScrollbarLayerImpl> Create( | 20 static scoped_ptr<ScrollbarLayerImpl> Create( |
| 20 LayerTreeImpl* tree_impl, | 21 LayerTreeImpl* tree_impl, |
| 21 int id, | 22 int id, |
| 22 ScrollbarOrientation orientation); | 23 ScrollbarOrientation orientation); |
| 23 virtual ~ScrollbarLayerImpl(); | 24 virtual ~ScrollbarLayerImpl(); |
| 24 | 25 |
| 25 // LayerImpl implementation. | 26 // LayerImpl implementation. |
| 26 virtual ScrollbarLayerImpl* ToScrollbarLayer() OVERRIDE; | 27 virtual ScrollbarLayerImpl* ToScrollbarLayer() OVERRIDE; |
| 27 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) | 28 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) |
| 28 OVERRIDE; | 29 OVERRIDE; |
| 29 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; | 30 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; |
| 30 | 31 |
| 31 virtual bool WillDraw(DrawMode draw_mode, | 32 virtual bool WillDraw(DrawMode draw_mode, |
| 32 ResourceProvider* resource_provider) OVERRIDE; | 33 ResourceProvider* resource_provider) OVERRIDE; |
| 33 virtual void AppendQuads(QuadSink* quad_sink, | 34 virtual void AppendQuads(QuadSink* quad_sink, |
| 34 AppendQuadsData* append_quads_data) OVERRIDE; | 35 AppendQuadsData* append_quads_data) OVERRIDE; |
| 35 | 36 |
| 36 virtual void DidLoseOutputSurface() OVERRIDE; | |
| 37 | |
| 38 int scroll_layer_id() const { return scroll_layer_id_; } | 37 int scroll_layer_id() const { return scroll_layer_id_; } |
| 39 void set_scroll_layer_id(int id) { scroll_layer_id_ = id; } | 38 void set_scroll_layer_id(int id) { scroll_layer_id_ = id; } |
| 40 | 39 |
| 41 ScrollbarOrientation Orientation() const; | 40 ScrollbarOrientation Orientation() const; |
| 42 float CurrentPos() const; | 41 float CurrentPos() const; |
| 43 int Maximum() const; | 42 int Maximum() const; |
| 44 | 43 |
| 45 void set_thumb_thickness(int thumb_thickness) { | 44 void set_thumb_thickness(int thumb_thickness) { |
| 46 thumb_thickness_ = thumb_thickness; | 45 thumb_thickness_ = thumb_thickness; |
| 47 } | 46 } |
| 48 int thumb_thickness() const { return thumb_thickness_; } | 47 int thumb_thickness() const { return thumb_thickness_; } |
| 49 void set_thumb_length(int thumb_length) { | 48 void set_thumb_length(int thumb_length) { |
| 50 thumb_length_ = thumb_length; | 49 thumb_length_ = thumb_length; |
| 51 } | 50 } |
| 52 void set_track_start(int track_start) { | 51 void set_track_start(int track_start) { |
| 53 track_start_ = track_start; | 52 track_start_ = track_start; |
| 54 } | 53 } |
| 55 void set_track_length(int track_length) { | 54 void set_track_length(int track_length) { |
| 56 track_length_ = track_length; | 55 track_length_ = track_length; |
| 57 } | 56 } |
| 58 void set_vertical_adjust(float vertical_adjust) { | 57 void set_vertical_adjust(float vertical_adjust) { |
| 59 vertical_adjust_ = vertical_adjust; | 58 vertical_adjust_ = vertical_adjust; |
| 60 } | 59 } |
| 61 void set_track_resource_id(ResourceProvider::ResourceId id) { | 60 void set_track_ui_resource_id(UIResourceId uid) { |
| 62 track_resource_id_ = id; | 61 track_ui_resource_id_ = uid; |
| 63 } | 62 } |
| 64 void set_thumb_resource_id(ResourceProvider::ResourceId id) { | 63 void set_thumb_ui_resource_id(UIResourceId uid) { |
| 65 thumb_resource_id_ = id; | 64 thumb_ui_resource_id_ = uid; |
| 66 } | 65 } |
| 67 void set_visible_to_total_length_ratio(float ratio) { | 66 void set_visible_to_total_length_ratio(float ratio) { |
| 68 visible_to_total_length_ratio_ = ratio; | 67 visible_to_total_length_ratio_ = ratio; |
| 69 } | 68 } |
| 70 void set_is_overlay_scrollbar(bool is_overlay_scrollbar) { | 69 void set_is_overlay_scrollbar(bool is_overlay_scrollbar) { |
| 71 is_overlay_scrollbar_ = is_overlay_scrollbar; | 70 is_overlay_scrollbar_ = is_overlay_scrollbar; |
| 72 } | 71 } |
| 73 bool is_overlay_scrollbar() const { return is_overlay_scrollbar_; } | 72 bool is_overlay_scrollbar() const { return is_overlay_scrollbar_; } |
| 74 | 73 |
| 75 void SetCurrentPos(float current_pos) { current_pos_ = current_pos; } | 74 void SetCurrentPos(float current_pos) { current_pos_ = current_pos; } |
| 76 void SetMaximum(int maximum) { maximum_ = maximum; } | 75 void SetMaximum(int maximum) { maximum_ = maximum; } |
| 77 | 76 |
| 78 gfx::Rect ComputeThumbQuadRect() const; | 77 gfx::Rect ComputeThumbQuadRect() const; |
| 79 | 78 |
| 80 protected: | 79 protected: |
| 81 ScrollbarLayerImpl(LayerTreeImpl* tree_impl, | 80 ScrollbarLayerImpl(LayerTreeImpl* tree_impl, |
| 82 int id, | 81 int id, |
| 83 ScrollbarOrientation orientation); | 82 ScrollbarOrientation orientation); |
| 84 | 83 |
| 85 private: | 84 private: |
| 86 virtual const char* LayerTypeAsString() const OVERRIDE; | 85 virtual const char* LayerTypeAsString() const OVERRIDE; |
| 87 | 86 |
| 88 gfx::Rect ScrollbarLayerRectToContentRect(gfx::RectF layer_rect) const; | 87 gfx::Rect ScrollbarLayerRectToContentRect(gfx::RectF layer_rect) const; |
| 89 | 88 |
| 90 ResourceProvider::ResourceId track_resource_id_; | 89 UIResourceId track_ui_resource_id_; |
| 91 ResourceProvider::ResourceId thumb_resource_id_; | 90 UIResourceId thumb_ui_resource_id_; |
| 92 | 91 |
| 93 float current_pos_; | 92 float current_pos_; |
| 94 int maximum_; | 93 int maximum_; |
| 95 int thumb_thickness_; | 94 int thumb_thickness_; |
| 96 int thumb_length_; | 95 int thumb_length_; |
| 97 int track_start_; | 96 int track_start_; |
| 98 int track_length_; | 97 int track_length_; |
| 99 ScrollbarOrientation orientation_; | 98 ScrollbarOrientation orientation_; |
| 100 | 99 |
| 101 // Difference between the clip layer's height and the visible viewport | 100 // Difference between the clip layer's height and the visible viewport |
| 102 // height (which may differ in the presence of top-controls hiding). | 101 // height (which may differ in the presence of top-controls hiding). |
| 103 float vertical_adjust_; | 102 float vertical_adjust_; |
| 104 | 103 |
| 105 float visible_to_total_length_ratio_; | 104 float visible_to_total_length_ratio_; |
| 106 | 105 |
| 107 int scroll_layer_id_; | 106 int scroll_layer_id_; |
| 108 | 107 |
| 109 bool is_overlay_scrollbar_; | 108 bool is_overlay_scrollbar_; |
| 110 | 109 |
| 111 DISALLOW_COPY_AND_ASSIGN(ScrollbarLayerImpl); | 110 DISALLOW_COPY_AND_ASSIGN(ScrollbarLayerImpl); |
| 112 }; | 111 }; |
| 113 | 112 |
| 114 } // namespace cc | 113 } // namespace cc |
| 115 #endif // CC_LAYERS_SCROLLBAR_LAYER_IMPL_H_ | 114 #endif // CC_LAYERS_SCROLLBAR_LAYER_IMPL_H_ |
| OLD | NEW |