| OLD | NEW |
| (Empty) |
| 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 | |
| 5 #ifndef CC_LAYERS_SCROLLBAR_LAYER_IMPL_BASE_H_ | |
| 6 #define CC_LAYERS_SCROLLBAR_LAYER_IMPL_BASE_H_ | |
| 7 | |
| 8 #include "cc/base/cc_export.h" | |
| 9 #include "cc/input/scrollbar.h" | |
| 10 #include "cc/layers/layer.h" | |
| 11 #include "cc/layers/layer_impl.h" | |
| 12 | |
| 13 namespace cc { | |
| 14 | |
| 15 class LayerTreeImpl; | |
| 16 | |
| 17 class CC_EXPORT ScrollbarLayerImplBase : public LayerImpl { | |
| 18 public: | |
| 19 int ScrollLayerId() const { | |
| 20 return scroll_layer_ ? scroll_layer_->id() : Layer::INVALID_ID; | |
| 21 } | |
| 22 int ClipLayerId() const { | |
| 23 return clip_layer_ ? clip_layer_->id() : Layer::INVALID_ID; | |
| 24 } | |
| 25 | |
| 26 void SetScrollLayerAndClipLayerByIds(int scroll_layer_id, int clip_layer_id); | |
| 27 void ClearScrollLayer() { scroll_layer_ = nullptr; } | |
| 28 void ClearClipLayer() { clip_layer_ = nullptr; } | |
| 29 | |
| 30 float current_pos() const { return current_pos_; } | |
| 31 bool SetCurrentPos(float current_pos); | |
| 32 int maximum() const { return maximum_; } | |
| 33 bool SetMaximum(int maximum); | |
| 34 | |
| 35 bool SetVerticalAdjust(float vertical_adjust); | |
| 36 | |
| 37 bool is_overlay_scrollbar() const { return is_overlay_scrollbar_; } | |
| 38 void set_is_overlay_scrollbar(bool is_overlay) { | |
| 39 is_overlay_scrollbar_ = is_overlay; | |
| 40 } | |
| 41 | |
| 42 ScrollbarOrientation orientation() const { return orientation_; } | |
| 43 bool is_left_side_vertical_scrollbar() { | |
| 44 return is_left_side_vertical_scrollbar_; | |
| 45 } | |
| 46 | |
| 47 bool CanScrollOrientation() const; | |
| 48 | |
| 49 void PushPropertiesTo(LayerImpl* layer) override; | |
| 50 ScrollbarLayerImplBase* ToScrollbarLayer() override; | |
| 51 void PushScrollClipPropertiesTo(LayerImpl* layer); | |
| 52 | |
| 53 bool SetVisibleToTotalLengthRatio(float ratio); | |
| 54 // Thumb quad rect in layer space. | |
| 55 virtual gfx::Rect ComputeThumbQuadRect() const; | |
| 56 | |
| 57 float thumb_thickness_scale_factor() { | |
| 58 return thumb_thickness_scale_factor_; | |
| 59 } | |
| 60 bool SetThumbThicknessScaleFactor(float thumb_thickness_scale_factor); | |
| 61 | |
| 62 void ScrollbarParametersDidChange(bool on_resize); | |
| 63 | |
| 64 protected: | |
| 65 ScrollbarLayerImplBase(LayerTreeImpl* tree_impl, | |
| 66 int id, | |
| 67 ScrollbarOrientation orientation, | |
| 68 bool is_left_side_vertical_scrollbar, | |
| 69 bool is_overlay); | |
| 70 ~ScrollbarLayerImplBase() override; | |
| 71 | |
| 72 gfx::Rect ScrollbarLayerRectToContentRect(const gfx::RectF& layer_rect) const; | |
| 73 | |
| 74 float visible_to_total_length_ratio() const { | |
| 75 return visible_to_total_length_ratio_; | |
| 76 } | |
| 77 float vertical_adjust() const { return vertical_adjust_; } | |
| 78 | |
| 79 virtual int ThumbThickness() const = 0; | |
| 80 virtual int ThumbLength() const = 0; | |
| 81 virtual float TrackLength() const = 0; | |
| 82 virtual int TrackStart() const = 0; | |
| 83 // Indicates whether the thumb length can be changed without going back to the | |
| 84 // main thread. | |
| 85 virtual bool IsThumbResizable() const = 0; | |
| 86 | |
| 87 private: | |
| 88 LayerImpl* scroll_layer_; | |
| 89 LayerImpl* clip_layer_; | |
| 90 bool is_overlay_scrollbar_; | |
| 91 | |
| 92 float thumb_thickness_scale_factor_; | |
| 93 float current_pos_; | |
| 94 int maximum_; | |
| 95 ScrollbarOrientation orientation_; | |
| 96 bool is_left_side_vertical_scrollbar_; | |
| 97 | |
| 98 // Difference between the clip layer's height and the visible viewport | |
| 99 // height (which may differ in the presence of top-controls hiding). | |
| 100 float vertical_adjust_; | |
| 101 | |
| 102 float visible_to_total_length_ratio_; | |
| 103 | |
| 104 DISALLOW_COPY_AND_ASSIGN(ScrollbarLayerImplBase); | |
| 105 }; | |
| 106 | |
| 107 } // namespace cc | |
| 108 | |
| 109 #endif // CC_LAYERS_SCROLLBAR_LAYER_IMPL_BASE_H_ | |
| OLD | NEW |