mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Add 'mLineHeight' properrty to 'DarkEditWidget' to control line height.
This commit is contained in:
parent
8194f58f59
commit
fa96e0783c
4 changed files with 34 additions and 20 deletions
|
@ -894,11 +894,11 @@ namespace Beefy.gfx
|
||||||
return (int32)theString.Length;
|
return (int32)theString.Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float GetLineSpacing()
|
public float GetLineSpacing(float heightMultiplier = 1.0f)
|
||||||
{
|
{
|
||||||
if (mFTFont == null)
|
if (mFTFont == null)
|
||||||
return 0;
|
return 0;
|
||||||
return mFTFont.mHeight;
|
return mFTFont.mHeight * heightMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float GetHeight()
|
public float GetHeight()
|
||||||
|
|
|
@ -50,6 +50,7 @@ namespace Beefy.theme.dark
|
||||||
}
|
}
|
||||||
|
|
||||||
public Font mFont;
|
public Font mFont;
|
||||||
|
public float mLineHeight = 1.0f;
|
||||||
public uint32[] mTextColors = sDefaultColors;
|
public uint32[] mTextColors = sDefaultColors;
|
||||||
public uint32 mHiliteColor = 0xFF2f5c88;
|
public uint32 mHiliteColor = 0xFF2f5c88;
|
||||||
public uint32 mUnfocusedHiliteColor = 0x00000000;
|
public uint32 mUnfocusedHiliteColor = 0x00000000;
|
||||||
|
@ -104,7 +105,7 @@ namespace Beefy.theme.dark
|
||||||
mLineCoords.GrowUninitialized(mData.mLineStarts.Count);
|
mLineCoords.GrowUninitialized(mData.mLineStarts.Count);
|
||||||
mLineCoordJumpTable.Clear();
|
mLineCoordJumpTable.Clear();
|
||||||
|
|
||||||
float fontHeight = mFont.GetLineSpacing();
|
float fontHeight = mFont.GetLineSpacing(mLineHeight);
|
||||||
int prevJumpIdx = -1;
|
int prevJumpIdx = -1;
|
||||||
float jumpCoordSpacing = GetJumpCoordSpacing();
|
float jumpCoordSpacing = GetJumpCoordSpacing();
|
||||||
|
|
||||||
|
@ -214,6 +215,13 @@ namespace Beefy.theme.dark
|
||||||
return defaultVal;
|
return defaultVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float GetTextOffset()
|
||||||
|
{
|
||||||
|
float baseLineSpacing = mFont.GetLineSpacing();
|
||||||
|
float lineSpacing = mFont.GetLineSpacing(mLineHeight);
|
||||||
|
return lineSpacing / 2.0f - baseLineSpacing / 2.0f;
|
||||||
|
}
|
||||||
|
|
||||||
public int FindUncollapsedLine(int line)
|
public int FindUncollapsedLine(int line)
|
||||||
{
|
{
|
||||||
var line;
|
var line;
|
||||||
|
@ -509,7 +517,7 @@ namespace Beefy.theme.dark
|
||||||
((embed.mKind == .HideLine) && (!hideLine)))
|
((embed.mKind == .HideLine) && (!hideLine)))
|
||||||
selStartX += GS!(4);
|
selStartX += GS!(4);
|
||||||
|
|
||||||
Rect rect = .(selStartX, mLineCoords[lineIdx] - GS!(1), embed.GetWidth(hideLine), mFont.GetLineSpacing() + GS!(3));
|
Rect rect = .(selStartX, mLineCoords[lineIdx] - GS!(1) + GetTextOffset(), embed.GetWidth(hideLine), mFont.GetLineSpacing() + GS!(3));
|
||||||
if (rect.mY < 0)
|
if (rect.mY < 0)
|
||||||
rect.mY = 0;
|
rect.mY = 0;
|
||||||
return rect;
|
return rect;
|
||||||
|
@ -526,7 +534,9 @@ namespace Beefy.theme.dark
|
||||||
|
|
||||||
#unwarn
|
#unwarn
|
||||||
int lineCount = GetLineCount();
|
int lineCount = GetLineCount();
|
||||||
float lineSpacing = mFont.GetLineSpacing();
|
float lineSpacing = mFont.GetLineSpacing(mLineHeight);
|
||||||
|
float fontLineSpacing = mFont.GetLineSpacing();
|
||||||
|
float textYOffset = GetTextOffset();
|
||||||
|
|
||||||
float offsetY = mTextInsets.mTop;
|
float offsetY = mTextInsets.mTop;
|
||||||
if (mHeight < lineSpacing)
|
if (mHeight < lineSpacing)
|
||||||
|
@ -565,7 +575,7 @@ namespace Beefy.theme.dark
|
||||||
{
|
{
|
||||||
if (mHiliteCurrentLine && selStartIdx == selEndIdx)
|
if (mHiliteCurrentLine && selStartIdx == selEndIdx)
|
||||||
{
|
{
|
||||||
float thickness = 2 * (lineSpacing / 18);
|
float thickness = 2 * (fontLineSpacing / 18);
|
||||||
// This isn't quite the right value, but I'm not sure how to get this
|
// This isn't quite the right value, but I'm not sure how to get this
|
||||||
// to properly highlight the whole line without getting cut off - this works well for now.
|
// to properly highlight the whole line without getting cut off - this works well for now.
|
||||||
float totalLineWidth = mEditWidget.mScrollContentContainer.mWidth - thickness;
|
float totalLineWidth = mEditWidget.mScrollContentContainer.mWidth - thickness;
|
||||||
|
@ -596,18 +606,18 @@ namespace Beefy.theme.dark
|
||||||
if (mCharWidth <= 2)
|
if (mCharWidth <= 2)
|
||||||
{
|
{
|
||||||
using (g.PushColor(Color.Mult(cursorColor, Color.Get(brightness * 0.75f))))
|
using (g.PushColor(Color.Mult(cursorColor, Color.Get(brightness * 0.75f))))
|
||||||
g.FillRect(x, y, GS!(2), lineSpacing);
|
g.FillRect(x, y + textYOffset, GS!(2), fontLineSpacing);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
using (g.PushColor(Color.Mult(cursorColor, Color.Get(brightness * 0.30f))))
|
using (g.PushColor(Color.Mult(cursorColor, Color.Get(brightness * 0.30f))))
|
||||||
g.FillRect(x, y, mCharWidth, lineSpacing);
|
g.FillRect(x, y + textYOffset, mCharWidth, fontLineSpacing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
using (g.PushColor(Color.Mult(cursorColor, Color.Get(brightness))))
|
using (g.PushColor(Color.Mult(cursorColor, Color.Get(brightness))))
|
||||||
g.FillRect(x, y, Math.Max(1.0f, GS!(1)), lineSpacing);
|
g.FillRect(x, y + textYOffset, Math.Max(1.0f, GS!(1)), fontLineSpacing);
|
||||||
}
|
}
|
||||||
drewCursor = true;
|
drewCursor = true;
|
||||||
}
|
}
|
||||||
|
@ -701,7 +711,7 @@ namespace Beefy.theme.dark
|
||||||
}
|
}
|
||||||
|
|
||||||
float nextX = curX;
|
float nextX = curX;
|
||||||
nextX = DrawText(g, sectionText, curX, curY, curTypeIdAndFlags);
|
nextX = DrawText(g, sectionText, curX, curY + textYOffset, curTypeIdAndFlags);
|
||||||
DrawSectionFlagsOver(g, curX, curY, nextX - curX, flags);
|
DrawSectionFlagsOver(g, curX, curY, nextX - curX, flags);
|
||||||
|
|
||||||
//int32 lineDrawStartColumn = lineDrawStart - lineStart;
|
//int32 lineDrawStartColumn = lineDrawStart - lineStart;
|
||||||
|
|
|
@ -1215,7 +1215,7 @@ namespace IDE.ui
|
||||||
{
|
{
|
||||||
bool isRenameSymbol = (IDEApp.sApp.mSymbolReferenceHelper != null) && (IDEApp.sApp.mSymbolReferenceHelper.mKind == SymbolReferenceHelper.Kind.Rename);
|
bool isRenameSymbol = (IDEApp.sApp.mSymbolReferenceHelper != null) && (IDEApp.sApp.mSymbolReferenceHelper.mKind == SymbolReferenceHelper.Kind.Rename);
|
||||||
using (g.PushColor(isRenameSymbol ? (uint32)0x28FFFFFF : (uint32)0x18FFFFFF))
|
using (g.PushColor(isRenameSymbol ? (uint32)0x28FFFFFF : (uint32)0x18FFFFFF))
|
||||||
g.FillRect(x, y, width, mFont.GetLineSpacing());
|
g.FillRect(x, y, width, mFont.GetLineSpacing(mLineHeight));
|
||||||
|
|
||||||
DrawSectionFlagsOver(g, x, y, width, (uint8)(flags & ~(uint8)SourceElementFlags.SymbolReference));
|
DrawSectionFlagsOver(g, x, y, width, (uint8)(flags & ~(uint8)SourceElementFlags.SymbolReference));
|
||||||
return;
|
return;
|
||||||
|
@ -1224,7 +1224,7 @@ namespace IDE.ui
|
||||||
if ((flags & (uint8)SourceElementFlags.Find_CurrentSelection) != 0)
|
if ((flags & (uint8)SourceElementFlags.Find_CurrentSelection) != 0)
|
||||||
{
|
{
|
||||||
using (g.PushColor(0x504C575C))
|
using (g.PushColor(0x504C575C))
|
||||||
g.FillRect(x, y, width, mFont.GetLineSpacing());
|
g.FillRect(x, y, width, mFont.GetLineSpacing(mLineHeight));
|
||||||
|
|
||||||
DrawSectionFlagsOver(g, x, y, width, (uint8)(flags & ~(uint8)(SourceElementFlags.Find_CurrentSelection | .Find_Matches)));
|
DrawSectionFlagsOver(g, x, y, width, (uint8)(flags & ~(uint8)(SourceElementFlags.Find_CurrentSelection | .Find_Matches)));
|
||||||
return;
|
return;
|
||||||
|
@ -1233,7 +1233,7 @@ namespace IDE.ui
|
||||||
if ((flags & (uint8)SourceElementFlags.Find_Matches) != 0)
|
if ((flags & (uint8)SourceElementFlags.Find_Matches) != 0)
|
||||||
{
|
{
|
||||||
using (g.PushColor(0x50D0C090))
|
using (g.PushColor(0x50D0C090))
|
||||||
g.FillRect(x, y, width, mFont.GetLineSpacing());
|
g.FillRect(x, y, width, mFont.GetLineSpacing(mLineHeight));
|
||||||
|
|
||||||
DrawSectionFlagsOver(g, x, y, width, (uint8)(flags & ~(uint8)SourceElementFlags.Find_Matches));
|
DrawSectionFlagsOver(g, x, y, width, (uint8)(flags & ~(uint8)SourceElementFlags.Find_Matches));
|
||||||
return;
|
return;
|
||||||
|
@ -1277,7 +1277,7 @@ namespace IDE.ui
|
||||||
if (underlineColor != 0)
|
if (underlineColor != 0)
|
||||||
{
|
{
|
||||||
using (g.PushColor(underlineColor))
|
using (g.PushColor(underlineColor))
|
||||||
gApp.DrawSquiggle(g, x, y, width);
|
gApp.DrawSquiggle(g, x, y + GetTextOffset(), width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5851,7 +5851,7 @@ namespace IDE.ui
|
||||||
}
|
}
|
||||||
orderedEmitEmbeds.Sort(scope (lhs, rhs) => lhs.line <=> rhs.line);
|
orderedEmitEmbeds.Sort(scope (lhs, rhs) => lhs.line <=> rhs.line);
|
||||||
|
|
||||||
float fontHeight = mFont.GetLineSpacing();
|
float fontHeight = mFont.GetLineSpacing(mLineHeight);
|
||||||
int prevJumpIdx = -1;
|
int prevJumpIdx = -1;
|
||||||
float jumpCoordSpacing = GetJumpCoordSpacing();
|
float jumpCoordSpacing = GetJumpCoordSpacing();
|
||||||
|
|
||||||
|
@ -6430,8 +6430,10 @@ namespace IDE.ui
|
||||||
let height = mFont.GetHeight() + GS!(2);
|
let height = mFont.GetHeight() + GS!(2);
|
||||||
using (g.PushColor(DarkTheme.COLOR_CHAR_PAIR_HILITE))
|
using (g.PushColor(DarkTheme.COLOR_CHAR_PAIR_HILITE))
|
||||||
{
|
{
|
||||||
g.FillRect(x1, y1, charWidth, height);
|
float offset = GetTextOffset();
|
||||||
g.FillRect(x2, y2, charWidth, height);
|
|
||||||
|
g.FillRect(x1, y1 + offset, charWidth, height);
|
||||||
|
g.FillRect(x2, y2 + offset, charWidth, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4550,7 +4550,7 @@ namespace IDE.ui
|
||||||
{
|
{
|
||||||
float editX = GetEditX();
|
float editX = GetEditX();
|
||||||
|
|
||||||
float lineSpacing = ewc.mFont.GetLineSpacing();
|
float lineSpacing = ewc.mFont.GetLineSpacing(ewc.mLineHeight);
|
||||||
int cursorLineNumber = mEditWidget.mEditWidgetContent.CursorLineAndColumn.mLine;
|
int cursorLineNumber = mEditWidget.mEditWidgetContent.CursorLineAndColumn.mLine;
|
||||||
bool hiliteCurrentLine = mEditWidget.mHasFocus;
|
bool hiliteCurrentLine = mEditWidget.mHasFocus;
|
||||||
|
|
||||||
|
@ -4719,6 +4719,8 @@ namespace IDE.ui
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float offset = ewc.GetTextOffset();
|
||||||
|
|
||||||
if ((gApp.mSettings.mEditorSettings.mShowLineNumbers) && (mEmbedKind == .None))
|
if ((gApp.mSettings.mEditorSettings.mShowLineNumbers) && (mEmbedKind == .None))
|
||||||
{
|
{
|
||||||
String lineStr = scope String(16);
|
String lineStr = scope String(16);
|
||||||
|
@ -4748,7 +4750,7 @@ namespace IDE.ui
|
||||||
default: lineStr.AppendF("{0}", lineIdx + 1);
|
default: lineStr.AppendF("{0}", lineIdx + 1);
|
||||||
}
|
}
|
||||||
using (g.PushColor(DarkTheme.COLOR_TEXT))
|
using (g.PushColor(DarkTheme.COLOR_TEXT))
|
||||||
g.DrawString(lineStr, 0, GS!(2) + ewc.mLineCoords[lineIdx], FontAlign.Right, editX - GS!(14));
|
g.DrawString(lineStr, 0, GS!(2) + ewc.mLineCoords[lineIdx] + offset, FontAlign.Right, editX - GS!(14));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4787,7 +4789,7 @@ namespace IDE.ui
|
||||||
{
|
{
|
||||||
using (g.PushColor(0xFFA5A5A5))
|
using (g.PushColor(0xFFA5A5A5))
|
||||||
{
|
{
|
||||||
g.FillRect(editX - (int)GS!(7.5f), ewc.mLineCoords[lineIdx] - (int)GS!(0.5f), (int)GS!(1.5f), lineSpacing);
|
g.FillRect(editX - (int)GS!(7.5f), ewc.mLineCoords[lineIdx] - offset - (int)GS!(0.5f), (int)GS!(1.5f), lineSpacing + offset);
|
||||||
g.FillRect(editX - (int)GS!(7.5f), ewc.mLineCoords[lineIdx] + lineSpacing - (int)GS!(1.5f), GS!(5), (int)GS!(1.5f));
|
g.FillRect(editX - (int)GS!(7.5f), ewc.mLineCoords[lineIdx] + lineSpacing - (int)GS!(1.5f), GS!(5), (int)GS!(1.5f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue