Add a builder for a pane.
The code is used to experiment with a different approach of the implementation of a listbox.
This commit is contained in:
parent
2d966e6d52
commit
950169d49e
10 changed files with 209 additions and 1 deletions
|
@ -39,6 +39,10 @@
|
|||
name=font_style
|
||||
value="^(normal|bold|italic|underline)?$"
|
||||
[/type]
|
||||
[type]
|
||||
name=grow_direction
|
||||
value="^horizontal|vertical$"
|
||||
[/type]
|
||||
[type]
|
||||
name=h_align
|
||||
value="^left|right|center$"
|
||||
|
@ -1495,6 +1499,28 @@
|
|||
default=initial_auto
|
||||
[/key]
|
||||
[/tag]
|
||||
[tag]
|
||||
name="pane"
|
||||
min="0"
|
||||
max="-1"
|
||||
super="generic/widget_instance"
|
||||
[tag]
|
||||
name="item_definition"
|
||||
min="1"
|
||||
max="1"
|
||||
super="gui/window/resolution/grid"
|
||||
[/tag]
|
||||
[key]
|
||||
name="grow_direction"
|
||||
type="grow_direction"
|
||||
mandatory="true"
|
||||
[/key]
|
||||
[key]
|
||||
name="parallel_items"
|
||||
type="unsigned"
|
||||
mandatory="true"
|
||||
[/key]
|
||||
[/tag]
|
||||
[tag]
|
||||
name="panel"
|
||||
min="0"
|
||||
|
|
|
@ -51,6 +51,7 @@ src/gui/auxiliary/window_builder/label.cpp
|
|||
src/gui/auxiliary/window_builder/listbox.cpp
|
||||
src/gui/auxiliary/window_builder/minimap.cpp
|
||||
src/gui/auxiliary/window_builder/multi_page.cpp
|
||||
src/gui/auxiliary/window_builder/pane.cpp
|
||||
src/gui/auxiliary/window_builder/panel.cpp
|
||||
src/gui/auxiliary/window_builder/password_box.cpp
|
||||
src/gui/auxiliary/window_builder/progress_bar.cpp
|
||||
|
|
|
@ -459,6 +459,7 @@ set(wesnoth-main_SRC
|
|||
gui/auxiliary/window_builder/listbox.cpp
|
||||
gui/auxiliary/window_builder/minimap.cpp
|
||||
gui/auxiliary/window_builder/multi_page.cpp
|
||||
gui/auxiliary/window_builder/pane.cpp
|
||||
gui/auxiliary/window_builder/panel.cpp
|
||||
gui/auxiliary/window_builder/password_box.cpp
|
||||
gui/auxiliary/window_builder/progress_bar.cpp
|
||||
|
|
|
@ -303,6 +303,7 @@ wesnoth_sources = Split("""
|
|||
gui/auxiliary/window_builder/listbox.cpp
|
||||
gui/auxiliary/window_builder/minimap.cpp
|
||||
gui/auxiliary/window_builder/multi_page.cpp
|
||||
gui/auxiliary/window_builder/pane.cpp
|
||||
gui/auxiliary/window_builder/panel.cpp
|
||||
gui/auxiliary/window_builder/password_box.cpp
|
||||
gui/auxiliary/window_builder/progress_bar.cpp
|
||||
|
|
|
@ -523,6 +523,19 @@ tline::tline(const config& cfg)
|
|||
* several times until the entire surface
|
||||
* is filled. The last images are
|
||||
* truncated. $
|
||||
*
|
||||
* grow_direction & Determines how an image is resized.
|
||||
* Possible values:
|
||||
* @* scale The image is scaled.
|
||||
* @* stretch The first row or column
|
||||
* of pixels is copied over the entire
|
||||
* image. (Can only be used to scale resize
|
||||
* in one direction, else falls
|
||||
* back to scale.)
|
||||
* @* tile The image is placed
|
||||
* several times until the entire surface
|
||||
* is filled. The last images are
|
||||
* truncated. $
|
||||
* @end{table}
|
||||
* @allow{type}{name="unsigned"}{value="^\d+$"}
|
||||
* @allow{type}{name="f_unsigned"}{value="^.+$"}
|
||||
|
@ -544,6 +557,7 @@ tline::tline(const config& cfg)
|
|||
* @allow{type}{name="border"}{value="^(top|bottom|left|right|all)?(,\s*(top|bottom|left|right|all))*$"}
|
||||
* @allow{type}{name="scrollbar_mode"}{value="^always|never|auto|initial_auto$"}
|
||||
* @allow{type}{name="resize_mode"}{value="^scale|stretch|tile$"}
|
||||
* @allow{type}{name="grow_direction"}{value="^horizontal|vertical$"}
|
||||
*
|
||||
* @remove{type}{name="section"}
|
||||
* @remove{type}{name="config"}
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "gui/auxiliary/window_builder/minimap.hpp"
|
||||
#include "gui/auxiliary/window_builder/button.hpp"
|
||||
#include "gui/auxiliary/window_builder/drawing.hpp"
|
||||
#include "gui/auxiliary/window_builder/pane.hpp"
|
||||
#include "gui/auxiliary/window_builder/password_box.hpp"
|
||||
#include "gui/auxiliary/window_builder/viewport.hpp"
|
||||
#endif
|
||||
|
@ -172,6 +173,10 @@ tbuilder_widget_ptr create_builder_widget(const config& cfg)
|
|||
return new tbuilder_grid(c);
|
||||
}
|
||||
|
||||
if(const config& pane = cfg.child("pane")) {
|
||||
return new implementation::tbuilder_pane(pane);
|
||||
}
|
||||
|
||||
if(const config& viewport = cfg.child("viewport")) {
|
||||
return new implementation::tbuilder_viewport(viewport);
|
||||
}
|
||||
|
|
77
src/gui/auxiliary/window_builder/pane.cpp
Normal file
77
src/gui/auxiliary/window_builder/pane.cpp
Normal file
|
@ -0,0 +1,77 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2012 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 as published by
|
||||
the Free Software Foundation; either version 2 of the License, 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/window_builder/pane.hpp"
|
||||
|
||||
#include "gettext.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
namespace implementation {
|
||||
|
||||
tbuilder_pane::tbuilder_pane(const config& cfg)
|
||||
: tbuilder_widget(cfg)
|
||||
, grow_direction(
|
||||
lexical_cast<tplacer_::tgrow_direction>(cfg["grow_direction"]))
|
||||
, parallel_items(cfg["parallel_items"])
|
||||
, item_definition(new tbuilder_grid(cfg.child("item_definition", "[pane]")))
|
||||
{
|
||||
VALIDATE(parallel_items > 0, _("Need at least 1 parallel item."));
|
||||
}
|
||||
|
||||
tpane* tbuilder_pane::build() const
|
||||
{
|
||||
return tpane::build(*this);
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
|
||||
} // namespace gui2
|
||||
|
||||
/*WIKI_MACRO
|
||||
* @begin{macro}{pane_description}
|
||||
*
|
||||
* A pane is a container where new members can be added and removed
|
||||
* during run-time.
|
||||
* @end{macro}
|
||||
*/
|
||||
|
||||
/*WIKI
|
||||
* @page = GUIWidgetInstanceWML
|
||||
* @order = 2_viewport
|
||||
* @begin{parent}{name="gui/window/resolution/grid/row/column/"}
|
||||
* @begin{tag}{name="pane"}{min=0}{max=-1}{super="generic/widget_instance"}
|
||||
* == Label ==
|
||||
*
|
||||
* @macro = viewport_description
|
||||
*
|
||||
* List with the label specific variables:
|
||||
* @begin{table}{config}
|
||||
* grow_direction & grow_direction & &
|
||||
* The direction in which new items grow. $
|
||||
* parallel_items & unsigned & &
|
||||
* The number of items that are growing in
|
||||
* parallel. $
|
||||
* item_definition & section & &
|
||||
* The definition of a new item. $
|
||||
* @end{table}
|
||||
*
|
||||
* @begin{tag}{name="item_definition"}{min=1}{max=1}{super="gui/window/resolution/grid"}
|
||||
* @end{tag}{name="item_definition"}
|
||||
* @end{tag}{name="pane"}
|
||||
* @end{parent}{name="gui/window/resolution/grid/row/column/"}
|
||||
*/
|
46
src/gui/auxiliary/window_builder/pane.hpp
Normal file
46
src/gui/auxiliary/window_builder/pane.hpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2012 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 as published by
|
||||
the Free Software Foundation; either version 2 of the License, 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_WINDOW_BUILDER_PANE_HPP_INCLUDED
|
||||
#define GUI_AUXILIARY_WINDOW_BUILDER_PANE_HPP_INCLUDED
|
||||
|
||||
#include "gui/auxiliary/placer.hpp"
|
||||
#include "gui/widgets/pane.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
class tpane;
|
||||
|
||||
namespace implementation {
|
||||
|
||||
struct tbuilder_pane
|
||||
: public tbuilder_widget
|
||||
{
|
||||
explicit tbuilder_pane(const config& cfg);
|
||||
|
||||
tpane* build() const;
|
||||
|
||||
tplacer_::tgrow_direction grow_direction;
|
||||
|
||||
unsigned parallel_items;
|
||||
|
||||
tbuilder_grid_ptr item_definition;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
|
||||
} // namespace gui2
|
||||
|
||||
#endif
|
|
@ -21,6 +21,7 @@
|
|||
#include "gui/widgets/grid.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
#include "utils/const_clone.tpp"
|
||||
#include "gui/auxiliary/window_builder/pane.hpp"
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
|
@ -107,7 +108,6 @@ struct tpane_implementation
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
tpane::tpane(const tbuilder_grid_ptr item_builder)
|
||||
: twidget()
|
||||
, items_()
|
||||
|
@ -125,6 +125,30 @@ tpane::tpane(const tbuilder_grid_ptr item_builder)
|
|||
, event::tdispatcher::back_pre_child);
|
||||
}
|
||||
|
||||
tpane::tpane(const implementation::tbuilder_pane& builder)
|
||||
: twidget(builder)
|
||||
, items_()
|
||||
, item_builder_(builder.item_definition)
|
||||
, item_id_generator_(0)
|
||||
, placer_(tplacer_::build(
|
||||
builder.grow_direction
|
||||
, builder.parallel_items))
|
||||
{
|
||||
connect_signal<event::REQUEST_PLACEMENT>(
|
||||
boost::bind(
|
||||
&tpane::signal_handler_request_placement
|
||||
, this
|
||||
, _1
|
||||
, _2
|
||||
, _3)
|
||||
, event::tdispatcher::back_pre_child);
|
||||
}
|
||||
|
||||
tpane* tpane::build(const implementation::tbuilder_pane& builder)
|
||||
{
|
||||
return new tpane(builder);
|
||||
}
|
||||
|
||||
unsigned tpane::create_item(
|
||||
const std::map<std::string, string_map>& item_data
|
||||
, const std::map<std::string, std::string>& tags)
|
||||
|
|
|
@ -26,6 +26,10 @@
|
|||
|
||||
namespace gui2 {
|
||||
|
||||
namespace implementation {
|
||||
class tbuilder_pane;
|
||||
} // namespace implementation
|
||||
|
||||
class tgrid;
|
||||
|
||||
class tpane
|
||||
|
@ -49,8 +53,17 @@ public:
|
|||
|
||||
typedef boost::function<bool(const titem&)> tfilter_functor;
|
||||
|
||||
/** @deprecated Use the second overload. */
|
||||
explicit tpane(const tbuilder_grid_ptr item_builder);
|
||||
|
||||
private:
|
||||
|
||||
explicit tpane(const implementation::tbuilder_pane& builder);
|
||||
|
||||
public:
|
||||
|
||||
static tpane* build(const implementation::tbuilder_pane& builder);
|
||||
|
||||
/**
|
||||
* Creates a new item.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue