finalcut/src/include/final/fscrollbar.h

183 lines
6.4 KiB
C
Raw Normal View History

2017-11-04 07:03:53 +01:00
/***********************************************************************
* fscrollbar.h - Widget FScrollbar *
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2012-2019 Markus Gans *
2017-11-04 07:03:53 +01:00
* *
* The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
* as published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. *
* *
* The Final Cut is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this program. If not, see *
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
/* Inheritance diagram
*
*
*
* FTerm
*
*
*
*
* FVTerm FObject
*
*
*
*
*
*
* FWidget
*
*
*
*
* FScrollbar
*
*/
2015-05-23 13:35:12 +02:00
#ifndef FSCROLLBAR_H
#define FSCROLLBAR_H
2015-05-23 13:35:12 +02:00
#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
#error "Only <final/final.h> can be included directly."
#endif
#include "final/fwidget.h"
2015-05-23 13:35:12 +02:00
namespace finalcut
{
2015-05-23 13:35:12 +02:00
//----------------------------------------------------------------------
// class FScrollbar
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
class FScrollbar : public FWidget
{
2017-09-11 03:06:02 +02:00
public:
// Using-declarations
using FWidget::setGeometry;
// Enumeration
enum sType
{
noScroll = 0,
scrollJump = 1,
scrollStepBackward = 2,
scrollStepForward = 3,
scrollPageBackward = 4,
scrollPageForward = 5,
scrollWheelUp = 6,
scrollWheelDown = 7
};
// Constructors
explicit FScrollbar (FWidget* = nullptr);
2019-01-12 09:11:22 +01:00
explicit FScrollbar (fc::orientation = fc::vertical, FWidget* = nullptr);
// Disable copy constructor
FScrollbar (const FScrollbar&) = delete;
2017-09-11 03:06:02 +02:00
// Destructor
virtual ~FScrollbar();
// Disable assignment operator (=)
FScrollbar& operator = (const FScrollbar&) = delete;
2017-09-11 03:06:02 +02:00
// Accessors
2018-12-31 06:18:39 +01:00
virtual const char* getClassName() const override;
int getValue() const;
sType getScrollType() const;
2017-09-11 03:06:02 +02:00
// Mutators
2018-12-31 06:18:39 +01:00
void setMinimum (int);
void setMaximum (int);
void setRange (int, int);
void setValue (int);
void setSteps (double);
void setPageSize (int, int);
2019-01-12 09:11:22 +01:00
void setOrientation (fc::orientation);
virtual void setGeometry ( const FPoint&, const FSize&
, bool = true ) override;
2017-09-11 03:06:02 +02:00
// Methods
2018-12-31 06:18:39 +01:00
virtual void resize() override;
virtual void redraw() override;
void calculateSliderValues();
void drawVerticalBar();
void drawHorizontalBar();
void drawBar();
2017-09-11 03:06:02 +02:00
// Event handlers
2018-12-31 06:18:39 +01:00
virtual void onMouseDown (FMouseEvent*) override;
virtual void onMouseUp (FMouseEvent*) override;
virtual void onMouseMove (FMouseEvent*) override;
virtual void onWheel (FWheelEvent*) override;
virtual void onTimer (FTimerEvent*) override;
2017-09-11 03:06:02 +02:00
private:
// Methods
2018-12-31 06:18:39 +01:00
void init();
virtual void draw() override;
void drawButtons();
sType getClickedScrollType (int, int);
sType getVerticalClickedScrollType (int);
sType getHorizontalClickedScrollType (int);
int getSliderClickPos (int, int);
void jumpToClickPos (int, int);
void jumpToClickPos (int);
void avoidScrollOvershoot();
void processScroll();
2017-09-11 03:06:02 +02:00
// Data Members
2019-01-12 09:11:22 +01:00
sType scroll_type{FScrollbar::noScroll};
bool threshold_reached{false};
int threshold_time{500};
int repeat_time{10};
int slider_click_pos{-1};
int slider_click_stop_pos{-1};
int current_slider_pos{-1};
int slider_pos{0};
std::size_t slider_length{18}; // = bar_length
std::size_t bar_length{18}; // = length - 2
int val{0};
int min{0};
int max{99};
double steps{1};
int pagesize{0};
std::size_t length{20};
fc::orientation bar_orientation{fc::vertical};
int max_color{getMaxColor()};
2015-05-23 13:35:12 +02:00
};
#pragma pack(pop)
// FScrollbar inline functions
//----------------------------------------------------------------------
inline const char* FScrollbar::getClassName() const
{ return "FScrollbar"; }
//----------------------------------------------------------------------
inline int FScrollbar::getValue() const
{ return val; }
//----------------------------------------------------------------------
inline FScrollbar::sType FScrollbar::getScrollType() const
{ return scroll_type; }
2015-05-23 13:35:12 +02:00
} // namespace finalcut
#endif // FSCROLLBAR_H