Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signals #112

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ CmakeSettings.json
CombinedSources*.cpp
.DS_Store
*~
/cmake-build-debug
/cmake-build-release
/.idea
Comment on lines +16 to +18
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"cmake-build-debug" and "cmake-build-release" shouldn't be in .gitignore since they are specific to your build. The .idea can remain in .gitignore as this might benefit more people.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use clion ide and it copies files in this folders. GitHub is olweys chalking the folders if it could add then to commit and so on. Therefore in gitignore I ignored builds folder for clion for better stability and working. It shouldn't do any bad think to anyone through because I doubt tgui would use them.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realize that the ide created those debug and release folders too, I though you created those and the ide only created the .idea folder.
Since those folder names seem to be the default setting for clion, you can keep these folders in .gitignore too.

11 changes: 11 additions & 0 deletions gui-builder/include/WidgetProperties/WidgetProperties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ struct WidgetProperties
widget->setVisible(parseBoolean(value, true));
else if (property == "Enabled")
widget->setEnabled(parseBoolean(value, true));
else if (property == "UserData")
widget->setUserData(value.toAnsiString());
else // Renderer property
widget->getRenderer()->setProperty(property, value);
}
Expand All @@ -67,6 +69,15 @@ struct WidgetProperties
pairs["Height"] = {"String", widget->getSizeLayout().y.toString()};
pairs["Visible"] = {"Bool", tgui::Serializer::serialize(widget->isVisible())};
pairs["Enabled"] = {"Bool", tgui::Serializer::serialize(widget->isEnabled())};
try
{
pairs["UserData"] = {"String", widget->getUserData<std::string>()};
}
catch(const std::bad_cast&)
{
pairs["UserData"] = {"String", ""};
}


PropertyValueMap rendererPairs;
const auto renderer = widget->getSharedRenderer();
Expand Down
5 changes: 2 additions & 3 deletions gui-builder/src/Form.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ bool Form::setSelectedWidgetName(const std::string& name)
}
}

m_selectedWidget->ptr->getParent()->setWidgetName(m_selectedWidget->ptr, name);
m_selectedWidget->ptr->Widget::setWidgetName(name);
m_selectedWidget->name = name;
return true;
}
Expand Down Expand Up @@ -575,12 +575,11 @@ void Form::drawExtra(sf::RenderWindow& window) const
void Form::importLoadedWidgets(tgui::Container::Ptr parent)
{
const auto& widgets = parent->getWidgets();
const auto& widgetNames = parent->getWidgetNames();
for (std::size_t i = 0; i < widgets.size(); ++i)
{
const std::string id = tgui::to_string(widgets[i].get());
m_widgets[id] = std::make_shared<WidgetInfo>(widgets[i]);
m_widgets[id]->name = widgetNames[i];
m_widgets[id]->name = widgets[i]->getWidgetName();
m_widgets[id]->theme = "Custom";

if (widgets[i]->isContainer())
Expand Down
2 changes: 1 addition & 1 deletion gui-builder/src/GuiBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2218,7 +2218,7 @@ void GuiBuilder::fillWidgetHierarchyTreeRecursively(std::vector<sf::String>& hie
const size_t widgetCount = asContainer->getWidgets().size();
for (size_t i = 0; i < widgetCount; ++i)
{
hierarchy.push_back(asContainer->getWidgetNames()[i]);
hierarchy.push_back(asContainer->getWidgets()[i]->getWidgetName());
fillWidgetHierarchyTreeRecursively(hierarchy, asContainer->getWidgets()[i]);
hierarchy.pop_back();
}
Expand Down
25 changes: 16 additions & 9 deletions include/TGUI/Container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,26 @@ namespace tgui
return m_widgets;
}


#ifndef TGUI_REMOVE_DEPRECATED_CODE
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns a list of the names of all the widgets in this container
///
/// @return Vector of all widget names
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const std::vector<sf::String>& getWidgetNames() const
TGUI_DEPRECATED("Use getWidgets() and Widget::getWidgetName instead") const std::vector<sf::String> getWidgetNames() const
{
std::vector<sf::String> m_widgetNames;
m_widgetNames.reserve(m_widgets.size());

for (std::size_t i = 0; i < m_widgets.size(); ++i)
{
m_widgetNames.emplace_back(m_widgets[i]->getWidgetName());
}

return m_widgetNames;
}

#endif

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Adds a widget to the container
Expand Down Expand Up @@ -186,7 +194,7 @@ namespace tgui
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
virtual void removeAllWidgets();


#ifndef TGUI_REMOVE_DEPRECATED_CODE
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the name of a widget
///
Expand All @@ -196,19 +204,19 @@ namespace tgui
/// @return True when the name was changed, false when the widget wasn't part of this container.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool setWidgetName(const Widget::Ptr& widget, const std::string& name);
TGUI_DEPRECATED("Use Widget::setWidgetName instead") bool setWidgetName(const Widget::Ptr& widget, const std::string& name);


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the name of a widget
///
/// @param widget Widget of which the name should be retrieved
///
/// @return Name of the widget or an empty string when the widget didn't exist or wasn't given a name
/// @return Name of the widget or an empty string when the widget wasn't part of this container or wasn't given a name
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
std::string getWidgetName(const Widget::ConstPtr& widget) const;

TGUI_DEPRECATED("Use Widget::getWidgetName instead") std::string getWidgetName(const Widget::ConstPtr& widget) const;
#endif

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Unchecks all the radio buttons
Expand Down Expand Up @@ -465,7 +473,6 @@ namespace tgui
protected:

std::vector<Widget::Ptr> m_widgets;
std::vector<sf::String> m_widgetNames;

Widget::Ptr m_widgetBelowMouse;
Widget::Ptr m_focusedWidget;
Expand Down
14 changes: 7 additions & 7 deletions include/TGUI/Gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,15 @@ namespace tgui
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const std::vector<Widget::Ptr>& getWidgets() const;


#ifndef TGUI_REMOVE_DEPRECATED_CODE
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns a list of the names of all the widgets
///
/// @return Vector of all widget names
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const std::vector<sf::String>& getWidgetNames() const;

TGUI_DEPRECATED("Use getWidgets() and Widget::getWidgetName instead") const std::vector<sf::String> getWidgetNames() const;
#endif

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Adds a widget to the container
Expand Down Expand Up @@ -291,7 +291,7 @@ namespace tgui
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void removeAllWidgets();


#ifndef TGUI_REMOVE_DEPRECATED_CODE
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the name of a widget
///
Expand All @@ -301,7 +301,7 @@ namespace tgui
/// @return True when the name was changed, false when the widget wasn't part of this container
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool setWidgetName(const Widget::Ptr& widget, const std::string& name);
TGUI_DEPRECATED("Use Widget::setWidgetName instead") bool setWidgetName(const Widget::Ptr& widget, const std::string& name);


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -312,8 +312,8 @@ namespace tgui
/// @return Name of the widget or an empty string when the widget didn't exist or wasn't given a name
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
std::string getWidgetName(const Widget::Ptr& widget) const;

TGUI_DEPRECATED("Use Widget::getWidgetName instead") std::string getWidgetName(const Widget::Ptr& widget) const;
#endif

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Focuses the next widget
Expand Down
Loading