5#include "fifechan/widgets/scrollarea.hpp"
9#include "fifechan/exception.hpp"
10#include "fifechan/graphics.hpp"
14 ScrollArea::ScrollArea()
19 ScrollArea::ScrollArea(
Widget* content)
31 ScrollArea::~ScrollArea()
35 }
catch (std::exception&) {
44 if (widget !=
nullptr) {
118 }
else if (hScroll < 0) {
173 throwException(
"Width should be greater then 0.");
186 int const x = mouseEvent.
getX();
187 int const y = mouseEvent.
getY();
250 if ((barDim.
height - length) > 0) {
263 if ((barDim.
width - length) > 0) {
306 trackColor.
a = alpha;
308 shadowColor.
a = alpha;
327 trackColor.
a = alpha;
329 shadowColor.
a = alpha;
354 Color highlightColor;
363 highlightColor = faceColor - 0x303030;
364 highlightColor.
a = alpha;
366 shadowColor.
a = alpha;
372 highlightColor = faceColor + 0x303030;
373 highlightColor.
a = alpha;
374 shadowColor = faceColor - 0x303030;
375 shadowColor.
a = alpha;
394 int const w = dim.
height / 2;
395 int const h = (w / 2) + 2;
396 for (i = 0; i < w / 2; ++i) {
397 graphics->
drawLine(w - i + offset, i + h + offset, w + i + offset, i + h + offset);
409 Color highlightColor;
418 highlightColor = faceColor - 0x303030;
419 highlightColor.
a = alpha;
421 shadowColor.
a = alpha;
427 highlightColor = faceColor + 0x303030;
428 highlightColor.
a = alpha;
429 shadowColor = faceColor - 0x303030;
430 shadowColor.
a = alpha;
449 int const w = dim.
height / 2;
451 for (i = 0; i < w / 2; ++i) {
452 graphics->
drawLine(w - i + offset, -i + h + offset, w + i + offset, -i + h + offset);
463 Color highlightColor;
472 highlightColor = faceColor - 0x303030;
473 highlightColor.
a = alpha;
475 shadowColor.
a = alpha;
481 highlightColor = faceColor + 0x303030;
482 highlightColor.
a = alpha;
483 shadowColor = faceColor - 0x303030;
484 shadowColor.
a = alpha;
503 int const w = dim.
width / 2;
505 for (i = 0; i < w / 2; ++i) {
506 graphics->
drawLine(i + h + offset, w - i + offset, i + h + offset, w + i + offset);
518 Color highlightColor;
527 highlightColor = faceColor - 0x303030;
528 highlightColor.
a = alpha;
530 shadowColor.
a = alpha;
536 highlightColor = faceColor + 0x303030;
537 highlightColor.
a = alpha;
538 shadowColor = faceColor - 0x303030;
539 shadowColor.
a = alpha;
558 int const w = dim.
width / 2;
560 for (i = 0; i < w / 2; ++i) {
561 graphics->
drawLine(-i + h + offset, w - i + offset, -i + h + offset, w + i + offset);
575 Color highlightColor = faceColor + 0x303030;
576 highlightColor.
a = alpha;
577 Color shadowColor = faceColor - 0x303030;
578 shadowColor.
a = alpha;
602 Color highlightColor = faceColor + 0x303030;
603 highlightColor.
a = alpha;
604 Color shadowColor = faceColor - 0x303030;
605 shadowColor.
a = alpha;
649 if (
mHPolicy == ScrollPolicy::ShowAuto &&
mVPolicy == ScrollPolicy::ShowAuto) {
671 case ScrollPolicy::ShowNever:
675 case ScrollPolicy::ShowAlways:
679 case ScrollPolicy::ShowAuto:
680 if (
mVPolicy == ScrollPolicy::ShowNever) {
689 throwException(
"Horizontal scroll policy invalid.");
693 case ScrollPolicy::ShowNever:
697 case ScrollPolicy::ShowAlways:
701 case ScrollPolicy::ShowAuto:
702 if (
mHPolicy == ScrollPolicy::ShowNever) {
710 throwException(
"Vertical scroll policy invalid.");
836 length = std::min(length, barDim.
height);
861 length = barDim.
width;
866 length = std::min(length, barDim.
width);
880 throwException(
"Widget not content widget");
966 if (content !=
nullptr) {
977 if (content !=
nullptr) {
988 if (content !=
nullptr) {
999 static_cast<void>(recursion);
1001 if (content !=
nullptr) {
1012 if (content !=
nullptr) {
1022 static_cast<void>(recursion);
1028 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.