mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-07 06:39:23 +00:00
* Use varargs in Canvas::print.
* Added min/max size to display::Window. Added flags for windows that should be on located at the left/bottom side of a Frame. * Reversed print order in WindowLog*. * Added display::TextElement and subclasses for flexible printing to a char buffer with associated attributes. Added display::Attributes and display::Canvas::print_attributes. * Added display::WindowText for use with display::TextElement's. * Added ui::ElementMenu for generic menus, and started work adding this to ui::Download. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@751 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -14,6 +14,8 @@ libsub_ui_a_SOURCES = \
|
||||
element_file_list.h \
|
||||
element_log_complete.cc \
|
||||
element_log_complete.h \
|
||||
element_menu.cc \
|
||||
element_menu.h \
|
||||
element_peer_info.cc \
|
||||
element_peer_info.h \
|
||||
element_peer_list.cc \
|
||||
|
||||
+59
-43
@@ -51,6 +51,7 @@
|
||||
#include "download.h"
|
||||
#include "root.h"
|
||||
#include "element_file_list.h"
|
||||
#include "element_menu.h"
|
||||
#include "element_peer_info.h"
|
||||
#include "element_peer_list.h"
|
||||
#include "element_tracker_list.h"
|
||||
@@ -62,11 +63,25 @@ namespace ui {
|
||||
Download::Download(DPtr d) :
|
||||
m_download(d),
|
||||
m_state(DISPLAY_MAX_SIZE),
|
||||
|
||||
m_windowDownloadStatus(new WDownloadStatus(d)) {
|
||||
m_focusDisplay(false) {
|
||||
|
||||
m_focus = m_peers.end();
|
||||
|
||||
m_windowDownloadStatus = new WDownloadStatus(d);
|
||||
m_windowDownloadStatus->set_bottom(true);
|
||||
|
||||
ElementMenu* elementMenu = new ElementMenu;
|
||||
|
||||
elementMenu->push_back("Peer List", sigc::bind(sigc::mem_fun(this, &Download::activate_display_focus), DISPLAY_PEER_LIST));
|
||||
// elementMenu->push_back("Peer Info", sigc::bind(sigc::mem_fun(this, &Download::activate_display_focus), DISPLAY_PEER_INFO));
|
||||
elementMenu->push_back("File List", sigc::bind(sigc::mem_fun(this, &Download::activate_display_focus), DISPLAY_FILE_LIST));
|
||||
elementMenu->push_back("Tracker List", sigc::bind(sigc::mem_fun(this, &Download::activate_display_focus), DISPLAY_TRACKER_LIST));
|
||||
elementMenu->push_back("Chunks Seen", sigc::bind(sigc::mem_fun(this, &Download::activate_display_focus), DISPLAY_CHUNKS_SEEN));
|
||||
elementMenu->push_back("Transfer List", sigc::bind(sigc::mem_fun(this, &Download::activate_display_focus), DISPLAY_TRANSFER_LIST));
|
||||
|
||||
elementMenu->focus_next();
|
||||
|
||||
m_uiArray[DISPLAY_MENU] = elementMenu;
|
||||
m_uiArray[DISPLAY_PEER_LIST] = new ElementPeerList(d, &m_peers, &m_focus);
|
||||
m_uiArray[DISPLAY_PEER_INFO] = new ElementPeerInfo(d, &m_peers, &m_focus);
|
||||
m_uiArray[DISPLAY_FILE_LIST] = new ElementFileList(d);
|
||||
@@ -95,14 +110,19 @@ Download::~Download() {
|
||||
}
|
||||
|
||||
void
|
||||
Download::activate(display::Frame* frame) {
|
||||
Download::activate(display::Frame* frame, bool focus) {
|
||||
if (is_active())
|
||||
throw torrent::client_error("ui::Download::activate() called on an already activated object.");
|
||||
|
||||
control->input()->push_back(&m_bindings);
|
||||
|
||||
m_frame = frame;
|
||||
activate_display(DISPLAY_PEER_LIST);
|
||||
m_frame->initialize_row(2);
|
||||
|
||||
m_frame->frame(1)->initialize_window(m_windowDownloadStatus);
|
||||
m_windowDownloadStatus->set_active(true);
|
||||
|
||||
activate_display_menu(DISPLAY_PEER_LIST);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -112,35 +132,42 @@ Download::disable() {
|
||||
|
||||
control->input()->erase(&m_bindings);
|
||||
|
||||
activate_display(DISPLAY_MAX_SIZE);
|
||||
activate_display_focus(DISPLAY_MAX_SIZE);
|
||||
|
||||
m_windowDownloadStatus->set_active(false);
|
||||
m_frame->clear();
|
||||
|
||||
m_frame = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
Download::activate_display(Display displayType) {
|
||||
Download::activate_display(Display displayType, bool focusDisplay) {
|
||||
if (!is_active())
|
||||
throw torrent::client_error("ui::Download::activate_display(...) !is_active().");
|
||||
|
||||
if (displayType > DISPLAY_MAX_SIZE)
|
||||
throw torrent::client_error("ui::Download::activate_display(...) out of bounds");
|
||||
|
||||
if (displayType == m_state)
|
||||
if (focusDisplay == m_focusDisplay && displayType == m_state)
|
||||
return;
|
||||
|
||||
display::Frame* frame = m_frame->frame(0);
|
||||
|
||||
// Cleanup previous state.
|
||||
switch (m_state) {
|
||||
case DISPLAY_MENU:
|
||||
break;
|
||||
|
||||
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[DISPLAY_MENU]->disable();
|
||||
m_uiArray[m_state]->disable();
|
||||
|
||||
m_windowDownloadStatus->set_active(false);
|
||||
m_frame->frame(1)->clear();
|
||||
|
||||
m_frame->clear();
|
||||
frame->clear();
|
||||
break;
|
||||
|
||||
case DISPLAY_MAX_SIZE:
|
||||
@@ -148,21 +175,23 @@ Download::activate_display(Display displayType) {
|
||||
}
|
||||
|
||||
m_state = displayType;
|
||||
m_focusDisplay = focusDisplay;
|
||||
|
||||
// Initialize new state.
|
||||
switch (displayType) {
|
||||
case DISPLAY_MENU:
|
||||
break;
|
||||
|
||||
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);
|
||||
frame->initialize_column(2);
|
||||
|
||||
m_uiArray[displayType]->activate(m_frame->frame(0));
|
||||
|
||||
m_frame->frame(1)->initialize_window(m_windowDownloadStatus);
|
||||
m_windowDownloadStatus->set_active(true);
|
||||
m_uiArray[DISPLAY_MENU]->activate(frame->frame(0), !focusDisplay);
|
||||
m_uiArray[displayType]->activate(frame->frame(1), focusDisplay);
|
||||
break;
|
||||
|
||||
case DISPLAY_MAX_SIZE:
|
||||
@@ -185,7 +214,7 @@ Download::receive_next() {
|
||||
else
|
||||
m_focus = m_peers.begin();
|
||||
|
||||
mark_dirty();
|
||||
// mark_dirty();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -195,7 +224,7 @@ Download::receive_prev() {
|
||||
else
|
||||
m_focus = m_peers.end();
|
||||
|
||||
mark_dirty();
|
||||
// mark_dirty();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -205,7 +234,7 @@ Download::receive_disconnect_peer() {
|
||||
|
||||
m_download->download()->disconnect_peer(*m_focus);
|
||||
|
||||
mark_dirty();
|
||||
// mark_dirty();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -247,14 +276,6 @@ Download::receive_max_peers(int t) {
|
||||
m_download->download()->set_peers_max(std::max(m_download->download()->peers_max() + t, (uint32_t)5));
|
||||
}
|
||||
|
||||
void
|
||||
Download::receive_change(Display d) {
|
||||
if (d == m_state)
|
||||
return;
|
||||
|
||||
activate_display(d);
|
||||
}
|
||||
|
||||
void
|
||||
Download::receive_snub_peer() {
|
||||
if (m_focus == m_peers.end())
|
||||
@@ -262,7 +283,7 @@ Download::receive_snub_peer() {
|
||||
|
||||
m_focus->set_snubbed(!m_focus->is_snubbed());
|
||||
|
||||
mark_dirty();
|
||||
// mark_dirty();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -291,30 +312,25 @@ Download::bind_keys() {
|
||||
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::activate_display_focus), DISPLAY_PEER_INFO);
|
||||
m_bindings['o'] = sigc::bind(sigc::mem_fun(this, &Download::activate_display_focus), DISPLAY_TRACKER_LIST);
|
||||
m_bindings['i'] = sigc::bind(sigc::mem_fun(this, &Download::activate_display_focus), DISPLAY_CHUNKS_SEEN);
|
||||
m_bindings['u'] = sigc::bind(sigc::mem_fun(this, &Download::activate_display_focus), 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);
|
||||
|
||||
// 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);
|
||||
m_uiArray[DISPLAY_PEER_INFO]->bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_PEER_LIST);
|
||||
m_uiArray[DISPLAY_FILE_LIST]->bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_PEER_LIST);
|
||||
m_uiArray[DISPLAY_TRACKER_LIST]->bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_PEER_LIST);
|
||||
m_uiArray[DISPLAY_CHUNKS_SEEN]->bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_PEER_LIST);
|
||||
m_uiArray[DISPLAY_TRANSFER_LIST]->bindings()[KEY_LEFT]= sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_PEER_LIST);
|
||||
m_uiArray[DISPLAY_PEER_LIST]->bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(this, &Download::activate_display_focus), DISPLAY_MENU);
|
||||
m_uiArray[DISPLAY_PEER_INFO]->bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(this, &Download::activate_display_focus), DISPLAY_MENU);
|
||||
m_uiArray[DISPLAY_FILE_LIST]->bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(this, &Download::activate_display_focus), DISPLAY_MENU);
|
||||
m_uiArray[DISPLAY_TRACKER_LIST]->bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(this, &Download::activate_display_focus), DISPLAY_MENU);
|
||||
m_uiArray[DISPLAY_CHUNKS_SEEN]->bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(this, &Download::activate_display_focus), DISPLAY_MENU);
|
||||
m_uiArray[DISPLAY_TRANSFER_LIST]->bindings()[KEY_LEFT]= sigc::bind(sigc::mem_fun(this, &Download::activate_display_focus), DISPLAY_MENU);
|
||||
|
||||
// Doesn't belong here.
|
||||
m_uiArray[DISPLAY_PEER_LIST]->bindings()['*'] = sigc::mem_fun(this, &Download::receive_snub_peer);
|
||||
m_uiArray[DISPLAY_PEER_INFO]->bindings()['*'] = sigc::mem_fun(this, &Download::receive_snub_peer);
|
||||
}
|
||||
|
||||
void
|
||||
Download::mark_dirty() {
|
||||
// (*m_window)->mark_dirty();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+8
-5
@@ -64,6 +64,7 @@ public:
|
||||
typedef std::list<torrent::Peer> PList;
|
||||
|
||||
typedef enum {
|
||||
DISPLAY_MENU,
|
||||
DISPLAY_PEER_LIST,
|
||||
DISPLAY_PEER_INFO,
|
||||
DISPLAY_FILE_LIST,
|
||||
@@ -76,10 +77,13 @@ public:
|
||||
Download(DPtr d);
|
||||
~Download();
|
||||
|
||||
void activate(display::Frame* frame);
|
||||
void activate(display::Frame* frame, bool focus = true);
|
||||
void disable();
|
||||
|
||||
void activate_display(Display d);
|
||||
void activate_display(Display d, bool focusDisplay);
|
||||
|
||||
void activate_display_focus(Display d) { activate_display(d, true); }
|
||||
void activate_display_menu(Display d) { activate_display(d, false); }
|
||||
|
||||
void receive_next_priority();
|
||||
void receive_prev_priority();
|
||||
@@ -101,14 +105,11 @@ private:
|
||||
void receive_max_uploads(int t);
|
||||
void receive_min_peers(int t);
|
||||
void receive_max_peers(int t);
|
||||
void receive_change(Display d);
|
||||
|
||||
void receive_snub_peer();
|
||||
|
||||
void bind_keys();
|
||||
|
||||
void mark_dirty();
|
||||
|
||||
DPtr m_download;
|
||||
PList m_peers;
|
||||
PList::iterator m_focus;
|
||||
@@ -116,6 +117,8 @@ private:
|
||||
Display m_state;
|
||||
ElementBase* m_uiArray[DISPLAY_MAX_SIZE];
|
||||
|
||||
bool m_focusDisplay;
|
||||
|
||||
WDownloadStatus* m_windowDownloadStatus;
|
||||
|
||||
sigc::connection m_connPeerConnected;
|
||||
|
||||
@@ -55,7 +55,6 @@
|
||||
|
||||
#include "display/window_log.h"
|
||||
#include "display/window_title.h"
|
||||
#include "display/window_statusbar.h"
|
||||
|
||||
#include "control.h"
|
||||
#include "download.h"
|
||||
@@ -90,7 +89,7 @@ DownloadList::~DownloadList() {
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::activate(display::Frame* frame) {
|
||||
DownloadList::activate(display::Frame* frame, bool focus) {
|
||||
if (is_active())
|
||||
throw torrent::client_error("ui::DownloadList::activate() called on an already activated object");
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
DownloadList();
|
||||
~DownloadList();
|
||||
|
||||
void activate(display::Frame* frame);
|
||||
void activate(display::Frame* frame, bool focus = true);
|
||||
void disable();
|
||||
|
||||
void activate_display(Display d);
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
|
||||
input::Bindings& bindings() { return m_bindings; }
|
||||
|
||||
virtual void activate(display::Frame* frame) = 0;
|
||||
virtual void activate(display::Frame* frame, bool focus = true) = 0;
|
||||
virtual void disable() = 0;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -61,11 +61,12 @@ ElementChunksSeen::ElementChunksSeen(core::Download* d) :
|
||||
}
|
||||
|
||||
void
|
||||
ElementChunksSeen::activate(display::Frame* frame) {
|
||||
ElementChunksSeen::activate(display::Frame* frame, bool focus) {
|
||||
if (is_active())
|
||||
throw torrent::client_error("ui::ElementChunksSeen::activate(...) is_active().");
|
||||
|
||||
control->input()->push_back(&m_bindings);
|
||||
if (focus)
|
||||
control->input()->push_back(&m_bindings);
|
||||
|
||||
m_window = new WChunksSeen(m_download, &m_focus);
|
||||
m_window->set_active(true);
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
|
||||
ElementChunksSeen(core::Download* d);
|
||||
|
||||
void activate(display::Frame* frame);
|
||||
void activate(display::Frame* frame, bool focus = true);
|
||||
void disable();
|
||||
|
||||
display::Window* window();
|
||||
|
||||
@@ -83,7 +83,7 @@ ElementDownloadList::ElementDownloadList() :
|
||||
}
|
||||
|
||||
void
|
||||
ElementDownloadList::activate(display::Frame* frame) {
|
||||
ElementDownloadList::activate(display::Frame* frame, bool focus) {
|
||||
if (is_active())
|
||||
throw torrent::client_error("ui::ElementDownloadList::activate(...) is_active().");
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
|
||||
ElementDownloadList();
|
||||
|
||||
void activate(display::Frame* frame);
|
||||
void activate(display::Frame* frame, bool focus = true);
|
||||
void disable();
|
||||
|
||||
core::View* view() { return m_view; }
|
||||
|
||||
@@ -62,11 +62,12 @@ ElementFileList::ElementFileList(core::Download* d) :
|
||||
}
|
||||
|
||||
void
|
||||
ElementFileList::activate(display::Frame* frame) {
|
||||
ElementFileList::activate(display::Frame* frame, bool focus) {
|
||||
if (m_window != NULL)
|
||||
throw torrent::client_error("ui::ElementFileList::activate(...) is_active().");
|
||||
|
||||
control->input()->push_back(&m_bindings);
|
||||
if (focus)
|
||||
control->input()->push_back(&m_bindings);
|
||||
|
||||
m_window = new WFileList(m_download, &m_focus);
|
||||
m_window->set_active(true);
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
|
||||
ElementFileList(core::Download* d);
|
||||
|
||||
void activate(display::Frame* frame);
|
||||
void activate(display::Frame* frame, bool focus = true);
|
||||
void disable();
|
||||
|
||||
display::Window* window();
|
||||
|
||||
@@ -54,7 +54,7 @@ ElementLogComplete::ElementLogComplete(core::Log* l) :
|
||||
}
|
||||
|
||||
void
|
||||
ElementLogComplete::activate(display::Frame* frame) {
|
||||
ElementLogComplete::activate(display::Frame* frame, bool focus) {
|
||||
if (is_active())
|
||||
throw torrent::client_error("ui::ElementLogComplete::activate(...) is_active().");
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
|
||||
ElementLogComplete(core::Log* l);
|
||||
|
||||
void activate(display::Frame* frame);
|
||||
void activate(display::Frame* frame, bool focus = true);
|
||||
void disable();
|
||||
|
||||
display::Window* window();
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
// rTorrent - BitTorrent client
|
||||
// Copyright (C) 2005-2006, Jari Sundell
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations
|
||||
// including the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for
|
||||
// all of the code used other than OpenSSL. If you modify file(s)
|
||||
// with this exception, you may extend this exception to your version
|
||||
// of the file(s), but you are not obligated to do so. If you do not
|
||||
// wish to do so, delete this exception statement from your version.
|
||||
// If you delete this exception statement from all source files in the
|
||||
// program, then also delete it here.
|
||||
//
|
||||
// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
//
|
||||
// Skomakerveien 33
|
||||
// 3185 Skoppum, NORWAY
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <torrent/exceptions.h>
|
||||
|
||||
#include "display/frame.h"
|
||||
#include "display/window_text.h"
|
||||
#include "display/text_element_string.h"
|
||||
#include "input/manager.h"
|
||||
|
||||
#include "control.h"
|
||||
#include "element_menu.h"
|
||||
|
||||
namespace ui {
|
||||
|
||||
struct ElementMenuEntry {
|
||||
display::TextElementString* m_element;
|
||||
|
||||
ElementMenu::slot_type m_slotFocus;
|
||||
ElementMenu::slot_type m_slotSelect;
|
||||
};
|
||||
|
||||
ElementMenu::ElementMenu() :
|
||||
m_window(new WindowText),
|
||||
m_focus(focus_invalid) {
|
||||
|
||||
// Move bindings.
|
||||
m_bindings[KEY_UP] = sigc::mem_fun(this, &ElementMenu::focus_prev);
|
||||
m_bindings[KEY_DOWN] = sigc::mem_fun(this, &ElementMenu::focus_next);
|
||||
m_bindings[KEY_RIGHT] = sigc::mem_fun(this, &ElementMenu::focus_select);
|
||||
}
|
||||
|
||||
ElementMenu::~ElementMenu() {
|
||||
delete m_window;
|
||||
}
|
||||
|
||||
void
|
||||
ElementMenu::activate(display::Frame* frame, bool focus) {
|
||||
if (is_active())
|
||||
throw torrent::client_error("ui::ElementMenu::activate(...) is_active().");
|
||||
|
||||
if (focus)
|
||||
control->input()->push_back(&m_bindings);
|
||||
|
||||
m_window->set_active(true);
|
||||
|
||||
m_frame = frame;
|
||||
m_frame->initialize_window(m_window);
|
||||
}
|
||||
|
||||
void
|
||||
ElementMenu::disable() {
|
||||
if (!is_active())
|
||||
throw torrent::client_error("ui::ElementMenu::disable(...) !is_active().");
|
||||
|
||||
control->input()->erase(&m_bindings);
|
||||
|
||||
m_frame->clear();
|
||||
m_frame = NULL;
|
||||
|
||||
m_window->set_active(false);
|
||||
}
|
||||
|
||||
void
|
||||
ElementMenu::push_back(const std::string& name, const slot_type& slotSelect, const slot_type& slotFocus) {
|
||||
entry_type* entry = new entry_type;
|
||||
|
||||
entry->m_element = new display::TextElementString(name);
|
||||
entry->m_slotSelect = slotSelect;
|
||||
entry->m_slotFocus = slotFocus;
|
||||
|
||||
m_window->push_back(NULL);
|
||||
m_window->push_back(entry->m_element);
|
||||
|
||||
base_type::push_back(entry);
|
||||
|
||||
// For the moment, don't bother doing anything if the window is
|
||||
// already active.
|
||||
m_window->mark_dirty();
|
||||
}
|
||||
|
||||
void
|
||||
ElementMenu::focus_next() {
|
||||
if (empty() || (size() == 1 && m_focus == 0))
|
||||
return;
|
||||
|
||||
if (m_focus < size())
|
||||
base_type::operator[](m_focus)->m_element->set_attributes(display::Attributes::a_normal);
|
||||
|
||||
if (++m_focus >= size())
|
||||
m_focus = 0;
|
||||
|
||||
base_type::operator[](m_focus)->m_slotFocus();
|
||||
base_type::operator[](m_focus)->m_element->set_attributes(display::Attributes::a_reverse);
|
||||
|
||||
m_window->mark_dirty();
|
||||
}
|
||||
|
||||
void
|
||||
ElementMenu::focus_prev() {
|
||||
if (empty() || (size() == 1 && m_focus == 0))
|
||||
return;
|
||||
|
||||
if (m_focus < size())
|
||||
base_type::operator[](m_focus)->m_element->set_attributes(display::Attributes::a_normal);
|
||||
|
||||
if (--m_focus >= size())
|
||||
m_focus = size() - 1;
|
||||
|
||||
base_type::operator[](m_focus)->m_slotFocus();
|
||||
base_type::operator[](m_focus)->m_element->set_attributes(display::Attributes::a_reverse);
|
||||
|
||||
m_window->mark_dirty();
|
||||
}
|
||||
|
||||
void
|
||||
ElementMenu::focus_select() {
|
||||
if (m_focus >= size())
|
||||
return;
|
||||
|
||||
base_type::operator[](m_focus)->m_slotSelect();
|
||||
|
||||
m_window->mark_dirty();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
// rTorrent - BitTorrent client
|
||||
// Copyright (C) 2005-2006, Jari Sundell
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations
|
||||
// including the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for
|
||||
// all of the code used other than OpenSSL. If you modify file(s)
|
||||
// with this exception, you may extend this exception to your version
|
||||
// of the file(s), but you are not obligated to do so. If you do not
|
||||
// wish to do so, delete this exception statement from your version.
|
||||
// If you delete this exception statement from all source files in the
|
||||
// program, then also delete it here.
|
||||
//
|
||||
// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
//
|
||||
// Skomakerveien 33
|
||||
// 3185 Skoppum, NORWAY
|
||||
|
||||
#ifndef RTORRENT_UI_ELEMENT_MENU_H
|
||||
#define RTORRENT_UI_ELEMENT_MENU_H
|
||||
|
||||
#include <sigc++/slot.h>
|
||||
|
||||
#include "core/download.h"
|
||||
|
||||
#include "element_base.h"
|
||||
|
||||
namespace display {
|
||||
class WindowText;
|
||||
}
|
||||
|
||||
namespace ui {
|
||||
|
||||
struct ElementMenuEntry;
|
||||
|
||||
class ElementMenu : public ElementBase, public std::vector<ElementMenuEntry*> {
|
||||
public:
|
||||
typedef ElementMenuEntry entry_type;
|
||||
typedef std::vector<entry_type*> base_type;
|
||||
typedef sigc::slot0<void> slot_type;
|
||||
|
||||
typedef display::WindowText WindowText;
|
||||
|
||||
typedef uint32_t size_type;
|
||||
|
||||
typedef base_type::value_type value_type;
|
||||
typedef base_type::reference reference;
|
||||
typedef base_type::iterator iterator;
|
||||
typedef base_type::const_iterator const_iterator;
|
||||
typedef base_type::reverse_iterator reverse_iterator;
|
||||
|
||||
using base_type::empty;
|
||||
using base_type::size;
|
||||
|
||||
static const size_type focus_invalid = ~size_type();
|
||||
|
||||
ElementMenu();
|
||||
~ElementMenu();
|
||||
|
||||
void activate(display::Frame* frame, bool focus = false);
|
||||
void disable();
|
||||
|
||||
// Consider returning a pointer that can be used to manipulate
|
||||
// entries, f.ex disabling them.
|
||||
|
||||
void push_back(const std::string& name,
|
||||
const slot_type& slotSelect = slot_type(),
|
||||
const slot_type& slotFocus = slot_type());
|
||||
|
||||
void focus_next();
|
||||
void focus_prev();
|
||||
|
||||
void focus_select();
|
||||
|
||||
private:
|
||||
WindowText* m_window;
|
||||
|
||||
size_type m_focus;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -56,11 +56,12 @@ ElementPeerInfo::ElementPeerInfo(core::Download* d, PList* l, PList::iterator* f
|
||||
}
|
||||
|
||||
void
|
||||
ElementPeerInfo::activate(display::Frame* frame) {
|
||||
ElementPeerInfo::activate(display::Frame* frame, bool focus) {
|
||||
if (is_active())
|
||||
throw torrent::client_error("ui::ElementPeerInfo::activate(...) is_active().");
|
||||
|
||||
control->input()->push_back(&m_bindings);
|
||||
if (focus)
|
||||
control->input()->push_back(&m_bindings);
|
||||
|
||||
m_window = new WPeerInfo(m_download, m_list, m_focus);
|
||||
m_window->set_active(true);
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
|
||||
ElementPeerInfo(core::Download* d, PList* l, PList::iterator* f);
|
||||
|
||||
void activate(display::Frame* frame);
|
||||
void activate(display::Frame* frame, bool focus = true);
|
||||
void disable();
|
||||
|
||||
display::Window* window();
|
||||
|
||||
@@ -55,11 +55,12 @@ ElementPeerList::ElementPeerList(core::Download* d, PList* l, PList::iterator* f
|
||||
}
|
||||
|
||||
void
|
||||
ElementPeerList::activate(display::Frame* frame) {
|
||||
ElementPeerList::activate(display::Frame* frame, bool focus) {
|
||||
if (is_active())
|
||||
throw torrent::client_error("ui::ElementPeerList::activate(...) is_active().");
|
||||
|
||||
control->input()->push_back(&m_bindings);
|
||||
if (focus)
|
||||
control->input()->push_back(&m_bindings);
|
||||
|
||||
m_window = new WPeerList(m_download, m_list, m_focus);
|
||||
m_window->set_active(true);
|
||||
@@ -82,9 +83,4 @@ ElementPeerList::disable() {
|
||||
m_window = NULL;
|
||||
}
|
||||
|
||||
display::Window*
|
||||
ElementPeerList::window() {
|
||||
return m_window;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,8 +41,6 @@
|
||||
|
||||
#include "element_base.h"
|
||||
|
||||
class Control;
|
||||
|
||||
namespace display {
|
||||
class WindowPeerList;
|
||||
}
|
||||
@@ -56,11 +54,9 @@ public:
|
||||
|
||||
ElementPeerList(core::Download* d, PList* l, PList::iterator* f);
|
||||
|
||||
void activate(display::Frame* frame);
|
||||
void activate(display::Frame* frame, bool focus = true);
|
||||
void disable();
|
||||
|
||||
display::Window* window();
|
||||
|
||||
private:
|
||||
core::Download* m_download;
|
||||
WPeerList* m_window;
|
||||
|
||||
@@ -51,7 +51,7 @@ ElementStringList::ElementStringList() :
|
||||
}
|
||||
|
||||
void
|
||||
ElementStringList::activate(display::Frame* frame) {
|
||||
ElementStringList::activate(display::Frame* frame, bool focus) {
|
||||
if (is_active())
|
||||
throw torrent::client_error("ui::ElementStringList::activate(...) is_active().");
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
|
||||
ElementStringList();
|
||||
|
||||
void activate(display::Frame* frame);
|
||||
void activate(display::Frame* frame, bool focus = true);
|
||||
void disable();
|
||||
|
||||
display::Window* window() { return m_window; }
|
||||
|
||||
@@ -61,11 +61,12 @@ ElementTrackerList::ElementTrackerList(core::Download* d) :
|
||||
}
|
||||
|
||||
void
|
||||
ElementTrackerList::activate(display::Frame* frame) {
|
||||
ElementTrackerList::activate(display::Frame* frame, bool focus) {
|
||||
if (m_window != NULL)
|
||||
throw torrent::client_error("ui::ElementTrackerList::activate(...) is_active().");
|
||||
|
||||
control->input()->push_back(&m_bindings);
|
||||
if (focus)
|
||||
control->input()->push_back(&m_bindings);
|
||||
|
||||
m_window = new WTrackerList(m_download, &m_focus);
|
||||
m_window->set_active(true);
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
|
||||
ElementTrackerList(core::Download* d);
|
||||
|
||||
void activate(display::Frame* frame);
|
||||
void activate(display::Frame* frame, bool focus = true);
|
||||
void disable();
|
||||
|
||||
display::Window* window();
|
||||
|
||||
@@ -61,11 +61,12 @@ ElementTransferList::ElementTransferList(core::Download* d) :
|
||||
}
|
||||
|
||||
void
|
||||
ElementTransferList::activate(display::Frame* frame) {
|
||||
ElementTransferList::activate(display::Frame* frame, bool focus) {
|
||||
if (is_active())
|
||||
throw torrent::client_error("ui::ElementTransferList::activate(...) is_active().");
|
||||
|
||||
control->input()->push_back(&m_bindings);
|
||||
if (focus)
|
||||
control->input()->push_back(&m_bindings);
|
||||
|
||||
m_window = new WTransferList(m_download, &m_focus);
|
||||
m_window->set_active(true);
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
|
||||
ElementTransferList(core::Download* d);
|
||||
|
||||
void activate(display::Frame* frame);
|
||||
void activate(display::Frame* frame, bool focus = true);
|
||||
void disable();
|
||||
|
||||
display::Window* window();
|
||||
|
||||
@@ -91,6 +91,7 @@ Root::init(Control* c) {
|
||||
|
||||
m_windowTitle->set_active(true);
|
||||
m_windowStatusbar->set_active(true);
|
||||
m_windowStatusbar->set_bottom(true);
|
||||
|
||||
setup_keys();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user