Cleaned up ui::Root, fixed updating and hiding status bar.

Using displayScheduler for updating windows, much more efficient.

Added saving of some parts of the state of torrents.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@482 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-06-30 16:42:22 +00:00
parent 52884c3c39
commit 98ad8e8791
29 changed files with 221 additions and 95 deletions
+1 -2
View File
@@ -83,8 +83,7 @@ void
Manager::do_update() {
Canvas::refresh_std();
std::for_each(begin(), end(), rak::if_then(std::mem_fun(&Window::is_active), rak::if_then(std::mem_fun(&Window::is_dirty),
std::mem_fun(&Window::redraw))));
utils::displayScheduler.execute(utils::Timer::cache());
std::for_each(begin(), end(), rak::if_then(std::mem_fun(&Window::is_active), std::mem_fun(&Window::refresh)));
Canvas::do_update();
+21
View File
@@ -30,10 +30,31 @@ namespace display {
Window::Slot Window::m_slotAdjust;
Window::Window(Canvas* c, bool d, int h) :
m_canvas(c),
m_active(true),
m_dynamic(d),
m_minHeight(h) {
m_taskUpdate.set_iterator(utils::displayScheduler.end());
m_taskUpdate.set_slot(sigc::mem_fun(*this, &Window::redraw));
}
Window::~Window() {
utils::displayScheduler.erase(&m_taskUpdate);
delete m_canvas;
}
void
Window::set_active(bool a) {
if (a)
mark_dirty();
else
utils::displayScheduler.erase(&m_taskUpdate);
m_active = a;
}
void
Window::resize(int x, int y, int w, int h) {
if (x < 0 || y < 0)
+26 -20
View File
@@ -26,6 +26,7 @@
#include <sigc++/slot.h>
#include "canvas.h"
#include "utils/task.h"
#include "utils/timer.h"
namespace display {
@@ -36,46 +37,51 @@ class Window {
public:
typedef sigc::slot0<void> Slot;
Window(Canvas* c = NULL, bool d = false, int h = 1) :
m_canvas(c), m_active(true), m_dynamic(d), m_minHeight(h) {}
Window(Canvas* c = NULL, bool d = false, int h = 1);
virtual ~Window();
bool is_active() { return m_active; }
bool is_dynamic() { return m_dynamic; }
bool is_dirty() { return m_nextDraw <= utils::Timer::cache(); }
bool is_active() { return m_active; }
bool is_dynamic() { return m_dynamic; }
bool is_dirty() { return utils::displayScheduler.is_scheduled(&m_taskUpdate); }
utils::Timer get_next_draw() { return m_nextDraw; }
//utils::Timer get_next_draw() { return m_nextDraw; }
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; }
bool get_active() { return m_active; }
void set_active(bool a);
void refresh() { m_canvas->refresh(); }
void resize(int x, int y, int w, int h);
void refresh() { m_canvas->refresh(); }
void resize(int x, int y, int w, int h);
void mark_dirty() { m_nextDraw = utils::Timer::min(); }
void mark_dirty();
virtual void redraw() = 0;
virtual void redraw() = 0;
static void slot_adjust(Slot s) { m_slotAdjust = s; }
static void slot_adjust(Slot s) { m_slotAdjust = s; }
protected:
Window(const Window&);
void operator = (const Window&);
static Slot m_slotAdjust;
static Slot m_slotAdjust;
Canvas* m_canvas;
Canvas* m_canvas;
bool m_active;
bool m_dynamic;
int m_minHeight;
bool m_active;
bool m_dynamic;
int m_minHeight;
utils::Timer m_nextDraw;
utils::TaskItem m_taskUpdate;
};
inline void
Window::mark_dirty() {
utils::displayScheduler.erase(&m_taskUpdate);
utils::displayScheduler.insert(&m_taskUpdate, utils::Timer::cache());
}
}
#endif
+1 -1
View File
@@ -44,7 +44,7 @@ WindowDownloadList::~WindowDownloadList() {
void
WindowDownloadList::redraw() {
m_nextDraw = utils::Timer::cache().round_seconds() + 1000000;
utils::displayScheduler.insert(&m_taskUpdate, utils::Timer::cache().round_seconds() + 1000000);
m_canvas->erase();
+1 -1
View File
@@ -37,7 +37,7 @@ WindowDownloadStatusbar::WindowDownloadStatusbar(core::Download* d) :
void
WindowDownloadStatusbar::redraw() {
m_nextDraw = utils::Timer::cache().round_seconds() + 1000000;
utils::displayScheduler.insert(&m_taskUpdate, utils::Timer::cache().round_seconds() + 1000000);
m_canvas->erase();
+1 -1
View File
@@ -39,7 +39,7 @@ WindowFileList::WindowFileList(core::Download* d, unsigned int* focus) :
void
WindowFileList::redraw() {
m_nextDraw = utils::Timer::cache().round_seconds() + 10 * 1000000;
utils::displayScheduler.insert(&m_taskUpdate, utils::Timer::cache().round_seconds() + 10 * 1000000);
m_canvas->erase();
if (m_download->get_download().get_entry_size() == 0 ||
+1 -1
View File
@@ -44,7 +44,7 @@ WindowHttpQueue::WindowHttpQueue(core::HttpQueue* q) :
void
WindowHttpQueue::redraw() {
m_nextDraw = utils::Timer::cache().round_seconds() + 1000000;
utils::displayScheduler.insert(&m_taskUpdate, utils::Timer::cache().round_seconds() + 1000000);
cleanup_list();
-2
View File
@@ -37,9 +37,7 @@ WindowInput::WindowInput(input::TextInput* input) :
void
WindowInput::redraw() {
m_nextDraw = utils::Timer::max();
m_canvas->erase();
m_canvas->print(0, 0, "> %s", m_input->c_str());
if (m_focus)
+1 -3
View File
@@ -34,7 +34,7 @@ WindowLog::WindowLog(core::Log* l) :
Window(new Canvas, false, 0),
m_log(l) {
set_active(false);
m_active = false;
// We're trying out scheduled tasks instead.
m_connUpdate = l->signal_update().connect(sigc::mem_fun(*this, &WindowLog::receive_update));
@@ -51,8 +51,6 @@ WindowLog::find_older() {
void
WindowLog::redraw() {
m_nextDraw = utils::Timer::max();
m_canvas->erase();
int pos = 0;
-2
View File
@@ -49,8 +49,6 @@ WindowLogComplete::find_older() {
void
WindowLogComplete::redraw() {
m_nextDraw = utils::Timer::max();
m_canvas->erase();
int pos = 0;
+1 -1
View File
@@ -42,7 +42,7 @@ WindowPeerInfo::WindowPeerInfo(core::Download* d, PList* l, PList::iterator* f)
void
WindowPeerInfo::redraw() {
m_nextDraw = utils::Timer::cache().round_seconds() + 1000000;
utils::displayScheduler.insert(&m_taskUpdate, utils::Timer::cache().round_seconds() + 1000000);
m_canvas->erase();
int y = 0;
+1 -1
View File
@@ -41,7 +41,7 @@ WindowPeerList::WindowPeerList(core::Download* d, PList* l, PList::iterator* f)
void
WindowPeerList::redraw() {
m_nextDraw = utils::Timer::cache().round_seconds() + 1000000;
utils::displayScheduler.insert(&m_taskUpdate, utils::Timer::cache().round_seconds() + 1000000);
m_canvas->erase();
int x = 2;
+1 -1
View File
@@ -39,7 +39,7 @@ WindowStatusbar::WindowStatusbar(core::Manager* c) :
void
WindowStatusbar::redraw() {
m_nextDraw = utils::Timer::cache().round_seconds() + 1000000;
utils::displayScheduler.insert(&m_taskUpdate, utils::Timer::cache().round_seconds() + 1000000);
m_canvas->erase();
-2
View File
@@ -37,8 +37,6 @@ WindowStringList::~WindowStringList() {
void
WindowStringList::redraw() {
m_nextDraw = utils::Timer::max();
m_canvas->erase();
size_t ypos = 0;
+1 -1
View File
@@ -34,7 +34,7 @@ WindowTitle::WindowTitle(const std::string& s) :
void
WindowTitle::redraw() {
m_nextDraw = utils::Timer::cache().round_seconds() + 1000000;
utils::displayScheduler.insert(&m_taskUpdate, utils::Timer::cache().round_seconds() + 1000000);
m_canvas->erase();
m_canvas->print(std::max(0, (m_canvas->get_width() - (int)m_title.size()) / 2 - 4), 0,
+1 -1
View File
@@ -41,7 +41,7 @@ WindowTrackerList::WindowTrackerList(core::Download* d, unsigned int* focus) :
void
WindowTrackerList::redraw() {
// TODO: Make this depend on tracker signal.
m_nextDraw = utils::Timer::cache().round_seconds() + 10 * 1000000;
utils::displayScheduler.insert(&m_taskUpdate, utils::Timer::cache().round_seconds() + 10 * 1000000);
m_canvas->erase();
int pos = 0;