Don't create a new texture every time tiling is requested, though sadly this introduces a new issue
This commit is contained in:
@@ -80,7 +80,7 @@ void cButton::draw(){
|
||||
// TODO: How is it supposed to know it's a default button when this fact is stored in the dialog, not the button?
|
||||
if(key.spec && key.k == key_enter) drawFrame(2,frameStyle); // frame default button, to provide a visual cue that it's the default
|
||||
}else{
|
||||
tileImage(*inWindow,frame,bg_gworld,bg[parent->getBg()]);
|
||||
tileImage(*inWindow,frame,bg[parent->getBg()]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ void cLed::draw(){
|
||||
to_rect.left = frame.left + 18; // Possibly could be 20
|
||||
win_draw_string(*inWindow,to_rect,lbl,eTextMode::LEFT_TOP,style);
|
||||
}else{
|
||||
tileImage(*inWindow,frame,bg_gworld,bg[parent->getBg()]);
|
||||
tileImage(*inWindow,frame,bg[parent->getBg()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -927,14 +927,24 @@ void cDialog::run(){
|
||||
tabOrder[0].second->triggerFocusHandler(*this, tabOrder[0].first, false);
|
||||
currentFocus = tabOrder[0].first;
|
||||
}
|
||||
// Sometimes it seems like the Cocoa menu handling clobbers the active rendering context.
|
||||
// For whatever reason, delaying 100 milliseconds appears to fix this.
|
||||
sf::sleep(sf::milliseconds(100));
|
||||
win.create(sf::VideoMode(winRect.width(), winRect.height()), "Dialog", sf::Style::Titlebar);
|
||||
win.setActive();
|
||||
win.setVisible(true);
|
||||
makeFrontWindow(win);
|
||||
ModalSession dlog(win);
|
||||
paintTimer.restart();
|
||||
animTimer.restart();
|
||||
draw();
|
||||
while(dialogNotToast){
|
||||
draw();
|
||||
// TODO: This is just a hack to prevent the constant flickering.
|
||||
// All it actually does is slow the flickering to non-blinding frequency.
|
||||
if(paintTimer.getElapsedTime().asMilliseconds() > 500) {
|
||||
draw();
|
||||
paintTimer.restart();
|
||||
}
|
||||
dlog.pumpEvents();
|
||||
if(!win.pollEvent(currentEvent)) continue;
|
||||
location where;
|
||||
@@ -1375,7 +1385,7 @@ bool cDialog::doAnimations = false;
|
||||
|
||||
void cDialog::draw(){
|
||||
win.setActive();
|
||||
tileImage(win,winRect,bg_gworld,::bg[bg]);
|
||||
tileImage(win,winRect,::bg[bg]);
|
||||
if(doAnimations && animTimer.getElapsedTime().asMilliseconds() >= 500) {
|
||||
cPict::advanceAnim();
|
||||
animTimer.restart();
|
||||
|
@@ -170,7 +170,7 @@ private:
|
||||
std::string defaultButton;
|
||||
boost::any result;
|
||||
std::string fname;
|
||||
sf::Clock animTimer;
|
||||
sf::Clock animTimer, paintTimer;
|
||||
friend class cControl;
|
||||
};
|
||||
|
||||
|
@@ -539,7 +539,7 @@ void cPict::draw(){
|
||||
|
||||
if(!visible){ // Erase it
|
||||
rect.inset(-3, -3);
|
||||
tileImage(*inWindow,rect,bg_gworld,bg[parent->getBg()]);
|
||||
tileImage(*inWindow,rect,bg[parent->getBg()]);
|
||||
return;
|
||||
}
|
||||
if(picNum < 0) { // Just fill with black
|
||||
|
@@ -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;
|
||||
|
@@ -13,6 +13,7 @@
|
||||
/// Scrollbar-related classes and types.
|
||||
|
||||
#include "control.h"
|
||||
#include "graphtool.h"
|
||||
|
||||
/// A simple vertical scrollbar.
|
||||
/// This has no coupling with scrollable data; that must be handled externally by
|
||||
@@ -28,6 +29,7 @@ class cScrollbar : public cControl {
|
||||
} pressedPart;
|
||||
click_callback_t onClick;
|
||||
static sf::Texture scroll_gw;
|
||||
static tessel_ref_t bar_tessel[2];
|
||||
public:
|
||||
/// @copydoc cDialog::init()
|
||||
static void init();
|
||||
|
Reference in New Issue
Block a user