Merge pull request #251 from x-qq/fix_scrollbar_segfaults

fix for scrollbar segfaults

* fixes #206
* fixes broken mousewheel scrolling of the scenedit palette
* removed boost threads dependency
* added foundation for further refactoring of the drawing and event handling code: interfaces and drawable manager with layering
* removed a bunch of unneeded redraw calls
* removed some repeated recalculation of effectively constant values (boe.actions)
* removed recalculation of effectively constant scrollbar and button positions (boe.graphics)

Closes #251
This commit is contained in:
2020-02-09 15:55:51 -05:00
parent f141149287
commit deac7b0cb6
27 changed files with 444 additions and 219 deletions

View File

@@ -1777,25 +1777,12 @@ void handle_keystroke(sf::Event event) {
}
void handle_scroll(const sf::Event& event) {
rectangle pal_rect = terrain_buttons_rect, right_area_rect = {0,0,RIGHT_AREA_HEIGHT,RIGHT_AREA_WIDTH};
right_area_rect.offset(RIGHT_AREA_UL_X, RIGHT_AREA_UL_Y);
pal_rect.offset(RIGHT_AREA_UL_X,RIGHT_AREA_UL_Y);
pal_rect.height() = 16 * 17 + 2;
fill_rect(mainPtr, right_area_rect, sf::Color::Magenta);
location pos { translate_mouse_coordinates({event.mouseMove.x,event.mouseMove.y}) };
int amount = event.mouseWheel.delta;
if(right_sbar->isVisible() && pos.in(right_area_rect)) {
right_sbar->setPosition(right_sbar->getPosition() - amount);
redraw_screen();
} else if(pal_sbar->isVisible() && pos.in(pal_rect)) {
pal_sbar->setPosition(pal_sbar->getPosition() - amount);
set_up_terrain_buttons(false);
redraw_screen();
} else if(overall_mode < MODE_MAIN_SCREEN && pos.in(terrain_rect)) {
if(overall_mode < MODE_MAIN_SCREEN && pos.in(terrain_rect)) {
if(sf::Keyboard::isKeyPressed(sf::Keyboard::LControl) || sf::Keyboard::isKeyPressed(sf::Keyboard::RControl))
cen_x = minmax(4, town->max_dim - 5, cen_x - amount);
else cen_y = minmax(4, town->max_dim - 5, cen_y - amount);
redraw_screen();
}
}