Commit e73dc803 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Implement automatic scaling of the font in the onion skins docker

parent d28bea61
......@@ -23,6 +23,8 @@
#include "kis_equalizer_column.h"
#include "kis_signal_compressor.h"
#include "timeline_color_scheme.h"
#include "kis_debug.h"
......@@ -95,3 +97,22 @@ void KisEqualizerWidget::setValues(const EqualizerValues &v)
}
}
}
void KisEqualizerWidget::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event);
const QSize newSize = m_d->columns[1]->size();
QFont font =
TimelineColorScheme::instance()->getOnionSkinsFont(
QString::number(100), newSize);
if (font.pointSize() != this->font().pointSize()) {
setFont(font);
for (int i = -m_d->maxDistance; i <= m_d->maxDistance; i++) {
m_d->columns[i]->setFont(font);
}
}
}
......@@ -44,6 +44,7 @@ public:
EqualizerValues getValues() const;
void setValues(const EqualizerValues &values);
void resizeEvent(QResizeEvent *event);
Q_SIGNALS:
void sigConfigChanged();
......
......@@ -22,6 +22,9 @@
#include <QColor>
#include <QBrush>
#include <QPalette>
#include <QFont>
#include <QFontMetrics>
#include "kis_debug.h"
......@@ -64,9 +67,6 @@ QColor TimelineColorScheme::selectionColor() const
QColor TimelineColorScheme::activeLayerBackground() const
{
QColor color = qApp->palette().color(QPalette::Highlight);
QColor bgColor = qApp->palette().color(QPalette::Base);
int darkenCoeff = bgColor.value() < 128 ? 130 : 80;
return color;
}
......@@ -123,3 +123,24 @@ QColor TimelineColorScheme::onionSkinsButtonColor() const
const int lighterCoeff = bgColor.value() > 128 ? 120 : 80;
return m_d->baseColor.lighter(lighterCoeff);
}
QFont TimelineColorScheme::getOnionSkinsFont(const QString &maxString, const QSize &availableSize) const
{
QFont font = qApp->font();
while(font.pointSize() > 8) {
QFontMetrics fm(font);
QRect rc = fm.boundingRect(maxString);
if (rc.width() > availableSize.width() ||
rc.height() > availableSize.height()) {
font.setPointSize(font.pointSize() - 1);
} else {
break;
}
}
return font;
}
......@@ -23,6 +23,8 @@
class QColor;
class QBrush;
class QFont;
class QSize;
class TimelineColorScheme
{
......@@ -46,6 +48,8 @@ public:
QColor onionSkinsSliderColor() const;
QColor onionSkinsButtonColor() const;
QFont getOnionSkinsFont(const QString &maxString, const QSize &availableSize) const;
private:
struct Private;
const QScopedPointer<Private> m_d;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment