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