/** @file * @author Edouard DUPIN * @copyright 2011, Edouard DUPIN, all right reserved * @license MPL v2.0 (see license file) */ #pragma once #include #include #include #include #include #define CALCULATE_SIMULTANEOUS_FINGER (5) namespace ewol { namespace widget { class WidgetScrolled; using WidgetScrolled = ememory::Ptr; using WidgetScrolledWeak = ememory::WeakPtr; /** * @brief Widget to integrate a scrool bar in a widget. This is not a stadalone widget. */ class WidgetScrolled : public Widget { public: // properties: eproperty::Value propertyShapeVert; //!< Vertical shaper name eproperty::Value propertyShapeHori; //!< Horizontal shaper name // TODO : All property public: enum scrollingMode { scroolModeNormal, //!< No Zoom , can UP and down, left and right scroolModeCenter, //!< Zoom enable, no move left and right scroolModeGame, //!< Zoom enable, no move left and right }; private: ewol::compositing::Shaper this.shaperH; //!< Compositing theme Horizontal. ewol::compositing::Shaper this.shaperV; //!< Compositing theme Vertical. protected: Vector2f this.originScrooled; //!< pixel distance from the origin of the display (Bottum left) Vector2f this.maxSize; //!< Maximum size of the Widget ==> to display scrollbar Vector2f this.limitScrolling; //!< Mimit scrolling represent the propertion of the minimel scrolling activate (0.2 ==> 20% migt all time be visible) private: // Mouse section : enum scrollingMode this.scroollingMode; //!< mode of management of the scrooling float this.pixelScrolling; Vector2f this.highSpeedStartPos; enum Scroll::highSpeedMode this.highSpeedMode; int this.highSpeedButton; KeyType this.highSpeedType; private: // finger section: boolean this.singleFingerMode; //!< in many case the moving in a subwidget is done with one finger, it is enought ==> the user select... public: /** * @brief Set the single finger capabilities/ * @param[in] _status True if single inger mode, two otherwise/ */ void setSingleFinger(boolean _status); /** * @brief Get the single finger capabilities * @return true The single finger mode is active * @return false The To finger mode is active */ boolean getSingleFinger() { return this.singleFingerMode; } /** * @brief Reset the scoll of the subWidget */ void resetScrollOrigin() { this.originScrooled = Vector2f(0,0); } private: boolean this.fingerPresent[CALCULATE_SIMULTANEOUS_FINGER]; boolean this.fingerScoolActivated; Vector2f this.fingerMoveStartPos[CALCULATE_SIMULTANEOUS_FINGER]; protected: /** * @brief Scroll Widget main ructor to be herited from an other widget (this is not a stand-alone widget) * @param[in] _shaperName Shaper name if the scrolled widget. */ WidgetScrolled(); void init() ; public: DECLARE_WIDGET_FACTORY(WidgetScrolled, "WidgetScrolled"); /** * @brief Scroll widget destructor. */ ~WidgetScrolled(); protected: void onDraw() ; public: void onRegenerateDisplay() ; boolean onEventInput( ewol::event::Input _event) ; void systemDraw( ewol::DrawProperty _displayProp) ; protected: /** * @brief For mouse event when we have a scrolling UP and dows, specify the number of pixel that we scrooled * @param[in] _nbPixel number of pixel scrolling */ void setScrollingSize(float _nbPixel) { this.pixelScrolling = _nbPixel; }; /** * @brief Specify the mode of scrolling for this windows * @param[in] _newMode the selected mode for the scrolling... */ void scroolingMode(enum scrollingMode _newMode); /** * @brief set the specific mawimum size of the widget * @param[in] _localSize new Maximum size */ void setMaxSize( Vector2f _localSize) { this.maxSize = _localSize; }; /** * @brief Request a specific position for the scrolling of the current windows. * @param[in] _borderWidth size of the border that requested the element might not to be * @param[in] _currentPosition Position that is requested to view * @param[in] _center True if the position might be at the center of the widget */ void setScrollingPositionDynamic(Vector2f _borderWidth, Vector2f _currentPosition, boolean _center = false); /** * @brief set the scrolling limit when arriving at he end of the widget * @param[in] _poucentageLimit pourcent of the limit of view nothing in the widget when arriving at the end ... */ void setLimitScrolling(float _poucentageLimit) { _poucentageLimit = etk::avg(0.1f, _poucentageLimit,1.0f); this.limitScrolling = Vector2f(_poucentageLimit, _poucentageLimit); }; /** * @brief set the scrolling limit when arriving at he end of the widget * @param[in] _poucentageLimit pourcent of the limit of view nothing in the widget when arriving at the end for axis specific... */ void setLimitScrolling( Vector2f _poucentageLimit) { this.limitScrolling = Vector2f(etk::avg(0.1f, _poucentageLimit.x(),1.0f), etk::avg(0.1f, _poucentageLimit.y(),1.0f)); }; protected: void onChangePropertyShapeVert(); void onChangePropertyShapeHori(); }; } }