1 #ifndef JUGIMAP_GUI_TEXT_WIDGETS_H
2 #define JUGIMAP_GUI_TEXT_WIDGETS_H
11 #include "../utf8cpp/utf8.h"
14 #include "jmGuiCommon.h"
15 #include "jmGuiText.h"
29 class TextSegmentWord;
31 class TextFieldLineSubtext;
99 void Update()
override;
239 float GetRelativeScrollPosition(){
return relScrollPosition; }
254 SpriteLayer *layer =
nullptr;
255 TextSegment * textSegment =
nullptr;
258 GuiSlider * slider =
nullptr;
259 std::vector<TextFieldLine*>Lines;
262 std::string clickedTextName;
265 std::vector<float>gapWords;
266 float gapWordsMax = 5.0;
267 float localLinesSpacingFactor = 0.0;
273 int drawingDelayMS = 0;
274 int drawingDelayStartMS = 0;
279 int segmentHeight = 0;
280 int scrollingRange = 0;
281 float relScrollPosition = 0.0;
282 float relScrollStep = 0.25;
284 bool delayedDrawingFinished =
false;
285 bool alphaFadeAtMargin =
true;
288 std::vector<TextFieldLineSubtext*>clickableSubtexts;
291 int fsNumberOfLines = 5;
292 int fsLineHeight = 30;
293 int fsScrollDurationMS = 250;
294 int indexFirstLineInBox = -1;
297 void RebuildLines(
bool _rebuildEngineTexts=
true);
300 void Update_DelayByRow();
301 void Update_DelayByWord();
302 void Update_DelayByCharacters();
304 void UpdateVisibleRange(
float offset);
306 std::string GetClickedText();
313 class TextFieldLineSubtext
316 friend class GuiTextField;
317 friend class TextFieldLine;
322 Font* font =
nullptr;
323 TextSprite * textSprite =
nullptr;
325 bool visibleViaDrawingDelay =
true;
337 friend class GuiTextField;
339 std::vector<TextFieldLineSubtext>subtexts;
342 bool inVisibleBox =
false;
348 void Add(
const TextSegmentWord &_word,
float textPos);
349 void AddAsSeparateWords(
const TextSegmentWord &_word,
float textPos);
350 void UpdateEngineText(
int _subtextIndex, SpriteLayer *_layer, Font *_font,
int _xBox,
int _yPos);
374 void Update()
override;
382 void Start(
const std::string &_text);
386 void SetText(
const std::string &_text);
405 void SetBannedChars(
const std::string &_bannedChars){ bannedChars = _bannedChars; }
427 std::string defaultText;
430 char currentChar = 0;
434 int cursorFlashingMS = 250;
435 int cursorFlashingStartMS = 0;
437 bool allowEscToAbort =
false;
438 bool allowEmptyText =
true;
439 std::string bannedChars;
441 std::vector<char>allowedAsciCodes;
445 int indexInputBoxSprite_idle = 0;
446 int indexInputBoxSprite_CO = 0;
447 int indexInputBoxSprite_active = 0;
448 int indexInputBoxSprite_disabled = 0;
450 ColorRGBA textColor_idle{255,255,255};
452 ColorRGBA textColor_active{255,255,255};
456 void UpdateTextOnChange();
bool IsDelayedDrawingActive()
Returns true if a text segment is currently being drawn by the drawing delay; otherwise returns false...
Definition: jmGuiTextWidgets.h:218
bool ScrollTextDown()
Scroll the segment text down and return true. If scrolling is not possible returns false.
Definition: jmGuiTextWidgets.cpp:942
std::string GetText()
Returns the text.
Definition: jmGuiTextWidgets.h:389
void SetScrollingMode(ScrollingMode _scrollingMode)
Set the scrolling mode.
Definition: jmGuiTextWidgets.cpp:295
void SetVisible(bool _visible) override
Set the visibility of this widget.
Definition: jmGuiTextWidgets.cpp:288
void SetClickableRect(Recti _clickableBox)
Set the clickable area rectangle.
Definition: jmGuiTextWidgets.cpp:134
Text is displayed gradually by rows.
void Reset()
Reset the text field.
Definition: jmGuiTextWidgets.cpp:326
The GuiTextField class provides a widget for displaying text.
Definition: jmGuiTextWidgets.h:41
Color in RGBA color space - integer variant.
Definition: jmColor.h:15
void SetScrollingModeFixedStepProperties(int _numberOfLines, int _lineHeight, float _scrollDurationMS)
Set the scrolling properties if scrolling mode is ScrollingMode::FIXED_STEP.
Definition: jmGuiTextWidgets.cpp:302
GuiTextField(VectorShape *_vectorShape, Map *_map)
Construct a new GuiTextField from the given *_vectorShape* in the *_map*.
Definition: jmGuiTextWidgets.cpp:36
int GetTextSegmentHeight(TextSegment *_textSegment)
Returns the height of the given *_textSegment* in this text field.
Definition: jmGuiTextWidgets.cpp:141
bool IsTextSegmentFirstLineDisplayed()
Returns true if the first line of the text segement is displayed; otherwise returns false.
Definition: jmGuiTextWidgets.cpp:1085
void SetVisibleRect(Recti _visibleBox)
Set the visible area rectangle.
Definition: jmGuiTextWidgets.cpp:127
ScrollingMode
Definition: jmGuiTextWidgets.h:75
void SetVisible(bool _visible) override
Set the visibility of this widget.
Definition: jmGuiTextWidgets.cpp:1405
Alignment
The text alignment.
Definition: jmGuiTextWidgets.h:52
void SetAllowEmptyText(bool _allowEmptyText)
Set if empty text is allowed.
Definition: jmGuiTextWidgets.h:401
Alignment GetTextAlignment()
Returns the text alignment of this text field.
Definition: jmGuiTextWidgets.h:152
Text lines are aligned to the left edge.
The StandardSprite class defines the sprite from JugiMap Editor.
Definition: jmSprites.h:787
std::string GetClickedButtonName()
Returns the name of the clicked button if such event happens; otherwise returns an empty string.
Definition: jmGuiTextWidgets.h:119
Text is displayed instantly.
void SetDisabled(bool _disabled) override
Set the disabled state of this widget.
Definition: jmGuiTextWidgets.cpp:273
void SetAlphaFadeAtMargin(bool _alphaFadeAtMargin)
Set to true if alpha fade at margin between box and visible box is used.
Definition: jmGuiTextWidgets.h:156
Recti GetClickableRect()
Returns the clickable area rectangle.
Definition: jmGuiTextWidgets.h:194
Recti GetTextRect()
Returns the text area rectangle.
Definition: jmGuiTextWidgets.h:170
void MakeCharsFileNameSafe()
Set a string of banned characters in file name.
Definition: jmGuiTextWidgets.cpp:1544
void SetText(const std::string &_text)
Set the text.
Definition: jmGuiTextWidgets.cpp:1343
Rect< int > Recti
Rect struct in integer precision.
Definition: jmCommon.h:256
void SetBannedChars(const std::string &_bannedChars)
Set a string of characters which can not appear in the text.
Definition: jmGuiTextWidgets.h:405
bool IsTextSegmentLastLineDisplayed()
Returns true if the last line of the text segement is displayed; otherwise returns false.
Definition: jmGuiTextWidgets.cpp:1099
DrawingDelay
The drawing delay of displayed text.
Definition: jmGuiTextWidgets.h:64
DrawingDelay GetDrawingDelay()
Returns the drawing delay of this text field.
Definition: jmGuiTextWidgets.h:144
The TextSegment class defines a segment of text which can be accessed and displayed separatelly from ...
Definition: jmGuiText.h:125
void SetCursorFlashingSpeed(int _cursorFlashingMS)
Set the flashing interval of the text cursor in milliseconds.
Definition: jmGuiTextWidgets.cpp:1384
void SetTextAlignment(Alignment _textAlignment)
Set the text alignment to the given *_textAlignment*.
Definition: jmGuiTextWidgets.cpp:319
Text is displayed gradually by words.
bool ScrollTextUp()
Scroll the segment text up and returns true. If scrolling is not possible returns false.
Definition: jmGuiTextWidgets.cpp:896
The ComposedSprite class defines the composed sprite from JugiMap Editor.
Definition: jmSprites.h:682
void Start()
Start the text editing.
Definition: jmGuiTextWidgets.cpp:1314
void SetAllowEscToAbort(bool _allowEscToAbort)
Set if the escape key aborts editing.
Definition: jmGuiTextWidgets.h:397
void SetTextMaximumLength(int _maxLength)
Set the maximum number of characters of the text.
Definition: jmGuiTextWidgets.h:393
ScrollingMode GetScrollingMode()
Returns the scrolling mode of this text field.
Definition: jmGuiTextWidgets.h:128
The GuiTextField class provides a widget for text input.
Definition: jmGuiTextWidgets.h:362
void SetDrawingDelay(DrawingDelay _drawingDelay, int _drawingdelayMS)
Set the drawing delay to the given *_drawingDelay* and duration to *_drawingdelayMS* (in milliseconds...
Definition: jmGuiTextWidgets.cpp:311
GuiTextInput(ComposedSprite *_rootSprite)
Construct a new gui text input from the given *_rootSprite*.
Definition: jmGuiTextWidgets.cpp:1198
void Start(TextSegment *_textSegment)
Start displaying the given *_textSegment*.
Definition: jmGuiTextWidgets.cpp:158
Recti GetVisibleRect()
Returns the visible area rectangle.
Definition: jmGuiTextWidgets.h:184
The TextSprite class defines the text sprite from JugiMap Editor.
Definition: jmSprites.h:889
void SetLocalLinesSpacingFactor(float _spacingFactor)
Set the local factor for vertical lines spacing.
Definition: jmGuiTextWidgets.h:202
Text is displayed gradually by characters.
void SetTextRect(Recti _box)
Set the text area rectangle.
Definition: jmGuiTextWidgets.cpp:120
The VectorShape class defines the vector shape from JugiMap Editor.
Definition: jmVectorShapes.h:206
void SetDisabled(bool _disabled) override
Set the disabled state of this widget.
Definition: jmGuiTextWidgets.cpp:1390
The Map class defines the map element from JugiMap Editor.
Definition: jmMap.h:26
static float globalLinesSpacingFactor
Global factor for vertical lines spacing.
Definition: jmGuiTextWidgets.h:49
void SkipDelay()
Skip drawing delay of a text segment and show entire text immediately.
Definition: jmGuiTextWidgets.cpp:858
TextSegment * GetTextSegment()
Returns the text segment if exists; otherwise returns nullptr.
Definition: jmGuiTextWidgets.h:106