- enhancement: Folding button scales with editor font.
This commit is contained in:
parent
a3e6d111f8
commit
46b273a88d
1
NEWS.md
1
NEWS.md
|
@ -55,6 +55,7 @@ Red Panda C++ Version 2.27
|
||||||
- enhancement: Make output in the debug console cleaner.
|
- enhancement: Make output in the debug console cleaner.
|
||||||
- enhancement: Execute the last debug command in the debug console if ENTER pressed.
|
- enhancement: Execute the last debug command in the debug console if ENTER pressed.
|
||||||
- change: When debugging, don't auto set focus to the editor.
|
- change: When debugging, don't auto set focus to the editor.
|
||||||
|
- enhancement: Folding button scales with editor font.
|
||||||
|
|
||||||
Red Panda C++ Version 2.26
|
Red Panda C++ Version 2.26
|
||||||
- enhancement: Code suggestion for embedded std::vectors.
|
- enhancement: Code suggestion for embedded std::vectors.
|
||||||
|
|
|
@ -5275,7 +5275,7 @@ void Editor::applySettings()
|
||||||
|
|
||||||
// Set gutter properties
|
// Set gutter properties
|
||||||
gutter().setLeftOffset(pointToPixel(pSettings->editor().fontSize()) + pSettings->editor().gutterLeftOffset());
|
gutter().setLeftOffset(pointToPixel(pSettings->editor().fontSize()) + pSettings->editor().gutterLeftOffset());
|
||||||
gutter().setRightOffset(pSettings->editor().gutterRightOffset());
|
gutter().setRightOffset(pointToPixel(pSettings->editor().fontSize()) + pSettings->editor().gutterRightOffset());
|
||||||
gutter().setBorderStyle(QSynedit::GutterBorderStyle::None);
|
gutter().setBorderStyle(QSynedit::GutterBorderStyle::None);
|
||||||
gutter().setUseFontStyle(pSettings->editor().gutterUseCustomFont());
|
gutter().setUseFontStyle(pSettings->editor().gutterUseCustomFont());
|
||||||
if (pSettings->editor().gutterUseCustomFont()) {
|
if (pSettings->editor().gutterUseCustomFont()) {
|
||||||
|
|
|
@ -1365,7 +1365,7 @@ void Settings::Editor::doSave()
|
||||||
saveValue("gutter_visible", mGutterVisible);
|
saveValue("gutter_visible", mGutterVisible);
|
||||||
saveValue("gutter_auto_size", mGutterAutoSize);
|
saveValue("gutter_auto_size", mGutterAutoSize);
|
||||||
saveValue("gutter_left_offset",mGutterLeftOffset);
|
saveValue("gutter_left_offset",mGutterLeftOffset);
|
||||||
saveValue("gutter_right_offset",mGutterRightOffset);
|
saveValue("gutter_right_offset2",mGutterRightOffset);
|
||||||
saveValue("gutter_digits_count", mGutterDigitsCount);
|
saveValue("gutter_digits_count", mGutterDigitsCount);
|
||||||
saveValue("gutter_show_line_numbers",mGutterShowLineNumbers);
|
saveValue("gutter_show_line_numbers",mGutterShowLineNumbers);
|
||||||
saveValue("gutter_add_leading_zero",mGutterAddLeadingZero);
|
saveValue("gutter_add_leading_zero",mGutterAddLeadingZero);
|
||||||
|
@ -1514,7 +1514,11 @@ void Settings::Editor::doLoad()
|
||||||
mGutterVisible = boolValue("gutter_visible",true);
|
mGutterVisible = boolValue("gutter_visible",true);
|
||||||
mGutterAutoSize = boolValue("gutter_auto_size",true);
|
mGutterAutoSize = boolValue("gutter_auto_size",true);
|
||||||
mGutterLeftOffset = intValue("gutter_left_offset",6);
|
mGutterLeftOffset = intValue("gutter_left_offset",6);
|
||||||
mGutterRightOffset = intValue("gutter_right_offset",24);
|
mGutterRightOffset = intValue("gutter_right_offset",-1);
|
||||||
|
if (mGutterRightOffset>0)
|
||||||
|
mGutterRightOffset = std::max(0, mGutterRightOffset-20);
|
||||||
|
else
|
||||||
|
mGutterRightOffset = intValue("gutter_right_offset2",4);
|
||||||
mGutterDigitsCount = intValue("gutter_digits_count",1);
|
mGutterDigitsCount = intValue("gutter_digits_count",1);
|
||||||
mGutterShowLineNumbers = boolValue("gutter_show_line_numbers",true);
|
mGutterShowLineNumbers = boolValue("gutter_show_line_numbers",true);
|
||||||
mGutterAddLeadingZero = boolValue("gutter_add_leading_zero",false);
|
mGutterAddLeadingZero = boolValue("gutter_add_leading_zero",false);
|
||||||
|
|
|
@ -160,6 +160,7 @@ void QSynEditPainter::paintGutter(const QRect& clip)
|
||||||
|
|
||||||
// Draw the folding lines and squares
|
// Draw the folding lines and squares
|
||||||
if (mEdit->useCodeFolding()) {
|
if (mEdit->useCodeFolding()) {
|
||||||
|
int lineWidth = std::max(0.0,std::ceil(mEdit->font().pixelSize() / 15));
|
||||||
for (int row = mLastRow; row>= mFirstRow; row--) {
|
for (int row = mLastRow; row>= mFirstRow; row--) {
|
||||||
int line = mEdit->rowToLine(row);
|
int line = mEdit->rowToLine(row);
|
||||||
if ((line > mEdit->mDocument->count()) && (mEdit->mDocument->count() != 0))
|
if ((line > mEdit->mDocument->count()) && (mEdit->mDocument->count() != 0))
|
||||||
|
@ -171,7 +172,7 @@ void QSynEditPainter::paintGutter(const QRect& clip)
|
||||||
rcFold.setRight(rcFold.left() + mEdit->mGutter.rightOffset() - 4);
|
rcFold.setRight(rcFold.left() + mEdit->mGutter.rightOffset() - 4);
|
||||||
rcFold.setBottom(rcFold.top() + mEdit->mTextHeight);
|
rcFold.setBottom(rcFold.top() + mEdit->mTextHeight);
|
||||||
|
|
||||||
mPainter->setPen(mEdit->mCodeFolding.folderBarLinesColor);
|
mPainter->setPen(QPen(mEdit->mCodeFolding.folderBarLinesColor,lineWidth));
|
||||||
|
|
||||||
// Need to paint a line?
|
// Need to paint a line?
|
||||||
if (mEdit->foldAroundLine(line)) {
|
if (mEdit->foldAroundLine(line)) {
|
||||||
|
@ -200,24 +201,28 @@ void QSynEditPainter::paintGutter(const QRect& clip)
|
||||||
|
|
||||||
// make a square rect
|
// make a square rect
|
||||||
inflateRect(rcFold,-2, 0);
|
inflateRect(rcFold,-2, 0);
|
||||||
rcFold.setTop(
|
int size = std::min(mEdit->font().pixelSize() * 4 / 5, mEdit->mGutter.rightOffset()) - lineWidth;
|
||||||
rcFold.top() + ((mEdit->mTextHeight - rcFold.width()) / 2));
|
float centerX = rcFold.left() + rcFold.width() / 2.0;
|
||||||
rcFold.setBottom(rcFold.top() + rcFold.width());
|
float centerY = rcFold.top() + rcFold.height() / 2.0;
|
||||||
|
float halfSize = size / 2.0;
|
||||||
|
rcFold.setLeft(centerX - halfSize);
|
||||||
|
rcFold.setRight(centerX + halfSize);
|
||||||
|
rcFold.setTop(centerY - halfSize);
|
||||||
|
rcFold.setBottom(centerY + halfSize);
|
||||||
|
|
||||||
// Paint the square the user can click on
|
// Paint the square the user can click on
|
||||||
mPainter->setBrush(mEdit->mGutter.color());
|
mPainter->setBrush(mEdit->mGutter.color());
|
||||||
mPainter->setPen(mEdit->mCodeFolding.folderBarLinesColor);
|
//mPainter->setPen(mEdit->mCodeFolding.folderBarLinesColor);
|
||||||
mPainter->drawRect(rcFold);
|
mPainter->drawRect(rcFold);
|
||||||
|
|
||||||
// Paint minus sign
|
// Paint minus sign
|
||||||
mPainter->drawLine(
|
mPainter->drawLine(
|
||||||
rcFold.left() + 2, rcFold.top() + (rcFold.height() / 2 ),
|
rcFold.left() + lineWidth * 2 , centerY,
|
||||||
rcFold.right() - 2, rcFold.top() + (rcFold.height() / 2 ));
|
rcFold.right() - lineWidth * 2 , centerY );
|
||||||
// Paint vertical line of plus sign
|
// Paint vertical line of plus sign
|
||||||
if (foldRange->collapsed) {
|
if (foldRange->collapsed) {
|
||||||
x = rcFold.left() + (rcFold.width() / 2);
|
mPainter->drawLine(centerX, rcFold.top() + lineWidth * 2,
|
||||||
mPainter->drawLine(x, rcFold.top() + 2,
|
centerX, rcFold.bottom() - lineWidth * 2 );
|
||||||
x, rcFold.bottom() - 2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3220,8 +3220,7 @@ void QSynEdit::recalcCharExtent()
|
||||||
mTextHeight = 0;
|
mTextHeight = 0;
|
||||||
mCharWidth = 0;
|
mCharWidth = 0;
|
||||||
QFontMetrics fm(font());
|
QFontMetrics fm(font());
|
||||||
QFontMetrics fm2(font());
|
mTextHeight = fm.lineSpacing();
|
||||||
mTextHeight = std::max(fm.lineSpacing(),fm2.lineSpacing());
|
|
||||||
mCharWidth = fm.horizontalAdvance("M");
|
mCharWidth = fm.horizontalAdvance("M");
|
||||||
|
|
||||||
if (hasStyles[0]) { // has bold font
|
if (hasStyles[0]) { // has bold font
|
||||||
|
|
Loading…
Reference in New Issue