46 #if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT) 47 #error "Only <final/final.h> can be included directly." 53 #include "final/fapplication.h" 54 #include "final/fwidget.h" 55 #include "final/util/flog.h" 64 using FScrollbar = FScrollBar;
67 using FScrollBarPtr = std::shared_ptr<FScrollBar>;
77 using FWidget::setGeometry;
80 enum class ScrollType : uInt8
102 auto getClassName()
const ->
FString override;
103 auto getValue()
const noexcept -> int;
104 auto getScrollType()
const -> ScrollType;
107 void setMinimum (
int);
108 void setMaximum (
int);
109 void setRange (
int,
int);
111 void setSteps (
double);
112 void setPageSize (
int,
int);
113 void setOrientation (Orientation);
114 void setSize (
const FSize&,
bool =
true)
override;
115 void setGeometry (
const FPoint&,
const FSize&,
bool =
true)
override;
118 void resize()
override;
119 void redraw()
override;
120 void calculateSliderValues();
133 void draw()
override;
134 void drawVerticalBar();
135 void drawVerticalBackgroundLine();
136 void drawHorizontalBar();
137 void drawHorizontalBackgroundColumn();
139 void drawNewFontButtons();
140 void drawDefaultButtons();
141 auto getClickedScrollType (
int,
int)
const -> ScrollType;
142 auto getVerticalClickedScrollType (
int)
const -> ScrollType;
143 auto getHorizontalClickedScrollType (
int)
const -> ScrollType;
144 auto getNewFontHorizontalScrollType (
int)
const -> ScrollType;
145 auto getHorizontalScrollType (
int)
const -> ScrollType;
146 auto getSliderClickPos (
int,
int)
const -> int;
147 auto isMouseOutsideScrollBar (
int,
int)
const -> bool;
148 auto shouldStopTimer()
const -> bool;
149 void jumpToClickPos (
int,
int);
150 void jumpToClickPos (
int);
151 void handleJumpScroll (
int,
int);
153 void avoidScrollOvershoot();
154 void processScroll();
155 void changeOnResize();
156 void handleWidgetFocus()
const;
157 void handleSliderClick (
int,
int);
158 void handleTrackClick (
int,
int);
161 ScrollType scroll_type{ScrollType::None};
162 bool threshold_reached{
false};
163 int threshold_time{500};
165 int slider_click_pos{-1};
166 int slider_click_stop_pos{-1};
167 int current_slider_pos{-1};
169 std::size_t slider_length{18};
170 std::size_t bar_length{18};
176 std::size_t length{20};
177 Orientation bar_orientation{Orientation::Vertical};
178 int max_color{FVTerm::getFOutput()->getMaxColor()};
183 template <
typename Instance
185 void initScrollBar ( FScrollBarPtr& bar
187 , Instance cb_instance
188 ,
const Callback& cb_handler )
190 bar = std::make_shared<FScrollBar>(o, cb_instance);
197 std::bind(cb_handler, cb_instance, bar.get())
204 inline auto FScrollBar::getClassName()
const ->
FString 205 {
return "FScrollBar"; }
208 inline auto FScrollBar::getValue()
const noexcept ->
int 212 inline auto FScrollBar::getScrollType()
const -> ScrollType
213 {
return scroll_type; }
217 #endif // FSCROLLBAR_H
Definition: class_template.cpp:25