Removed GUI1 scrollpane class

Not sure when this became unused, but it is now.
This commit is contained in:
Charles Dang 2017-02-19 01:14:02 +11:00
parent 8a5274c39b
commit dec7c30644
5 changed files with 0 additions and 275 deletions

View file

@ -1180,8 +1180,6 @@
<Unit filename="../../src/widgets/scrollarea.hpp" />
<Unit filename="../../src/widgets/scrollbar.cpp" />
<Unit filename="../../src/widgets/scrollbar.hpp" />
<Unit filename="../../src/widgets/scrollpane.cpp" />
<Unit filename="../../src/widgets/scrollpane.hpp" />
<Unit filename="../../src/widgets/slider.cpp" />
<Unit filename="../../src/widgets/slider.hpp" />
<Unit filename="../../src/widgets/textbox.cpp" />

View file

@ -403,4 +403,3 @@ whiteboard/recruit.cpp
whiteboard/side_actions.cpp
whiteboard/suppose_dead.cpp
whiteboard/utility.cpp
widgets/scrollpane.cpp

View file

@ -1,186 +0,0 @@
/*
Copyright (C) 2004 - 2016 by Philippe Plantier <ayin@anathas.org>
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.
*/
/** @file */
#define GETTEXT_DOMAIN "wesnoth-lib"
#include <algorithm>
#include <boost/dynamic_bitset.hpp>
#include "widgets/scrollpane.hpp"
namespace {
class widget_finder {
public:
widget_finder(gui::widget* w) : w_(w) {}
bool operator()(const std::pair<int, gui::scrollpane::scrollpane_widget>& p)
{
if(p.second.w == w_)
return true;
return false;
}
private:
gui::widget* w_;
};
}
namespace gui {
scrollpane::scrollpane(CVideo &video) : scrollarea(video), border_(5)
{
content_pos_.x = 0;
content_pos_.y = 0;
update_content_size();
set_scroll_rate(40);
}
void scrollpane::clear()
{
content_.clear();
update_content_size();
}
void scrollpane::set_location(SDL_Rect const& rect)
{
scrollarea::set_location(rect);
set_shown_size(client_area().h);
update_widget_positions();
}
void scrollpane::hide(bool value)
{
for(widget_map::iterator itor = content_.begin(); itor != content_.end(); ++itor) {
itor->second.w->hide_override(value);
}
}
void scrollpane::add_widget(widget* w, int x, int y, int z_order)
{
if (w == nullptr)
return;
widget_map::iterator itor = std::find_if(content_.begin(), content_.end(), widget_finder(w));
if (itor != content_.end())
return;
scrollpane_widget spw(w, x, y, z_order);
w->set_clip_rect(client_area());
content_.insert(std::pair<int, scrollpane_widget>(z_order, spw));
position_widget(spw);
// Recalculates the whole content size
update_content_size();
}
void scrollpane::remove_widget(widget* w)
{
widget_map::iterator itor = std::find_if(content_.begin(), content_.end(), widget_finder(w));
if (itor != content_.end())
content_.erase(itor);
update_content_size();
}
void scrollpane::set_inner_location(const SDL_Rect& /*rect*/)
{
for(widget_map::iterator itor = content_.begin(); itor != content_.end(); ++itor) {
itor->second.w->set_clip_rect(client_area());
}
}
void scrollpane::draw()
{
//draws the scrollpane background
}
void scrollpane::scroll(unsigned int pos)
{
if (static_cast<int>(pos) == content_pos_.y)
return;
content_pos_.y = pos;
update_widget_positions();
}
void scrollpane::update_widget_positions()
{
widget_map::iterator itor;
boost::dynamic_bitset<> hidden(content_.size());
int i = 0;
for(itor = content_.begin(); itor != content_.end(); ++itor) {
hidden[i++] = (itor->second.w->state_ == HIDDEN);
itor->second.w->hide();
}
for(itor = content_.begin(); itor != content_.end(); ++itor) {
position_widget(itor->second);
}
i = 0;
for(itor = content_.begin(); itor != content_.end(); ++itor) {
if (!hidden[i++])
itor->second.w->hide(false);
}
set_dirty();
}
void scrollpane::position_widget(scrollpane_widget& spw)
{
spw.w->set_location(spw.x + location().x + border_,
spw.y + location().y - content_pos_.y + border_);
}
SDL_Rect scrollpane::client_area() const
{
SDL_Rect res;
res.x = location().x + border_;
res.y = location().y + border_;
res.w = location().w > 2 * border_ ? location().w - 2 * border_ : 0;
res.h = location().h > 2 * border_ ? location().h - 2 * border_ : 0;
return res;
}
void scrollpane::update_content_size()
{
int maxx = 0;
int maxy = 0;
for(widget_map::iterator itor = content_.begin(); itor != content_.end(); ++itor) {
if(itor->second.x + itor->second.w->width() > maxx) {
maxx = itor->second.x + itor->second.w->width();
}
if(itor->second.y + itor->second.w->height() > maxy) {
maxy = itor->second.y + itor->second.w->height();
}
}
content_pos_.w = maxx;
content_pos_.h = maxy;
set_full_size(maxy);
set_shown_size(client_area().h);
set_dirty();
}
} // namespace gui

View file

@ -1,85 +0,0 @@
/*
Copyright (C) 2004 - 2016 by Philippe Plantier <ayin@anathas.org>
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.
*/
/** @file */
#ifndef SCROLLPANE_HPP_INCLUDED
#define SCROLLPANE_HPP_INCLUDED
#include <map>
#include <vector>
#include <SDL.h>
#include "sdl/surface.hpp"
#include "scrollarea.hpp"
namespace gui {
/** Scrollpane. */
class scrollpane : public scrollarea
{
public:
struct scrollpane_widget {
scrollpane_widget(widget* w, int x=0, int y=0, int z_order=0)
: w(w), x(x), y(y), z_order(z_order) {}
widget* w;
int x;
int y;
int z_order;
};
/**
* Create a scrollpane.
* @todo FIXME: parameterlist ??
*/
//- @param d the display object
//- @param pane the widget where wheel events take place
//- @param callback a callback interface for warning that the grip has been moved
scrollpane(CVideo &video);
virtual void set_location(SDL_Rect const &rect);
// VC++ doesn't like a 'using scrollarea::set_location' directive here,
// so we declare an inline forwarding function instead.
void set_location(int x, int y) { widget::set_location(x,y); }
virtual void hide(bool value=true);
void add_widget(widget* w, int x, int y, int z_order = 0);
void remove_widget(widget* w);
void clear();
protected:
//virtual void handle_event(const SDL_Event& event);
//virtual void process_event();
virtual void draw();
virtual void set_inner_location(SDL_Rect const &rect);
virtual void scroll(unsigned int pos);
private:
void update_widget_positions();
void position_widget(scrollpane_widget& spw);
SDL_Rect client_area() const;
void update_content_size();
int border_;
typedef std::multimap<int, scrollpane_widget> widget_map;
widget_map content_;
SDL_Rect content_pos_;
};
} // namespace gui
#endif

View file

@ -126,7 +126,6 @@ private:
bool mouse_lock_local_;
static bool mouse_lock_;
friend class scrollpane;
friend class dialog;
};