Add the skeletal code for the new viewport widget.
The code is used to experiment with a different approach of the implementation of a listbox.
This commit is contained in:
parent
0621eb4f0e
commit
3e5352e0c4
6 changed files with 135 additions and 3 deletions
|
@ -164,5 +164,6 @@ src/widgets/scrollbar.cpp
|
|||
src/widgets/scrollpane.cpp
|
||||
src/widgets/slider.cpp
|
||||
src/widgets/textbox.cpp
|
||||
src/widgets/viewport.cpp
|
||||
src/widgets/widget.cpp
|
||||
src/wml_exception.cpp
|
||||
|
|
|
@ -550,6 +550,7 @@ set(wesnoth-main_SRC
|
|||
gui/widgets/tree_view.cpp
|
||||
gui/widgets/tree_view_node.cpp
|
||||
gui/widgets/vertical_scrollbar.cpp
|
||||
gui/widgets/viewport.cpp
|
||||
gui/widgets/widget.cpp
|
||||
gui/widgets/window.cpp
|
||||
halo.cpp
|
||||
|
|
|
@ -127,6 +127,7 @@ libwesnoth_sources = Split("""
|
|||
widgets/scrollbar.cpp
|
||||
widgets/slider.cpp
|
||||
widgets/textbox.cpp
|
||||
widgets/viewport.cpp
|
||||
widgets/widget.cpp
|
||||
wml_exception.cpp
|
||||
""")
|
||||
|
|
|
@ -22,12 +22,14 @@
|
|||
#include "gui/auxiliary/log.hpp"
|
||||
#include "gui/auxiliary/widget_definition/listbox.hpp"
|
||||
#include "gui/auxiliary/window_builder/helper.hpp"
|
||||
#include "gui/widgets/grid.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/pane.hpp"
|
||||
#include "gui/widgets/viewport.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "wml_exception.hpp"
|
||||
|
||||
|
@ -100,9 +102,31 @@ twidget* tbuilder_listbox::build() const
|
|||
return widget;
|
||||
#else
|
||||
if(new_widgets) {
|
||||
tpane *widget = new tpane(list_builder);
|
||||
widget->set_id(id);
|
||||
return widget;
|
||||
|
||||
tpane *pane = new tpane(list_builder);
|
||||
pane->set_id(id);
|
||||
|
||||
tviewport *viewport = new tviewport();
|
||||
|
||||
tgrid* grid = new tgrid();
|
||||
grid->set_rows_cols(1, 2);
|
||||
grid->set_child(
|
||||
pane
|
||||
, 0
|
||||
, 0
|
||||
, tgrid::VERTICAL_GROW_SEND_TO_CLIENT
|
||||
| tgrid::HORIZONTAL_GROW_SEND_TO_CLIENT
|
||||
, tgrid::BORDER_ALL);
|
||||
|
||||
grid->set_child(
|
||||
viewport
|
||||
, 0
|
||||
, 1
|
||||
, tgrid::VERTICAL_GROW_SEND_TO_CLIENT
|
||||
| tgrid::HORIZONTAL_GROW_SEND_TO_CLIENT
|
||||
, tgrid::BORDER_ALL);
|
||||
|
||||
return grid;
|
||||
}
|
||||
|
||||
tlistbox *widget = new tlistbox(
|
||||
|
|
53
src/gui/widgets/viewport.cpp
Normal file
53
src/gui/widgets/viewport.cpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
/* $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/widgets/viewport.hpp"
|
||||
|
||||
#include "gui/auxiliary/log.hpp"
|
||||
|
||||
#define LOG_SCOPE_HEADER "tviewport [" + id() + "] " + __func__
|
||||
#define LOG_HEADER LOG_SCOPE_HEADER + ':'
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
tviewport::tviewport()
|
||||
{
|
||||
}
|
||||
|
||||
void tviewport::request_reduce_width(const unsigned /*maximum_width*/)
|
||||
{
|
||||
}
|
||||
|
||||
tpoint tviewport::calculate_best_size() const
|
||||
{
|
||||
return tpoint(500, 500);
|
||||
}
|
||||
|
||||
bool tviewport::disable_click_dismiss() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
iterator::twalker_* tviewport::create_walker()
|
||||
{
|
||||
/**
|
||||
* @todo Implement properly.
|
||||
*/
|
||||
return NULL;
|
||||
}
|
||||
|
||||
} // namespace gui2
|
52
src/gui/widgets/viewport.hpp
Normal file
52
src/gui/widgets/viewport.hpp
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* $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_WIDGETS_VIEWPORT_HPP_INCLUDED
|
||||
#define GUI_WIDGETS_VIEWPORT_HPP_INCLUDED
|
||||
|
||||
#include "gui/widgets/widget.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
class tgrid;
|
||||
|
||||
class tviewport
|
||||
: public twidget
|
||||
{
|
||||
public:
|
||||
|
||||
tviewport();
|
||||
|
||||
/** Inherited from twidget. */
|
||||
void request_reduce_width(const unsigned maximum_width);
|
||||
|
||||
private:
|
||||
/** Inherited from twidget. */
|
||||
tpoint calculate_best_size() const;
|
||||
|
||||
public:
|
||||
/** Inherited from twidget. */
|
||||
bool disable_click_dismiss() const;
|
||||
|
||||
/** Inherited from twidget. */
|
||||
virtual iterator::twalker_* create_walker();
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
} // namespace gui2
|
||||
|
||||
#endif
|
Loading…
Add table
Reference in a new issue