Skip to content

Commit

Permalink
Improved whitespace rendering performance on wrapped lines, now it ha…
Browse files Browse the repository at this point in the history
…s the same cost than non-wrapped lines.

Fixed: Debugger gutter not drawing its background.
Fixed: horizontal scrollbar sometimes being visible on wrapped documents.
Updated CSS Specification documentation.
  • Loading branch information
SpartanJ committed Feb 27, 2025
1 parent a08148b commit a91fde6
Show file tree
Hide file tree
Showing 6 changed files with 286 additions and 124 deletions.
93 changes: 93 additions & 0 deletions docs/articles/cssspecification.md
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,21 @@ Custom cursors not yet supported (but supported by the engine, only not implemen

---

### disable-editor-flags

Allows disabling specific behavior flags for the code editor component.
Flags set here take precedence over [enable-editor-flags](#enable-editor-flags).
Multiple flags are separated by `|`.

* Applicable to: Any element child of a EE::UI::UICodeEditor (CodeEditor)
* Data Type: [string-list](#string-list-data-type)
* Value List:
* All flags listed in [enable-editor-flags](#enable-editor-flags) can be used here to disable their respective features.
* `editorfeatures`: Macro Flag - Disables line numbers, whitespace display, folding regions, current line highlight, matching bracket highlight, selection match highlight, color picker, minimap, and find/replace. Resets line breaking and forces the editor to use the default style.
* Default value: _No value_

---

### display-percent

Enables/disables displaying the percentage of progress in the progress bar.
Expand Down Expand Up @@ -583,6 +598,41 @@ Sets if the element is enabled

---

### enable-editor-flags

Allows enabling specific behavior flags for the code editor component. Multiple flags can be specified, separated by `|`.

* Applicable to: Any element child of a EE::UI::UICodeEditor (CodeEditor)
* Data Type: [string-list](#string-list-data-type)
* Value List:
* `linenumber`: Displays line numbers in the gutter.
* `foldingregion`: Shows code folding regions for collapsing/expanding blocks.
* `whitespaces`: Renders whitespace characters (spaces, tabs) as visible symbols.
* `lineendings`: Displays line ending characters (e.g., CR, LF).
* `highlightcurrentline`: Highlights the background of the current line containing the cursor.
* `highlightmatchingbracket`: Highlights the bracket matching the one under the cursor.
* `highlightselectionmatch`: Highlights all occurrences of the selected text in the document.
* `colorpickeronselection`: Opens a color picker dialog when a color value is selected.
* `verticalscrollbar`: Enables the vertical scrollbar for scrolling through content.
* `horizontalscrollbar`: Enables the horizontal scrollbar for scrolling through content.
* `colorpreview`: Shows a color preview on mouse hover.
* `interactivelinks`: Enables interaction with clickable hyperlinks within the editor.
* `displayloader`: Displays a loading indicator while the document is loading.
* `defaultcontextmenu`: Provides a default context menu with standard editing options.
* `minimap`: Shows a minimap (overview) of the document on the right side.
* `autoclosexmltags`: Automatically inserts closing tags in XML/HTML documents.
* `findreplace`: Enables the find and replace functionality.
* `showindentationguides`: Displays vertical guides to indicate indentation levels.
* `linesrelativeposition`: Shows the relative position of lines (e.g., in a diff view).
* `lockedicon`: Displays a lock icon when the editor is in a locked state.
* `foldsalwaysvisible`: Keeps fold markers visible even when not hovered.
* `foldsvisible`: Makes folded code regions visible.
* `flashcursor`: Enables a flashing animation for the text cursor.
* `defaultstyle`: Applies the default styling and theme to the editor.
* Default value: _No value_

---

### font-family

Read [font-family](https://developer.mozilla.org/en-US/docs/Web/CSS/font-family) documentation.
Expand Down Expand Up @@ -1052,6 +1102,33 @@ Sets a extra line spacing to the line box.

---

### line-wrap-mode

Specifies the line wrap mode of the element.

* Applicable to: Any element child of a EE::UI::UICodeEditor (CodeEditor)
* Data Type: [string-list](#string-list-data-type)
* Value List:
* `word`: Wraps against words.
* `letter`: Wraps against letters.
* `nowrap`: Does not wrap.
* Default value: `nowrap`

---

### line-wrap-type

Specifies if line must wrap against its viewport or the defined line breaking column.

* Applicable to: Any element child of a EE::UI::UICodeEditor (CodeEditor)
* Data Type: [string-list](#string-list-data-type)
* Value List:
* `viewport`: Wrap against the element viewport.
* `line_breaking_column`: Wraps against the line breaking column.
* Default value: `viewport`

---

### locked

Enable or disable editing on code editor elements.
Expand Down Expand Up @@ -1462,6 +1539,22 @@ Sets the vertical separation between each element in the grid layout.

---

### row-valign

Sets the vertical alignment of the elements in a stack layout. Elements in the same row will align
based on the maximum element height in that row.

* Applicable to: EE::UI::UIStackLayout (StackLayout)
* Data Type: [string-list](#string-list-data-type)

* Value List:
* `top`: Aligns to the top of the row.
* `bottom`: Aligns to the bottom of the row.
* `center`: Aligns to the center of the row.
* Default value: `bottom`

---

### row-weight

Sets the percentage height of the child elements of a grid layout.
Expand Down
36 changes: 25 additions & 11 deletions include/eepp/graphics/text.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@

namespace EE { namespace Graphics {

enum class CharacterAlignment : Uint32 { Left = 0, Center = 1, Right = 2 };

struct WhitespaceDisplayConfig {
String::StringBaseType spaceDisplayCharacter{ 0 };
String::StringBaseType tabDisplayCharacter{ 0 };
CharacterAlignment tabAlign{ CharacterAlignment::Center };
Color color;
};

class EE_API Text {
public:
static bool TextShaperEnabled;
Expand Down Expand Up @@ -48,21 +57,25 @@ class EE_API Text {
const Color& outlineColor = Color::Black,
const Color& shadowColor = Color::Black,
const Vector2f& shadowOffset = { 1, 1 }, const Uint32& tabWidth = 4,
Uint32 textDrawHints = 0 );
Uint32 textDrawHints = 0,
const WhitespaceDisplayConfig& whitespaceDisplayConfig = {} );

static Sizef draw( const String& string, const Vector2f& pos, const FontStyleConfig& config,
const Uint32& tabWidth = 4, Uint32 textDrawHints = 0 );
const Uint32& tabWidth = 4, Uint32 textDrawHints = 0,
const WhitespaceDisplayConfig& whitespaceDisplayConfig = {} );

static Sizef draw( const String::View& string, const Vector2f& pos, Font* font, Float fontSize,
const Color& fontColor, Uint32 style = 0, Float outlineThickness = 0.f,
const Color& outlineColor = Color::Black,
const Color& shadowColor = Color::Black,
const Vector2f& shadowOffset = { 1, 1 }, const Uint32& tabWidth = 4,
Uint32 textDrawHints = 0 );
Uint32 textDrawHints = 0,
const WhitespaceDisplayConfig& whitespaceDisplayConfig = {} );

static Sizef draw( const String::View& string, const Vector2f& pos,
const FontStyleConfig& config, const Uint32& tabWidth = 4,
Uint32 textDrawHints = 0 );
Uint32 textDrawHints = 0,
const WhitespaceDisplayConfig& whitespaceDisplayConfig = {} );

static void drawUnderline( const Vector2f& pos, Float width, Font* font, Float fontSize,
const Color& fontColor, const Uint32& style, Float outlineThickness,
Expand Down Expand Up @@ -315,16 +328,17 @@ class EE_API Text {
const Float& outlineThickness = 0.f );

template <typename StringType>
static Sizef draw( const StringType& string, const Vector2f& pos, Font* font, Float fontSize,
const Color& fontColor, Uint32 style = 0, Float outlineThickness = 0.f,
const Color& outlineColor = Color::Black,
const Color& shadowColor = Color::Black,
const Vector2f& shadowOffset = { 1, 1 }, const Uint32& tabWidth = 4,
Uint32 textDrawHints = 0 );
static Sizef
draw( const StringType& string, const Vector2f& pos, Font* font, Float fontSize,
const Color& fontColor, Uint32 style = 0, Float outlineThickness = 0.f,
const Color& outlineColor = Color::Black, const Color& shadowColor = Color::Black,
const Vector2f& shadowOffset = { 1, 1 }, const Uint32& tabWidth = 4,
Uint32 textDrawHints = 0, const WhitespaceDisplayConfig& whitespaceDisplayConfig = {} );

template <typename StringType>
static Sizef draw( const StringType& string, const Vector2f& pos, const FontStyleConfig& config,
const Uint32& tabWidth = 4, Uint32 textDrawHints = 0 );
const Uint32& tabWidth = 4, Uint32 textDrawHints = 0,
const WhitespaceDisplayConfig& whitespaceDisplayConfig = {} );

template <typename StringType>
static std::size_t findLastCharPosWithinLength( Font* font, const Uint32& fontSize,
Expand Down
2 changes: 0 additions & 2 deletions include/eepp/ui/uicodeeditor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class UILoader;
class UIPopUpMenu;
class UIMenuItem;

enum class CharacterAlignment : Uint32 { Left = 0, Center = 1, Right = 2 };

using DocumentLineRange = std::pair<Int64, Int64>;
using DocumentViewLineRange = std::pair<VisibleIndex, VisibleIndex>;

Expand Down
Loading

0 comments on commit a91fde6

Please sign in to comment.