Krita Source Code Documentation
Loading...
Searching...
No Matches
SvgTextCursor.cpp File Reference
#include "SvgTextCursor.h"
#include "KoCanvasBase.h"
#include "KoColorDisplayRendererInterface.h"
#include "KoSvgTextProperties.h"
#include "SvgTextInsertCommand.h"
#include "SvgTextInsertRichCommand.h"
#include "SvgTextMergePropertiesRangeCommand.h"
#include "SvgTextRemoveCommand.h"
#include "SvgTextRemoveTransformsFromRange.h"
#include "SvgTextShapeManagerBlocker.h"
#include "SvgTextShortCuts.h"
#include "KoSvgTextShapeMarkupConverter.h"
#include "KoSvgPaste.h"
#include "KoColorBackground.h"
#include "KoShapeStroke.h"
#include "KoColor.h"
#include "KoViewConverter.h"
#include "kis_coordinates_converter.h"
#include "kis_painting_tweaks.h"
#include "KoCanvasController.h"
#include "KoCanvasResourceProvider.h"
#include <kis_signal_compressor.h>
#include <KisHandlePainterHelper.h>
#include <kis_acyclic_signal_connector.h>
#include "kundo2command.h"
#include <QTimer>
#include <QDebug>
#include <QClipboard>
#include <QMimeData>
#include <QApplication>
#include <QKeyEvent>
#include <QKeySequence>
#include <QAction>
#include <kis_assert.h>
#include <QInputMethodEvent>
#include <QBuffer>
#include <QWidget>

Go to the source code of this file.

Classes

struct  IMEDecorationInfo
 
class  SvgTextCursor::InputQueryUpdateBlocker
 
struct  SvgTextCursorPropertyInterface::Private
 
class  SvgTextCursor
 The SvgTextCursor class. More...
 
struct  TypeSettingDecorInfo
 

Functions

static QColor bgColorForCaret (QColor c, KisHandlePalette handlePalette, int opacity=64)
 
int calcLineHeight (const KoSvgText::LineHeightInfo &lineHeight, const KoSvgText::FontMetrics &metrics, const qreal scaleMetrics)
 
QTransform posAndRotateTransform (const QPointF pos, const qreal rotateDeg)
 
void processBaseline (const SvgTextCursor::TypeSettingModeHandle handle, const int metric, const bool isHorizontal, QTransform t, const qreal scaleMetrics, const QPointF &advance, QMap< SvgTextCursor::TypeSettingModeHandle, QPainterPath > &decor)
 
void processEdges (QTransform t, QMap< SvgTextCursor::TypeSettingModeHandle, int > values, const bool isHorizontal, const qreal scaleMetrics, const QPointF advance, QPainterPath &path)
 
QMap< SvgTextCursor::TypeSettingModeHandle, int > typeSettingBaselinesFromMetrics (const KoSvgText::FontMetrics metrics, const qreal lineGap, const bool isHorizontal)
 

Function Documentation

◆ bgColorForCaret()

static QColor bgColorForCaret ( QColor c,
KisHandlePalette handlePalette,
int opacity = 64 )
static

Definition at line 835 of file SvgTextCursor.cpp.

836{
838 return QColor(handlePalette.black.red(), handlePalette.black.green(), handlePalette.black.blue(), opacity);
839 } else {
840 return QColor(handlePalette.white.red(), handlePalette.white.green(), handlePalette.white.blue(), opacity);
841 }
842}
qreal luminosityCoarse(const QColor &c, bool sRGBtrc)
luminosityCoarse This calculates the luminosity of the given QColor. It uses a very coarse (10 step) ...

References KisHandlePalette::black, KisPaintingTweaks::luminosityCoarse(), and KisHandlePalette::white.

◆ calcLineHeight()

int calcLineHeight ( const KoSvgText::LineHeightInfo & lineHeight,
const KoSvgText::FontMetrics & metrics,
const qreal scaleMetrics )

Lineheight calculation is a little tricky sometimes... Maybe we should generalize this so the one in the layout and this one uses the same base function.

Definition at line 1792 of file SvgTextCursor.cpp.

1792 {
1793 if (!lineHeight.isNormal) {
1794 if (lineHeight.isNumber) {
1795 return (lineHeight.value * (metrics.ascender-metrics.descender))-(metrics.ascender-metrics.descender);
1796 } else {
1797 return (lineHeight.length.value/scaleMetrics)-(metrics.ascender-metrics.descender);
1798 }
1799 }
1800 return metrics.lineGap;
1801}
qint32 lineGap
additional linegap between consecutive lines.
Definition KoSvgText.h:341
qint32 descender
distance for origin to bottom.
Definition KoSvgText.h:340
qint32 ascender
distance from origin to top.
Definition KoSvgText.h:339
bool isNumber
Length or number.
Definition KoSvgText.h:695
CssLengthPercentage length
Definition KoSvgText.h:693
bool isNormal
It's a number indicating the lineHeight;.
Definition KoSvgText.h:696

References KoSvgText::FontMetrics::ascender, KoSvgText::FontMetrics::descender, KoSvgText::LineHeightInfo::isNormal, KoSvgText::LineHeightInfo::isNumber, KoSvgText::LineHeightInfo::length, KoSvgText::FontMetrics::lineGap, KoSvgText::CssLengthPercentage::value, and KoSvgText::LineHeightInfo::value.

◆ posAndRotateTransform()

QTransform posAndRotateTransform ( const QPointF pos,
const qreal rotateDeg )

Definition at line 1847 of file SvgTextCursor.cpp.

1847 {
1848 QTransform t = QTransform::fromTranslate(pos.x(), pos.y());
1849 t.rotate(rotateDeg);
1850 return t;
1851}

◆ processBaseline()

void processBaseline ( const SvgTextCursor::TypeSettingModeHandle handle,
const int metric,
const bool isHorizontal,
QTransform t,
const qreal scaleMetrics,
const QPointF & advance,
QMap< SvgTextCursor::TypeSettingModeHandle, QPainterPath > & decor )

Definition at line 1803 of file SvgTextCursor.cpp.

1807 {
1808 QPointF offset = isHorizontal? QPointF(0, -(metric*scaleMetrics)): QPointF(metric*scaleMetrics, 0);
1809
1810 QPainterPath p = decor.value(handle);
1811
1812 const QPointF startPos = t.map(offset);
1813 const QPointF endPos = t.map(offset+advance);
1814 if (p.currentPosition() != startPos) {
1815 p.moveTo(startPos);
1816 }
1817 p.lineTo(endPos);
1818
1819 decor.insert(handle, p);
1820}
const Params2D p

References p.

◆ processEdges()

void processEdges ( QTransform t,
QMap< SvgTextCursor::TypeSettingModeHandle, int > values,
const bool isHorizontal,
const qreal scaleMetrics,
const QPointF advance,
QPainterPath & path )

Definition at line 1822 of file SvgTextCursor.cpp.

1826 {
1827 QPointF p1(values.first(), 0);
1828 QPointF p2(values.last(), 0);
1829 Q_FOREACH(const int val, values) {
1830 if (val < p1.x()) {
1831 p1.setX(val);
1832 }
1833 if (val > p2.x()) {
1834 p2.setX(val);
1835 }
1836 }
1837 if (isHorizontal) {
1838 p1 = QPointF(p1.y(), -p1.x());
1839 p2 = QPointF(p2.y(), -p2.x());
1840 }
1841 p1 *= scaleMetrics;
1842 p2 *= scaleMetrics;
1843 path.moveTo(t.map(p1+advance));
1844 path.lineTo(t.map(p2+advance));
1845}
QPointF p2
QPointF p1

References p1, and p2.

◆ typeSettingBaselinesFromMetrics()

QMap< SvgTextCursor::TypeSettingModeHandle, int > typeSettingBaselinesFromMetrics ( const KoSvgText::FontMetrics metrics,
const qreal lineGap,
const bool isHorizontal )

Definition at line 539 of file SvgTextCursor.cpp.

539 {
540 return QMap<SvgTextCursor::TypeSettingModeHandle, int> {
548 {SvgTextCursor::BaselineMiddle, isHorizontal? metrics.xHeight/2: metrics.ideographicCenterBaseline},
549 {SvgTextCursor::LineHeightTop, metrics.ascender+(lineGap/2)},
550 {SvgTextCursor::LineHeightBottom, metrics.descender-(lineGap/2)},
552 };
553}
qint32 ideographicCenterBaseline
default baseline for vertical, centered between over and under.
Definition KoSvgText.h:347
qint32 ideographicUnderBaseline
location of ideographic under baseline from origin, may fall back to descender.
Definition KoSvgText.h:346
qint32 xHeight
height of X, defaults to 0.5 fontsize.
Definition KoSvgText.h:334
qint32 alphabeticBaseline
location of alphabetic baseline from origin.
Definition KoSvgText.h:343
qint32 mathematicalBaseline
location of mathematical baseline from origin.
Definition KoSvgText.h:344
qint32 hangingBaseline
location of the hanging baseline used in north brahmic scripts.
Definition KoSvgText.h:354
@ BaselineAlphabetic
Baselines.
@ BaselineShift
The text properties handles.

References KoSvgText::FontMetrics::alphabeticBaseline, KoSvgText::FontMetrics::ascender, SvgTextCursor::Ascender, SvgTextCursor::BaselineAlphabetic, SvgTextCursor::BaselineCentral, SvgTextCursor::BaselineHanging, SvgTextCursor::BaselineIdeographic, SvgTextCursor::BaselineMathematical, SvgTextCursor::BaselineMiddle, SvgTextCursor::BaselineShift, KoSvgText::FontMetrics::descender, SvgTextCursor::Descender, KoSvgText::FontMetrics::hangingBaseline, KoSvgText::FontMetrics::ideographicCenterBaseline, KoSvgText::FontMetrics::ideographicUnderBaseline, SvgTextCursor::LineHeightBottom, SvgTextCursor::LineHeightTop, KoSvgText::FontMetrics::mathematicalBaseline, and KoSvgText::FontMetrics::xHeight.