mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
dpi
This commit is contained in:
parent
86ae71f674
commit
f36d346a4f
3 changed files with 22 additions and 10 deletions
|
@ -31,28 +31,38 @@ int MessageRef::getHeight() const
|
||||||
}
|
}
|
||||||
|
|
||||||
// return true if redraw is required
|
// return true if redraw is required
|
||||||
bool MessageRef::layout(int width)
|
bool MessageRef::layout(int width, float dpiMultiplyer)
|
||||||
{
|
{
|
||||||
bool layoutRequired = false;
|
bool layoutRequired = false;
|
||||||
|
|
||||||
// check if width changed
|
// check if width changed
|
||||||
const bool widthChanged = width != this->currentLayoutWidth;
|
bool widthChanged = width != this->currentLayoutWidth;
|
||||||
layoutRequired |= widthChanged;
|
layoutRequired |= widthChanged;
|
||||||
this->currentLayoutWidth = width;
|
this->currentLayoutWidth = width;
|
||||||
|
|
||||||
// check if emotes changed
|
// check if emotes changed
|
||||||
const bool imagesChanged = this->emoteGeneration != EmoteManager::instance->getGeneration();
|
bool imagesChanged = this->emoteGeneration != EmoteManager::instance->getGeneration();
|
||||||
layoutRequired |= imagesChanged;
|
layoutRequired |= imagesChanged;
|
||||||
this->emoteGeneration = EmoteManager::instance->getGeneration();
|
this->emoteGeneration = EmoteManager::instance->getGeneration();
|
||||||
|
|
||||||
// check if text changed
|
// check if text changed
|
||||||
const bool textChanged = this->fontGeneration != FontManager::getInstance().getGeneration();
|
bool textChanged = this->fontGeneration != FontManager::getInstance().getGeneration();
|
||||||
layoutRequired |= textChanged;
|
layoutRequired |= textChanged;
|
||||||
this->fontGeneration = FontManager::getInstance().getGeneration();
|
this->fontGeneration = FontManager::getInstance().getGeneration();
|
||||||
|
|
||||||
// check if work mask changed
|
// check if work mask changed
|
||||||
const bool wordMaskChanged =
|
bool wordMaskChanged =
|
||||||
this->currentWordTypes != SettingsManager::getInstance().getWordTypeMask();
|
this->currentWordTypes != SettingsManager::getInstance().getWordTypeMask();
|
||||||
layoutRequired |= wordMaskChanged;
|
layoutRequired |= wordMaskChanged;
|
||||||
this->currentWordTypes = SettingsManager::getInstance().getWordTypeMask();
|
this->currentWordTypes = SettingsManager::getInstance().getWordTypeMask();
|
||||||
|
|
||||||
|
// check if dpi changed
|
||||||
|
bool dpiChanged = this->dpiMultiplyer != dpiMultiplyer;
|
||||||
|
layoutRequired |= dpiChanged;
|
||||||
|
this->dpiMultiplyer = dpiMultiplyer;
|
||||||
|
imagesChanged |= dpiChanged;
|
||||||
|
textChanged |= dpiChanged;
|
||||||
|
|
||||||
// update word sizes if needed
|
// update word sizes if needed
|
||||||
if (imagesChanged) {
|
if (imagesChanged) {
|
||||||
this->updateImageSizes();
|
this->updateImageSizes();
|
||||||
|
@ -213,7 +223,8 @@ void MessageRef::updateTextSizes()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QFontMetrics &metrics = word.getFontMetrics();
|
QFontMetrics &metrics = word.getFontMetrics();
|
||||||
word.setSize(metrics.width(word.getText()), metrics.height());
|
word.setSize((int)(metrics.width(word.getText()) * this->dpiMultiplyer),
|
||||||
|
(int)(metrics.height() * this->dpiMultiplyer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,7 +232,7 @@ void MessageRef::updateImageSizes()
|
||||||
{
|
{
|
||||||
const int mediumTextLineHeight =
|
const int mediumTextLineHeight =
|
||||||
FontManager::getInstance().getFontMetrics(FontManager::Medium).height();
|
FontManager::getInstance().getFontMetrics(FontManager::Medium).height();
|
||||||
const qreal emoteScale = SettingsManager::getInstance().emoteScale.get();
|
const qreal emoteScale = SettingsManager::getInstance().emoteScale.get() * this->dpiMultiplyer;
|
||||||
const bool scaleEmotesByLineHeight =
|
const bool scaleEmotesByLineHeight =
|
||||||
SettingsManager::getInstance().scaleEmotesByLineHeight.get();
|
SettingsManager::getInstance().scaleEmotesByLineHeight.get();
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ public:
|
||||||
Message *getMessage();
|
Message *getMessage();
|
||||||
int getHeight() const;
|
int getHeight() const;
|
||||||
|
|
||||||
bool layout(int width);
|
bool layout(int width, float dpiMultiplyer);
|
||||||
|
|
||||||
const std::vector<WordPart> &getWordParts() const;
|
const std::vector<WordPart> &getWordParts() const;
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ private:
|
||||||
int currentLayoutWidth = -1;
|
int currentLayoutWidth = -1;
|
||||||
int fontGeneration = -1;
|
int fontGeneration = -1;
|
||||||
int emoteGeneration = -1;
|
int emoteGeneration = -1;
|
||||||
|
float dpiMultiplyer = -1;
|
||||||
|
|
||||||
Word::Type currentWordTypes = Word::None;
|
Word::Type currentWordTypes = Word::None;
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,7 @@ void ChannelView::actuallyLayoutMessages()
|
||||||
for (size_t i = start; i < messages.getLength(); ++i) {
|
for (size_t i = start; i < messages.getLength(); ++i) {
|
||||||
auto message = messages[i];
|
auto message = messages[i];
|
||||||
|
|
||||||
redrawRequired |= message->layout(layoutWidth);
|
redrawRequired |= message->layout(layoutWidth, this->getDpiMultiplier());
|
||||||
|
|
||||||
y += message->getHeight();
|
y += message->getHeight();
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ void ChannelView::actuallyLayoutMessages()
|
||||||
for (std::size_t i = messages.getLength() - 1; i > 0; i--) {
|
for (std::size_t i = messages.getLength() - 1; i > 0; i--) {
|
||||||
auto *message = messages[i].get();
|
auto *message = messages[i].get();
|
||||||
|
|
||||||
message->layout(layoutWidth);
|
message->layout(layoutWidth, this->getDpiMultiplier());
|
||||||
|
|
||||||
h -= message->getHeight();
|
h -= message->getHeight();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue