mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +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;
|
||||
}
|
||||
|
||||
public float GetLineSpacing()
|
||||
public float GetLineSpacing(float heightMultiplier = 1.0f)
|
||||
{
|
||||
if (mFTFont == null)
|
||||
return 0;
|
||||
return mFTFont.mHeight;
|
||||
return mFTFont.mHeight * heightMultiplier;
|
||||
}
|
||||
|
||||
public float GetHeight()
|
||||
|
|
|
@ -50,6 +50,7 @@ namespace Beefy.theme.dark
|
|||
}
|
||||
|
||||
public Font mFont;
|
||||
public float mLineHeight = 1.0f;
|
||||
public uint32[] mTextColors = sDefaultColors;
|
||||
public uint32 mHiliteColor = 0xFF2f5c88;
|
||||
public uint32 mUnfocusedHiliteColor = 0x00000000;
|
||||
|
@ -104,7 +105,7 @@ namespace Beefy.theme.dark
|
|||
mLineCoords.GrowUninitialized(mData.mLineStarts.Count);
|
||||
mLineCoordJumpTable.Clear();
|
||||
|
||||
float fontHeight = mFont.GetLineSpacing();
|
||||
float fontHeight = mFont.GetLineSpacing(mLineHeight);
|
||||
int prevJumpIdx = -1;
|
||||
float jumpCoordSpacing = GetJumpCoordSpacing();
|
||||
|
||||
|
@ -214,6 +215,13 @@ namespace Beefy.theme.dark
|
|||
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)
|
||||
{
|
||||
var line;
|
||||
|
@ -509,7 +517,7 @@ namespace Beefy.theme.dark
|
|||
((embed.mKind == .HideLine) && (!hideLine)))
|
||||
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)
|
||||
rect.mY = 0;
|
||||
return rect;
|
||||
|
@ -526,7 +534,9 @@ namespace Beefy.theme.dark
|
|||
|
||||
#unwarn
|
||||
int lineCount = GetLineCount();
|
||||
float lineSpacing = mFont.GetLineSpacing();
|
||||
float lineSpacing = mFont.GetLineSpacing(mLineHeight);
|
||||
float fontLineSpacing = mFont.GetLineSpacing();
|
||||
float textYOffset = GetTextOffset();
|
||||
|
||||
float offsetY = mTextInsets.mTop;
|
||||
if (mHeight < lineSpacing)
|
||||
|
@ -565,7 +575,7 @@ namespace Beefy.theme.dark
|
|||
{
|
||||
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
|
||||
// to properly highlight the whole line without getting cut off - this works well for now.
|
||||
float totalLineWidth = mEditWidget.mScrollContentContainer.mWidth - thickness;
|
||||
|
@ -596,18 +606,18 @@ namespace Beefy.theme.dark
|
|||
if (mCharWidth <= 2)
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
@ -701,7 +711,7 @@ namespace Beefy.theme.dark
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
//int32 lineDrawStartColumn = lineDrawStart - lineStart;
|
||||
|
|
|
@ -1215,7 +1215,7 @@ namespace IDE.ui
|
|||
{
|
||||
bool isRenameSymbol = (IDEApp.sApp.mSymbolReferenceHelper != null) && (IDEApp.sApp.mSymbolReferenceHelper.mKind == SymbolReferenceHelper.Kind.Rename);
|
||||
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));
|
||||
return;
|
||||
|
@ -1224,7 +1224,7 @@ namespace IDE.ui
|
|||
if ((flags & (uint8)SourceElementFlags.Find_CurrentSelection) != 0)
|
||||
{
|
||||
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)));
|
||||
return;
|
||||
|
@ -1233,7 +1233,7 @@ namespace IDE.ui
|
|||
if ((flags & (uint8)SourceElementFlags.Find_Matches) != 0)
|
||||
{
|
||||
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));
|
||||
return;
|
||||
|
@ -1277,7 +1277,7 @@ namespace IDE.ui
|
|||
if (underlineColor != 0)
|
||||
{
|
||||
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);
|
||||
|
||||
float fontHeight = mFont.GetLineSpacing();
|
||||
float fontHeight = mFont.GetLineSpacing(mLineHeight);
|
||||
int prevJumpIdx = -1;
|
||||
float jumpCoordSpacing = GetJumpCoordSpacing();
|
||||
|
||||
|
@ -6430,8 +6430,10 @@ namespace IDE.ui
|
|||
let height = mFont.GetHeight() + GS!(2);
|
||||
using (g.PushColor(DarkTheme.COLOR_CHAR_PAIR_HILITE))
|
||||
{
|
||||
g.FillRect(x1, y1, charWidth, height);
|
||||
g.FillRect(x2, y2, charWidth, height);
|
||||
float offset = GetTextOffset();
|
||||
|
||||
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 lineSpacing = ewc.mFont.GetLineSpacing();
|
||||
float lineSpacing = ewc.mFont.GetLineSpacing(ewc.mLineHeight);
|
||||
int cursorLineNumber = mEditWidget.mEditWidgetContent.CursorLineAndColumn.mLine;
|
||||
bool hiliteCurrentLine = mEditWidget.mHasFocus;
|
||||
|
||||
|
@ -4719,6 +4719,8 @@ namespace IDE.ui
|
|||
}*/
|
||||
}
|
||||
|
||||
float offset = ewc.GetTextOffset();
|
||||
|
||||
if ((gApp.mSettings.mEditorSettings.mShowLineNumbers) && (mEmbedKind == .None))
|
||||
{
|
||||
String lineStr = scope String(16);
|
||||
|
@ -4748,7 +4750,7 @@ namespace IDE.ui
|
|||
default: lineStr.AppendF("{0}", lineIdx + 1);
|
||||
}
|
||||
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))
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue