Use icons in general_text_field (#3944)
* Use icons in general_text_field * Use icons for general_text_field * Add </buttonbar> * Use 4 spaces
This commit is contained in:
parent
d487a2e72e
commit
dd9d5c89e1
@ -1,15 +1,20 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<stkgui>
|
<stkgui>
|
||||||
<div x="2%" y="10%" width="96%" height="80%" layout="vertical-row" >
|
<div x="2%" y="6%" width="96%" height="88%" layout="vertical-row" >
|
||||||
<label id="title" raw_text="Text" proportion="1"/>
|
<label id="title" raw_text="Text" height="36%"/>
|
||||||
|
|
||||||
<spacer height="7%" width="10" />
|
<spacer height="7%" width="10" />
|
||||||
<textbox id="textfield" width="75%" align="center"/>
|
<textbox id="textfield" width="75%" align="center"/>
|
||||||
|
<spacer height="9%" width="10" />
|
||||||
|
|
||||||
<spacer height="7%" width="20" />
|
<buttonbar id="buttons" height="36%" width="30%" align="center">
|
||||||
<button id="ok" I18N="In the general textfield dialog" text="OK" align="center" proportion="1"/>
|
|
||||||
|
|
||||||
<spacer height="5%" width="20" />
|
<icon-button id="ok" width="128" height="128" icon="gui/icons/green_check.png"
|
||||||
<button id="cancel" I18N="In the general textfield dialog" text="Cancel" align="center" proportion="1"/>
|
I18N="In the general textfield dialog" text="OK" align="center"/>
|
||||||
|
|
||||||
|
<icon-button id="cancel" width="128" height="128" icon="gui/icons/remove.png"
|
||||||
|
I18N="In the general textfield dialog" text="Cancel" align="center"/>
|
||||||
|
|
||||||
|
</buttonbar>
|
||||||
</div>
|
</div>
|
||||||
</stkgui>
|
</stkgui>
|
||||||
|
@ -18,8 +18,9 @@
|
|||||||
#include "states_screens/dialogs/general_text_field_dialog.hpp"
|
#include "states_screens/dialogs/general_text_field_dialog.hpp"
|
||||||
|
|
||||||
#include "guiengine/engine.hpp"
|
#include "guiengine/engine.hpp"
|
||||||
#include "guiengine/widgets/button_widget.hpp"
|
#include "guiengine/widgets/icon_button_widget.hpp"
|
||||||
#include "guiengine/widgets/label_widget.hpp"
|
#include "guiengine/widgets/label_widget.hpp"
|
||||||
|
#include "guiengine/widgets/ribbon_widget.hpp"
|
||||||
#include "guiengine/widgets/text_box_widget.hpp"
|
#include "guiengine/widgets/text_box_widget.hpp"
|
||||||
#include "states_screens/state_manager.hpp"
|
#include "states_screens/state_manager.hpp"
|
||||||
#include "utils/string_utils.hpp"
|
#include "utils/string_utils.hpp"
|
||||||
@ -60,18 +61,27 @@ GeneralTextFieldDialog::~GeneralTextFieldDialog()
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
GUIEngine::EventPropagation GeneralTextFieldDialog::processEvent(const std::string& eventSource)
|
GUIEngine::EventPropagation GeneralTextFieldDialog::processEvent(const std::string& eventSource)
|
||||||
{
|
{
|
||||||
if (eventSource == "cancel")
|
GUIEngine::RibbonWidget* buttons_ribbon =
|
||||||
|
getWidget<GUIEngine::RibbonWidget>("buttons");
|
||||||
|
|
||||||
|
if(eventSource == "buttons")
|
||||||
|
{
|
||||||
|
const std::string& button =
|
||||||
|
buttons_ribbon->getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
||||||
|
|
||||||
|
if (button == "cancel")
|
||||||
{
|
{
|
||||||
dismiss();
|
dismiss();
|
||||||
return GUIEngine::EVENT_BLOCK;
|
return GUIEngine::EVENT_BLOCK;
|
||||||
}
|
}
|
||||||
else if (eventSource == "ok")
|
else if (button == "ok")
|
||||||
{
|
{
|
||||||
// If validation callback return true, dismiss the dialog
|
// If validation callback return true, dismiss the dialog
|
||||||
if (!m_self_destroy && m_val_cb(m_title, m_text_field))
|
if (!m_self_destroy && m_val_cb(m_title, m_text_field))
|
||||||
m_self_destroy = true;
|
m_self_destroy = true;
|
||||||
return GUIEngine::EVENT_BLOCK;
|
return GUIEngine::EVENT_BLOCK;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return GUIEngine::EVENT_LET;
|
return GUIEngine::EVENT_LET;
|
||||||
} // processEvent
|
} // processEvent
|
||||||
|
|
||||||
@ -79,7 +89,7 @@ GUIEngine::EventPropagation GeneralTextFieldDialog::processEvent(const std::stri
|
|||||||
void GeneralTextFieldDialog::onEnterPressedInternal()
|
void GeneralTextFieldDialog::onEnterPressedInternal()
|
||||||
{
|
{
|
||||||
// Cancel button pressed
|
// Cancel button pressed
|
||||||
ButtonWidget* cancel_button = getWidget<ButtonWidget>("cancel");
|
IconButtonWidget* cancel_button = getWidget<IconButtonWidget>("cancel");
|
||||||
if (GUIEngine::isFocusedForPlayer(cancel_button, PLAYER_ID_GAME_MASTER))
|
if (GUIEngine::isFocusedForPlayer(cancel_button, PLAYER_ID_GAME_MASTER))
|
||||||
{
|
{
|
||||||
std::string fake_event = "cancel";
|
std::string fake_event = "cancel";
|
||||||
|
Loading…
Reference in New Issue
Block a user