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 FScrollbarPtr = std::shared_ptr<FScrollbar>;
74 using FWidget::setGeometry;
99 auto getClassName()
const ->
FString override;
100 auto getValue()
const noexcept -> int;
101 auto getScrollType()
const -> ScrollType;
104 void setMinimum (
int);
105 void setMaximum (
int);
106 void setRange (
int,
int);
108 void setSteps (
double);
109 void setPageSize (
int,
int);
110 void setOrientation (Orientation);
111 void setSize (
const FSize&,
bool =
true)
override;
112 void setGeometry (
const FPoint&,
const FSize&,
bool =
true)
override;
115 void resize()
override;
116 void redraw()
override;
117 void calculateSliderValues();
130 void draw()
override;
131 void drawVerticalBar();
132 void drawVerticalBackgroundLine();
133 void drawHorizontalBar();
134 void drawHorizontalBackgroundColumn();
136 auto getClickedScrollType (
int,
int)
const -> ScrollType;
137 auto getVerticalClickedScrollType (
int)
const -> ScrollType;
138 auto getHorizontalClickedScrollType (
int)
const -> ScrollType;
139 auto getNewFontHorizontalScrollType (
int)
const -> ScrollType;
140 auto getHorizontalScrollType (
int)
const -> ScrollType;
141 auto getSliderClickPos (
int,
int)
const -> int;
142 auto isMouseOutsideScrollbar (
int,
int)
const -> bool;
143 auto shouldStopTimer()
const -> bool;
144 void jumpToClickPos (
int,
int);
145 void jumpToClickPos (
int);
146 void handleJumpScroll (
int,
int);
148 void avoidScrollOvershoot();
149 void processScroll();
150 void changeOnResize();
151 void handleWidgetFocus()
const;
152 void handleSliderClick (
int,
int);
153 void handleTrackClick (
int,
int);
156 ScrollType scroll_type{ScrollType::None};
157 bool threshold_reached{
false};
158 int threshold_time{500};
160 int slider_click_pos{-1};
161 int slider_click_stop_pos{-1};
162 int current_slider_pos{-1};
164 std::size_t slider_length{18};
165 std::size_t bar_length{18};
171 std::size_t length{20};
172 Orientation bar_orientation{Orientation::Vertical};
173 int max_color{FVTerm::getFOutput()->getMaxColor()};
178 template <
typename Instance
180 void initScrollbar ( FScrollbarPtr& bar
182 , Instance cb_instance
183 ,
const Callback& cb_handler )
185 bar = std::make_shared<FScrollbar>(o, cb_instance);
192 std::bind(cb_handler, cb_instance, bar.get())
199 inline auto FScrollbar::getClassName()
const ->
FString 200 {
return "FScrollbar"; }
203 inline auto FScrollbar::getValue()
const noexcept ->
int 207 inline auto FScrollbar::getScrollType()
const -> ScrollType
208 {
return scroll_type; }
212 #endif // FSCROLLBAR_H
Definition: class_template.cpp:25