mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-07 14:49:21 +00:00
* Moved handling of events from DownloadList into ElementDownloadList
and WindowLog. * Added bindings to input::TextInput and disabled other bindings while it is active. * ^K now sets ignore_commands. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@750 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -71,9 +71,9 @@ public:
|
||||
static void erase_std() { werase(stdscr); }
|
||||
|
||||
void print_border(chtype ls, chtype rs,
|
||||
chtype ts, chtype bs,
|
||||
chtype tl, chtype tr,
|
||||
chtype bl, chtype br) { wborder(m_window, ls, rs, ts, bs, tl, tr, bl, br); }
|
||||
chtype ts, chtype bs,
|
||||
chtype tl, chtype tr,
|
||||
chtype bl, chtype br) { wborder(m_window, ls, rs, ts, bs, tl, tr, bl, br); }
|
||||
|
||||
// The format string is non-const, but that will not be a problem
|
||||
// since the string shall always be a C string choosen at
|
||||
@@ -89,27 +89,27 @@ public:
|
||||
|
||||
template <typename A1, typename A2, typename A3>
|
||||
void print(int x, int y, char* str,
|
||||
A1 a1, A2 a2, A3 a3) { mvwprintw(m_window, y, x, str, a1, a2, a3); }
|
||||
A1 a1, A2 a2, A3 a3) { mvwprintw(m_window, y, x, str, a1, a2, a3); }
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4>
|
||||
void print(int x, int y, char* str,
|
||||
A1 a1, A2 a2, A3 a3, A4 a4) { mvwprintw(m_window, y, x, str, a1, a2, a3, a4); }
|
||||
A1 a1, A2 a2, A3 a3, A4 a4) { mvwprintw(m_window, y, x, str, a1, a2, a3, a4); }
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4, typename A5>
|
||||
void print(int x, int y, char* str,
|
||||
A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) { mvwprintw(m_window, y, x, str, a1, a2, a3, a4, a5); }
|
||||
A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) { mvwprintw(m_window, y, x, str, a1, a2, a3, a4, a5); }
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
|
||||
void print(int x, int y, char* str,
|
||||
A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) { mvwprintw(m_window, y, x, str, a1, a2, a3, a4, a5, a6); }
|
||||
A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) { mvwprintw(m_window, y, x, str, a1, a2, a3, a4, a5, a6); }
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7>
|
||||
void print(int x, int y, char* str,
|
||||
A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) { mvwprintw(m_window, y, x, str, a1, a2, a3, a4, a5, a6, a7); }
|
||||
A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) { mvwprintw(m_window, y, x, str, a1, a2, a3, a4, a5, a6, a7); }
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8>
|
||||
void print(int x, int y, char* str,
|
||||
A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) { mvwprintw(m_window, y, x, str, a1, a2, a3, a4, a5, a6, a7, a8); }
|
||||
A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) { mvwprintw(m_window, y, x, str, a1, a2, a3, a4, a5, a6, a7, a8); }
|
||||
|
||||
void print_char(const chtype ch) { waddch(m_window, ch); }
|
||||
|
||||
|
||||
@@ -221,6 +221,27 @@ Frame::refresh() {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Frame::redraw() {
|
||||
switch (m_type) {
|
||||
case TYPE_NONE:
|
||||
break;
|
||||
|
||||
case TYPE_WINDOW:
|
||||
if (m_window->is_active() && !m_window->is_offscreen())
|
||||
m_window->redraw();
|
||||
|
||||
break;
|
||||
|
||||
case TYPE_ROW:
|
||||
case TYPE_COLUMN:
|
||||
for (Frame **itr = m_container, **last = m_container + m_containerSize; itr != last; ++itr)
|
||||
(*itr)->redraw();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Frame::balance(uint32_t x, uint32_t y, uint32_t width, uint32_t height) {
|
||||
m_positionX = x;
|
||||
@@ -289,6 +310,10 @@ Frame::balance(uint32_t x, uint32_t y, uint32_t width, uint32_t height) {
|
||||
(*itr)->m_width = s;
|
||||
}
|
||||
|
||||
// Use the pre-calculated frame sizes to balance the sub-frames. If
|
||||
// the frame is too small, it will set the remaining windows to zero
|
||||
// extent which will flag them as offscreen.
|
||||
|
||||
for (Frame **itr = m_container, **last = m_container + m_containerSize; itr != last; ++itr) {
|
||||
if (m_type == TYPE_ROW) {
|
||||
(*itr)->balance(x, y, m_width, std::min((*itr)->m_height, height));
|
||||
|
||||
@@ -87,6 +87,8 @@ public:
|
||||
void clear();
|
||||
|
||||
void refresh();
|
||||
void redraw();
|
||||
|
||||
void balance(uint32_t x, uint32_t y, uint32_t width, uint32_t height);
|
||||
|
||||
private:
|
||||
|
||||
@@ -87,7 +87,9 @@ Manager::receive_update() {
|
||||
|
||||
display::Canvas::resize_term(display::Canvas::term_size());
|
||||
Canvas::redraw_std();
|
||||
|
||||
adjust_layout();
|
||||
m_rootFrame.redraw();
|
||||
}
|
||||
|
||||
Canvas::refresh_std();
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
void set_title(const std::string& str) { m_title = str; }
|
||||
|
||||
bool focus() const { return m_focus; }
|
||||
void set_focus(bool f) { mark_dirty(); m_focus = f; }
|
||||
void set_focus(bool f) { m_focus = f; if (is_active()) mark_dirty(); }
|
||||
|
||||
virtual void redraw();
|
||||
|
||||
|
||||
@@ -48,11 +48,14 @@ WindowLog::WindowLog(core::Log* l) :
|
||||
Window(new Canvas, flag_width_dynamic, 0, 0),
|
||||
m_log(l) {
|
||||
|
||||
m_taskUpdate.set_slot(rak::mem_fn(this, &WindowLog::receive_update)),
|
||||
|
||||
// We're trying out scheduled tasks instead.
|
||||
m_connUpdate = l->signal_update().connect(sigc::mem_fun(*this, &WindowLog::receive_update));
|
||||
}
|
||||
|
||||
WindowLog::~WindowLog() {
|
||||
priority_queue_erase(&taskScheduler, &m_taskUpdate);
|
||||
m_connUpdate.disconnect();
|
||||
}
|
||||
|
||||
@@ -75,19 +78,28 @@ WindowLog::redraw() {
|
||||
}
|
||||
}
|
||||
|
||||
// When WindowLog is activated, call receive_update() to ensure it
|
||||
// gets updated.
|
||||
void
|
||||
WindowLog::receive_update() {
|
||||
if (!is_active())
|
||||
return;
|
||||
|
||||
iterator itr = find_older();
|
||||
extent_type h = std::min(std::distance(m_log->begin(), itr), (std::iterator_traits<iterator>::difference_type)10);
|
||||
|
||||
if (h != m_minHeight) {
|
||||
set_active(h != 0);
|
||||
|
||||
m_minHeight = h;
|
||||
m_slotAdjust();
|
||||
|
||||
} else {
|
||||
mark_dirty();
|
||||
}
|
||||
|
||||
mark_dirty();
|
||||
priority_queue_erase(&taskScheduler, &m_taskUpdate);
|
||||
|
||||
if (h != 0)
|
||||
priority_queue_insert(&taskScheduler, &m_taskUpdate, (cachedTime + rak::timer::from_seconds(30)).round_seconds());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,15 +52,17 @@ public:
|
||||
WindowLog(core::Log* l);
|
||||
~WindowLog();
|
||||
|
||||
virtual void redraw();
|
||||
virtual void redraw();
|
||||
|
||||
void receive_update();
|
||||
void receive_update();
|
||||
|
||||
private:
|
||||
inline iterator find_older();
|
||||
inline iterator find_older();
|
||||
|
||||
core::Log* m_log;
|
||||
sigc::connection m_connUpdate;
|
||||
core::Log* m_log;
|
||||
sigc::connection m_connUpdate;
|
||||
|
||||
rak::priority_item m_taskUpdate;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user