6#include "fifechan/widgets/scrollarea.hpp"
14#include "fifechan/exception.hpp"
15#include "fifechan/graphics.hpp"
19 ScrollArea::ScrollArea()
24 ScrollArea::ScrollArea(
Widget* content)
38 ScrollArea::~ScrollArea()
43 }
catch (std::exception
const & e) {
44 std::cerr <<
"[ScrollArea] Exception in destructor: " << e.what() <<
"\n";
52 if (widget !=
nullptr) {
126 }
else if (hScroll < 0) {
194 int const x = mouseEvent.
getX();
195 int const y = mouseEvent.
getY();
258 if ((barDim.
height - length) > 0) {
271 if ((barDim.
width - length) > 0) {
314 trackColor.
a = alpha;
316 shadowColor.
a = alpha;
335 trackColor.
a = alpha;
337 shadowColor.
a = alpha;
362 Color highlightColor;
371 highlightColor = faceColor -
Color(0x303030);
372 highlightColor.
a = alpha;
374 shadowColor.
a = alpha;
380 highlightColor = faceColor +
Color(0x303030);
381 highlightColor.
a = alpha;
382 shadowColor = faceColor -
Color(0x303030);
383 shadowColor.
a = alpha;
402 int const w = dim.
height / 2;
403 int const h = (w / 2) + 2;
404 for (i = 0; i < w / 2; ++i) {
405 graphics->
drawLine(w - i + offset, i + h + offset, w + i + offset, i + h + offset);
417 Color highlightColor;
426 highlightColor = faceColor -
Color(0x303030);
427 highlightColor.
a = alpha;
429 shadowColor.
a = alpha;
435 highlightColor = faceColor +
Color(0x303030);
436 highlightColor.
a = alpha;
437 shadowColor = faceColor -
Color(0x303030);
438 shadowColor.
a = alpha;
457 int const w = dim.
height / 2;
459 for (i = 0; i < w / 2; ++i) {
460 graphics->
drawLine(w - i + offset, -i + h + offset, w + i + offset, -i + h + offset);
471 Color highlightColor;
480 highlightColor = faceColor -
Color(0x303030);
481 highlightColor.
a = alpha;
483 shadowColor.
a = alpha;
489 highlightColor = faceColor +
Color(0x303030);
490 highlightColor.
a = alpha;
491 shadowColor = faceColor -
Color(0x303030);
492 shadowColor.
a = alpha;
511 int const w = dim.
width / 2;
513 for (i = 0; i < w / 2; ++i) {
514 graphics->
drawLine(i + h + offset, w - i + offset, i + h + offset, w + i + offset);
526 Color highlightColor;
535 highlightColor = faceColor -
Color(0x303030);
536 highlightColor.
a = alpha;
538 shadowColor.
a = alpha;
544 highlightColor = faceColor +
Color(0x303030);
545 highlightColor.
a = alpha;
546 shadowColor = faceColor -
Color(0x303030);
547 shadowColor.
a = alpha;
566 int const w = dim.
width / 2;
568 for (i = 0; i < w / 2; ++i) {
569 graphics->
drawLine(-i + h + offset, w - i + offset, -i + h + offset, w + i + offset);
583 Color highlightColor = faceColor +
Color(0x303030);
584 highlightColor.
a = alpha;
585 Color shadowColor = faceColor -
Color(0x303030);
586 shadowColor.
a = alpha;
610 Color highlightColor = faceColor +
Color(0x303030);
611 highlightColor.
a = alpha;
612 Color shadowColor = faceColor -
Color(0x303030);
613 shadowColor.
a = alpha;
657 if (
mHPolicy == ScrollPolicy::ShowAuto &&
mVPolicy == ScrollPolicy::ShowAuto) {
679 case ScrollPolicy::ShowNever:
683 case ScrollPolicy::ShowAlways:
687 case ScrollPolicy::ShowAuto:
688 if (
mVPolicy == ScrollPolicy::ShowNever) {
701 case ScrollPolicy::ShowNever:
705 case ScrollPolicy::ShowAlways:
709 case ScrollPolicy::ShowAuto:
710 if (
mHPolicy == ScrollPolicy::ShowNever) {
737 assert(
"mVBarVisible must be true here" &&
mVBarVisible);
761 assert(
"mHBarVisible must be true here" &&
mHBarVisible);
845 length = std::min(length, barDim.
height);
870 length = barDim.
width;
875 length = std::min(length, barDim.
width);
975 if (content !=
nullptr) {
986 if (content !=
nullptr) {
997 if (content !=
nullptr) {
1008 static_cast<void>(recursion);
1010 if (content !=
nullptr) {
1021 if (content !=
nullptr) {
1031 static_cast<void>(recursion);
1037 if (content !=
nullptr) {
uint8_t a
Alpha color component (0-255).
Abstract interface providing primitive drawing functions (lines, rectangles, etc.).
virtual void popClipArea()
Removes the top most clip area from the stack.
virtual bool pushClipArea(Rectangle area)
Pushes a clip area onto the stack.
virtual void drawLine(int x1, int y1, int x2, int y2)=0
Draws a line.
virtual void setColor(Color const &color)=0
Sets the color to use when drawing.
virtual void fillRectangle(Rectangle const &rectangle)=0
Draws a filled rectangle.
Represents a mouse event.
int getX() const
Gets the x coordinate of the mouse event.
int getY() const
Gets the y coordinate of the mouse event.
Represents a rectangular area (X, Y, Width, Height).
int width
Holds the width of the rectangle.
int y
Holds the x coordinate of the rectangle.
int x
Holds the x coordinate of the rectangle.
int height
Holds the height of the rectangle.
bool isEmpty() const
Checks whether the rectangle is empty or not.
Represents dimensions defined by width and height.
Used replacement tokens by configure_file():
void throwException(std::string const &message, std::source_location location=std::source_location::current())
Throw an Exception capturing the current source location.