Refactor rendering to use an SFML view for placing the main UI within the overall interface
This commit is contained in:
@@ -203,11 +203,15 @@ bool cControl::handleClick(location){
|
||||
if(!inWindow->pollEvent(e)) continue;
|
||||
if(e.type == sf::Event::MouseButtonReleased){
|
||||
done = true;
|
||||
clicked = frame.contains(e.mouseButton.x, e.mouseButton.y);
|
||||
location clickPos(e.mouseButton.x, e.mouseButton.y);
|
||||
clickPos = inWindow->mapPixelToCoords(clickPos);
|
||||
clicked = frame.contains(clickPos);
|
||||
depressed = false;
|
||||
} else if(e.type == sf::Event::MouseMoved){
|
||||
restore_cursor();
|
||||
depressed = frame.contains(e.mouseMove.x, e.mouseMove.y);
|
||||
location toPos(e.mouseMove.x, e.mouseMove.y);
|
||||
toPos = inWindow->mapPixelToCoords(toPos);
|
||||
depressed = frame.contains(toPos);
|
||||
}
|
||||
}
|
||||
if(get_bool_pref("PlaySounds", true)) {
|
||||
|
||||
@@ -146,6 +146,7 @@ bool cTextField::handleClick(location clickLoc) {
|
||||
} else if(e.type == sf::Event::MouseMoved){
|
||||
restore_cursor();
|
||||
location newLoc(e.mouseMove.x, e.mouseMove.y);
|
||||
newLoc = inWindow->mapPixelToCoords(newLoc);
|
||||
set_ip(newLoc, &cTextField::selectionPoint);
|
||||
if(is_double) {
|
||||
if(selectionPoint > initial_ip) {
|
||||
|
||||
@@ -111,11 +111,14 @@ bool cScrollbar::handleClick(location where) {
|
||||
while(!done){
|
||||
redraw();
|
||||
if(!inWindow->pollEvent(e)) continue;
|
||||
sf::Vector2i mouseLoc = sf::Mouse::getPosition(*inWindow);
|
||||
location mouseLoc = sf::Mouse::getPosition(*inWindow);
|
||||
mouseLoc = inWindow->mapPixelToCoords(mouseLoc);
|
||||
int mousePos = vert ? mouseLoc.y : mouseLoc.x;
|
||||
if(e.type == sf::Event::MouseButtonReleased){
|
||||
done = true;
|
||||
clicked = frame.contains(e.mouseButton.x, e.mouseButton.y);
|
||||
location clickLoc(e.mouseButton.x, e.mouseButton.y);
|
||||
clickLoc = inWindow->mapPixelToCoords(clickLoc);
|
||||
clicked = frame.contains(clickLoc);
|
||||
depressed = false;
|
||||
switch(pressedPart) {
|
||||
case PART_UP: pos--; break;
|
||||
@@ -147,7 +150,9 @@ bool cScrollbar::handleClick(location where) {
|
||||
depressed = mousePos >= bar_end - btn_size;
|
||||
break;
|
||||
}
|
||||
if(pressedPart != PART_THUMB && !frame.contains(e.mouseMove.x, e.mouseMove.y)) depressed = false;
|
||||
location toLoc(e.mouseMove.x, e.mouseMove.y);
|
||||
toLoc = inWindow->mapPixelToCoords(toLoc);
|
||||
if(pressedPart != PART_THUMB && !frame.contains(toLoc)) depressed = false;
|
||||
}
|
||||
pos = minmax(0,max,pos);
|
||||
if(parent && !link.empty())
|
||||
|
||||
Reference in New Issue
Block a user