| Index: views/controls/scrollbar/base_scroll_bar.h
|
| diff --git a/views/controls/scrollbar/bitmap_scroll_bar.h b/views/controls/scrollbar/base_scroll_bar.h
|
| similarity index 61%
|
| copy from views/controls/scrollbar/bitmap_scroll_bar.h
|
| copy to views/controls/scrollbar/base_scroll_bar.h
|
| index ce072bf18a10c0f1aeff20cf28a9f6308dba1929..7dc037b8c1e8b4318919933dccd6dcb29ada5a51 100644
|
| --- a/views/controls/scrollbar/bitmap_scroll_bar.h
|
| +++ b/views/controls/scrollbar/base_scroll_bar.h
|
| @@ -2,8 +2,8 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef VIEWS_CONTROLS_SCROLLBAR_BITMAP_SCROLL_BAR_H_
|
| -#define VIEWS_CONTROLS_SCROLLBAR_BITMAP_SCROLL_BAR_H_
|
| +#ifndef VIEWS_CONTROLS_SCROLLBAR_BASE_SCROLL_BAR_H_
|
| +#define VIEWS_CONTROLS_SCROLLBAR_BASE_SCROLL_BAR_H_
|
| #pragma once
|
|
|
| #include "views/context_menu_controller.h"
|
| @@ -14,62 +14,22 @@
|
|
|
| namespace views {
|
|
|
| -namespace {
|
| -class BitmapScrollBarThumb;
|
| -}
|
| +class BaseScrollBarThumb;
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
| //
|
| -// BitmapScrollBar
|
| -//
|
| -// A ScrollBar subclass that implements a scroll bar rendered using bitmaps
|
| -// that the user provides. There are bitmaps for the up and down buttons, as
|
| -// well as for the thumb and track. This is intended for creating UIs that
|
| -// have customized, non-native appearances, like floating HUDs etc.
|
| -//
|
| -// Maybe TODO(beng): (Cleanup) If we need to, we may want to factor rendering
|
| -// out of this altogether and have the user supply
|
| -// Background impls for each component, and just use those
|
| -// to render, so that for example we get native theme
|
| -// rendering.
|
| +// BaseScrollBar
|
| //
|
| ///////////////////////////////////////////////////////////////////////////////
|
| -class BitmapScrollBar : public ScrollBar,
|
| - public ButtonListener,
|
| - public ContextMenuController,
|
| - public Menu::Delegate {
|
| +class VIEWS_EXPORT BaseScrollBar : public ScrollBar,
|
| + public ContextMenuController,
|
| + public Menu::Delegate {
|
| public:
|
| - BitmapScrollBar(bool horizontal, bool show_scroll_buttons);
|
| - virtual ~BitmapScrollBar() { }
|
| + BaseScrollBar(bool horizontal, BaseScrollBarThumb* thumb);
|
| + virtual ~BaseScrollBar() { }
|
|
|
| // Get the bounds of the "track" area that the thumb is free to slide within.
|
| - gfx::Rect GetTrackBounds() const;
|
| -
|
| - // A list of parts that the user may supply bitmaps for.
|
| - enum ScrollBarPart {
|
| - // The button used to represent scrolling up/left by 1 line.
|
| - PREV_BUTTON = 0,
|
| - // The button used to represent scrolling down/right by 1 line.
|
| - // IMPORTANT: The code assumes the prev and next
|
| - // buttons have equal width and equal height.
|
| - NEXT_BUTTON,
|
| - // The top/left segment of the thumb on the scrollbar.
|
| - THUMB_START_CAP,
|
| - // The tiled background image of the thumb.
|
| - THUMB_MIDDLE,
|
| - // The bottom/right segment of the thumb on the scrollbar.
|
| - THUMB_END_CAP,
|
| - // The grippy that is rendered in the center of the thumb.
|
| - THUMB_GRIPPY,
|
| - // The tiled background image of the thumb track.
|
| - THUMB_TRACK,
|
| - PART_COUNT
|
| - };
|
| -
|
| - // Sets the bitmap to be rendered for the specified part and state.
|
| - void SetImage(ScrollBarPart part,
|
| - CustomButton::ButtonState state,
|
| - SkBitmap* bitmap);
|
| + virtual gfx::Rect GetTrackBounds() const = 0;
|
|
|
| // An enumeration of different amounts of incremental scroll, representing
|
| // events sent from different parts of the UI/keyboard.
|
| @@ -96,23 +56,19 @@ class BitmapScrollBar : public ScrollBar,
|
| void ScrollByContentsOffset(int contents_offset);
|
|
|
| // View overrides:
|
| - virtual gfx::Size GetPreferredSize() OVERRIDE;
|
| - virtual void Layout() OVERRIDE;
|
| + virtual gfx::Size GetPreferredSize() OVERRIDE = 0;
|
| + virtual void Layout() OVERRIDE = 0;
|
| virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE;
|
| virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE;
|
| virtual void OnMouseCaptureLost() OVERRIDE;
|
| virtual bool OnKeyPressed(const KeyEvent& event) OVERRIDE;
|
| virtual bool OnMouseWheel(const MouseWheelEvent& event) OVERRIDE;
|
|
|
| - // BaseButton::ButtonListener overrides:
|
| - virtual void ButtonPressed(Button* sender,
|
| - const views::Event& event) OVERRIDE;
|
| -
|
| // ScrollBar overrides:
|
| virtual void Update(int viewport_size,
|
| int content_size,
|
| int contents_scroll_offset) OVERRIDE;
|
| - virtual int GetLayoutSize() const OVERRIDE;
|
| + virtual int GetLayoutSize() const OVERRIDE = 0;
|
| virtual int GetPosition() const OVERRIDE;
|
|
|
| // ContextMenuController overrides.
|
| @@ -127,7 +83,19 @@ class BitmapScrollBar : public ScrollBar,
|
|
|
| protected:
|
| // View overrides:
|
| - virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
|
| + virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE = 0;
|
| +
|
| + BaseScrollBarThumb* GetThumb() const;
|
| +
|
| + CustomButton::ButtonState GetThumbTrackState() const;
|
| +
|
| + // Wrapper functions that calls the controller. We need this since native
|
| + // scrollbars wrap around a different scrollbar. When calling the controller
|
| + // we need to pass in the appropriate scrollbar. For normal scrollbars it's
|
| + // the |this| scrollbar, for native scrollbars it's the native scrollbar used
|
| + // to create this.
|
| + virtual void ScrollToPosition(int position);
|
| + virtual int GetScrollIncrement(bool is_page, bool is_positive);
|
|
|
| private:
|
| // Called when the mouse is pressed down in the track area.
|
| @@ -154,9 +122,7 @@ class BitmapScrollBar : public ScrollBar,
|
| // pressing the mouse button down in it).
|
| void SetThumbTrackState(CustomButton::ButtonState state);
|
|
|
| - // The thumb needs to be able to access the part images.
|
| - friend BitmapScrollBarThumb;
|
| - SkBitmap* images_[PART_COUNT][CustomButton::BS_COUNT];
|
| + BaseScrollBarThumb* thumb_;
|
|
|
| // The size of the scrolled contents, in pixels.
|
| int contents_size_;
|
| @@ -164,11 +130,6 @@ class BitmapScrollBar : public ScrollBar,
|
| // The current amount the contents is offset by in the viewport.
|
| int contents_scroll_offset_;
|
|
|
| - // Up/Down/Left/Right buttons and the Thumb.
|
| - ImageButton* prev_button_;
|
| - ImageButton* next_button_;
|
| - BitmapScrollBarThumb* thumb_;
|
| -
|
| // The state of the scrollbar track. Typically, the track will highlight when
|
| // the user presses the mouse on them (during page scrolling).
|
| CustomButton::ButtonState thumb_track_state_;
|
| @@ -187,12 +148,9 @@ class BitmapScrollBar : public ScrollBar,
|
| // was invoked.
|
| int context_menu_mouse_position_;
|
|
|
| - // True if the scroll buttons at each end of the scroll bar should be shown.
|
| - bool show_scroll_buttons_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(BitmapScrollBar);
|
| + DISALLOW_COPY_AND_ASSIGN(BaseScrollBar);
|
| };
|
|
|
| } // namespace views
|
|
|
| -#endif // VIEWS_CONTROLS_SCROLLBAR_BITMAP_SCROLL_BAR_H_
|
| +#endif // VIEWS_CONTROLS_SCROLLBAR_BASE_SCROLL_BAR_H_
|
|
|