Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
* Renamed the widget from size_fixater to size_lock.
  Thanks @shikadilord for the suggestion.
* Fixed build with -Werror=reorder.
* Fixed: the line of size_fixater.cpp was indented with spaces
  in CMakeLists.txt.
* Added newlines to the end of the new files.
  • Loading branch information
jyrkive committed Oct 28, 2016
1 parent 7ead84e commit 53af829
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 39 deletions.
4 changes: 2 additions & 2 deletions projectfiles/VC12/wesnoth.vcxproj
Expand Up @@ -2581,7 +2581,7 @@
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Test_Debug|Win32'">$(IntDir)Gui\Widgets\</ObjectFileName>
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Test_Release|Win32'">$(IntDir)Gui\Widgets\</ObjectFileName>
</ClCompile>
<ClCompile Include="..\..\src\gui\widgets\size_fixater.cpp">
<ClCompile Include="..\..\src\gui\widgets\size_lock.cpp">
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)Gui\Widgets</ObjectFileName>
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)Gui\Widgets</ObjectFileName>
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='ReleaseDEBUG|Win32'">$(IntDir)Gui\Widgets</ObjectFileName>
Expand Down Expand Up @@ -4352,7 +4352,7 @@
<ClInclude Include="..\..\src\gui\widgets\scroll_label.hpp" />
<ClInclude Include="..\..\src\gui\widgets\selectable.hpp" />
<ClInclude Include="..\..\src\gui\widgets\settings.hpp" />
<ClInclude Include="..\..\src\gui\widgets\size_fixater.hpp" />
<ClInclude Include="..\..\src\gui\widgets\size_lock.hpp" />
<ClInclude Include="..\..\src\gui\widgets\slider.hpp" />
<ClInclude Include="..\..\src\gui\widgets\spacer.hpp" />
<ClInclude Include="..\..\src\gui\widgets\stacked_widget.hpp" />
Expand Down
4 changes: 2 additions & 2 deletions projectfiles/VC12/wesnoth.vcxproj.filters
Expand Up @@ -1558,7 +1558,7 @@
<ClCompile Include="..\..\src\font\text_formatting.cpp">
<Filter>Font</Filter>
</ClCompile>
<ClCompile Include="..\..\src\gui\widgets\size_fixater.cpp">
<ClCompile Include="..\..\src\gui\widgets\size_lock.cpp">
<Filter>Gui\Widgets</Filter>
</ClCompile>
</ItemGroup>
Expand Down Expand Up @@ -3020,7 +3020,7 @@
<ClInclude Include="..\..\src\font\error.hpp">
<Filter>Font</Filter>
</ClInclude>
<ClInclude Include="..\..\src\gui\widgets\size_fixater.hpp">
<ClInclude Include="..\..\src\gui\widgets\size_lock.hpp">
<Filter>Gui\Widgets</Filter>
</ClInclude>
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Expand Up @@ -536,7 +536,7 @@ set(wesnoth-gui_widget_SRC
gui/widgets/scrollbar_container.cpp
gui/widgets/scrollbar_panel.cpp
gui/widgets/settings.cpp
gui/widgets/size_fixater.cpp
gui/widgets/size_lock.cpp
gui/widgets/slider.cpp
gui/widgets/spacer.cpp
gui/widgets/stacked_widget.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/SConscript
Expand Up @@ -466,7 +466,7 @@ wesnoth_sources = Split("""
gui/widgets/scrollbar_panel.cpp
gui/widgets/scrollbar.cpp
gui/widgets/settings.cpp
gui/widgets/size_fixater.cpp
gui/widgets/size_lock.cpp
gui/widgets/slider.cpp
gui/widgets/spacer.cpp
gui/widgets/stacked_widget.cpp
Expand Down
46 changes: 23 additions & 23 deletions src/gui/widgets/size_fixater.cpp → src/gui/widgets/size_lock.cpp
Expand Up @@ -14,7 +14,7 @@

#define GETTEXT_DOMAIN "wesnoth-lib"

#include "size_fixater.hpp"
#include "size_lock.hpp"

#include <gettext.hpp>
#include <gui/core/register_widget.hpp>
Expand All @@ -25,17 +25,17 @@
namespace gui2
{

REGISTER_WIDGET(size_fixater)
REGISTER_WIDGET(size_lock)

void tsize_fixater::layout_children()
void tsize_lock::layout_children()
{
assert(generator_ != nullptr);
assert(generator_->get_item_count() == 1);

generator_->item(0).layout_children();
}

void tsize_fixater::finalize(tbuilder_grid_const_ptr widget_builder)
void tsize_lock::finalize(tbuilder_grid_const_ptr widget_builder)
{
assert(generator_ != nullptr);

Expand All @@ -47,7 +47,7 @@ void tsize_fixater::finalize(tbuilder_grid_const_ptr widget_builder)
delete old_grid;
}

tsize_fixater_definition::tsize_fixater_definition(const config& cfg) :
tsize_lock_definition::tsize_lock_definition(const config& cfg) :
tcontrol_definition(cfg)
{
DBG_GUI_P << "Parsing fixed size widget " << id << '\n';
Expand All @@ -57,22 +57,22 @@ tsize_fixater_definition::tsize_fixater_definition(const config& cfg) :

/*WIKI
* @page = GUIWidgetDefinitionWML
* @order = 1_size_fixater
* @order = 1_size_lock
*
* == Size fixater ==
* == Size lock ==
*
* A size fixater contains one child widget and forces it to have the specified size.
* A size lock contains one child widget and forces it to have the specified size.
* This can be used, for example, when there are two list boxes in different rows of
* the same grid and it's desired that only one list box changes size when its
* contents change.
*
* A size fixater has no states.
* A size lock has no states.
* @begin{parent}{name="gui/"}
* @begin{tag}{name="size_fixater_definition"}{min=0}{max=-1}{super="generic/widget_definition"}
* @end{tag}{name="size_fixater_definition"}
* @begin{tag}{name="size_lock_definition"}{min=0}{max=-1}{super="generic/widget_definition"}
* @end{tag}{name="size_lock_definition"}
* @end{tag}{name="gui/"}
*/
tsize_fixater_definition::tresolution::tresolution(const config& cfg) :
tsize_lock_definition::tresolution::tresolution(const config& cfg) :
tresolution_definition_(cfg), grid(nullptr)
{
const config& child = cfg.child("grid");
Expand All @@ -83,12 +83,12 @@ tsize_fixater_definition::tresolution::tresolution(const config& cfg) :

/*WIKI
* @page = GUIWidgetInstanceWML
* @order = 2_size_fixater
* @order = 2_size_lock
* @begin{parent}{name="gui/window/resolution/grid/row/column/"}
* @begin{tag}{name="size_fixater"}{min=0}{max=-1}{super="generic/widget_instance"}
* == Size fixater ==
* @begin{tag}{name="size_lock"}{min=0}{max=-1}{super="generic/widget_instance"}
* == Size lock ==
*
* A size fixater contains one child widget and forces it to have the specified size.
* A size lock contains one child widget and forces it to have the specified size.
* This can be used, for example, when there are two list boxes in different rows of
* the same grid and it's desired that only one list box changes size when its
* contents change.
Expand All @@ -101,30 +101,30 @@ tsize_fixater_definition::tresolution::tresolution(const config& cfg) :
*
* The variables available are the same as for window resolution, see
* [[GuiToolkitWML#Resolution_2]] for the list of items.
* @end{tag}{name="size_fixater"}
* @end{tag}{name="size_lock"}
* @end{parent}{name="gui/window/resolution/grid/row/column/"}
*/

namespace implementation
{

tbuilder_size_fixater::tbuilder_size_fixater(const config& cfg) :
tbuilder_control(cfg), width_(cfg["width"]), height_(cfg["height"]), content_(nullptr)
tbuilder_size_lock::tbuilder_size_lock(const config& cfg) :
tbuilder_control(cfg), content_(nullptr), width_(cfg["width"]), height_(cfg["height"])
{
VALIDATE(cfg.has_child("widget"), _("No widget defined."));
content_ = std::make_shared<tbuilder_grid>(cfg.child("widget"));
}

twidget* tbuilder_size_fixater::build() const
twidget* tbuilder_size_lock::build() const
{
tsize_fixater* widget = new tsize_fixater();
tsize_lock* widget = new tsize_lock();

init_control(widget);

DBG_GUI_G << "Window builder: placed fixed size widget '" << id <<
"' with definition '" << definition << "'.\n";

auto conf = std::static_pointer_cast<const tsize_fixater_definition::tresolution>(widget->config());
auto conf = std::static_pointer_cast<const tsize_lock_definition::tresolution>(widget->config());
assert(conf != nullptr);

widget->init_grid(conf->grid);
Expand All @@ -145,4 +145,4 @@ twidget* tbuilder_size_fixater::build() const

}

}
}
20 changes: 10 additions & 10 deletions src/gui/widgets/size_fixater.hpp → src/gui/widgets/size_lock.hpp
Expand Up @@ -27,17 +27,17 @@ namespace gui2

namespace implementation
{
struct tbuilder_size_fixater;
struct tbuilder_size_lock;
}

/* A fixed-size widget that wraps an arbitrary widget and forces it to the given size. */

class tsize_fixater : public tcontainer_
class tsize_lock : public tcontainer_
{
friend struct implementation::tbuilder_size_fixater;
friend struct implementation::tbuilder_size_lock;

public:
tsize_fixater() :
tsize_lock() :
tcontainer_(1),
generator_(
tgenerator_::build(false, false, tgenerator_::independent, false))
Expand Down Expand Up @@ -91,7 +91,7 @@ namespace gui2
/** See @ref tcontrol::get_control_type. */
const std::string& get_control_type() const override
{
static const std::string control_type = "size_fixater";
static const std::string control_type = "size_lock";
return control_type;
}

Expand All @@ -102,9 +102,9 @@ namespace gui2
}
};

struct tsize_fixater_definition : public tcontrol_definition
struct tsize_lock_definition : public tcontrol_definition
{
explicit tsize_fixater_definition(const config& cfg);
explicit tsize_lock_definition(const config& cfg);

struct tresolution : public tresolution_definition_
{
Expand All @@ -117,9 +117,9 @@ namespace gui2
namespace implementation
{

struct tbuilder_size_fixater : public tbuilder_control
struct tbuilder_size_lock : public tbuilder_control
{
explicit tbuilder_size_fixater(const config& cfg);
explicit tbuilder_size_lock(const config& cfg);

using tbuilder_control::build;

Expand All @@ -133,4 +133,4 @@ namespace gui2
}
}

#endif
#endif

0 comments on commit 53af829

Please sign in to comment.