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