mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-10 04:02:30 +00:00
* Moved all remaining classes to use the new display::Frame.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@749 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+13
-14
@@ -207,7 +207,7 @@ Frame::refresh() {
|
||||
break;
|
||||
|
||||
case TYPE_WINDOW:
|
||||
if (m_window->is_active())
|
||||
if (m_window->is_active() && !m_window->is_offscreen())
|
||||
m_window->refresh();
|
||||
|
||||
break;
|
||||
@@ -232,9 +232,14 @@ Frame::balance(uint32_t x, uint32_t y, uint32_t width, uint32_t height) {
|
||||
return;
|
||||
|
||||
if (m_type == TYPE_WINDOW) {
|
||||
if (!m_window->is_active())
|
||||
// Ensure that we don't draw windows that are offscreen or have
|
||||
// zero extent.
|
||||
if (width == 0 || height == 0 || !m_window->is_active()) {
|
||||
m_window->set_offscreen(true);
|
||||
return;
|
||||
}
|
||||
|
||||
m_window->set_offscreen(false);
|
||||
m_window->resize(x, y, width, height);
|
||||
m_window->mark_dirty();
|
||||
return;
|
||||
@@ -284,26 +289,20 @@ Frame::balance(uint32_t x, uint32_t y, uint32_t width, uint32_t height) {
|
||||
(*itr)->m_width = s;
|
||||
}
|
||||
|
||||
// Expand/shrink m_w/h according to what is required to fill the min
|
||||
// height/width.
|
||||
// if (m_type == TYPE_ROW)
|
||||
// m_height -= remaining;
|
||||
// else
|
||||
// m_width -= remaining;
|
||||
|
||||
for (Frame **itr = m_container, **last = m_container + m_containerSize; itr != last; ++itr) {
|
||||
if (m_type == TYPE_ROW) {
|
||||
(*itr)->balance(x, y, m_width, (*itr)->m_height);
|
||||
(*itr)->balance(x, y, m_width, std::min((*itr)->m_height, height));
|
||||
|
||||
y += (*itr)->m_height;
|
||||
height -= (*itr)->m_height;
|
||||
|
||||
} else {
|
||||
(*itr)->balance(x, y, (*itr)->m_width, m_height);
|
||||
(*itr)->balance(x, y, std::min((*itr)->m_width, width), m_height);
|
||||
|
||||
x += (*itr)->m_width;
|
||||
width -= (*itr)->m_width;
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_type == TYPE_ROW && y != m_height) || (m_type == TYPE_COLUMN && x != m_width))
|
||||
throw torrent::client_error("Frame::balance(...) The algorithm did not end up with the correct remainder.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -93,8 +93,6 @@ Manager::receive_update() {
|
||||
Canvas::refresh_std();
|
||||
|
||||
rak::priority_queue_perform(&m_scheduler, cachedTime);
|
||||
|
||||
// std::for_each(begin(), end(), rak::if_then(std::mem_fun(&Window::is_active), std::mem_fun(&Window::refresh)));
|
||||
m_rootFrame.refresh();
|
||||
|
||||
Canvas::do_update();
|
||||
|
||||
@@ -46,16 +46,16 @@ Window::SlotTimer Window::m_slotSchedule;
|
||||
Window::SlotWindow Window::m_slotUnschedule;
|
||||
Window::Slot Window::m_slotAdjust;
|
||||
|
||||
// When constructing the window we set flag_offscreen so that redraw
|
||||
// doesn't get triggered until after a successful Frame::balance call.
|
||||
|
||||
Window::Window(Canvas* canvas, int flags, extent_type minWidth, extent_type minHeight) :
|
||||
m_canvas(canvas),
|
||||
m_flags(flags),
|
||||
m_flags(flags | flag_offscreen),
|
||||
m_minWidth(minWidth),
|
||||
m_minHeight(minHeight) {
|
||||
|
||||
m_taskUpdate.set_slot(rak::mem_fn(this, &Window::redraw));
|
||||
|
||||
if (flags & flag_active)
|
||||
mark_dirty();
|
||||
}
|
||||
|
||||
Window::~Window() {
|
||||
@@ -71,8 +71,11 @@ Window::set_active(bool state) {
|
||||
return;
|
||||
|
||||
if (state) {
|
||||
m_flags |= flag_active;
|
||||
// Set offscreen so we don't try rendering before Frame::balance
|
||||
// has been called.
|
||||
m_flags |= flag_active | flag_offscreen;
|
||||
mark_dirty();
|
||||
|
||||
} else {
|
||||
m_flags &= ~flag_active;
|
||||
m_slotUnschedule(this);
|
||||
|
||||
@@ -57,8 +57,9 @@ public:
|
||||
typedef rak::mem_fun2<Manager, void, Window*, rak::timer> SlotTimer;
|
||||
|
||||
static const int flag_active = (1 << 0);
|
||||
static const int flag_width_dynamic = (1 << 1);
|
||||
static const int flag_height_dynamic = (1 << 2);
|
||||
static const int flag_offscreen = (1 << 1);
|
||||
static const int flag_width_dynamic = (1 << 2);
|
||||
static const int flag_height_dynamic = (1 << 3);
|
||||
|
||||
Window(Canvas* canvas, int flags, extent_type minWidth, extent_type minHeight);
|
||||
|
||||
@@ -67,6 +68,9 @@ public:
|
||||
bool is_active() const { return m_flags & flag_active; }
|
||||
void set_active(bool state);
|
||||
|
||||
bool is_offscreen() const { return m_flags & flag_offscreen; }
|
||||
void set_offscreen(bool state) { if (state) m_flags |= flag_offscreen; else m_flags &= ~flag_offscreen; }
|
||||
|
||||
bool is_width_dynamic() const { return m_flags & flag_width_dynamic; }
|
||||
bool is_height_dynamic() const { return m_flags & flag_height_dynamic; }
|
||||
|
||||
|
||||
+86
-64
@@ -36,14 +36,13 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <sigc++/bind.h>
|
||||
#include <rak/functional.h>
|
||||
#include <torrent/exceptions.h>
|
||||
#include <torrent/torrent.h>
|
||||
#include <torrent/tracker_list.h>
|
||||
|
||||
#include "core/download.h"
|
||||
#include "input/bindings.h"
|
||||
#include "input/manager.h"
|
||||
#include "display/window_title.h"
|
||||
#include "display/window_download_statusbar.h"
|
||||
@@ -60,14 +59,11 @@
|
||||
|
||||
namespace ui {
|
||||
|
||||
Download::Download(DPtr d, Control* c) :
|
||||
Download::Download(DPtr d) :
|
||||
m_download(d),
|
||||
m_state(DISPLAY_MAX_SIZE),
|
||||
|
||||
m_windowDownloadStatus(new WDownloadStatus(d)),
|
||||
|
||||
m_control(c),
|
||||
m_bindings(new input::Bindings) {
|
||||
m_windowDownloadStatus(new WDownloadStatus(d)) {
|
||||
|
||||
m_focus = m_peers.end();
|
||||
|
||||
@@ -87,72 +83,99 @@ Download::Download(DPtr d, Control* c) :
|
||||
}
|
||||
|
||||
Download::~Download() {
|
||||
// if (m_window != m_control->display()->end())
|
||||
// throw std::logic_error("ui::Download::~Download() called on an active object");
|
||||
if (is_active())
|
||||
throw torrent::client_error("ui::Download::~Download() called on an active object.");
|
||||
|
||||
m_connPeerConnected.disconnect();
|
||||
m_connPeerDisconnected.disconnect();
|
||||
|
||||
delete m_bindings;
|
||||
|
||||
std::for_each(m_uiArray, m_uiArray + DISPLAY_MAX_SIZE, rak::call_delete<ElementBase>());
|
||||
|
||||
delete m_windowDownloadStatus;
|
||||
}
|
||||
|
||||
void
|
||||
Download::activate() {
|
||||
// if (m_window != m_control->display()->end())
|
||||
// throw std::logic_error("ui::Download::activate() called on an already activated object");
|
||||
Download::activate(display::Frame* frame) {
|
||||
if (is_active())
|
||||
throw torrent::client_error("ui::Download::activate() called on an already activated object.");
|
||||
|
||||
m_control->ui()->window_title()->set_title(m_download->download()->name());
|
||||
|
||||
// m_control->display()->push_front(m_windowDownloadStatus);
|
||||
// m_window = m_control->display()->insert(m_control->display()->begin(), NULL);
|
||||
// m_control->display()->push_front(m_control->ui()->window_title());
|
||||
|
||||
m_control->input()->push_front(m_bindings);
|
||||
control->input()->push_front(&m_bindings);
|
||||
|
||||
m_frame = frame;
|
||||
activate_display(DISPLAY_PEER_LIST);
|
||||
}
|
||||
|
||||
void
|
||||
Download::disable() {
|
||||
// if (m_window == m_control->display()->end())
|
||||
// throw std::logic_error("ui::Download::disable() called on an already disabled object");
|
||||
if (!is_active())
|
||||
throw torrent::client_error("ui::Download::disable() called on an already disabled object.");
|
||||
|
||||
disable_display();
|
||||
control->input()->erase(&m_bindings);
|
||||
|
||||
// m_control->display()->erase(m_window);
|
||||
// m_control->display()->erase(m_control->ui()->window_title());
|
||||
// m_control->display()->erase(m_windowDownloadStatus);
|
||||
|
||||
// m_window = m_control->display()->end();
|
||||
|
||||
m_control->input()->erase(m_bindings);
|
||||
activate_display(DISPLAY_MAX_SIZE);
|
||||
m_frame = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
Download::activate_display(Display d) {
|
||||
// if (m_window == m_control->display()->end())
|
||||
// throw std::logic_error("ui::Download::activate_display(...) could not find previous display iterator");
|
||||
Download::activate_display(Display displayType) {
|
||||
if (!is_active())
|
||||
throw torrent::client_error("ui::Download::activate_display(...) !is_active().");
|
||||
|
||||
if (d >= DISPLAY_MAX_SIZE)
|
||||
throw std::logic_error("ui::Download::activate_display(...) out of bounds");
|
||||
if (displayType > DISPLAY_MAX_SIZE)
|
||||
throw torrent::client_error("ui::Download::activate_display(...) out of bounds");
|
||||
|
||||
m_state = d;
|
||||
// m_uiArray[d]->activate(m_control, m_window);
|
||||
if (displayType == m_state)
|
||||
return;
|
||||
|
||||
m_control->display()->adjust_layout();
|
||||
}
|
||||
// Cleanup previous state.
|
||||
switch (m_state) {
|
||||
case DISPLAY_PEER_LIST:
|
||||
case DISPLAY_PEER_INFO:
|
||||
case DISPLAY_FILE_LIST:
|
||||
case DISPLAY_TRACKER_LIST:
|
||||
case DISPLAY_CHUNKS_SEEN:
|
||||
case DISPLAY_TRANSFER_LIST:
|
||||
m_uiArray[m_state]->disable();
|
||||
|
||||
// Does not delete disabled window.
|
||||
void
|
||||
Download::disable_display() {
|
||||
m_uiArray[m_state]->disable();
|
||||
m_windowDownloadStatus->set_active(false);
|
||||
m_frame->frame(1)->clear();
|
||||
|
||||
m_state = DISPLAY_MAX_SIZE;
|
||||
// *m_window = NULL;
|
||||
m_frame->clear();
|
||||
break;
|
||||
|
||||
case DISPLAY_MAX_SIZE:
|
||||
break;
|
||||
}
|
||||
|
||||
m_state = displayType;
|
||||
|
||||
// Initialize new state.
|
||||
switch (displayType) {
|
||||
case DISPLAY_PEER_LIST:
|
||||
case DISPLAY_PEER_INFO:
|
||||
case DISPLAY_FILE_LIST:
|
||||
case DISPLAY_TRACKER_LIST:
|
||||
case DISPLAY_CHUNKS_SEEN:
|
||||
case DISPLAY_TRANSFER_LIST:
|
||||
m_frame->initialize_row(2);
|
||||
|
||||
m_uiArray[displayType]->activate(m_frame->frame(0));
|
||||
|
||||
m_frame->frame(1)->initialize_window(m_windowDownloadStatus);
|
||||
m_windowDownloadStatus->set_active(true);
|
||||
break;
|
||||
|
||||
case DISPLAY_MAX_SIZE:
|
||||
break;
|
||||
}
|
||||
|
||||
// Set title.
|
||||
switch (displayType) {
|
||||
case DISPLAY_MAX_SIZE: break;
|
||||
default: control->ui()->window_title()->set_title(m_download->download()->name()); break;
|
||||
}
|
||||
|
||||
control->display()->adjust_layout();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -229,7 +252,6 @@ Download::receive_change(Display d) {
|
||||
if (d == m_state)
|
||||
return;
|
||||
|
||||
disable_display();
|
||||
activate_display(d);
|
||||
}
|
||||
|
||||
@@ -255,27 +277,27 @@ Download::receive_prev_priority() {
|
||||
|
||||
void
|
||||
Download::bind_keys() {
|
||||
(*m_bindings)['1'] = sigc::bind(sigc::mem_fun(this, &Download::receive_max_uploads), -1);
|
||||
(*m_bindings)['2'] = sigc::bind(sigc::mem_fun(this, &Download::receive_max_uploads), 1);
|
||||
(*m_bindings)['3'] = sigc::bind(sigc::mem_fun(this, &Download::receive_min_peers), -5);
|
||||
(*m_bindings)['4'] = sigc::bind(sigc::mem_fun(this, &Download::receive_min_peers), 5);
|
||||
(*m_bindings)['5'] = sigc::bind(sigc::mem_fun(this, &Download::receive_max_peers), -5);
|
||||
(*m_bindings)['6'] = sigc::bind(sigc::mem_fun(this, &Download::receive_max_peers), 5);
|
||||
(*m_bindings)['+'] = sigc::mem_fun(this, &Download::receive_next_priority);
|
||||
(*m_bindings)['-'] = sigc::mem_fun(this, &Download::receive_prev_priority);
|
||||
m_bindings['1'] = sigc::bind(sigc::mem_fun(this, &Download::receive_max_uploads), -1);
|
||||
m_bindings['2'] = sigc::bind(sigc::mem_fun(this, &Download::receive_max_uploads), 1);
|
||||
m_bindings['3'] = sigc::bind(sigc::mem_fun(this, &Download::receive_min_peers), -5);
|
||||
m_bindings['4'] = sigc::bind(sigc::mem_fun(this, &Download::receive_min_peers), 5);
|
||||
m_bindings['5'] = sigc::bind(sigc::mem_fun(this, &Download::receive_max_peers), -5);
|
||||
m_bindings['6'] = sigc::bind(sigc::mem_fun(this, &Download::receive_max_peers), 5);
|
||||
m_bindings['+'] = sigc::mem_fun(this, &Download::receive_next_priority);
|
||||
m_bindings['-'] = sigc::mem_fun(this, &Download::receive_prev_priority);
|
||||
|
||||
(*m_bindings)['k'] = sigc::mem_fun(this, &Download::receive_disconnect_peer);
|
||||
m_bindings['k'] = sigc::mem_fun(this, &Download::receive_disconnect_peer);
|
||||
|
||||
(*m_bindings)['t'] = sigc::bind(sigc::mem_fun(m_download->tracker_list(), &torrent::TrackerList::manual_request), false);
|
||||
(*m_bindings)['T'] = sigc::bind(sigc::mem_fun(m_download->tracker_list(), &torrent::TrackerList::manual_request), true);
|
||||
m_bindings['t'] = sigc::bind(sigc::mem_fun(m_download->tracker_list(), &torrent::TrackerList::manual_request), false);
|
||||
m_bindings['T'] = sigc::bind(sigc::mem_fun(m_download->tracker_list(), &torrent::TrackerList::manual_request), true);
|
||||
|
||||
(*m_bindings)['p'] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_PEER_INFO);
|
||||
(*m_bindings)['o'] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_TRACKER_LIST);
|
||||
(*m_bindings)['i'] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_CHUNKS_SEEN);
|
||||
(*m_bindings)['u'] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_TRANSFER_LIST);
|
||||
m_bindings['p'] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_PEER_INFO);
|
||||
m_bindings['o'] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_TRACKER_LIST);
|
||||
m_bindings['i'] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_CHUNKS_SEEN);
|
||||
m_bindings['u'] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_TRANSFER_LIST);
|
||||
|
||||
(*m_bindings)[KEY_UP] = sigc::mem_fun(this, &Download::receive_prev);
|
||||
(*m_bindings)[KEY_DOWN] = sigc::mem_fun(this, &Download::receive_next);
|
||||
m_bindings[KEY_UP] = sigc::mem_fun(this, &Download::receive_prev);
|
||||
m_bindings[KEY_DOWN] = sigc::mem_fun(this, &Download::receive_next);
|
||||
|
||||
// Key bindings for sub-ui's.
|
||||
m_uiArray[DISPLAY_PEER_LIST]->bindings()[KEY_RIGHT] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_FILE_LIST);
|
||||
|
||||
+6
-17
@@ -44,12 +44,9 @@
|
||||
#include "display/manager.h"
|
||||
#include "utils/list_focus.h"
|
||||
|
||||
class Control;
|
||||
#include "element_base.h"
|
||||
|
||||
namespace display {
|
||||
class Frame;
|
||||
class WindowTitle;
|
||||
class WindowStatusbar;
|
||||
class WindowDownloadStatusbar;
|
||||
}
|
||||
|
||||
@@ -59,9 +56,7 @@ namespace core {
|
||||
|
||||
namespace ui {
|
||||
|
||||
class ElementBase;
|
||||
|
||||
class Download {
|
||||
class Download : public ElementBase {
|
||||
public:
|
||||
typedef display::WindowDownloadStatusbar WDownloadStatus;
|
||||
|
||||
@@ -78,20 +73,19 @@ public:
|
||||
DISPLAY_MAX_SIZE
|
||||
} Display;
|
||||
|
||||
Download(DPtr d, Control* c);
|
||||
Download(DPtr d);
|
||||
~Download();
|
||||
|
||||
input::Bindings& get_bindings() { return *m_bindings; }
|
||||
|
||||
void activate();
|
||||
void activate(display::Frame* frame);
|
||||
void disable();
|
||||
|
||||
void activate_display(Display d);
|
||||
void disable_display();
|
||||
|
||||
void receive_next_priority();
|
||||
void receive_prev_priority();
|
||||
|
||||
display::Window* window() { return NULL; }
|
||||
|
||||
private:
|
||||
Download(const Download&);
|
||||
void operator = (const Download&);
|
||||
@@ -120,15 +114,10 @@ private:
|
||||
PList::iterator m_focus;
|
||||
|
||||
Display m_state;
|
||||
|
||||
display::Frame* m_frame;
|
||||
ElementBase* m_uiArray[DISPLAY_MAX_SIZE];
|
||||
|
||||
WDownloadStatus* m_windowDownloadStatus;
|
||||
|
||||
Control* m_control;
|
||||
input::Bindings* m_bindings;
|
||||
|
||||
sigc::connection m_connPeerConnected;
|
||||
sigc::connection m_connPeerDisconnected;
|
||||
};
|
||||
|
||||
+54
-52
@@ -68,10 +68,9 @@
|
||||
namespace ui {
|
||||
|
||||
DownloadList::DownloadList() :
|
||||
m_state(DISPLAY_NONE),
|
||||
|
||||
m_uiDownload(NULL) {
|
||||
m_state(DISPLAY_MAX_SIZE) {
|
||||
|
||||
m_uiArray[DISPLAY_DOWNLOAD] = NULL;
|
||||
m_uiArray[DISPLAY_DOWNLOAD_LIST] = new ElementDownloadList();
|
||||
m_uiArray[DISPLAY_LOG] = new ElementLogComplete(&control->core()->get_log_complete());
|
||||
m_uiArray[DISPLAY_STRING_LIST] = new ElementStringList();
|
||||
@@ -118,7 +117,7 @@ DownloadList::disable() {
|
||||
throw std::logic_error("ui::DownloadList::disable() called on an already disabled object");
|
||||
|
||||
receive_exit_input(INPUT_NONE);
|
||||
activate_display(DISPLAY_NONE);
|
||||
activate_display(DISPLAY_MAX_SIZE);
|
||||
|
||||
m_frame = NULL;
|
||||
|
||||
@@ -131,23 +130,34 @@ DownloadList::activate_display(Display displayType) {
|
||||
if (!is_active())
|
||||
throw torrent::client_error("ui::DownloadList::activate_display(...) !is_active().");
|
||||
|
||||
if (displayType >= DISPLAY_MAX_SIZE)
|
||||
if (displayType > DISPLAY_MAX_SIZE)
|
||||
throw torrent::client_error("ui::DownloadList::activate_display(...) out of bounds");
|
||||
|
||||
if (displayType == m_state)
|
||||
return;
|
||||
|
||||
// Don't use default.
|
||||
|
||||
// Cleanup previous state.
|
||||
switch (m_state) {
|
||||
case DISPLAY_DOWNLOAD:
|
||||
m_uiArray[m_state]->disable();
|
||||
|
||||
delete m_uiArray[m_state];
|
||||
m_uiArray[m_state] = NULL;
|
||||
|
||||
control->input()->push_front(&m_bindings);
|
||||
break;
|
||||
|
||||
case DISPLAY_DOWNLOAD_LIST:
|
||||
m_uiArray[DISPLAY_DOWNLOAD_LIST]->disable();
|
||||
m_uiArray[DISPLAY_LOG]->disable();
|
||||
|
||||
m_windowLog->set_active(false);
|
||||
m_frame->frame(1)->clear();
|
||||
|
||||
m_frame->clear();
|
||||
break;
|
||||
|
||||
case DISPLAY_LOG:
|
||||
case DISPLAY_STRING_LIST:
|
||||
m_uiArray[m_state]->disable();
|
||||
break;
|
||||
|
||||
@@ -159,17 +169,37 @@ DownloadList::activate_display(Display displayType) {
|
||||
|
||||
// Initialize new state.
|
||||
switch (displayType) {
|
||||
case DISPLAY_NONE:
|
||||
break;
|
||||
case DISPLAY_DOWNLOAD:
|
||||
// If no download has the focus, just return to the download list.
|
||||
if (m_view->focus() == m_view->end_visible()) {
|
||||
m_state = DISPLAY_MAX_SIZE;
|
||||
|
||||
activate_display(DISPLAY_DOWNLOAD_LIST);
|
||||
return;
|
||||
|
||||
} else {
|
||||
control->input()->erase(&m_bindings);
|
||||
|
||||
Download* download = new Download(*m_view->focus());
|
||||
|
||||
download->activate(m_frame);
|
||||
download->bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(*this, &DownloadList::activate_display), DISPLAY_DOWNLOAD_LIST);
|
||||
|
||||
m_uiArray[DISPLAY_DOWNLOAD] = download;
|
||||
break;
|
||||
}
|
||||
|
||||
case DISPLAY_DOWNLOAD_LIST:
|
||||
m_frame->initialize_column(2);
|
||||
m_frame->initialize_row(2);
|
||||
|
||||
m_uiArray[DISPLAY_DOWNLOAD_LIST]->activate(m_frame->frame(0));
|
||||
m_uiArray[DISPLAY_LOG]->activate(m_frame->frame(1));
|
||||
|
||||
m_frame->frame(1)->initialize_window(m_windowLog);
|
||||
m_windowLog->set_active(true);
|
||||
break;
|
||||
|
||||
case DISPLAY_LOG:
|
||||
case DISPLAY_STRING_LIST:
|
||||
m_uiArray[displayType]->activate(m_frame);
|
||||
break;
|
||||
|
||||
@@ -187,11 +217,6 @@ DownloadList::activate_display(Display displayType) {
|
||||
control->display()->adjust_layout();
|
||||
}
|
||||
|
||||
display::Window*
|
||||
DownloadList::window() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_next() {
|
||||
m_view->next_focus();
|
||||
@@ -238,37 +263,6 @@ DownloadList::receive_close_download() {
|
||||
m_view->set_last_changed();
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_view_download() {
|
||||
if (m_view->focus() == m_view->end_visible())
|
||||
return;
|
||||
|
||||
if (m_uiDownload != NULL)
|
||||
throw std::logic_error("DownloadList::receive_view_download() called but m_uiDownload != NULL");
|
||||
|
||||
disable();
|
||||
|
||||
m_uiDownload = new Download(*m_view->focus(), control);
|
||||
|
||||
m_uiDownload->activate();
|
||||
m_uiDownload->get_bindings()[KEY_LEFT] = sigc::mem_fun(*this, &DownloadList::receive_exit_download);
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_exit_download() {
|
||||
if (m_uiDownload == NULL)
|
||||
throw std::logic_error("DownloadList::receive_exit_download() called but m_uiDownload == NULL");
|
||||
|
||||
m_uiDownload->disable();
|
||||
delete m_uiDownload;
|
||||
m_uiDownload = NULL;
|
||||
|
||||
m_view->set_last_changed();
|
||||
activate(m_frame);
|
||||
|
||||
control->display()->adjust_layout();
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_next_priority() {
|
||||
if (m_view->focus() == m_view->end_visible())
|
||||
@@ -359,6 +353,14 @@ DownloadList::receive_view_input(Input type) {
|
||||
throw torrent::client_error("DownloadList::receive_view_input(...) Invalid input type.");
|
||||
}
|
||||
|
||||
ElementStringList* esl = dynamic_cast<ElementStringList*>(m_uiArray[DISPLAY_STRING_LIST]);
|
||||
|
||||
input->signal_show_next().connect(sigc::bind(sigc::mem_fun(*this, &DownloadList::activate_display), DISPLAY_STRING_LIST));
|
||||
input->signal_show_next().connect(sigc::mem_fun(*esl, &ElementStringList::next_screen));
|
||||
|
||||
input->signal_show_range().connect(sigc::hide(sigc::hide(sigc::bind(sigc::mem_fun(*this, &DownloadList::activate_display), DISPLAY_STRING_LIST))));
|
||||
input->signal_show_range().connect(sigc::mem_fun(*esl, &ElementStringList::set_range<utils::Directory::iterator>));
|
||||
|
||||
input->bindings()['\n'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_exit_input), type);
|
||||
input->bindings()[KEY_ENTER] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_exit_input), type);
|
||||
input->bindings()['\x07'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_exit_input), INPUT_NONE);
|
||||
@@ -409,6 +411,8 @@ DownloadList::receive_exit_input(Input type) {
|
||||
control->core()->push_log(e.what());
|
||||
}
|
||||
|
||||
activate_display(DISPLAY_DOWNLOAD_LIST);
|
||||
|
||||
delete input;
|
||||
}
|
||||
|
||||
@@ -417,9 +421,7 @@ DownloadList::receive_download_erased(core::Download* d) {
|
||||
if (m_view->focus() == m_view->end_visible() || *m_view->focus() != d)
|
||||
return;
|
||||
|
||||
if (m_uiDownload != NULL)
|
||||
receive_exit_download();
|
||||
|
||||
activate_display(DISPLAY_DOWNLOAD_LIST);
|
||||
receive_next();
|
||||
}
|
||||
|
||||
@@ -470,7 +472,7 @@ DownloadList::setup_keys() {
|
||||
|
||||
m_bindings[KEY_UP] = sigc::mem_fun(*this, &DownloadList::receive_prev);
|
||||
m_bindings[KEY_DOWN] = sigc::mem_fun(*this, &DownloadList::receive_next);
|
||||
m_bindings[KEY_RIGHT] = sigc::mem_fun(*this, &DownloadList::receive_view_download);
|
||||
m_bindings[KEY_RIGHT] = sigc::bind(sigc::mem_fun(*this, &DownloadList::activate_display), DISPLAY_DOWNLOAD);
|
||||
m_bindings['l'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::activate_display), DISPLAY_LOG);
|
||||
|
||||
m_bindings['1'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "main");
|
||||
|
||||
+4
-10
@@ -77,7 +77,7 @@ public:
|
||||
typedef sigc::slot1<void, const std::string&> SlotOpenUri;
|
||||
|
||||
typedef enum {
|
||||
DISPLAY_NONE,
|
||||
DISPLAY_DOWNLOAD,
|
||||
DISPLAY_DOWNLOAD_LIST,
|
||||
DISPLAY_LOG,
|
||||
DISPLAY_STRING_LIST,
|
||||
@@ -100,7 +100,7 @@ public:
|
||||
|
||||
void activate_display(Display d);
|
||||
|
||||
display::Window* window();
|
||||
display::Window* window() { return NULL; }
|
||||
|
||||
void slot_open_uri(SlotOpenUri s) { m_slotOpenUri = s; }
|
||||
|
||||
@@ -115,9 +115,6 @@ private:
|
||||
void receive_stop_download();
|
||||
void receive_close_download();
|
||||
|
||||
void receive_view_download();
|
||||
void receive_exit_download();
|
||||
|
||||
void receive_next_priority();
|
||||
void receive_prev_priority();
|
||||
|
||||
@@ -141,15 +138,12 @@ private:
|
||||
Display m_state;
|
||||
|
||||
ElementBase* m_uiArray[DISPLAY_MAX_SIZE];
|
||||
|
||||
WLog* m_windowLog;
|
||||
|
||||
rak::priority_item m_taskUpdate;
|
||||
|
||||
Download* m_uiDownload;
|
||||
|
||||
core::View* m_view;
|
||||
|
||||
rak::priority_item m_taskUpdate;
|
||||
|
||||
SlotOpenUri m_slotOpenUri;
|
||||
};
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
|
||||
#include <torrent/exceptions.h>
|
||||
|
||||
#include "display/frame.h"
|
||||
#include "display/window_download_chunks_seen.h"
|
||||
#include "input/manager.h"
|
||||
|
||||
@@ -67,7 +68,10 @@ ElementChunksSeen::activate(display::Frame* frame) {
|
||||
control->input()->push_front(&m_bindings);
|
||||
|
||||
m_window = new WChunksSeen(m_download, &m_focus);
|
||||
m_window->set_active(true);
|
||||
|
||||
m_frame = frame;
|
||||
m_frame->initialize_window(m_window);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -77,6 +81,9 @@ ElementChunksSeen::disable() {
|
||||
|
||||
control->input()->erase(&m_bindings);
|
||||
|
||||
m_frame->clear();
|
||||
m_frame = NULL;
|
||||
|
||||
delete m_window;
|
||||
m_window = NULL;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <torrent/exceptions.h>
|
||||
#include <torrent/file_list.h>
|
||||
|
||||
#include "display/frame.h"
|
||||
#include "display/window_file_list.h"
|
||||
#include "input/manager.h"
|
||||
|
||||
@@ -67,8 +68,11 @@ ElementFileList::activate(display::Frame* frame) {
|
||||
|
||||
control->input()->push_front(&m_bindings);
|
||||
|
||||
// *mItr = m_window = new WFileList(m_download, &m_focus);
|
||||
m_window = new WFileList(m_download, &m_focus);
|
||||
m_window->set_active(true);
|
||||
|
||||
m_frame = frame;
|
||||
m_frame->initialize_window(m_window);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -78,6 +82,9 @@ ElementFileList::disable() {
|
||||
|
||||
control->input()->erase(&m_bindings);
|
||||
|
||||
m_frame->clear();
|
||||
m_frame = NULL;
|
||||
|
||||
delete m_window;
|
||||
m_window = NULL;
|
||||
}
|
||||
|
||||
@@ -65,8 +65,6 @@ ElementLogComplete::activate(display::Frame* frame) {
|
||||
|
||||
m_frame = frame;
|
||||
m_frame->initialize_window(m_window);
|
||||
|
||||
control->display()->schedule(m_window, cachedTime);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
|
||||
#include <torrent/exceptions.h>
|
||||
|
||||
#include "display/frame.h"
|
||||
#include "display/window_peer_info.h"
|
||||
#include "input/manager.h"
|
||||
|
||||
@@ -62,7 +63,10 @@ ElementPeerInfo::activate(display::Frame* frame) {
|
||||
control->input()->push_front(&m_bindings);
|
||||
|
||||
m_window = new WPeerInfo(m_download, m_list, m_focus);
|
||||
m_window->set_active(true);
|
||||
|
||||
m_frame = frame;
|
||||
m_frame->initialize_window(m_window);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -72,6 +76,9 @@ ElementPeerInfo::disable() {
|
||||
|
||||
control->input()->erase(&m_bindings);
|
||||
|
||||
m_frame->clear();
|
||||
m_frame = NULL;
|
||||
|
||||
delete m_window;
|
||||
m_window = NULL;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
|
||||
#include <torrent/exceptions.h>
|
||||
|
||||
#include "display/frame.h"
|
||||
#include "display/window_peer_list.h"
|
||||
#include "input/manager.h"
|
||||
|
||||
@@ -51,7 +52,6 @@ ElementPeerList::ElementPeerList(core::Download* d, PList* l, PList::iterator* f
|
||||
m_window(NULL),
|
||||
m_list(l),
|
||||
m_focus(f) {
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
@@ -62,7 +62,10 @@ ElementPeerList::activate(display::Frame* frame) {
|
||||
control->input()->push_front(&m_bindings);
|
||||
|
||||
m_window = new WPeerList(m_download, m_list, m_focus);
|
||||
m_window->set_active(true);
|
||||
|
||||
m_frame = frame;
|
||||
m_frame->initialize_window(m_window);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -72,6 +75,9 @@ ElementPeerList::disable() {
|
||||
|
||||
control->input()->erase(&m_bindings);
|
||||
|
||||
m_frame->clear();
|
||||
m_frame = NULL;
|
||||
|
||||
delete m_window;
|
||||
m_window = NULL;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
|
||||
#include <torrent/exceptions.h>
|
||||
|
||||
#include "display/frame.h"
|
||||
#include "input/manager.h"
|
||||
|
||||
#include "control.h"
|
||||
@@ -57,9 +58,10 @@ ElementStringList::activate(display::Frame* frame) {
|
||||
control->input()->push_front(&m_bindings);
|
||||
|
||||
m_window = new WStringList();
|
||||
m_frame = frame;
|
||||
m_window->set_active(true);
|
||||
|
||||
m_window->set_range(m_list.begin(), m_list.end());
|
||||
m_frame = frame;
|
||||
m_frame->initialize_window(m_window);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -69,6 +71,9 @@ ElementStringList::disable() {
|
||||
|
||||
control->input()->erase(&m_bindings);
|
||||
|
||||
m_frame->clear();
|
||||
m_frame = NULL;
|
||||
|
||||
delete m_window;
|
||||
m_window = NULL;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <torrent/tracker.h>
|
||||
#include <torrent/tracker_list.h>
|
||||
|
||||
#include "display/frame.h"
|
||||
#include "display/window_tracker_list.h"
|
||||
#include "input/manager.h"
|
||||
|
||||
@@ -67,7 +68,10 @@ ElementTrackerList::activate(display::Frame* frame) {
|
||||
control->input()->push_front(&m_bindings);
|
||||
|
||||
m_window = new WTrackerList(m_download, &m_focus);
|
||||
m_window->set_active(true);
|
||||
|
||||
m_frame = frame;
|
||||
m_frame->initialize_window(m_window);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -77,6 +81,9 @@ ElementTrackerList::disable() {
|
||||
|
||||
control->input()->erase(&m_bindings);
|
||||
|
||||
m_frame->clear();
|
||||
m_frame = NULL;
|
||||
|
||||
delete m_window;
|
||||
m_window = NULL;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
|
||||
#include <torrent/exceptions.h>
|
||||
|
||||
#include "display/frame.h"
|
||||
#include "display/window_download_transfer_list.h"
|
||||
#include "input/manager.h"
|
||||
|
||||
@@ -67,7 +68,10 @@ ElementTransferList::activate(display::Frame* frame) {
|
||||
control->input()->push_front(&m_bindings);
|
||||
|
||||
m_window = new WTransferList(m_download, &m_focus);
|
||||
m_window->set_active(true);
|
||||
|
||||
m_frame = frame;
|
||||
m_frame->initialize_window(m_window);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -77,6 +81,9 @@ ElementTransferList::disable() {
|
||||
|
||||
control->input()->erase(&m_bindings);
|
||||
|
||||
m_frame->clear();
|
||||
m_frame = NULL;
|
||||
|
||||
delete m_window;
|
||||
m_window = NULL;
|
||||
}
|
||||
@@ -101,60 +108,60 @@ ElementTransferList::window() {
|
||||
|
||||
void
|
||||
ElementTransferList::receive_next() {
|
||||
// if (m_window == NULL)
|
||||
// throw torrent::client_error("ui::ElementTransferList::receive_next(...) called on a disabled object");
|
||||
if (m_window == NULL)
|
||||
throw torrent::client_error("ui::ElementTransferList::receive_next(...) called on a disabled object");
|
||||
|
||||
// if (++m_focus > m_window->max_focus())
|
||||
// m_focus = 0;
|
||||
if (++m_focus > m_window->max_focus())
|
||||
m_focus = 0;
|
||||
|
||||
// m_window->mark_dirty();
|
||||
}
|
||||
|
||||
void
|
||||
ElementTransferList::receive_prev() {
|
||||
// if (m_window == NULL)
|
||||
// throw torrent::client_error("ui::ElementTransferList::receive_prev(...) called on a disabled object");
|
||||
if (m_window == NULL)
|
||||
throw torrent::client_error("ui::ElementTransferList::receive_prev(...) called on a disabled object");
|
||||
|
||||
// if (m_focus > 0)
|
||||
// --m_focus;
|
||||
// else
|
||||
// m_focus = m_window->max_focus();
|
||||
if (m_focus > 0)
|
||||
--m_focus;
|
||||
else
|
||||
m_focus = m_window->max_focus();
|
||||
|
||||
// m_window->mark_dirty();
|
||||
}
|
||||
|
||||
void
|
||||
ElementTransferList::receive_pagenext() {
|
||||
// if (m_window == NULL)
|
||||
// throw torrent::client_error("ui::ElementTransferList::receive_pagenext(...) called on a disabled object");
|
||||
if (m_window == NULL)
|
||||
throw torrent::client_error("ui::ElementTransferList::receive_pagenext(...) called on a disabled object");
|
||||
|
||||
// unsigned int visible = m_window->height() - 1;
|
||||
// unsigned int scrollable = std::max<int>(m_window->rows() - visible, 0);
|
||||
unsigned int visible = m_window->height() - 1;
|
||||
unsigned int scrollable = std::max<int>(m_window->rows() - visible, 0);
|
||||
|
||||
// if (scrollable == 0 || m_focus == scrollable)
|
||||
// m_focus = 0;
|
||||
// else if (m_focus + visible / 2 < scrollable)
|
||||
// m_focus += visible / 2;
|
||||
// else
|
||||
// m_focus = scrollable;
|
||||
if (scrollable == 0 || m_focus == scrollable)
|
||||
m_focus = 0;
|
||||
else if (m_focus + visible / 2 < scrollable)
|
||||
m_focus += visible / 2;
|
||||
else
|
||||
m_focus = scrollable;
|
||||
|
||||
// m_window->mark_dirty();
|
||||
}
|
||||
|
||||
void
|
||||
ElementTransferList::receive_pageprev() {
|
||||
// if (m_window == NULL)
|
||||
// throw torrent::client_error("ui::ElementTransferList::receive_pageprev(...) called on a disabled object");
|
||||
if (m_window == NULL)
|
||||
throw torrent::client_error("ui::ElementTransferList::receive_pageprev(...) called on a disabled object");
|
||||
|
||||
// unsigned int visible = m_window->height() - 1;
|
||||
// unsigned int scrollable = std::max<int>(m_window->rows() - visible, 0);
|
||||
unsigned int visible = m_window->height() - 1;
|
||||
unsigned int scrollable = std::max<int>(m_window->rows() - visible, 0);
|
||||
|
||||
// if (m_focus > visible / 2)
|
||||
// m_focus -= visible / 2;
|
||||
// else if (scrollable > 0 && m_focus == 0)
|
||||
// m_focus = scrollable;
|
||||
// else
|
||||
// m_focus = 0;
|
||||
if (m_focus > visible / 2)
|
||||
m_focus -= visible / 2;
|
||||
else if (scrollable > 0 && m_focus == 0)
|
||||
m_focus = scrollable;
|
||||
else
|
||||
m_focus = 0;
|
||||
|
||||
// m_window->mark_dirty();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user