|
|
|
|
@ -6,7 +6,7 @@
|
|
|
|
|
namespace dvl { |
|
|
|
|
|
|
|
|
|
extern Art ArtScrollBarBackground; |
|
|
|
|
const decltype(SDL_Rect().w) SCROLLBAR_BG_WIDTH = 25; |
|
|
|
|
const Uint16 SCROLLBAR_BG_WIDTH = 25; |
|
|
|
|
|
|
|
|
|
extern Art ArtScrollBarArrow; |
|
|
|
|
enum class ScrollBarArrowFrame { |
|
|
|
|
@ -17,7 +17,7 @@ enum class ScrollBarArrowFrame {
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
extern Art ArtScrollBarThumb; |
|
|
|
|
const decltype(SDL_Rect().w) SCROLLBAR_ARROW_WIDTH = 25; |
|
|
|
|
const Uint16 SCROLLBAR_ARROW_WIDTH = 25; |
|
|
|
|
|
|
|
|
|
inline SDL_Rect UpArrowRect(const UiScrollBar &sb) |
|
|
|
|
{ |
|
|
|
|
@ -25,7 +25,7 @@ inline SDL_Rect UpArrowRect(const UiScrollBar &sb)
|
|
|
|
|
sb.rect.x, |
|
|
|
|
sb.rect.y, |
|
|
|
|
SCROLLBAR_ARROW_WIDTH, |
|
|
|
|
static_cast<decltype(SDL_Rect().h)>(sb.arrow->h()), |
|
|
|
|
static_cast<Uint16>(sb.arrow->h()), |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -33,13 +33,13 @@ inline SDL_Rect DownArrowRect(const UiScrollBar &sb)
|
|
|
|
|
{ |
|
|
|
|
return { |
|
|
|
|
sb.rect.x, |
|
|
|
|
static_cast<decltype(SDL_Rect().y)>(sb.rect.y + sb.rect.h - sb.arrow->h()), |
|
|
|
|
static_cast<Sint16>(sb.rect.y + sb.rect.h) - sb.arrow->h(), |
|
|
|
|
SCROLLBAR_ARROW_WIDTH, |
|
|
|
|
static_cast<decltype(SDL_Rect().h)>(sb.arrow->h()), |
|
|
|
|
static_cast<Uint16>(sb.arrow->h()), |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline decltype(SDL_Rect().h) BarHeight(const UiScrollBar &sb) |
|
|
|
|
inline Uint16 BarHeight(const UiScrollBar &sb) |
|
|
|
|
{ |
|
|
|
|
return sb.rect.h - 2 * sb.arrow->h(); |
|
|
|
|
} |
|
|
|
|
@ -48,7 +48,7 @@ inline SDL_Rect BarRect(const UiScrollBar &sb)
|
|
|
|
|
{ |
|
|
|
|
return { |
|
|
|
|
sb.rect.x, |
|
|
|
|
static_cast<decltype(SDL_Rect().y)>(sb.rect.y + sb.arrow->h()), |
|
|
|
|
static_cast<Sint16>(sb.rect.y + sb.arrow->h()), |
|
|
|
|
SCROLLBAR_BG_WIDTH, |
|
|
|
|
BarHeight(sb), |
|
|
|
|
}; |
|
|
|
|
@ -60,10 +60,10 @@ inline SDL_Rect ThumbRect(const UiScrollBar &sb, std::size_t selected_index, std
|
|
|
|
|
const int thumb_max_y = BarHeight(sb) - sb.thumb->h(); |
|
|
|
|
const int thumb_y = (selected_index * thumb_max_y / (num_items - 1)); |
|
|
|
|
return { |
|
|
|
|
static_cast<decltype(SDL_Rect().x)>(sb.rect.x + THUMB_OFFSET_X), |
|
|
|
|
static_cast<decltype(SDL_Rect().y)>(sb.rect.y + sb.arrow->h() + thumb_y), |
|
|
|
|
static_cast<decltype(SDL_Rect().w)>(sb.rect.w - THUMB_OFFSET_X), |
|
|
|
|
static_cast<decltype(SDL_Rect().h)>(sb.thumb->h()), |
|
|
|
|
static_cast<Sint16>(sb.rect.x + THUMB_OFFSET_X), |
|
|
|
|
static_cast<Sint16>(sb.rect.y + sb.arrow->h() + thumb_y), |
|
|
|
|
static_cast<Uint16>(sb.rect.w - THUMB_OFFSET_X), |
|
|
|
|
static_cast<Uint16>(sb.thumb->h()), |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|