Don't create a new texture every time tiling is requested, though sadly this introduces a new issue
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "mathutil.h"
|
||||
|
||||
sf::Texture cScrollbar::scroll_gw;
|
||||
tessel_ref_t cScrollbar::bar_tessel[2];
|
||||
|
||||
cScrollbar::cScrollbar(cDialog& parent) : cControl(CTRL_SCROLL, parent) {}
|
||||
|
||||
@@ -19,6 +20,10 @@ cScrollbar::cScrollbar(sf::RenderWindow& parent) : cControl(CTRL_SCROLL, parent)
|
||||
|
||||
void cScrollbar::init() {
|
||||
scroll_gw.loadFromImage(*ResMgr::get<ImageRsrc>("dlogscroll"));
|
||||
RECT bar_rect = {0,48,16,64};
|
||||
bar_tessel[0] = prepareForTiling(scroll_gw, bar_rect);
|
||||
bar_rect.offset(0,16);
|
||||
bar_tessel[1] = prepareForTiling(scroll_gw, bar_rect);
|
||||
}
|
||||
|
||||
bool cScrollbar::isClickable(){
|
||||
@@ -149,7 +154,7 @@ sf::Color cScrollbar::getColour() throw(xUnsupportedProp) {
|
||||
|
||||
void cScrollbar::draw() {
|
||||
if(!isVisible()) return;
|
||||
static const RECT up_rect = {0,0,16,16}, down_rect = {0,16,16,32}, thumb_rect = {0,32,16,48}, bar_rect = {0,48,16,64};
|
||||
static const RECT up_rect = {0,0,16,16}, down_rect = {0,16,16,32}, thumb_rect = {0,32,16,48};
|
||||
int bar_height = frame.height() - 32;
|
||||
inWindow->setActive();
|
||||
RECT draw_rect = frame, from_rect = up_rect;
|
||||
@@ -160,10 +165,8 @@ void cScrollbar::draw() {
|
||||
if(pos > 0) {
|
||||
draw_rect.top = draw_rect.bottom;
|
||||
draw_rect.height() = pos * (bar_height - 16) / max;
|
||||
from_rect = bar_rect;
|
||||
if(depressed && pressedPart == PART_PGUP)
|
||||
from_rect.offset(0,16);
|
||||
tileImage(*inWindow, draw_rect, scroll_gw, from_rect);
|
||||
bool pressed = depressed && pressedPart == PART_PGUP;
|
||||
tileImage(*inWindow, draw_rect, bar_tessel[pressed]);
|
||||
}
|
||||
draw_rect.top = draw_rect.bottom;
|
||||
draw_rect.height() = 16;
|
||||
@@ -174,10 +177,8 @@ void cScrollbar::draw() {
|
||||
if(pos < max) {
|
||||
draw_rect.top = draw_rect.bottom;
|
||||
draw_rect.bottom = frame.bottom - 16;
|
||||
from_rect = bar_rect;
|
||||
if(depressed && pressedPart == PART_PGDN)
|
||||
from_rect.offset(0,16);
|
||||
tileImage(*inWindow, draw_rect, scroll_gw, from_rect);
|
||||
bool pressed = depressed && pressedPart == PART_PGDN;
|
||||
tileImage(*inWindow, draw_rect, bar_tessel[pressed]);
|
||||
}
|
||||
draw_rect = frame;
|
||||
draw_rect.top = draw_rect.bottom - 16;
|
||||
|
Reference in New Issue
Block a user