Move thorizontal_scrollbar_definition to a new file.
This commit is contained in:
parent
fc35486cd0
commit
3f1fd92c11
9 changed files with 137 additions and 78 deletions
|
@ -11,6 +11,7 @@ src/gui/auxiliary/event/handler.cpp
|
|||
src/gui/auxiliary/log.cpp
|
||||
src/gui/auxiliary/widget_definition.cpp
|
||||
src/gui/auxiliary/widget_definition/button.cpp
|
||||
src/gui/auxiliary/widget_definition/horizontal_scrollbar.cpp
|
||||
src/gui/auxiliary/widget_definition/vertical_scrollbar.cpp
|
||||
src/gui/auxiliary/window_builder/button.cpp
|
||||
src/gui/auxiliary/window_builder/control.cpp
|
||||
|
|
|
@ -227,6 +227,7 @@ set(wesnoth-main_SRC
|
|||
gui/auxiliary/timer.cpp
|
||||
gui/auxiliary/widget_definition.cpp
|
||||
gui/auxiliary/widget_definition/button.cpp
|
||||
gui/auxiliary/widget_definition/horizontal_scrollbar.cpp
|
||||
gui/auxiliary/widget_definition/vertical_scrollbar.cpp
|
||||
gui/auxiliary/window_builder/button.cpp
|
||||
gui/auxiliary/window_builder/control.cpp
|
||||
|
|
|
@ -107,6 +107,7 @@ wesnoth_source = \
|
|||
gui/auxiliary/timer.cpp \
|
||||
gui/auxiliary/widget_definition.cpp \
|
||||
gui/auxiliary/widget_definition/button.cpp \
|
||||
gui/auxiliary/widget_definition/horizontal_scrollbar.cpp \
|
||||
gui/auxiliary/widget_definition/vertical_scrollbar.cpp \
|
||||
gui/auxiliary/window_builder/button.cpp \
|
||||
gui/auxiliary/window_builder/control.cpp \
|
||||
|
|
|
@ -267,6 +267,7 @@ wesnoth_sources = Split("""
|
|||
gui/auxiliary/timer.cpp
|
||||
gui/auxiliary/widget_definition.cpp
|
||||
gui/auxiliary/widget_definition/button.cpp
|
||||
gui/auxiliary/widget_definition/horizontal_scrollbar.cpp
|
||||
gui/auxiliary/widget_definition/vertical_scrollbar.cpp
|
||||
gui/auxiliary/window_builder/button.cpp
|
||||
gui/auxiliary/window_builder/control.cpp
|
||||
|
|
87
src/gui/auxiliary/widget_definition/horizontal_scrollbar.cpp
Normal file
87
src/gui/auxiliary/widget_definition/horizontal_scrollbar.cpp
Normal file
|
@ -0,0 +1,87 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2007 - 2010 by Mark de Wever <koraq@xs4all.nl>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2
|
||||
or at your option any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#define GETTEXT_DOMAIN "wesnoth-lib"
|
||||
|
||||
#include "gui/auxiliary/widget_definition/horizontal_scrollbar.hpp"
|
||||
|
||||
#include "gui/auxiliary/log.hpp"
|
||||
#include "wml_exception.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
thorizontal_scrollbar_definition::
|
||||
thorizontal_scrollbar_definition(const config& cfg) :
|
||||
tcontrol_definition(cfg)
|
||||
{
|
||||
DBG_GUI_P << "Parsing horizontal scrollbar " << id << '\n';
|
||||
|
||||
load_resolutions<tresolution>(cfg);
|
||||
}
|
||||
|
||||
thorizontal_scrollbar_definition::tresolution::tresolution(const config& cfg) :
|
||||
tresolution_definition_(cfg),
|
||||
minimum_positioner_length(
|
||||
lexical_cast_default<unsigned>(cfg["minimum_positioner_length"])),
|
||||
maximum_positioner_length(
|
||||
lexical_cast_default<unsigned>(cfg["maximum_positioner_length"])),
|
||||
left_offset(lexical_cast_default<unsigned>(cfg["left_offset"])),
|
||||
right_offset(lexical_cast_default<unsigned>(cfg["right_offset"]))
|
||||
{
|
||||
/*WIKI
|
||||
* @page = GUIWidgetDefinitionWML
|
||||
* @order = 1_vertical_scrollbar
|
||||
*
|
||||
* == Horizontal scrollbar ==
|
||||
*
|
||||
* @macro = horizontal_scrollbar_description
|
||||
*
|
||||
* The resolution for a horizontal scrollbar also contains the following keys:
|
||||
* @start_table = config
|
||||
* minimum_positioner_length (unsigned)
|
||||
* The minumum size the positioner is
|
||||
* allowed to be. The engine needs to know
|
||||
* this in order to calculate the best size
|
||||
* for the positioner.
|
||||
* maximum_positioner_length (unsigned = 0)
|
||||
* The maximum size the positioner is
|
||||
* allowed to be. If minimum and maximum are
|
||||
* the same value the positioner is fixed
|
||||
* size. If the maximum is 0 (and the
|
||||
* minimum not) there's no maximum.
|
||||
* left_offset (unsigned = 0) The number of pixels at the left which
|
||||
* can't be used by the positioner.
|
||||
* right_offset (unsigned = 0) The number of pixels at the right which
|
||||
* can't be used by the positioner.
|
||||
* @end_table
|
||||
*
|
||||
* The following states exist:
|
||||
* * state_enabled, the horizontal scrollbar is enabled.
|
||||
* * state_disabled, the horizontal scrollbar is disabled.
|
||||
* * state_pressed, the left mouse button is down on the positioner of the horizontal scrollbar.
|
||||
* * state_focussed, the mouse is over the positioner of the horizontal scrollbar.
|
||||
*/
|
||||
|
||||
VALIDATE(minimum_positioner_length,
|
||||
missing_mandatory_wml_key("resolution", "minimum_positioner_length"));
|
||||
|
||||
// Note the order should be the same as the enum tstate is scrollbar.hpp.
|
||||
state.push_back(tstate_definition(cfg.child("state_enabled")));
|
||||
state.push_back(tstate_definition(cfg.child("state_disabled")));
|
||||
state.push_back(tstate_definition(cfg.child("state_pressed")));
|
||||
state.push_back(tstate_definition(cfg.child("state_focussed")));
|
||||
}
|
||||
|
||||
} // namespace gui2
|
||||
|
43
src/gui/auxiliary/widget_definition/horizontal_scrollbar.hpp
Normal file
43
src/gui/auxiliary/widget_definition/horizontal_scrollbar.hpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2007 - 2010 by Mark de Wever <koraq@xs4all.nl>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2
|
||||
or at your option any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#ifndef GUI_AUXILIARY_WIDGET_DEFINITION_HORIZONTAL_SCROLLBAR_HPP_INCLUDED
|
||||
#define GUI_AUXILIARY_WIDGET_DEFINITION_HORIZONTAL_SCROLLBAR_HPP_INCLUDED
|
||||
|
||||
#include "gui/auxiliary/widget_definition.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
struct thorizontal_scrollbar_definition
|
||||
: public tcontrol_definition
|
||||
{
|
||||
explicit thorizontal_scrollbar_definition(const config& cfg);
|
||||
|
||||
struct tresolution
|
||||
: public tresolution_definition_
|
||||
{
|
||||
explicit tresolution(const config& cfg);
|
||||
|
||||
unsigned minimum_positioner_length;
|
||||
unsigned maximum_positioner_length;
|
||||
|
||||
unsigned left_offset;
|
||||
unsigned right_offset;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace gui2
|
||||
|
||||
#endif
|
||||
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
#include "gui/widgets/horizontal_scrollbar.hpp"
|
||||
|
||||
#include "gui/auxiliary/widget_definition/horizontal_scrollbar.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
unsigned thorizontal_scrollbar::minimum_positioner_length() const
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "gettext.hpp"
|
||||
#include "gui/auxiliary/log.hpp"
|
||||
#include "gui/auxiliary/widget_definition/button.hpp"
|
||||
#include "gui/auxiliary/widget_definition/horizontal_scrollbar.cpp"
|
||||
#include "gui/auxiliary/widget_definition/vertical_scrollbar.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
#include "serialization/parser.hpp"
|
||||
|
@ -442,68 +443,6 @@ tstate_definition::tstate_definition(const config &cfg) :
|
|||
canvas.set_cfg(draw);
|
||||
}
|
||||
|
||||
thorizontal_scrollbar_definition::
|
||||
thorizontal_scrollbar_definition(const config& cfg) :
|
||||
tcontrol_definition(cfg)
|
||||
{
|
||||
DBG_GUI_P << "Parsing horizontal scrollbar " << id << '\n';
|
||||
|
||||
load_resolutions<tresolution>(cfg);
|
||||
}
|
||||
|
||||
thorizontal_scrollbar_definition::tresolution::tresolution(const config& cfg) :
|
||||
tresolution_definition_(cfg),
|
||||
minimum_positioner_length(
|
||||
lexical_cast_default<unsigned>(cfg["minimum_positioner_length"])),
|
||||
maximum_positioner_length(
|
||||
lexical_cast_default<unsigned>(cfg["maximum_positioner_length"])),
|
||||
left_offset(lexical_cast_default<unsigned>(cfg["left_offset"])),
|
||||
right_offset(lexical_cast_default<unsigned>(cfg["right_offset"]))
|
||||
{
|
||||
/*WIKI
|
||||
* @page = GUIWidgetDefinitionWML
|
||||
* @order = 1_vertical_scrollbar
|
||||
*
|
||||
* == Horizontal scrollbar ==
|
||||
*
|
||||
* @macro = horizontal_scrollbar_description
|
||||
*
|
||||
* The resolution for a horizontal scrollbar also contains the following keys:
|
||||
* @start_table = config
|
||||
* minimum_positioner_length (unsigned)
|
||||
* The minumum size the positioner is
|
||||
* allowed to be. The engine needs to know
|
||||
* this in order to calculate the best size
|
||||
* for the positioner.
|
||||
* maximum_positioner_length (unsigned = 0)
|
||||
* The maximum size the positioner is
|
||||
* allowed to be. If minimum and maximum are
|
||||
* the same value the positioner is fixed
|
||||
* size. If the maximum is 0 (and the
|
||||
* minimum not) there's no maximum.
|
||||
* left_offset (unsigned = 0) The number of pixels at the left which
|
||||
* can't be used by the positioner.
|
||||
* right_offset (unsigned = 0) The number of pixels at the right which
|
||||
* can't be used by the positioner.
|
||||
* @end_table
|
||||
*
|
||||
* The following states exist:
|
||||
* * state_enabled, the horizontal scrollbar is enabled.
|
||||
* * state_disabled, the horizontal scrollbar is disabled.
|
||||
* * state_pressed, the left mouse button is down on the positioner of the horizontal scrollbar.
|
||||
* * state_focussed, the mouse is over the positioner of the horizontal scrollbar.
|
||||
*/
|
||||
|
||||
VALIDATE(minimum_positioner_length,
|
||||
missing_mandatory_wml_key("resolution", "minimum_positioner_length"));
|
||||
|
||||
// Note the order should be the same as the enum tstate is scrollbar.hpp.
|
||||
state.push_back(tstate_definition(cfg.child("state_enabled")));
|
||||
state.push_back(tstate_definition(cfg.child("state_disabled")));
|
||||
state.push_back(tstate_definition(cfg.child("state_pressed")));
|
||||
state.push_back(tstate_definition(cfg.child("state_focussed")));
|
||||
}
|
||||
|
||||
timage_definition::timage_definition(const config& cfg) :
|
||||
tcontrol_definition(cfg)
|
||||
{
|
||||
|
|
|
@ -94,22 +94,6 @@ const std::string& get_id(const twindow_type window_type);
|
|||
struct tlistbox_definition;
|
||||
typedef tlistbox_definition thorizontal_listbox_definition;
|
||||
|
||||
struct thorizontal_scrollbar_definition : public tcontrol_definition
|
||||
{
|
||||
thorizontal_scrollbar_definition(const config& cfg);
|
||||
|
||||
struct tresolution : public tresolution_definition_
|
||||
{
|
||||
tresolution(const config& cfg);
|
||||
|
||||
unsigned minimum_positioner_length;
|
||||
unsigned maximum_positioner_length;
|
||||
|
||||
unsigned left_offset;
|
||||
unsigned right_offset;
|
||||
};
|
||||
};
|
||||
|
||||
struct timage_definition : public tcontrol_definition
|
||||
{
|
||||
timage_definition(const config& cfg);
|
||||
|
|
Loading…
Add table
Reference in a new issue