Changeset View
Standalone View
source/gui/ObjectTypes/CInput.h
Show All 25 Lines | |||||
/** | /** | ||||
* Text field where you can input and edit the text. | * Text field where you can input and edit the text. | ||||
* | * | ||||
* It doesn't use IGUITextOwner, because we don't need | * It doesn't use IGUITextOwner, because we don't need | ||||
* any other features than word-wrapping, and we need to be | * any other features than word-wrapping, and we need to be | ||||
* able to rapidly change the string. | * able to rapidly change the string. | ||||
*/ | */ | ||||
class CInput : public IGUIObject, public IGUIScrollBarOwner | class CInput : public IGUIObject, public IGUIScrollBarOwner | ||||
elexis: Before someone suggests removing the comment, one could also check whether it would be more… | |||||
Done Inline ActionsIGUITextOwner is used to prebuild string, but caption of input will change too frequently to benefit from that. Silier: IGUITextOwner is used to prebuild string, but caption of input will change too frequently to… | |||||
Done Inline ActionsI will remove inheritance since I am overriding most of the functions anyway Silier: I will remove inheritance since I am overriding most of the functions anyway | |||||
{ | { | ||||
GUI_OBJECT(CInput) | GUI_OBJECT(CInput) | ||||
protected: // forwards | protected: // forwards | ||||
struct SRow; | struct SRow; | ||||
public: | public: | ||||
CInput(CGUI& pGUI); | CInput(CGUI& pGUI); | ||||
Show All 11 Lines | public: | ||||
// Same as above, but only on one row in X, and a given value, not the mouse's. | // Same as above, but only on one row in X, and a given value, not the mouse's. | ||||
// wanted is filled with x if the row didn't extend as far as the mouse pos. | // wanted is filled with x if the row didn't extend as far as the mouse pos. | ||||
int GetXTextPosition(const std::list<SRow>::const_iterator& c, const float& x, float& wanted) const; | int GetXTextPosition(const std::list<SRow>::const_iterator& c, const float& x, float& wanted) const; | ||||
protected: | protected: | ||||
/** | /** | ||||
* @see IGUIObject#HandleMessage() | * @see IGUIObject#HandleMessage() | ||||
*/ | */ | ||||
virtual void HandleMessage(SGUIMessage& Message); | virtual void HandleMessage(SGUIMessage& Message); | ||||
Not Done Inline ActionsWhy do you need these AddText methods? Especially in case there is the only one usage in the constructor. vladislavbelov: Why do you need these `AddText` methods? Especially in case there is the only one usage in the… | |||||
/** | /** | ||||
* Handle events manually to catch keyboard inputting. | * Handle events manually to catch keyboard inputting. | ||||
*/ | */ | ||||
virtual InReaction ManuallyHandleEvent(const SDL_Event_* ev); | virtual InReaction ManuallyHandleEvent(const SDL_Event_* ev); | ||||
/** | /** | ||||
* Handle events manually to catch keys which change the text. | * Handle events manually to catch keys which change the text. | ||||
▲ Show 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | protected: | ||||
/// If the cursor should be drawn or not. | /// If the cursor should be drawn or not. | ||||
bool m_CursorVisState; | bool m_CursorVisState; | ||||
// Settings | // Settings | ||||
i32 m_BufferPosition; | i32 m_BufferPosition; | ||||
float m_BufferZone; | float m_BufferZone; | ||||
CStrW m_Caption; | CStrW m_Caption; | ||||
CStrW m_PlaceholderText; | |||||
Not Done Inline ActionsPerhaps CGUIText could be used to support tags (such as font) and avoid m_PlaceholderColor (or perhaps CGUIString is more consistent with COList columns or something, dunno, but there are those two possibilities. Actually COList seems to use CStrW, so there are three. CStrW would be consistent with m_Caption.) elexis: Perhaps `CGUIText` could be used to support tags (such as font) and avoid `m_PlaceholderColor`… | |||||
Done Inline ActionsCGUIString is required for CGUIText constructor so thats why not CStrW. Not sure if CGUIText can be created from js like CGUIString is but I will check. Silier: CGUIString is required for CGUIText constructor so thats why not CStrW. Not sure if CGUIText… | |||||
Done Inline ActionsFor the record: Silier: For the record:
Engine.GetGUIObjectByName("modGenericFilter").placeholder_text = setStringTags… | |||||
i32 m_CellID; | i32 m_CellID; | ||||
CStrW m_Font; | CStrW m_Font; | ||||
CStrW m_MaskChar; | CStrW m_MaskChar; | ||||
bool m_Mask; | bool m_Mask; | ||||
i32 m_MaxLength; | i32 m_MaxLength; | ||||
bool m_MultiLine; | bool m_MultiLine; | ||||
bool m_Readonly; | bool m_Readonly; | ||||
bool m_ScrollBar; | bool m_ScrollBar; | ||||
CStr m_ScrollBarStyle; | CStr m_ScrollBarStyle; | ||||
CGUISpriteInstance m_Sprite; | CGUISpriteInstance m_Sprite; | ||||
CGUISpriteInstance m_SpriteSelectArea; | CGUISpriteInstance m_SpriteSelectArea; | ||||
CGUIColor m_TextColor; | CGUIColor m_TextColor; | ||||
CGUIColor m_TextColorSelected; | CGUIColor m_TextColorSelected; | ||||
CGUIColor m_PlaceholderColor; | |||||
}; | }; | ||||
#endif // INCLUDED_CINPUT | #endif // INCLUDED_CINPUT |
Before someone suggests removing the comment, one could also check whether it would be more logically consistent to not introduce the inheritance, or to inherit but use it for both text renderings, since there would be 3 lines using the new IGUITextOwner inheritance vs. 2000 lines managing and rendering text without IGUITextOwner.
The class should use the IGUITextOwner if CInput shall be able to print selectable colorized, perhaps link-clickable text, for example for ToS, chat, mapdescription, but would require rewriting the entire class (and D1781).