mirror of
https://github.com/raysan5/raygui.git
synced 2026-01-30 10:49:19 -05:00
REVIEWED: GuiTextinputBox() to support secret text
This commit is contained in:
22
src/raygui.h
22
src/raygui.h
@ -529,7 +529,7 @@ RAYGUIAPI Vector2 GuiGrid(Rectangle bounds, const char *text, float spacing, int
|
|||||||
RAYGUIAPI int GuiListView(Rectangle bounds, const char *text, int *scrollIndex, int active); // List View control, returns selected list item index
|
RAYGUIAPI int GuiListView(Rectangle bounds, const char *text, int *scrollIndex, int active); // List View control, returns selected list item index
|
||||||
RAYGUIAPI int GuiListViewEx(Rectangle bounds, const char **text, int count, int *focus, int *scrollIndex, int active); // List View with extended parameters
|
RAYGUIAPI int GuiListViewEx(Rectangle bounds, const char **text, int count, int *focus, int *scrollIndex, int active); // List View with extended parameters
|
||||||
RAYGUIAPI int GuiMessageBox(Rectangle bounds, const char *title, const char *message, const char *buttons); // Message Box control, displays a message
|
RAYGUIAPI int GuiMessageBox(Rectangle bounds, const char *title, const char *message, const char *buttons); // Message Box control, displays a message
|
||||||
RAYGUIAPI int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, const char *buttons, char *text); // Text Input Box control, ask for text
|
RAYGUIAPI int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, const char *buttons, char *text, bool secret); // Text Input Box control, ask for text, supports secret
|
||||||
RAYGUIAPI Color GuiColorPicker(Rectangle bounds, const char *text, Color color); // Color Picker control (multiple color controls)
|
RAYGUIAPI Color GuiColorPicker(Rectangle bounds, const char *text, Color color); // Color Picker control (multiple color controls)
|
||||||
RAYGUIAPI Color GuiColorPanel(Rectangle bounds, const char *text, Color color); // Color Panel control
|
RAYGUIAPI Color GuiColorPanel(Rectangle bounds, const char *text, Color color); // Color Panel control
|
||||||
RAYGUIAPI float GuiColorBarAlpha(Rectangle bounds, const char *text, float alpha); // Color Bar Alpha control
|
RAYGUIAPI float GuiColorBarAlpha(Rectangle bounds, const char *text, float alpha); // Color Bar Alpha control
|
||||||
@ -3083,16 +3083,16 @@ int GuiMessageBox(Rectangle bounds, const char *title, const char *message, cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Text Input Box control, ask for text
|
// Text Input Box control, ask for text
|
||||||
int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, const char *buttons, char *text)
|
int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, const char *buttons, char *text, int *secretViewActive)
|
||||||
{
|
{
|
||||||
#if !defined(RAYGUI_TEXTINPUTBOX_BUTTON_HEIGHT)
|
#if !defined(RAYGUI_TEXTINPUTBOX_BUTTON_HEIGHT)
|
||||||
#define RAYGUI_TEXTINPUTBOX_BUTTON_HEIGHT 24
|
#define RAYGUI_TEXTINPUTBOX_BUTTON_HEIGHT 28
|
||||||
#endif
|
#endif
|
||||||
#if !defined(RAYGUI_TEXTINPUTBOX_BUTTON_PADDING)
|
#if !defined(RAYGUI_TEXTINPUTBOX_BUTTON_PADDING)
|
||||||
#define RAYGUI_TEXTINPUTBOX_BUTTON_PADDING 10
|
#define RAYGUI_TEXTINPUTBOX_BUTTON_PADDING 12
|
||||||
#endif
|
#endif
|
||||||
#if !defined(RAYGUI_TEXTINPUTBOX_HEIGHT)
|
#if !defined(RAYGUI_TEXTINPUTBOX_HEIGHT)
|
||||||
#define RAYGUI_TEXTINPUTBOX_HEIGHT 24
|
#define RAYGUI_TEXTINPUTBOX_HEIGHT 28
|
||||||
#endif
|
#endif
|
||||||
#if !defined(RAYGUI_TEXTINPUTBOX_MAX_TEXT_LENGTH)
|
#if !defined(RAYGUI_TEXTINPUTBOX_MAX_TEXT_LENGTH)
|
||||||
#define RAYGUI_TEXTINPUTBOX_MAX_TEXT_LENGTH 256
|
#define RAYGUI_TEXTINPUTBOX_MAX_TEXT_LENGTH 256
|
||||||
@ -3146,7 +3146,17 @@ int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, co
|
|||||||
GuiSetStyle(LABEL, TEXT_ALIGNMENT, prevTextAlignment);
|
GuiSetStyle(LABEL, TEXT_ALIGNMENT, prevTextAlignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GuiTextBox(textBoxBounds, text, RAYGUI_TEXTINPUTBOX_MAX_TEXT_LENGTH, textEditMode)) textEditMode = !textEditMode;
|
if (secretViewActive != NULL)
|
||||||
|
{
|
||||||
|
if (GuiTextBox((Rectangle){ textBoxBounds.x, textBoxBounds.y, textBoxBounds.width - 4 - RAYGUI_TEXTINPUTBOX_HEIGHT, textBoxBounds.height },
|
||||||
|
((*secretViewActive == 1) || textEditMode)? text : "****************", RAYGUI_TEXTINPUTBOX_MAX_TEXT_LENGTH, textEditMode)) textEditMode = !textEditMode;
|
||||||
|
|
||||||
|
*secretViewActive = GuiToggle((Rectangle){ textBoxBounds.x + textBoxBounds.width - RAYGUI_TEXTINPUTBOX_HEIGHT, textBoxBounds.y, RAYGUI_TEXTINPUTBOX_HEIGHT, RAYGUI_TEXTINPUTBOX_HEIGHT }, (*secretViewActive == 1)? "#44#" : "#45#", *secretViewActive);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (GuiTextBox(textBoxBounds, text, RAYGUI_TEXTINPUTBOX_MAX_TEXT_LENGTH, textEditMode)) textEditMode = !textEditMode;
|
||||||
|
}
|
||||||
|
|
||||||
int prevBtnTextAlignment = GuiGetStyle(BUTTON, TEXT_ALIGNMENT);
|
int prevBtnTextAlignment = GuiGetStyle(BUTTON, TEXT_ALIGNMENT);
|
||||||
GuiSetStyle(BUTTON, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER);
|
GuiSetStyle(BUTTON, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER);
|
||||||
|
|||||||
Reference in New Issue
Block a user