diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-04-23 20:21:11 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2018-04-23 20:21:17 +0200 |
commit | b0bfb8b8d1479502bd5adf17e6a1b94ec00c63ca (patch) | |
tree | 8c8471f9c03f602f32ce0c9ba7dcd7a2caec1f6c /src | |
parent | 39936316f2f080bd216abd9ed49d36ba1006854d (diff) |
Fix issue where text is not visible if window is too small, set window minimum size
Diffstat (limited to 'src')
-rw-r--r-- | src/Channel.cpp | 5 | ||||
-rw-r--r-- | src/Text.cpp | 6 | ||||
-rw-r--r-- | src/main.cpp | 10 |
3 files changed, 14 insertions, 7 deletions
diff --git a/src/Channel.cpp b/src/Channel.cpp index 347a6a6..d7d6dc5 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -44,11 +44,6 @@ namespace dchat Message *message = new Message(&localOfflineUser, u8"Message after big emoji"); messageBoard.addMessage(message); } - - { - Message *message = new Message(&localOfflineUser, u8"aaa\n[emoji](https://discordemoji.com/assets/emoji/Feels3DMan.gif)\nbbb"); - messageBoard.addMessage(message); - } } Channel::~Channel() diff --git a/src/Text.cpp b/src/Text.cpp index fc3effe..fa46277 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -318,7 +318,11 @@ namespace dchat pos.y += floor(vspace); // Origin is at bottom left, we want it to be at top left // TODO: Do not use maxWidth here. Max width might be set to 99999 and actual text width might be 200. Text width should be calculated instead - if(pos.x + maxWidth <= 0.0f || pos.x >= maxWidth || pos.y + totalHeight <= 0.0f || pos.y >= target.getSize().y) return; + //sf::FloatRect targetRect(0.0f, 0.0f, maxWidth, target.getSize().y); + //sf::FloatRect textRect(pos.x, pos.y, maxWidth, ) + //colRect.contains() + //if(pos.x + maxWidth <= 0.0f || pos.x >= maxWidth || pos.y + totalHeight <= 0.0f || pos.y >= target.getSize().y) return; + if(pos.y + totalHeight <= 0.0f || pos.y >= target.getSize().y) return; states.transform.translate(pos); states.texture = &font.getTexture(characterSize); diff --git a/src/main.cpp b/src/main.cpp index 6d9a9c0..3cebfe7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -45,7 +45,15 @@ int main(int argc, char **argv) window.close(); else if(event.type == sf::Event::Resized) { - sf::View view(sf::FloatRect(0.0f, 0.0f, event.size.width, event.size.height)); + sf::FloatRect viewRect(0.0f, 0.0f, event.size.width, event.size.height); + const int minWidth = 800; + if(event.size.width < minWidth) + { + viewRect.width = minWidth; + window.setSize(sf::Vector2u(minWidth, event.size.height)); + } + + sf::View view(viewRect); window.setView(view); } channel.processEvent(event); |