mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-05 17:52:29 +00:00
Adding active/disabled status on windows so it's easier to show/hide
them while keeping the order. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@284 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -26,13 +26,17 @@ Manager::adjust_layout() {
|
|||||||
int countDynamic = 0;
|
int countDynamic = 0;
|
||||||
int staticHeight = 0;
|
int staticHeight = 0;
|
||||||
|
|
||||||
std::for_each(begin(), end(), func::accumulate(staticHeight, std::mem_fun(&Window::get_min_height)));
|
std::for_each(begin(), end(), func::if_then(std::mem_fun(&Window::is_active), func::accumulate(staticHeight, std::mem_fun(&Window::get_min_height))));
|
||||||
std::for_each(begin(), end(), func::accumulate(countDynamic, std::mem_fun(&Window::is_dynamic)));
|
std::for_each(begin(), end(), func::if_then(std::mem_fun(&Window::is_active), func::accumulate(countDynamic, std::mem_fun(&Window::is_dynamic))));
|
||||||
|
|
||||||
int dynamic = std::max(0, Canvas::get_screen_height() - staticHeight);
|
int dynamic = std::max(0, Canvas::get_screen_height() - staticHeight);
|
||||||
int height = 0, h;
|
int height = 0, h;
|
||||||
|
|
||||||
for (iterator itr = begin(); itr != end(); ++itr, height += h) {
|
for (iterator itr = begin(); itr != end(); ++itr, height += h) {
|
||||||
|
h = 0;
|
||||||
|
|
||||||
|
if (!(*itr)->is_active())
|
||||||
|
continue;
|
||||||
|
|
||||||
if ((*itr)->is_dynamic()) {
|
if ((*itr)->is_dynamic()) {
|
||||||
dynamic -= h = (dynamic + countDynamic - 1) / countDynamic;
|
dynamic -= h = (dynamic + countDynamic - 1) / countDynamic;
|
||||||
@@ -52,8 +56,8 @@ void
|
|||||||
Manager::do_update() {
|
Manager::do_update() {
|
||||||
Canvas::refresh_std();
|
Canvas::refresh_std();
|
||||||
|
|
||||||
std::for_each(begin(), end(), std::mem_fun(&Window::redraw));
|
std::for_each(begin(), end(), func::if_then(std::mem_fun(&Window::is_active), std::mem_fun(&Window::redraw)));
|
||||||
std::for_each(begin(), end(), std::mem_fun(&Window::refresh));
|
std::for_each(begin(), end(), func::if_then(std::mem_fun(&Window::is_active), std::mem_fun(&Window::refresh)));
|
||||||
|
|
||||||
Canvas::do_update();
|
Canvas::do_update();
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-5
@@ -10,19 +10,23 @@ class Canvas;
|
|||||||
class Window {
|
class Window {
|
||||||
public:
|
public:
|
||||||
Window(Canvas* c = NULL, bool d = false, int h = 1) :
|
Window(Canvas* c = NULL, bool d = false, int h = 1) :
|
||||||
m_canvas(c), m_dynamic(d), m_minHeight(h) {}
|
m_canvas(c), m_active(true), m_dynamic(d), m_minHeight(h) {}
|
||||||
|
|
||||||
virtual ~Window();
|
virtual ~Window();
|
||||||
|
|
||||||
bool is_dynamic() { return m_dynamic; }
|
bool is_active() { return m_active; }
|
||||||
bool is_dirty() { return m_lastDraw == 0; }
|
bool is_dynamic() { return m_dynamic; }
|
||||||
|
bool is_dirty() { return m_lastDraw == 0; }
|
||||||
|
|
||||||
int get_min_height() { return m_minHeight; }
|
int get_min_height() { return m_minHeight; }
|
||||||
|
|
||||||
|
bool get_active() { return m_active; }
|
||||||
|
void set_active(bool a) { m_active = a; }
|
||||||
|
|
||||||
void refresh();
|
void refresh();
|
||||||
void resize(int x, int y, int w, int h);
|
void resize(int x, int y, int w, int h);
|
||||||
|
|
||||||
void mark_dirty() { m_lastDraw = 0; }
|
void mark_dirty() { m_lastDraw = 0; }
|
||||||
|
|
||||||
virtual void redraw() = 0;
|
virtual void redraw() = 0;
|
||||||
|
|
||||||
@@ -32,6 +36,7 @@ protected:
|
|||||||
|
|
||||||
Canvas* m_canvas;
|
Canvas* m_canvas;
|
||||||
|
|
||||||
|
bool m_active;
|
||||||
bool m_dynamic;
|
bool m_dynamic;
|
||||||
int m_minHeight;
|
int m_minHeight;
|
||||||
|
|
||||||
|
|||||||
+20
-1
@@ -54,7 +54,6 @@ equal(Type t, Ftor f) {
|
|||||||
|
|
||||||
template <typename Dest, typename Src>
|
template <typename Dest, typename Src>
|
||||||
struct _on : public std::unary_function<typename Src::argument_type, typename Dest::result_type> {
|
struct _on : public std::unary_function<typename Src::argument_type, typename Dest::result_type> {
|
||||||
|
|
||||||
_on(Dest d, Src s) : m_dest(d), m_src(s) {}
|
_on(Dest d, Src s) : m_dest(d), m_src(s) {}
|
||||||
|
|
||||||
typename Dest::result_type operator () (typename Src::argument_type arg) {
|
typename Dest::result_type operator () (typename Src::argument_type arg) {
|
||||||
@@ -71,6 +70,26 @@ on(Dest d, Src s) {
|
|||||||
return _on<Dest, Src>(d, s);
|
return _on<Dest, Src>(d, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename Cond, typename Then>
|
||||||
|
struct _if_then {
|
||||||
|
_if_then(Cond c, Then t) : m_cond(c), m_then(t) {}
|
||||||
|
|
||||||
|
template <typename Arg>
|
||||||
|
void operator () (Arg& a) {
|
||||||
|
if (m_cond(a))
|
||||||
|
m_then(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
Cond m_cond;
|
||||||
|
Then m_then;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename Cond, typename Then>
|
||||||
|
inline _if_then<Cond, Then>
|
||||||
|
if_then(Cond c, Then t) {
|
||||||
|
return _if_then<Cond, Then>(c, t);
|
||||||
|
}
|
||||||
|
|
||||||
struct _call_delete
|
struct _call_delete
|
||||||
: public std::unary_function<void, void> {
|
: public std::unary_function<void, void> {
|
||||||
|
|
||||||
|
|||||||
@@ -45,8 +45,11 @@ DownloadList::~DownloadList() {
|
|||||||
|
|
||||||
void
|
void
|
||||||
DownloadList::activate() {
|
DownloadList::activate() {
|
||||||
|
m_textInput->set_active(false);
|
||||||
|
|
||||||
m_control->get_input().push_front(m_bindings);
|
m_control->get_input().push_front(m_bindings);
|
||||||
|
|
||||||
|
m_control->get_display().push_back(m_textInput);
|
||||||
m_control->get_display().push_back(m_status);
|
m_control->get_display().push_back(m_status);
|
||||||
m_control->get_display().push_front(m_window);
|
m_control->get_display().push_front(m_window);
|
||||||
m_control->get_display().push_front(m_title);
|
m_control->get_display().push_front(m_title);
|
||||||
@@ -54,7 +57,7 @@ DownloadList::activate() {
|
|||||||
|
|
||||||
void
|
void
|
||||||
DownloadList::disable() {
|
DownloadList::disable() {
|
||||||
if (m_textInput->get_focus()) {
|
if (m_textInput->is_active()) {
|
||||||
m_textInput->get_input()->clear();
|
m_textInput->get_input()->clear();
|
||||||
receive_exit_input();
|
receive_exit_input();
|
||||||
}
|
}
|
||||||
@@ -64,6 +67,7 @@ DownloadList::disable() {
|
|||||||
m_control->get_display().erase(m_title);
|
m_control->get_display().erase(m_title);
|
||||||
m_control->get_display().erase(m_window);
|
m_control->get_display().erase(m_window);
|
||||||
m_control->get_display().erase(m_status);
|
m_control->get_display().erase(m_status);
|
||||||
|
m_control->get_display().erase(m_textInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -144,8 +148,8 @@ DownloadList::receive_exit_download() {
|
|||||||
|
|
||||||
void
|
void
|
||||||
DownloadList::receive_view_input() {
|
DownloadList::receive_view_input() {
|
||||||
m_control->get_display().erase(m_status);
|
m_status->set_active(false);
|
||||||
m_control->get_display().push_back(m_textInput);
|
m_textInput->set_active(true);
|
||||||
m_control->get_display().adjust_layout();
|
m_control->get_display().adjust_layout();
|
||||||
|
|
||||||
m_control->get_input().set_text_input(m_textInput->get_input());
|
m_control->get_input().set_text_input(m_textInput->get_input());
|
||||||
@@ -158,8 +162,8 @@ DownloadList::receive_view_input() {
|
|||||||
|
|
||||||
void
|
void
|
||||||
DownloadList::receive_exit_input() {
|
DownloadList::receive_exit_input() {
|
||||||
m_control->get_display().erase(m_textInput);
|
m_status->set_active(true);
|
||||||
m_control->get_display().push_back(m_status);
|
m_textInput->set_active(false);
|
||||||
m_control->get_display().adjust_layout();
|
m_control->get_display().adjust_layout();
|
||||||
|
|
||||||
m_control->get_input().set_text_input();
|
m_control->get_input().set_text_input();
|
||||||
|
|||||||
Reference in New Issue
Block a user