mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:27:45 +00:00
GTextEditor: Add support for different text alignments.
Currently only CenterLeft and CenterRight are supported, but it would be very straightforward to add other alignments as well.
This commit is contained in:
parent
16f6a3af3c
commit
62f0aae4ca
2 changed files with 57 additions and 9 deletions
|
@ -3,6 +3,7 @@
|
|||
#include <LibGUI/GScrollableWidget.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <SharedGraphics/TextAlignment.h>
|
||||
|
||||
class GAction;
|
||||
class GMenu;
|
||||
|
@ -69,6 +70,9 @@ public:
|
|||
GTextEditor(Type, GWidget* parent);
|
||||
virtual ~GTextEditor() override;
|
||||
|
||||
TextAlignment text_alignment() const { return m_text_alignment; }
|
||||
void set_text_alignment(TextAlignment);
|
||||
|
||||
Type type() const { return m_type; }
|
||||
bool is_single_line() const { return m_type == SingleLine; }
|
||||
bool is_multi_line() const { return m_type == MultiLine; }
|
||||
|
@ -173,11 +177,13 @@ private:
|
|||
void insert_at_cursor_or_replace_selection(const String&);
|
||||
void delete_selection();
|
||||
void did_update_selection();
|
||||
int content_x_for_position(const GTextPosition&) const;
|
||||
|
||||
Type m_type { MultiLine };
|
||||
|
||||
Vector<OwnPtr<Line>> m_lines;
|
||||
GTextPosition m_cursor;
|
||||
TextAlignment m_text_alignment { TextAlignment::CenterLeft };
|
||||
bool m_cursor_state { true };
|
||||
bool m_in_drag_select { false };
|
||||
bool m_ruler_visible { true };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue