mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-08 15:19:20 +00:00
* Allow Frame's to be located in both rows and columns. Improved min
height/width for windows. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@748 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -208,6 +208,24 @@ greater(Type t, Ftor f) {
|
|||||||
return _greater<Type, Ftor>(t, f);
|
return _greater<Type, Ftor>(t, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename FtorA, typename FtorB>
|
||||||
|
struct greater2_t : public std::binary_function<typename FtorA::argument_type, typename FtorB::argument_type, bool> {
|
||||||
|
greater2_t(FtorA f_a, FtorB f_b) : m_f_a(f_a), m_f_b(f_b) {}
|
||||||
|
|
||||||
|
bool operator () (typename FtorA::argument_type a, typename FtorB::argument_type b) {
|
||||||
|
return m_f_a(a) > m_f_b(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
FtorA m_f_a;
|
||||||
|
FtorB m_f_b;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename FtorA, typename FtorB>
|
||||||
|
inline greater2_t<FtorA, FtorB>
|
||||||
|
greater2(FtorA f_a, FtorB f_b) {
|
||||||
|
return greater2_t<FtorA,FtorB>(f_a,f_b);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Type, typename Ftor>
|
template <typename Type, typename Ftor>
|
||||||
struct less_equal_t {
|
struct less_equal_t {
|
||||||
typedef bool result_type;
|
typedef bool result_type;
|
||||||
@@ -277,6 +295,27 @@ on(Src s, Dest d) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Creates a functor for accessing a member.
|
// Creates a functor for accessing a member.
|
||||||
|
template <typename Class, typename Member>
|
||||||
|
struct mem_ptr_t : public std::unary_function<Class*, Member&> {
|
||||||
|
mem_ptr_t(Member Class::*m) : m_member(m) {}
|
||||||
|
|
||||||
|
Member& operator () (Class* c) {
|
||||||
|
return c->*m_member;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Member& operator () (const Class* c) {
|
||||||
|
return c->*m_member;
|
||||||
|
}
|
||||||
|
|
||||||
|
Member Class::*m_member;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename Class, typename Member>
|
||||||
|
inline mem_ptr_t<Class, Member>
|
||||||
|
mem_ptr(Member Class::*m) {
|
||||||
|
return mem_ptr_t<Class, Member>(m);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Class, typename Member>
|
template <typename Class, typename Member>
|
||||||
struct mem_ptr_ref_t : public std::unary_function<Class&, Member&> {
|
struct mem_ptr_ref_t : public std::unary_function<Class&, Member&> {
|
||||||
mem_ptr_ref_t(Member Class::*m) : m_member(m) {}
|
mem_ptr_ref_t(Member Class::*m) : m_member(m) {}
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ public:
|
|||||||
|
|
||||||
int get_x() { int x, y; getyx(m_window, y, x); return x; }
|
int get_x() { int x, y; getyx(m_window, y, x); return x; }
|
||||||
int get_y() { int x, y; getyx(m_window, y, x); return y; }
|
int get_y() { int x, y; getyx(m_window, y, x); return y; }
|
||||||
int get_width() { int x, y; getmaxyx(m_window, y, x); return x; }
|
int width() { int x, y; getmaxyx(m_window, y, x); return x; }
|
||||||
int get_height() { int x, y; getmaxyx(m_window, y, x); return y; }
|
int height() { int x, y; getmaxyx(m_window, y, x); return y; }
|
||||||
|
|
||||||
chtype get_background() { return getbkgd(m_window); }
|
chtype get_background() { return getbkgd(m_window); }
|
||||||
void set_background(chtype c) { return wbkgdset(m_window, c); }
|
void set_background(chtype c) { return wbkgdset(m_window, c); }
|
||||||
|
|||||||
+102
-32
@@ -56,18 +56,39 @@ Frame::Frame() :
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Frame::is_dynamic() const {
|
Frame::is_width_dynamic() const {
|
||||||
switch (m_type) {
|
switch (m_type) {
|
||||||
case TYPE_NONE:
|
case TYPE_NONE:
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
case TYPE_WINDOW:
|
case TYPE_WINDOW:
|
||||||
return m_window->is_active() && m_window->is_dynamic();
|
return m_window->is_active() && m_window->is_width_dynamic();
|
||||||
|
|
||||||
case TYPE_ROW:
|
case TYPE_ROW:
|
||||||
case TYPE_COLUMN:
|
case TYPE_COLUMN:
|
||||||
for (size_type i = 0; i < m_containerSize; ++i)
|
for (size_type i = 0; i < m_containerSize; ++i)
|
||||||
if (m_container[i]->is_dynamic())
|
if (m_container[i]->is_width_dynamic())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Frame::is_height_dynamic() const {
|
||||||
|
switch (m_type) {
|
||||||
|
case TYPE_NONE:
|
||||||
|
return false;
|
||||||
|
|
||||||
|
case TYPE_WINDOW:
|
||||||
|
return m_window->is_active() && m_window->is_height_dynamic();
|
||||||
|
|
||||||
|
case TYPE_ROW:
|
||||||
|
case TYPE_COLUMN:
|
||||||
|
for (size_type i = 0; i < m_containerSize; ++i)
|
||||||
|
if (m_container[i]->is_height_dynamic())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -83,7 +104,10 @@ Frame::preferred_size() const {
|
|||||||
return pair_type(0, 0);
|
return pair_type(0, 0);
|
||||||
|
|
||||||
case TYPE_WINDOW:
|
case TYPE_WINDOW:
|
||||||
return m_window->is_active() ? pair_type(0, m_window->get_min_height()) : pair_type(0, 0);
|
if (m_window->is_active())
|
||||||
|
return pair_type(std::max<uint32_t>(m_window->min_width(), 1), std::max<uint32_t>(m_window->min_height(), 1));
|
||||||
|
else
|
||||||
|
return pair_type(0, 0);
|
||||||
|
|
||||||
case TYPE_ROW:
|
case TYPE_ROW:
|
||||||
case TYPE_COLUMN:
|
case TYPE_COLUMN:
|
||||||
@@ -129,14 +153,29 @@ Frame::initialize_window(Window* window) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Frame::initialize_container(Type containerType, size_type size) {
|
Frame::initialize_row(size_type size) {
|
||||||
if (m_type != TYPE_NONE || (containerType != TYPE_ROW && containerType != TYPE_COLUMN))
|
if (m_type != TYPE_NONE)
|
||||||
throw torrent::client_error("Frame::initialize_container(...) Invalid state.");
|
throw torrent::client_error("Frame::initialize_container(...) Invalid state.");
|
||||||
|
|
||||||
if (size > max_size)
|
if (size > max_size)
|
||||||
throw torrent::client_error("Frame::initialize_container(...) size >= max_size.");
|
throw torrent::client_error("Frame::initialize_container(...) size >= max_size.");
|
||||||
|
|
||||||
m_type = containerType;
|
m_type = TYPE_ROW;
|
||||||
|
m_containerSize = size;
|
||||||
|
|
||||||
|
for (size_type i = 0; i < m_containerSize; ++i)
|
||||||
|
m_container[i] = new Frame();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Frame::initialize_column(size_type size) {
|
||||||
|
if (m_type != TYPE_NONE)
|
||||||
|
throw torrent::client_error("Frame::initialize_container(...) Invalid state.");
|
||||||
|
|
||||||
|
if (size > max_size)
|
||||||
|
throw torrent::client_error("Frame::initialize_container(...) size >= max_size.");
|
||||||
|
|
||||||
|
m_type = TYPE_COLUMN;
|
||||||
m_containerSize = size;
|
m_containerSize = size;
|
||||||
|
|
||||||
for (size_type i = 0; i < m_containerSize; ++i)
|
for (size_type i = 0; i < m_containerSize; ++i)
|
||||||
@@ -193,47 +232,78 @@ Frame::balance(uint32_t x, uint32_t y, uint32_t width, uint32_t height) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_type == TYPE_WINDOW) {
|
if (m_type == TYPE_WINDOW) {
|
||||||
if (m_window->is_active())
|
if (!m_window->is_active())
|
||||||
m_window->resize(x, y, width, height);
|
return;
|
||||||
|
|
||||||
|
m_window->resize(x, y, width, height);
|
||||||
|
m_window->mark_dirty();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t size;
|
// Find the size of the static frames. The dynamic frames are added
|
||||||
|
// to a temporary list for the second pass. Each frame uses the
|
||||||
|
// m_width and m_height as temporary storage for width and height in
|
||||||
|
// this algorithm.
|
||||||
|
size_type dynamicSize = 0;
|
||||||
|
Frame* dynamicFrames[max_size];
|
||||||
|
|
||||||
if (m_type == TYPE_ROW)
|
int remaining = m_type == TYPE_ROW ? height : width;
|
||||||
size = height - std::min(height, preferred_size().second);
|
|
||||||
else
|
|
||||||
size = width - std::min(width, preferred_size().first);
|
|
||||||
|
|
||||||
uint32_t dynamicCount = std::count_if(m_container, m_container + m_containerSize, std::mem_fun(&Frame::is_dynamic));
|
|
||||||
|
|
||||||
for (Frame **itr = m_container, **last = m_container + m_containerSize; itr != last; ++itr) {
|
for (Frame **itr = m_container, **last = m_container + m_containerSize; itr != last; ++itr) {
|
||||||
uint32_t s;
|
pair_type p = (*itr)->preferred_size();
|
||||||
|
(*itr)->m_width = p.first;
|
||||||
|
(*itr)->m_height = p.second;
|
||||||
|
|
||||||
if ((*itr)->is_dynamic()) {
|
if ((m_type == TYPE_ROW && (*itr)->is_height_dynamic()) || (m_type == TYPE_COLUMN && (*itr)->is_width_dynamic()))
|
||||||
s = (size + dynamicCount - 1) / dynamicCount;
|
dynamicFrames[dynamicSize++] = *itr;
|
||||||
|
else
|
||||||
|
remaining -= m_type == TYPE_ROW ? p.second : p.first;
|
||||||
|
}
|
||||||
|
|
||||||
size -= s;
|
// Sort the dynamic frames by the min size in the direction we are
|
||||||
dynamicCount--;
|
// interested in. Then try to satisfy the largest first, and if we
|
||||||
|
// have any remaining space we can use that to extend it and any
|
||||||
|
// following frames.
|
||||||
|
//
|
||||||
|
// Else if we're short, only give each what they require.
|
||||||
|
|
||||||
} else {
|
if (m_type == TYPE_ROW)
|
||||||
s = 0;
|
std::sort(dynamicFrames, dynamicFrames + dynamicSize, rak::greater2(rak::mem_ptr(&Frame::m_height), rak::mem_ptr(&Frame::m_height)));
|
||||||
}
|
else
|
||||||
|
std::sort(dynamicFrames, dynamicFrames + dynamicSize, rak::greater2(rak::mem_ptr(&Frame::m_width), rak::mem_ptr(&Frame::m_width)));
|
||||||
|
|
||||||
|
for (Frame **itr = dynamicFrames, **last = dynamicFrames + dynamicSize; itr != last; ++itr, --dynamicSize) {
|
||||||
|
uint32_t s = std::max<uint32_t>((std::max(remaining, 0) + dynamicSize - 1) / dynamicSize,
|
||||||
|
m_type == TYPE_ROW ? (*itr)->m_height : (*itr)->m_width);
|
||||||
|
|
||||||
|
remaining -= s;
|
||||||
|
|
||||||
|
if (m_type == TYPE_ROW)
|
||||||
|
(*itr)->m_height = s;
|
||||||
|
else
|
||||||
|
(*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) {
|
if (m_type == TYPE_ROW) {
|
||||||
s += (*itr)->preferred_size().second;
|
(*itr)->balance(x, y, m_width, (*itr)->m_height);
|
||||||
|
y += (*itr)->m_height;
|
||||||
(*itr)->balance(x, y, m_width, s);
|
|
||||||
y += s;
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
s += (*itr)->preferred_size().first;
|
(*itr)->balance(x, y, (*itr)->m_width, m_height);
|
||||||
|
x += (*itr)->m_width;
|
||||||
(*itr)->balance(x, y, s, height);
|
|
||||||
x += s;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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.");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -59,7 +59,8 @@ public:
|
|||||||
|
|
||||||
Frame();
|
Frame();
|
||||||
|
|
||||||
bool is_dynamic() const;
|
bool is_width_dynamic() const;
|
||||||
|
bool is_height_dynamic() const;
|
||||||
|
|
||||||
pair_type preferred_size() const;
|
pair_type preferred_size() const;
|
||||||
|
|
||||||
@@ -80,7 +81,8 @@ public:
|
|||||||
void set_container_size(size_type size);
|
void set_container_size(size_type size);
|
||||||
|
|
||||||
void initialize_window(Window* window);
|
void initialize_window(Window* window);
|
||||||
void initialize_container(Type containerType, size_type size);
|
void initialize_row(size_type size);
|
||||||
|
void initialize_column(size_type size);
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
|||||||
+21
-12
@@ -46,28 +46,37 @@ Window::SlotTimer Window::m_slotSchedule;
|
|||||||
Window::SlotWindow Window::m_slotUnschedule;
|
Window::SlotWindow Window::m_slotUnschedule;
|
||||||
Window::Slot Window::m_slotAdjust;
|
Window::Slot Window::m_slotAdjust;
|
||||||
|
|
||||||
Window::Window(Canvas* c, bool d, int h) :
|
Window::Window(Canvas* canvas, int flags, extent_type minWidth, extent_type minHeight) :
|
||||||
m_canvas(c),
|
m_canvas(canvas),
|
||||||
m_active(true),
|
m_flags(flags),
|
||||||
m_dynamic(d),
|
m_minWidth(minWidth),
|
||||||
m_minHeight(h) {
|
m_minHeight(minHeight) {
|
||||||
|
|
||||||
m_taskUpdate.set_slot(rak::mem_fn(this, &Window::redraw));
|
m_taskUpdate.set_slot(rak::mem_fn(this, &Window::redraw));
|
||||||
|
|
||||||
|
if (flags & flag_active)
|
||||||
|
mark_dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
Window::~Window() {
|
Window::~Window() {
|
||||||
m_slotUnschedule(this);
|
if (is_active())
|
||||||
|
m_slotUnschedule(this);
|
||||||
|
|
||||||
delete m_canvas;
|
delete m_canvas;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Window::set_active(bool a) {
|
Window::set_active(bool state) {
|
||||||
if (a)
|
if (state == is_active())
|
||||||
mark_dirty();
|
return;
|
||||||
else
|
|
||||||
m_slotUnschedule(this);
|
|
||||||
|
|
||||||
m_active = a;
|
if (state) {
|
||||||
|
m_flags |= flag_active;
|
||||||
|
mark_dirty();
|
||||||
|
} else {
|
||||||
|
m_flags &= ~flag_active;
|
||||||
|
m_slotUnschedule(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
+22
-13
@@ -50,30 +50,38 @@ class Manager;
|
|||||||
|
|
||||||
class Window {
|
class Window {
|
||||||
public:
|
public:
|
||||||
|
typedef uint32_t extent_type;
|
||||||
|
|
||||||
typedef rak::mem_fun0<Manager, void> Slot;
|
typedef rak::mem_fun0<Manager, void> Slot;
|
||||||
typedef rak::mem_fun1<Manager, void, Window*> SlotWindow;
|
typedef rak::mem_fun1<Manager, void, Window*> SlotWindow;
|
||||||
typedef rak::mem_fun2<Manager, void, Window*, rak::timer> SlotTimer;
|
typedef rak::mem_fun2<Manager, void, Window*, rak::timer> SlotTimer;
|
||||||
|
|
||||||
Window(Canvas* c = NULL, bool d = false, int h = 1);
|
static const int flag_active = (1 << 0);
|
||||||
|
static const int flag_width_dynamic = (1 << 1);
|
||||||
|
static const int flag_height_dynamic = (1 << 2);
|
||||||
|
|
||||||
|
Window(Canvas* canvas, int flags, extent_type minWidth, extent_type minHeight);
|
||||||
|
|
||||||
virtual ~Window();
|
virtual ~Window();
|
||||||
|
|
||||||
bool is_active() { return m_active; }
|
bool is_active() const { return m_flags & flag_active; }
|
||||||
bool is_dynamic() { return m_dynamic; }
|
void set_active(bool state);
|
||||||
|
|
||||||
|
bool is_width_dynamic() const { return m_flags & flag_width_dynamic; }
|
||||||
|
bool is_height_dynamic() const { return m_flags & flag_height_dynamic; }
|
||||||
|
|
||||||
bool is_dirty() { return m_taskUpdate.is_queued(); }
|
bool is_dirty() { return m_taskUpdate.is_queued(); }
|
||||||
|
void mark_dirty() { m_slotSchedule(this, cachedTime + 1); }
|
||||||
|
|
||||||
int get_min_height() const { return m_minHeight; }
|
extent_type min_width() const { return m_minWidth; }
|
||||||
|
extent_type min_height() const { return m_minHeight; }
|
||||||
|
|
||||||
bool get_active() { return m_active; }
|
extent_type width() const { return m_canvas->width(); }
|
||||||
void set_active(bool a);
|
extent_type height() const { return m_canvas->height(); }
|
||||||
|
|
||||||
void refresh() { m_canvas->refresh(); }
|
void refresh() { m_canvas->refresh(); }
|
||||||
void resize(int x, int y, int w, int h);
|
void resize(int x, int y, int w, int h);
|
||||||
|
|
||||||
int get_height() const { return m_canvas->get_height(); }
|
|
||||||
|
|
||||||
void mark_dirty() { m_slotSchedule(this, cachedTime + 1); }
|
|
||||||
|
|
||||||
virtual void redraw() = 0;
|
virtual void redraw() = 0;
|
||||||
|
|
||||||
rak::priority_item* task_update() { return &m_taskUpdate; }
|
rak::priority_item* task_update() { return &m_taskUpdate; }
|
||||||
@@ -93,9 +101,10 @@ protected:
|
|||||||
|
|
||||||
Canvas* m_canvas;
|
Canvas* m_canvas;
|
||||||
|
|
||||||
bool m_active;
|
int m_flags;
|
||||||
bool m_dynamic;
|
|
||||||
int m_minHeight;
|
extent_type m_minWidth;
|
||||||
|
extent_type m_minHeight;
|
||||||
|
|
||||||
rak::priority_item m_taskUpdate;
|
rak::priority_item m_taskUpdate;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
namespace display {
|
namespace display {
|
||||||
|
|
||||||
WindowDownloadChunksSeen::WindowDownloadChunksSeen(core::Download* d, unsigned int *focus) :
|
WindowDownloadChunksSeen::WindowDownloadChunksSeen(core::Download* d, unsigned int *focus) :
|
||||||
Window(new Canvas, true),
|
Window(new Canvas, flag_width_dynamic | flag_height_dynamic, 0, 0),
|
||||||
m_download(d),
|
m_download(d),
|
||||||
m_focus(focus) {
|
m_focus(focus) {
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,7 @@ WindowDownloadChunksSeen::redraw() {
|
|||||||
m_slotSchedule(this, (cachedTime + rak::timer::from_seconds(10)).round_seconds());
|
m_slotSchedule(this, (cachedTime + rak::timer::from_seconds(10)).round_seconds());
|
||||||
m_canvas->erase();
|
m_canvas->erase();
|
||||||
|
|
||||||
if (m_canvas->get_height() < 3 || m_canvas->get_width() < 18)
|
if (m_canvas->height() < 3 || m_canvas->width() < 18)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_canvas->print(2, 0, "Chunks seen: [C/A/D %i/%i/%.2f]",
|
m_canvas->print(2, 0, "Chunks seen: [C/A/D %i/%i/%.2f]",
|
||||||
@@ -102,7 +102,7 @@ WindowDownloadChunksSeen::redraw() {
|
|||||||
while (itrTransfer != transferChunks.end() && (uint32_t)(chunk - seen) > (*itrTransfer)->index())
|
while (itrTransfer != transferChunks.end() && (uint32_t)(chunk - seen) > (*itrTransfer)->index())
|
||||||
itrTransfer++;
|
itrTransfer++;
|
||||||
|
|
||||||
for (int y = 1; y < m_canvas->get_height() && chunk < last; ++y) {
|
for (int y = 1; y < m_canvas->height() && chunk < last; ++y) {
|
||||||
m_canvas->print(0, y, "%5u ", (int)(chunk - seen));
|
m_canvas->print(0, y, "%5u ", (int)(chunk - seen));
|
||||||
|
|
||||||
while (chunk < last) {
|
while (chunk < last) {
|
||||||
@@ -124,7 +124,7 @@ WindowDownloadChunksSeen::redraw() {
|
|||||||
chunk++;
|
chunk++;
|
||||||
|
|
||||||
if ((chunk - seen) % 10 == 0) {
|
if ((chunk - seen) % 10 == 0) {
|
||||||
if (m_canvas->get_x() + 12 > m_canvas->get_width())
|
if (m_canvas->get_x() + 12 > m_canvas->width())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
m_canvas->print_char(' ');
|
m_canvas->print_char(' ');
|
||||||
@@ -135,7 +135,7 @@ WindowDownloadChunksSeen::redraw() {
|
|||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
WindowDownloadChunksSeen::rows() const {
|
WindowDownloadChunksSeen::rows() const {
|
||||||
if (m_canvas->get_width() < 18)
|
if (m_canvas->width() < 18)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return (m_download->download()->chunks_total() + chunks_per_row() - 1) / chunks_per_row();
|
return (m_download->download()->chunks_total() + chunks_per_row() - 1) / chunks_per_row();
|
||||||
|
|||||||
@@ -54,9 +54,9 @@ public:
|
|||||||
virtual void redraw();
|
virtual void redraw();
|
||||||
|
|
||||||
unsigned int rows() const;
|
unsigned int rows() const;
|
||||||
unsigned int chunks_per_row() const { return (m_canvas->get_width() - 6) / 11 * 10; }
|
unsigned int chunks_per_row() const { return (width() - 6) / 11 * 10; }
|
||||||
|
|
||||||
unsigned int max_focus() const { return std::max<int>(rows() - get_height() + 1, 0); }
|
unsigned int max_focus() const { return std::max<int>(rows() - height() + 1, 0); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
core::Download* m_download;
|
core::Download* m_download;
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ WindowDownloadList::redraw() {
|
|||||||
|
|
||||||
m_canvas->print(0, 0, "%s", ("[View: " + m_view->name() + "]").c_str());
|
m_canvas->print(0, 0, "%s", ("[View: " + m_view->name() + "]").c_str());
|
||||||
|
|
||||||
if (m_view->empty_visible() || m_canvas->get_width() < 5 || m_canvas->get_height() < 2)
|
if (m_view->empty_visible() || m_canvas->width() < 5 || m_canvas->height() < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
typedef std::pair<core::View::iterator, core::View::iterator> Range;
|
typedef std::pair<core::View::iterator, core::View::iterator> Range;
|
||||||
@@ -81,7 +81,7 @@ WindowDownloadList::redraw() {
|
|||||||
Range range = rak::advance_bidirectional(m_view->begin_visible(),
|
Range range = rak::advance_bidirectional(m_view->begin_visible(),
|
||||||
m_view->focus() != m_view->end_visible() ? m_view->focus() : m_view->begin_visible(),
|
m_view->focus() != m_view->end_visible() ? m_view->focus() : m_view->begin_visible(),
|
||||||
m_view->end_visible(),
|
m_view->end_visible(),
|
||||||
m_canvas->get_height() / 3);
|
m_canvas->height() / 3);
|
||||||
|
|
||||||
// Make sure we properly fill out the last lines so it looks like
|
// Make sure we properly fill out the last lines so it looks like
|
||||||
// there are more torrents, yet don't hide it if we got the last one
|
// there are more torrents, yet don't hide it if we got the last one
|
||||||
@@ -92,9 +92,9 @@ WindowDownloadList::redraw() {
|
|||||||
int pos = 1;
|
int pos = 1;
|
||||||
|
|
||||||
while (range.first != range.second) {
|
while (range.first != range.second) {
|
||||||
char buffer[m_canvas->get_width()];
|
char buffer[m_canvas->width()];
|
||||||
char* position;
|
char* position;
|
||||||
char* last = buffer + m_canvas->get_width() - 2;
|
char* last = buffer + m_canvas->width() - 2;
|
||||||
|
|
||||||
position = print_download_title(buffer, last, *range.first);
|
position = print_download_title(buffer, last, *range.first);
|
||||||
m_canvas->print(0, pos++, "%c %s", range.first == m_view->focus() ? '*' : ' ', buffer);
|
m_canvas->print(0, pos++, "%c %s", range.first == m_view->focus() ? '*' : ' ', buffer);
|
||||||
|
|||||||
@@ -51,7 +51,9 @@ namespace display {
|
|||||||
|
|
||||||
class WindowDownloadList : public Window {
|
class WindowDownloadList : public Window {
|
||||||
public:
|
public:
|
||||||
WindowDownloadList() : Window(new Canvas, true), m_view(NULL) {}
|
WindowDownloadList() :
|
||||||
|
Window(new Canvas, flag_width_dynamic | flag_height_dynamic, 120, 1),
|
||||||
|
m_view(NULL) {}
|
||||||
~WindowDownloadList();
|
~WindowDownloadList();
|
||||||
|
|
||||||
virtual void redraw();
|
virtual void redraw();
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
namespace display {
|
namespace display {
|
||||||
|
|
||||||
WindowDownloadStatusbar::WindowDownloadStatusbar(core::Download* d) :
|
WindowDownloadStatusbar::WindowDownloadStatusbar(core::Download* d) :
|
||||||
Window(new Canvas, false, 3),
|
Window(new Canvas, flag_width_dynamic, 0, 3),
|
||||||
m_download(d) {
|
m_download(d) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,35 +59,33 @@ WindowDownloadStatusbar::redraw() {
|
|||||||
|
|
||||||
m_canvas->erase();
|
m_canvas->erase();
|
||||||
|
|
||||||
char buffer[m_canvas->get_width()];
|
char buffer[m_canvas->width()];
|
||||||
char* position;
|
char* position;
|
||||||
char* last = buffer + m_canvas->get_width() - 2;
|
char* last = buffer + m_canvas->width() - 2;
|
||||||
|
|
||||||
position = print_download_info(buffer, last, m_download);
|
position = print_download_info(buffer, last, m_download);
|
||||||
m_canvas->print(0, 0, "%s", buffer);
|
m_canvas->print(0, 0, "%s", buffer);
|
||||||
|
|
||||||
position = buffer + std::max(snprintf(buffer, last - buffer, "Peers: %i(%i) Min/Max: %i/%i Uploads: %i U/I/C/A: %i/%i/%i/%i Failed: %i",
|
position = buffer + std::max(snprintf(buffer, last - buffer, "Peers: %i(%i) Min/Max: %i/%i Uploads: %i U/I/C/A: %i/%i/%i/%i Failed: %i",
|
||||||
(int)m_download->download()->peers_connected(),
|
(int)m_download->download()->peers_connected(),
|
||||||
(int)m_download->download()->peers_not_connected(),
|
(int)m_download->download()->peers_not_connected(),
|
||||||
(int)m_download->download()->peers_min(),
|
(int)m_download->download()->peers_min(),
|
||||||
(int)m_download->download()->peers_max(),
|
(int)m_download->download()->peers_max(),
|
||||||
(int)m_download->download()->uploads_max(),
|
(int)m_download->download()->uploads_max(),
|
||||||
(int)m_download->download()->peers_currently_unchoked(),
|
(int)m_download->download()->peers_currently_unchoked(),
|
||||||
(int)m_download->download()->peers_currently_interested(),
|
(int)m_download->download()->peers_currently_interested(),
|
||||||
(int)m_download->download()->peers_complete(),
|
(int)m_download->download()->peers_complete(),
|
||||||
(int)m_download->download()->peers_accounted(),
|
(int)m_download->download()->peers_accounted(),
|
||||||
(int)m_download->chunks_failed()),
|
(int)m_download->chunks_failed()),
|
||||||
0);
|
0);
|
||||||
// position = buffer + std::max(snprintf(position, last - buffer, " Priority: %s",
|
|
||||||
// core::Download::priority_to_string(m_download->variable()->get("priority").as_value())),
|
|
||||||
// 0);
|
|
||||||
m_canvas->print(0, 1, "%s", buffer);
|
m_canvas->print(0, 1, "%s", buffer);
|
||||||
|
|
||||||
position = print_download_status(buffer, last, m_download);
|
position = print_download_status(buffer, last, m_download);
|
||||||
m_canvas->print(0, 2, "[%c:%i] %s",
|
m_canvas->print(0, 2, "[%c:%i] %s",
|
||||||
m_download->tracker_list()->is_busy() ? 'C' : ' ',
|
m_download->tracker_list()->is_busy() ? 'C' : ' ',
|
||||||
(int)(m_download->download()->tracker_list().timeout() / 1000000),
|
(int)(m_download->download()->tracker_list().timeout() / 1000000),
|
||||||
buffer);
|
buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
namespace display {
|
namespace display {
|
||||||
|
|
||||||
WindowDownloadTransferList::WindowDownloadTransferList(core::Download* d, unsigned int *focus) :
|
WindowDownloadTransferList::WindowDownloadTransferList(core::Download* d, unsigned int *focus) :
|
||||||
Window(new Canvas, true),
|
Window(new Canvas, flag_width_dynamic | flag_height_dynamic, 0, 0),
|
||||||
m_download(d),
|
m_download(d),
|
||||||
m_focus(focus) {
|
m_focus(focus) {
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,7 @@ WindowDownloadTransferList::redraw() {
|
|||||||
m_slotSchedule(this, (cachedTime + rak::timer::from_seconds(1)).round_seconds());
|
m_slotSchedule(this, (cachedTime + rak::timer::from_seconds(1)).round_seconds());
|
||||||
m_canvas->erase();
|
m_canvas->erase();
|
||||||
|
|
||||||
if (m_canvas->get_height() < 3 || m_canvas->get_width() < 18)
|
if (m_canvas->height() < 3 || m_canvas->width() < 18)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const torrent::TransferList* transfers = m_download->download()->transfer_list();
|
const torrent::TransferList* transfers = m_download->download()->transfer_list();
|
||||||
@@ -73,7 +73,7 @@ WindowDownloadTransferList::redraw() {
|
|||||||
// is just something i threw in there, someone really should
|
// is just something i threw in there, someone really should
|
||||||
// prettify this. (This is a very subtle hint)
|
// prettify this. (This is a very subtle hint)
|
||||||
|
|
||||||
for (int y = 1; y < m_canvas->get_height() && itr != transfers->end(); ++y, ++itr) {
|
for (int y = 1; y < m_canvas->height() && itr != transfers->end(); ++y, ++itr) {
|
||||||
m_canvas->print(0, y, "%5u [P: %u F: %u]", (*itr)->index(), (*itr)->priority(), (*itr)->failed());
|
m_canvas->print(0, y, "%5u [P: %u F: %u]", (*itr)->index(), (*itr)->priority(), (*itr)->failed());
|
||||||
|
|
||||||
// Handle window size.
|
// Handle window size.
|
||||||
@@ -106,7 +106,7 @@ WindowDownloadTransferList::redraw() {
|
|||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
WindowDownloadTransferList::rows() const {
|
WindowDownloadTransferList::rows() const {
|
||||||
if (m_canvas->get_width() < 18)
|
if (m_canvas->width() < 18)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// return (m_download->download()->chunks_total() + chunks_per_row() - 1) / chunks_per_row();
|
// return (m_download->download()->chunks_total() + chunks_per_row() - 1) / chunks_per_row();
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public:
|
|||||||
virtual void redraw();
|
virtual void redraw();
|
||||||
|
|
||||||
unsigned int rows() const;
|
unsigned int rows() const;
|
||||||
unsigned int max_focus() const { return std::max<int>(rows() - get_height() + 1, 0); }
|
unsigned int max_focus() const { return std::max<int>(rows() - height() + 1, 0); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char key_id(torrent::BlockTransfer::key_type key);
|
char key_id(torrent::BlockTransfer::key_type key);
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
namespace display {
|
namespace display {
|
||||||
|
|
||||||
WindowFileList::WindowFileList(core::Download* d, unsigned int* focus) :
|
WindowFileList::WindowFileList(core::Download* d, unsigned int* focus) :
|
||||||
Window(new Canvas, true),
|
Window(new Canvas, flag_width_dynamic | flag_height_dynamic, 0, 0),
|
||||||
m_download(d),
|
m_download(d),
|
||||||
m_focus(focus) {
|
m_focus(focus) {
|
||||||
}
|
}
|
||||||
@@ -78,7 +78,7 @@ WindowFileList::redraw() {
|
|||||||
|
|
||||||
torrent::FileList fl = m_download->download()->file_list();
|
torrent::FileList fl = m_download->download()->file_list();
|
||||||
|
|
||||||
if (fl.size() == 0 || m_canvas->get_height() < 2)
|
if (fl.size() == 0 || m_canvas->height() < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
@@ -95,7 +95,7 @@ WindowFileList::redraw() {
|
|||||||
if (*m_focus >= fl.size())
|
if (*m_focus >= fl.size())
|
||||||
throw std::logic_error("WindowFileList::redraw() called on an object with a bad focus value");
|
throw std::logic_error("WindowFileList::redraw() called on an object with a bad focus value");
|
||||||
|
|
||||||
Range range = rak::advance_bidirectional<unsigned int>(0, *m_focus, fl.size(), m_canvas->get_height() - pos);
|
Range range = rak::advance_bidirectional<unsigned int>(0, *m_focus, fl.size(), m_canvas->height() - pos);
|
||||||
|
|
||||||
while (range.first != range.second) {
|
while (range.first != range.second) {
|
||||||
torrent::File e = fl.get(range.first);
|
torrent::File e = fl.get(range.first);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
namespace display {
|
namespace display {
|
||||||
|
|
||||||
WindowHttpQueue::WindowHttpQueue(core::HttpQueue* q) :
|
WindowHttpQueue::WindowHttpQueue(core::HttpQueue* q) :
|
||||||
Window(new Canvas, false, 1),
|
Window(new Canvas, flag_width_dynamic, 0, 1),
|
||||||
m_queue(q) {
|
m_queue(q) {
|
||||||
|
|
||||||
set_active(false);
|
set_active(false);
|
||||||
@@ -75,7 +75,7 @@ WindowHttpQueue::redraw() {
|
|||||||
int pos = 10;
|
int pos = 10;
|
||||||
Container::iterator itr = m_container.begin();
|
Container::iterator itr = m_container.begin();
|
||||||
|
|
||||||
while (itr != m_container.end() && pos + 20 < m_canvas->get_width()) {
|
while (itr != m_container.end() && pos + 20 < m_canvas->width()) {
|
||||||
if (itr->m_http == NULL)
|
if (itr->m_http == NULL)
|
||||||
m_canvas->print(pos, 0, "%s done", itr->m_name.c_str());
|
m_canvas->print(pos, 0, "%s done", itr->m_name.c_str());
|
||||||
|
|
||||||
|
|||||||
@@ -46,10 +46,10 @@ namespace display {
|
|||||||
void
|
void
|
||||||
WindowInput::redraw() {
|
WindowInput::redraw() {
|
||||||
m_canvas->erase();
|
m_canvas->erase();
|
||||||
m_canvas->print(0, 0, "> %s", m_input != NULL ? m_input->c_str() : "<NULL>");
|
m_canvas->print(0, 0, "%s> %s", m_title.c_str(), m_input != NULL ? m_input->c_str() : "<NULL>");
|
||||||
|
|
||||||
if (m_focus)
|
if (m_focus)
|
||||||
m_canvas->set_attr(m_input->get_pos() + 2, 0, 1, A_REVERSE, COLOR_PAIR(0));
|
m_canvas->set_attr(m_input->get_pos() + 2 + m_title.size(), 0, 1, A_REVERSE, COLOR_PAIR(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,8 @@
|
|||||||
#ifndef RTORRENT_DISPLAY_WINDOW_INPUT_H
|
#ifndef RTORRENT_DISPLAY_WINDOW_INPUT_H
|
||||||
#define RTORRENT_DISPLAY_WINDOW_INPUT_H
|
#define RTORRENT_DISPLAY_WINDOW_INPUT_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
namespace input {
|
namespace input {
|
||||||
@@ -47,11 +49,17 @@ namespace display {
|
|||||||
|
|
||||||
class WindowInput : public Window {
|
class WindowInput : public Window {
|
||||||
public:
|
public:
|
||||||
WindowInput() : Window(new Canvas, false, 1), m_input(NULL), m_focus(false) {}
|
WindowInput() :
|
||||||
|
Window(new Canvas, flag_width_dynamic, 0, 1),
|
||||||
|
m_input(NULL),
|
||||||
|
m_focus(false) {}
|
||||||
|
|
||||||
input::TextInput* input() { return m_input; }
|
input::TextInput* input() { return m_input; }
|
||||||
void set_input(input::TextInput* input) { m_input = input; }
|
void set_input(input::TextInput* input) { m_input = input; }
|
||||||
|
|
||||||
|
const std::string& title() const { return m_title; }
|
||||||
|
void set_title(const std::string& str) { m_title = str; }
|
||||||
|
|
||||||
bool focus() const { return m_focus; }
|
bool focus() const { return m_focus; }
|
||||||
void set_focus(bool f) { mark_dirty(); m_focus = f; }
|
void set_focus(bool f) { mark_dirty(); m_focus = f; }
|
||||||
|
|
||||||
@@ -59,6 +67,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
input::TextInput* m_input;
|
input::TextInput* m_input;
|
||||||
|
std::string m_title;
|
||||||
|
|
||||||
bool m_focus;
|
bool m_focus;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -45,11 +45,9 @@
|
|||||||
namespace display {
|
namespace display {
|
||||||
|
|
||||||
WindowLog::WindowLog(core::Log* l) :
|
WindowLog::WindowLog(core::Log* l) :
|
||||||
Window(new Canvas, false, 0),
|
Window(new Canvas, flag_width_dynamic, 0, 0),
|
||||||
m_log(l) {
|
m_log(l) {
|
||||||
|
|
||||||
m_active = false;
|
|
||||||
|
|
||||||
// We're trying out scheduled tasks instead.
|
// We're trying out scheduled tasks instead.
|
||||||
m_connUpdate = l->signal_update().connect(sigc::mem_fun(*this, &WindowLog::receive_update));
|
m_connUpdate = l->signal_update().connect(sigc::mem_fun(*this, &WindowLog::receive_update));
|
||||||
}
|
}
|
||||||
@@ -69,7 +67,7 @@ WindowLog::redraw() {
|
|||||||
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
for (core::Log::iterator itr = m_log->begin(), end = find_older(); itr != end && pos < m_canvas->get_height(); ++itr) {
|
for (core::Log::iterator itr = m_log->begin(), end = find_older(); itr != end && pos < m_canvas->height(); ++itr) {
|
||||||
char buffer[16];
|
char buffer[16];
|
||||||
print_hhmmss_local(buffer, buffer + 16, static_cast<time_t>(itr->first.seconds()));
|
print_hhmmss_local(buffer, buffer + 16, static_cast<time_t>(itr->first.seconds()));
|
||||||
|
|
||||||
@@ -80,7 +78,7 @@ WindowLog::redraw() {
|
|||||||
void
|
void
|
||||||
WindowLog::receive_update() {
|
WindowLog::receive_update() {
|
||||||
iterator itr = find_older();
|
iterator itr = find_older();
|
||||||
int h = std::min(std::distance(m_log->begin(), itr), (std::iterator_traits<iterator>::difference_type)10);
|
extent_type h = std::min(std::distance(m_log->begin(), itr), (std::iterator_traits<iterator>::difference_type)10);
|
||||||
|
|
||||||
if (h != m_minHeight) {
|
if (h != m_minHeight) {
|
||||||
set_active(h != 0);
|
set_active(h != 0);
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
namespace display {
|
namespace display {
|
||||||
|
|
||||||
WindowLogComplete::WindowLogComplete(core::Log* l) :
|
WindowLogComplete::WindowLogComplete(core::Log* l) :
|
||||||
Window(new Canvas, true),
|
Window(new Canvas, flag_width_dynamic | flag_height_dynamic, 30, 1),
|
||||||
m_log(l) {
|
m_log(l) {
|
||||||
|
|
||||||
// We're trying out scheduled tasks instead.
|
// We're trying out scheduled tasks instead.
|
||||||
@@ -67,9 +67,9 @@ WindowLogComplete::redraw() {
|
|||||||
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
// m_canvas->print(std::max(0, (int)m_canvas->get_width() / 2 - 5), pos++, "*** Log ***");
|
// m_canvas->print(std::max(0, (int)m_canvas->width() / 2 - 5), pos++, "*** Log ***");
|
||||||
|
|
||||||
for (core::Log::iterator itr = m_log->begin(), e = m_log->end(); itr != e && pos < m_canvas->get_height(); ++itr) {
|
for (core::Log::iterator itr = m_log->begin(), e = m_log->end(); itr != e && pos < m_canvas->height(); ++itr) {
|
||||||
char buffer[16];
|
char buffer[16];
|
||||||
print_hhmmss_local(buffer, buffer + 16, static_cast<time_t>(itr->first.seconds()));
|
print_hhmmss_local(buffer, buffer + 16, static_cast<time_t>(itr->first.seconds()));
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@
|
|||||||
namespace display {
|
namespace display {
|
||||||
|
|
||||||
WindowPeerInfo::WindowPeerInfo(core::Download* d, PList* l, PList::iterator* f) :
|
WindowPeerInfo::WindowPeerInfo(core::Download* d, PList* l, PList::iterator* f) :
|
||||||
Window(new Canvas, true),
|
Window(new Canvas, flag_width_dynamic | flag_height_dynamic, 0, 0),
|
||||||
m_download(d),
|
m_download(d),
|
||||||
m_list(l),
|
m_list(l),
|
||||||
m_focus(f) {
|
m_focus(f) {
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
namespace display {
|
namespace display {
|
||||||
|
|
||||||
WindowPeerList::WindowPeerList(core::Download* d, PList* l, PList::iterator* f) :
|
WindowPeerList::WindowPeerList(core::Download* d, PList* l, PList::iterator* f) :
|
||||||
Window(new Canvas, true),
|
Window(new Canvas, flag_width_dynamic | flag_height_dynamic, 0, 0),
|
||||||
m_download(d),
|
m_download(d),
|
||||||
m_list(l),
|
m_list(l),
|
||||||
m_focus(f) {
|
m_focus(f) {
|
||||||
@@ -87,7 +87,7 @@ WindowPeerList::redraw() {
|
|||||||
Range range = rak::advance_bidirectional(m_list->begin(),
|
Range range = rak::advance_bidirectional(m_list->begin(),
|
||||||
*m_focus != m_list->end() ? *m_focus : m_list->begin(),
|
*m_focus != m_list->end() ? *m_focus : m_list->begin(),
|
||||||
m_list->end(),
|
m_list->end(),
|
||||||
m_canvas->get_height() - y);
|
m_canvas->height() - y);
|
||||||
|
|
||||||
if (m_download->download()->chunks_total() <= 0)
|
if (m_download->download()->chunks_total() <= 0)
|
||||||
throw std::logic_error("WindowPeerList::redraw() m_slotChunksTotal() returned invalid value");
|
throw std::logic_error("WindowPeerList::redraw() m_slotChunksTotal() returned invalid value");
|
||||||
|
|||||||
@@ -53,9 +53,9 @@ WindowStatusbar::redraw() {
|
|||||||
m_canvas->erase();
|
m_canvas->erase();
|
||||||
|
|
||||||
// TODO: Make a buffer with size = get_width?
|
// TODO: Make a buffer with size = get_width?
|
||||||
char buffer[m_canvas->get_width() + 1];
|
char buffer[m_canvas->width() + 1];
|
||||||
char* position;
|
char* position;
|
||||||
char* last = buffer + m_canvas->get_width();
|
char* last = buffer + m_canvas->width();
|
||||||
|
|
||||||
// if (torrent::up_throttle() == 0)
|
// if (torrent::up_throttle() == 0)
|
||||||
// position = std::max(snprintf(buffer, 128, "off/"), 0);
|
// position = std::max(snprintf(buffer, 128, "off/"), 0);
|
||||||
@@ -96,7 +96,7 @@ WindowStatusbar::redraw() {
|
|||||||
|
|
||||||
if (last > buffer) {
|
if (last > buffer) {
|
||||||
position = print_status_extra(buffer, last, control);
|
position = print_status_extra(buffer, last, control);
|
||||||
m_canvas->print(m_canvas->get_width() - (position - buffer), 0, "%s", buffer);
|
m_canvas->print(m_canvas->width() - (position - buffer), 0, "%s", buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_lastTick = control->tick();
|
m_lastTick = control->tick();
|
||||||
|
|||||||
@@ -45,7 +45,9 @@ namespace display {
|
|||||||
|
|
||||||
class WindowStatusbar : public Window {
|
class WindowStatusbar : public Window {
|
||||||
public:
|
public:
|
||||||
WindowStatusbar() : Window(new Canvas, false, 1), m_lastTick(0) {}
|
WindowStatusbar() :
|
||||||
|
Window(new Canvas, flag_width_dynamic, 0, 1),
|
||||||
|
m_lastTick(0) {}
|
||||||
|
|
||||||
virtual void redraw();
|
virtual void redraw();
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
namespace display {
|
namespace display {
|
||||||
|
|
||||||
WindowStringList::WindowStringList() :
|
WindowStringList::WindowStringList() :
|
||||||
Window(new Canvas, true) {
|
Window(new Canvas, flag_width_dynamic | flag_height_dynamic, 0, 0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowStringList::~WindowStringList() {
|
WindowStringList::~WindowStringList() {
|
||||||
@@ -61,22 +61,22 @@ WindowStringList::redraw() {
|
|||||||
|
|
||||||
while (itr != m_last) {
|
while (itr != m_last) {
|
||||||
|
|
||||||
if (ypos == (size_t)m_canvas->get_height()) {
|
if (ypos == (size_t)m_canvas->height()) {
|
||||||
ypos = 0;
|
ypos = 0;
|
||||||
xpos += width + 2;
|
xpos += width + 2;
|
||||||
|
|
||||||
if (xpos + 20 >= (size_t)m_canvas->get_width())
|
if (xpos + 20 >= (size_t)m_canvas->width())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
width = 0;
|
width = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
width = std::max(itr->size(), width);
|
width = std::max(itr->size(), width);
|
||||||
|
|
||||||
if (xpos + itr->size() <= (size_t)m_canvas->get_width())
|
if (xpos + itr->size() <= (size_t)m_canvas->width())
|
||||||
m_canvas->print(xpos, ypos++, "%s", itr->c_str());
|
m_canvas->print(xpos, ypos++, "%s", itr->c_str());
|
||||||
else
|
else
|
||||||
m_canvas->print(xpos, ypos++, "%s", itr->substr(0, m_canvas->get_width() - xpos).c_str());
|
m_canvas->print(xpos, ypos++, "%s", itr->substr(0, m_canvas->width() - xpos).c_str());
|
||||||
|
|
||||||
++itr;
|
++itr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ WindowTitle::redraw() {
|
|||||||
m_slotSchedule(this, (cachedTime + rak::timer::from_seconds(1)).round_seconds());
|
m_slotSchedule(this, (cachedTime + rak::timer::from_seconds(1)).round_seconds());
|
||||||
m_canvas->erase();
|
m_canvas->erase();
|
||||||
|
|
||||||
m_canvas->print(std::max(0, (m_canvas->get_width() - (int)m_title.size()) / 2 - 4), 0,
|
m_canvas->print(std::max(0, (m_canvas->width() - (int)m_title.size()) / 2 - 4), 0,
|
||||||
"*** %s ***", m_title.c_str());
|
"*** %s ***", m_title.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace display {
|
|||||||
|
|
||||||
class WindowTitle : public Window {
|
class WindowTitle : public Window {
|
||||||
public:
|
public:
|
||||||
WindowTitle() : Window(new Canvas, false, 1) {}
|
WindowTitle() : Window(new Canvas, flag_width_dynamic, 0, 1) {}
|
||||||
|
|
||||||
const std::string& title() const { return m_title; }
|
const std::string& title() const { return m_title; }
|
||||||
void set_title(const std::string& title) { m_title = title; mark_dirty(); }
|
void set_title(const std::string& title) { m_title = title; mark_dirty(); }
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
namespace display {
|
namespace display {
|
||||||
|
|
||||||
WindowTrackerList::WindowTrackerList(core::Download* d, unsigned int* focus) :
|
WindowTrackerList::WindowTrackerList(core::Download* d, unsigned int* focus) :
|
||||||
Window(new Canvas, true),
|
Window(new Canvas, flag_width_dynamic | flag_height_dynamic, 0, 0),
|
||||||
m_download(d),
|
m_download(d),
|
||||||
m_focus(focus) {
|
m_focus(focus) {
|
||||||
}
|
}
|
||||||
@@ -74,24 +74,24 @@ WindowTrackerList::redraw() {
|
|||||||
|
|
||||||
typedef std::pair<unsigned int, unsigned int> Range;
|
typedef std::pair<unsigned int, unsigned int> Range;
|
||||||
|
|
||||||
Range range = rak::advance_bidirectional<unsigned int>(0, *m_focus, tl->size(), (m_canvas->get_height() + 1) / 2);
|
Range range = rak::advance_bidirectional<unsigned int>(0, *m_focus, tl->size(), (m_canvas->height() + 1) / 2);
|
||||||
|
|
||||||
while (range.first != range.second) {
|
while (range.first != range.second) {
|
||||||
torrent::Tracker t = tl->get(range.first);
|
torrent::Tracker t = tl->get(range.first);
|
||||||
|
|
||||||
m_canvas->print(0, pos++, "%c %s",
|
m_canvas->print(0, pos++, "%c %s",
|
||||||
range.first == *m_focus ? '*' : ' ',
|
range.first == *m_focus ? '*' : ' ',
|
||||||
t.url().c_str());
|
t.url().c_str());
|
||||||
|
|
||||||
m_canvas->print(0, pos++, "%c Group: %2i Id: %s Focus: %s Enabled: %s Open: %s S/L: %u/%u",
|
m_canvas->print(0, pos++, "%c Group: %2i Id: %s Focus: %s Enabled: %s Open: %s S/L: %u/%u",
|
||||||
range.first == *m_focus ? '*' : ' ',
|
range.first == *m_focus ? '*' : ' ',
|
||||||
t.group(),
|
t.group(),
|
||||||
rak::copy_escape_html(t.tracker_id()).c_str(),
|
rak::copy_escape_html(t.tracker_id()).c_str(),
|
||||||
range.first == tl->focus() ? "yes" : " no",
|
range.first == tl->focus() ? "yes" : " no",
|
||||||
t.is_enabled() ? "yes" : " no",
|
t.is_enabled() ? "yes" : " no",
|
||||||
t.is_open() ? "yes" : " no",
|
t.is_open() ? "yes" : " no",
|
||||||
t.scrape_complete(),
|
t.scrape_complete(),
|
||||||
t.scrape_incomplete());
|
t.scrape_incomplete());
|
||||||
|
|
||||||
++range.first;
|
++range.first;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace input {
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
Bindings::pressed(int key) {
|
Bindings::pressed(int key) {
|
||||||
if (!m_active)
|
if (!m_enabled)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const_iterator itr = find(key);
|
const_iterator itr = find(key);
|
||||||
|
|||||||
@@ -63,17 +63,17 @@ public:
|
|||||||
|
|
||||||
using Base::operator[];
|
using Base::operator[];
|
||||||
|
|
||||||
Bindings() : m_active(true) {}
|
Bindings() : m_enabled(true) {}
|
||||||
|
|
||||||
void activate() { m_active = true; }
|
void enable() { m_enabled = true; }
|
||||||
void disable() { m_active = false; }
|
void disable() { m_enabled = false; }
|
||||||
|
|
||||||
bool pressed(int key);
|
bool pressed(int key);
|
||||||
|
|
||||||
void ignore(int key) { (*this)[key] = Slot(); }
|
void ignore(int key) { (*this)[key] = Slot(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_active;
|
bool m_enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ PathInput::PathInput() :
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
PathInput::pressed(int key) {
|
PathInput::pressed(int key) {
|
||||||
|
// Consider binding tab in m_bindings instead.
|
||||||
|
|
||||||
if (key != '\t') {
|
if (key != '\t') {
|
||||||
m_showNext = false;
|
m_showNext = false;
|
||||||
return TextInput::pressed(key);
|
return TextInput::pressed(key);
|
||||||
|
|||||||
@@ -44,7 +44,10 @@ namespace input {
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
TextInput::pressed(int key) {
|
TextInput::pressed(int key) {
|
||||||
if (m_alt) {
|
if (m_bindings.pressed(key)) {
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} else if (m_alt) {
|
||||||
m_alt = false;
|
m_alt = false;
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
@@ -123,7 +126,6 @@ TextInput::pressed(int key) {
|
|||||||
m_slotDirty();
|
m_slotDirty();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,8 @@
|
|||||||
#define RTORRENT_INPUT_TEXT_INPUT_H
|
#define RTORRENT_INPUT_TEXT_INPUT_H
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sigc++/slot.h>
|
|
||||||
|
#include "bindings.h"
|
||||||
|
|
||||||
namespace input {
|
namespace input {
|
||||||
|
|
||||||
@@ -68,11 +69,15 @@ public:
|
|||||||
|
|
||||||
std::string& str() { return *this; }
|
std::string& str() { return *this; }
|
||||||
|
|
||||||
|
Bindings& bindings() { return m_bindings; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_type m_pos;
|
size_type m_pos;
|
||||||
|
|
||||||
bool m_alt;
|
bool m_alt;
|
||||||
SlotDirty m_slotDirty;
|
SlotDirty m_slotDirty;
|
||||||
|
|
||||||
|
Bindings m_bindings;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+50
-29
@@ -117,11 +117,7 @@ DownloadList::disable() {
|
|||||||
if (!is_active())
|
if (!is_active())
|
||||||
throw std::logic_error("ui::DownloadList::disable() called on an already disabled object");
|
throw std::logic_error("ui::DownloadList::disable() called on an already disabled object");
|
||||||
|
|
||||||
// if (m_windowTextInput->is_active()) {
|
receive_exit_input(INPUT_NONE);
|
||||||
// m_windowTextInput->get_input()->clear();
|
|
||||||
// receive_exit_input(INPUT_NONE);
|
|
||||||
// }
|
|
||||||
|
|
||||||
activate_display(DISPLAY_NONE);
|
activate_display(DISPLAY_NONE);
|
||||||
|
|
||||||
m_frame = NULL;
|
m_frame = NULL;
|
||||||
@@ -133,10 +129,10 @@ DownloadList::disable() {
|
|||||||
void
|
void
|
||||||
DownloadList::activate_display(Display displayType) {
|
DownloadList::activate_display(Display displayType) {
|
||||||
if (!is_active())
|
if (!is_active())
|
||||||
throw std::logic_error("ui::DownloadList::activate_display(...) !is_active().");
|
throw torrent::client_error("ui::DownloadList::activate_display(...) !is_active().");
|
||||||
|
|
||||||
if (displayType >= DISPLAY_MAX_SIZE)
|
if (displayType >= DISPLAY_MAX_SIZE)
|
||||||
throw std::logic_error("ui::DownloadList::activate_display(...) out of bounds");
|
throw torrent::client_error("ui::DownloadList::activate_display(...) out of bounds");
|
||||||
|
|
||||||
if (displayType == m_state)
|
if (displayType == m_state)
|
||||||
return;
|
return;
|
||||||
@@ -146,6 +142,11 @@ DownloadList::activate_display(Display displayType) {
|
|||||||
// Cleanup previous state.
|
// Cleanup previous state.
|
||||||
switch (m_state) {
|
switch (m_state) {
|
||||||
case DISPLAY_DOWNLOAD_LIST:
|
case DISPLAY_DOWNLOAD_LIST:
|
||||||
|
m_uiArray[DISPLAY_DOWNLOAD_LIST]->disable();
|
||||||
|
m_uiArray[DISPLAY_LOG]->disable();
|
||||||
|
m_frame->clear();
|
||||||
|
break;
|
||||||
|
|
||||||
case DISPLAY_LOG:
|
case DISPLAY_LOG:
|
||||||
m_uiArray[m_state]->disable();
|
m_uiArray[m_state]->disable();
|
||||||
break;
|
break;
|
||||||
@@ -162,14 +163,13 @@ DownloadList::activate_display(Display displayType) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case DISPLAY_DOWNLOAD_LIST:
|
case DISPLAY_DOWNLOAD_LIST:
|
||||||
control->ui()->window_title()->set_title("rTorrent " VERSION " - libTorrent " + std::string(torrent::version()));
|
m_frame->initialize_column(2);
|
||||||
|
|
||||||
m_uiArray[displayType]->activate(m_frame);
|
m_uiArray[DISPLAY_DOWNLOAD_LIST]->activate(m_frame->frame(0));
|
||||||
|
m_uiArray[DISPLAY_LOG]->activate(m_frame->frame(1));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DISPLAY_LOG:
|
case DISPLAY_LOG:
|
||||||
control->ui()->window_title()->set_title("Log");
|
|
||||||
|
|
||||||
m_uiArray[displayType]->activate(m_frame);
|
m_uiArray[displayType]->activate(m_frame);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -177,6 +177,13 @@ DownloadList::activate_display(Display displayType) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set title.
|
||||||
|
switch (displayType) {
|
||||||
|
case DISPLAY_DOWNLOAD_LIST: control->ui()->window_title()->set_title("rTorrent " VERSION " - libTorrent " + std::string(torrent::version())); break;
|
||||||
|
case DISPLAY_LOG: control->ui()->window_title()->set_title("Log"); break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
control->display()->adjust_layout();
|
control->display()->adjust_layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,8 +231,10 @@ DownloadList::receive_close_download() {
|
|||||||
if (m_view->focus() == m_view->end_visible())
|
if (m_view->focus() == m_view->end_visible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
control->core()->download_list()->stop_normal(*m_view->focus());
|
core::Download* download = *m_view->focus();
|
||||||
control->core()->download_list()->close(*m_view->focus());
|
|
||||||
|
control->core()->download_list()->stop_normal(download);
|
||||||
|
control->core()->download_list()->close(download);
|
||||||
m_view->set_last_changed();
|
m_view->set_last_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,23 +332,39 @@ DownloadList::receive_view_input(Input type) {
|
|||||||
|
|
||||||
input::PathInput* input = new input::PathInput;
|
input::PathInput* input = new input::PathInput;
|
||||||
|
|
||||||
|
const char* title;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
case INPUT_LOAD_DEFAULT:
|
||||||
|
title = "load_start";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case INPUT_LOAD_MODIFIED:
|
||||||
|
title = "load";
|
||||||
|
break;
|
||||||
|
|
||||||
case INPUT_CHANGE_DIRECTORY:
|
case INPUT_CHANGE_DIRECTORY:
|
||||||
|
title = "change_directory";
|
||||||
|
|
||||||
input->str() = control->variable()->get_string("directory");
|
input->str() = control->variable()->get_string("directory");
|
||||||
input->set_pos(input->str().length());
|
input->set_pos(input->str().length());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
case INPUT_COMMAND:
|
||||||
|
title = "command";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw torrent::client_error("DownloadList::receive_view_input(...) Invalid input type.");
|
||||||
}
|
}
|
||||||
|
|
||||||
control->ui()->enable_input(input);
|
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);
|
||||||
|
|
||||||
// These bindings should be moved to f.ex TextInput?
|
m_bindings.disable();
|
||||||
m_bindings['\n'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_exit_input), type);
|
control->ui()->enable_input(title, input);
|
||||||
m_bindings[KEY_ENTER] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_exit_input), type);
|
|
||||||
m_bindings['\x07'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_exit_input), INPUT_NONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -351,14 +376,7 @@ DownloadList::receive_exit_input(Input type) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
control->ui()->disable_input();
|
control->ui()->disable_input();
|
||||||
|
m_bindings.enable();
|
||||||
// Urgh... this is ugly...
|
|
||||||
m_bindings.erase('\n');
|
|
||||||
m_bindings.erase(KEY_ENTER);
|
|
||||||
m_bindings.erase('\x07');
|
|
||||||
|
|
||||||
m_bindings['\n'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_view_input), INPUT_LOAD_MODIFIED);
|
|
||||||
m_bindings[KEY_ENTER] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_view_input), INPUT_LOAD_MODIFIED);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@@ -382,6 +400,9 @@ DownloadList::receive_exit_input(Input type) {
|
|||||||
case INPUT_COMMAND:
|
case INPUT_COMMAND:
|
||||||
control->variable()->process_command(input->str());
|
control->variable()->process_command(input->str());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw torrent::client_error("DownloadList::receive_exit_input(...) Invalid input type.");
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (torrent::input_error& e) {
|
} catch (torrent::input_error& e) {
|
||||||
@@ -460,8 +481,8 @@ DownloadList::setup_keys() {
|
|||||||
m_bindings['6'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "incomplete");
|
m_bindings['6'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "incomplete");
|
||||||
m_bindings['7'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "hashing");
|
m_bindings['7'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "hashing");
|
||||||
|
|
||||||
m_uiArray[DISPLAY_LOG]->bindings()[' '] = sigc::bind(sigc::mem_fun(*this, &DownloadList::activate_display), DISPLAY_DOWNLOAD_LIST);
|
m_uiArray[DISPLAY_LOG]->bindings()[' '] = sigc::bind(sigc::mem_fun(*this, &DownloadList::activate_display), DISPLAY_DOWNLOAD_LIST);
|
||||||
m_uiArray[DISPLAY_LOG]->bindings()[KEY_RIGHT] = sigc::bind(sigc::mem_fun(*this, &DownloadList::activate_display), DISPLAY_DOWNLOAD_LIST);
|
m_uiArray[DISPLAY_LOG]->bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(*this, &DownloadList::activate_display), DISPLAY_DOWNLOAD_LIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
// void
|
// void
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ ElementChunksSeen::receive_pagenext() {
|
|||||||
if (m_window == NULL)
|
if (m_window == NULL)
|
||||||
throw torrent::client_error("ui::ElementChunksSeen::receive_pagenext(...) called on a disabled object");
|
throw torrent::client_error("ui::ElementChunksSeen::receive_pagenext(...) called on a disabled object");
|
||||||
|
|
||||||
unsigned int visible = m_window->get_height() - 1;
|
unsigned int visible = m_window->height() - 1;
|
||||||
unsigned int scrollable = std::max<int>(m_window->rows() - visible, 0);
|
unsigned int scrollable = std::max<int>(m_window->rows() - visible, 0);
|
||||||
|
|
||||||
if (scrollable == 0 || m_focus == scrollable)
|
if (scrollable == 0 || m_focus == scrollable)
|
||||||
@@ -146,7 +146,7 @@ ElementChunksSeen::receive_pageprev() {
|
|||||||
if (m_window == NULL)
|
if (m_window == NULL)
|
||||||
throw torrent::client_error("ui::ElementChunksSeen::receive_pageprev(...) called on a disabled object");
|
throw torrent::client_error("ui::ElementChunksSeen::receive_pageprev(...) called on a disabled object");
|
||||||
|
|
||||||
unsigned int visible = m_window->get_height() - 1;
|
unsigned int visible = m_window->height() - 1;
|
||||||
unsigned int scrollable = std::max<int>(m_window->rows() - visible, 0);
|
unsigned int scrollable = std::max<int>(m_window->rows() - visible, 0);
|
||||||
|
|
||||||
if (m_focus > visible / 2)
|
if (m_focus > visible / 2)
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ ElementDownloadList::activate(display::Frame* frame) {
|
|||||||
control->input()->push_front(&m_bindings);
|
control->input()->push_front(&m_bindings);
|
||||||
|
|
||||||
m_window = new WDownloadList();
|
m_window = new WDownloadList();
|
||||||
|
m_window->set_active(true);
|
||||||
m_window->set_view(m_view);
|
m_window->set_view(m_view);
|
||||||
|
|
||||||
m_frame = frame;
|
m_frame = frame;
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ ElementFileList::receive_pagenext() {
|
|||||||
if (m_window == NULL)
|
if (m_window == NULL)
|
||||||
throw torrent::client_error("ui::ElementFileList::receive_pagenext(...) called on a disabled object");
|
throw torrent::client_error("ui::ElementFileList::receive_pagenext(...) called on a disabled object");
|
||||||
|
|
||||||
unsigned int count = (m_window->get_height() - 1) / 2;
|
unsigned int count = (m_window->height() - 1) / 2;
|
||||||
|
|
||||||
if (m_focus + count < m_download->download()->file_list().size())
|
if (m_focus + count < m_download->download()->file_list().size())
|
||||||
m_focus += count;
|
m_focus += count;
|
||||||
@@ -143,7 +143,7 @@ ElementFileList::receive_pageprev() {
|
|||||||
if (fl.size() == 0)
|
if (fl.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
unsigned int count = (m_window->get_height() - 1) / 2;
|
unsigned int count = (m_window->height() - 1) / 2;
|
||||||
|
|
||||||
if (m_focus > count)
|
if (m_focus > count)
|
||||||
m_focus -= count;
|
m_focus -= count;
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ ElementLogComplete::activate(display::Frame* frame) {
|
|||||||
control->input()->push_front(&m_bindings);
|
control->input()->push_front(&m_bindings);
|
||||||
|
|
||||||
m_window = new WLogComplete(m_log);
|
m_window = new WLogComplete(m_log);
|
||||||
|
m_window->set_active(true);
|
||||||
|
|
||||||
m_frame = frame;
|
m_frame = frame;
|
||||||
m_frame->initialize_window(m_window);
|
m_frame->initialize_window(m_window);
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ ElementTransferList::receive_pagenext() {
|
|||||||
// if (m_window == NULL)
|
// if (m_window == NULL)
|
||||||
// throw torrent::client_error("ui::ElementTransferList::receive_pagenext(...) called on a disabled object");
|
// throw torrent::client_error("ui::ElementTransferList::receive_pagenext(...) called on a disabled object");
|
||||||
|
|
||||||
// unsigned int visible = m_window->get_height() - 1;
|
// unsigned int visible = m_window->height() - 1;
|
||||||
// unsigned int scrollable = std::max<int>(m_window->rows() - visible, 0);
|
// unsigned int scrollable = std::max<int>(m_window->rows() - visible, 0);
|
||||||
|
|
||||||
// if (scrollable == 0 || m_focus == scrollable)
|
// if (scrollable == 0 || m_focus == scrollable)
|
||||||
@@ -146,7 +146,7 @@ ElementTransferList::receive_pageprev() {
|
|||||||
// if (m_window == NULL)
|
// if (m_window == NULL)
|
||||||
// throw torrent::client_error("ui::ElementTransferList::receive_pageprev(...) called on a disabled object");
|
// throw torrent::client_error("ui::ElementTransferList::receive_pageprev(...) called on a disabled object");
|
||||||
|
|
||||||
// unsigned int visible = m_window->get_height() - 1;
|
// unsigned int visible = m_window->height() - 1;
|
||||||
// unsigned int scrollable = std::max<int>(m_window->rows() - visible, 0);
|
// unsigned int scrollable = std::max<int>(m_window->rows() - visible, 0);
|
||||||
|
|
||||||
// if (m_focus > visible / 2)
|
// if (m_focus > visible / 2)
|
||||||
|
|||||||
+6
-7
@@ -83,16 +83,14 @@ Root::init(Control* c) {
|
|||||||
|
|
||||||
display::Frame* rootFrame = m_control->display()->root_frame();
|
display::Frame* rootFrame = m_control->display()->root_frame();
|
||||||
|
|
||||||
rootFrame->initialize_container(display::Frame::TYPE_ROW, 5);
|
rootFrame->initialize_row(5);
|
||||||
rootFrame->frame(0)->initialize_window(m_windowTitle);
|
rootFrame->frame(0)->initialize_window(m_windowTitle);
|
||||||
rootFrame->frame(2)->initialize_window(m_windowHttpQueue);
|
rootFrame->frame(2)->initialize_window(m_windowHttpQueue);
|
||||||
rootFrame->frame(3)->initialize_window(m_windowInput);
|
rootFrame->frame(3)->initialize_window(m_windowInput);
|
||||||
rootFrame->frame(4)->initialize_window(m_windowStatusbar);
|
rootFrame->frame(4)->initialize_window(m_windowStatusbar);
|
||||||
|
|
||||||
m_control->display()->schedule(m_windowTitle, cachedTime);
|
m_windowTitle->set_active(true);
|
||||||
m_control->display()->schedule(m_windowStatusbar, cachedTime);
|
m_windowStatusbar->set_active(true);
|
||||||
|
|
||||||
m_windowInput->set_active(false);
|
|
||||||
|
|
||||||
setup_keys();
|
setup_keys();
|
||||||
|
|
||||||
@@ -187,7 +185,7 @@ Root::adjust_up_throttle(int throttle) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Root::enable_input(input::TextInput* input) {
|
Root::enable_input(const std::string& title, input::TextInput* input) {
|
||||||
if (m_windowInput->input() != NULL)
|
if (m_windowInput->input() != NULL)
|
||||||
throw torrent::client_error("Root::enable_input(...) m_windowInput->input() != NULL.");
|
throw torrent::client_error("Root::enable_input(...) m_windowInput->input() != NULL.");
|
||||||
|
|
||||||
@@ -196,8 +194,9 @@ Root::enable_input(input::TextInput* input) {
|
|||||||
m_windowStatusbar->set_active(false);
|
m_windowStatusbar->set_active(false);
|
||||||
|
|
||||||
m_windowInput->set_active(true);
|
m_windowInput->set_active(true);
|
||||||
m_windowInput->set_focus(true);
|
|
||||||
m_windowInput->set_input(input);
|
m_windowInput->set_input(input);
|
||||||
|
m_windowInput->set_title(title);
|
||||||
|
m_windowInput->set_focus(true);
|
||||||
|
|
||||||
control->input()->set_text_input(input);
|
control->input()->set_text_input(input);
|
||||||
control->display()->adjust_layout();
|
control->display()->adjust_layout();
|
||||||
|
|||||||
+1
-1
@@ -84,7 +84,7 @@ public:
|
|||||||
void adjust_down_throttle(int throttle);
|
void adjust_down_throttle(int throttle);
|
||||||
void adjust_up_throttle(int throttle);
|
void adjust_up_throttle(int throttle);
|
||||||
|
|
||||||
void enable_input(input::TextInput* input);
|
void enable_input(const std::string& title, input::TextInput* input);
|
||||||
void disable_input();
|
void disable_input();
|
||||||
|
|
||||||
input::TextInput* current_input();
|
input::TextInput* current_input();
|
||||||
|
|||||||
Reference in New Issue
Block a user