call redraw_everything() when cDialogs move
This commit is contained in:
@@ -35,6 +35,7 @@ extern sf::Texture bg_gworld;
|
||||
const short cDialog::BG_DARK = 5, cDialog::BG_LIGHT = 16;
|
||||
short cDialog::defaultBackground = cDialog::BG_DARK;
|
||||
cDialog* cDialog::topWindow = nullptr;
|
||||
void (*cDialog::redraw_everything)() = nullptr;
|
||||
|
||||
std::string cDialog::generateRandomString(){
|
||||
// Not bothering to seed, because it doesn't actually matter if it's truly random.
|
||||
@@ -517,7 +518,9 @@ void cDialog::run(std::function<void(cDialog&)> onopen){
|
||||
win.create(sf::VideoMode(1,1),"");
|
||||
win.close();
|
||||
win.create(sf::VideoMode(winRect.width(), winRect.height()), "Dialog", sf::Style::Titlebar);
|
||||
win.setPosition({parentPos.x + int(parentSz.x - winRect.width()) / 2, parentPos.y + int(parentSz.y - winRect.height()) / 2});
|
||||
winLastX = parentPos.x + int(parentSz.x - winRect.width()) / 2;
|
||||
winLastY = parentPos.y + int(parentSz.y - winRect.height()) / 2;
|
||||
win.setPosition({winLastX, winLastY});
|
||||
draw();
|
||||
makeFrontWindow(parent ? parent-> win : mainPtr);
|
||||
makeFrontWindow(win);
|
||||
@@ -690,6 +693,15 @@ void cDialog::handle_one_event(const sf::Event& currentEvent) {
|
||||
break;
|
||||
case sf::Event::GainedFocus:
|
||||
case sf::Event::MouseMoved:
|
||||
// Did the window move, potentially dirtying the canvas below it?
|
||||
auto winPosition = win.getPosition();
|
||||
if (winLastX != winPosition.x || winLastY != winPosition.y) {
|
||||
if (redraw_everything != NULL)
|
||||
redraw_everything();
|
||||
}
|
||||
winLastX = winPosition.x;
|
||||
winLastY = winPosition.y;
|
||||
|
||||
bool inField = false;
|
||||
for(auto& ctrl : controls) {
|
||||
if(ctrl.second->getType() == CTRL_FIELD && ctrl.second->getBounds().contains(currentEvent.mouseMove.x, currentEvent.mouseMove.y)) {
|
||||
|
@@ -41,6 +41,8 @@ class cDialog {
|
||||
short bg;
|
||||
sf::Color defTextClr;
|
||||
sf::RenderWindow win;
|
||||
int winLastX=-1;
|
||||
int winLastY=-1;
|
||||
std::string currentFocus;
|
||||
cDialog* parent;
|
||||
std::string generateRandomString();
|
||||
@@ -49,6 +51,7 @@ class cDialog {
|
||||
std::vector<std::pair<std::string,cTextField*>> tabOrder;
|
||||
static cDialog* topWindow; // Tracks the frontmost dialog.
|
||||
public:
|
||||
static void (*redraw_everything)();
|
||||
/// Performs essential startup initialization. Generally should not be called directly.
|
||||
static void init();
|
||||
/// The light background pattern used by the scenario editor dialogs.
|
||||
|
@@ -115,6 +115,8 @@ int main(int argc, char* argv[]) {
|
||||
debug_oldstructs();
|
||||
#endif
|
||||
try{
|
||||
cDialog::redraw_everything = &redraw_everything;
|
||||
|
||||
init_boe(argc, argv);
|
||||
|
||||
if(!get_bool_pref("GameRunBefore"))
|
||||
|
Reference in New Issue
Block a user