* 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:
rakshasa
2006-07-28 00:17:54 +00:00
parent fc76a11d71
commit 4c9fc671be
40 changed files with 363 additions and 193 deletions
+50 -29
View File
@@ -117,11 +117,7 @@ DownloadList::disable() {
if (!is_active())
throw std::logic_error("ui::DownloadList::disable() called on an already disabled object");
// if (m_windowTextInput->is_active()) {
// m_windowTextInput->get_input()->clear();
// receive_exit_input(INPUT_NONE);
// }
receive_exit_input(INPUT_NONE);
activate_display(DISPLAY_NONE);
m_frame = NULL;
@@ -133,10 +129,10 @@ DownloadList::disable() {
void
DownloadList::activate_display(Display displayType) {
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)
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)
return;
@@ -146,6 +142,11 @@ DownloadList::activate_display(Display displayType) {
// Cleanup previous state.
switch (m_state) {
case DISPLAY_DOWNLOAD_LIST:
m_uiArray[DISPLAY_DOWNLOAD_LIST]->disable();
m_uiArray[DISPLAY_LOG]->disable();
m_frame->clear();
break;
case DISPLAY_LOG:
m_uiArray[m_state]->disable();
break;
@@ -162,14 +163,13 @@ DownloadList::activate_display(Display displayType) {
break;
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;
case DISPLAY_LOG:
control->ui()->window_title()->set_title("Log");
m_uiArray[displayType]->activate(m_frame);
break;
@@ -177,6 +177,13 @@ DownloadList::activate_display(Display displayType) {
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();
}
@@ -224,8 +231,10 @@ DownloadList::receive_close_download() {
if (m_view->focus() == m_view->end_visible())
return;
control->core()->download_list()->stop_normal(*m_view->focus());
control->core()->download_list()->close(*m_view->focus());
core::Download* download = *m_view->focus();
control->core()->download_list()->stop_normal(download);
control->core()->download_list()->close(download);
m_view->set_last_changed();
}
@@ -323,23 +332,39 @@ DownloadList::receive_view_input(Input type) {
input::PathInput* input = new input::PathInput;
const char* title;
switch (type) {
case INPUT_LOAD_DEFAULT:
title = "load_start";
break;
case INPUT_LOAD_MODIFIED:
title = "load";
break;
case INPUT_CHANGE_DIRECTORY:
title = "change_directory";
input->str() = control->variable()->get_string("directory");
input->set_pos(input->str().length());
break;
default:
case INPUT_COMMAND:
title = "command";
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['\n'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_exit_input), type);
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);
m_bindings.disable();
control->ui()->enable_input(title, input);
}
void
@@ -351,14 +376,7 @@ DownloadList::receive_exit_input(Input type) {
return;
control->ui()->disable_input();
// 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);
m_bindings.enable();
try {
@@ -382,6 +400,9 @@ DownloadList::receive_exit_input(Input type) {
case INPUT_COMMAND:
control->variable()->process_command(input->str());
break;
default:
throw torrent::client_error("DownloadList::receive_exit_input(...) Invalid input type.");
}
} 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['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()[KEY_RIGHT] = 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_LEFT] = sigc::bind(sigc::mem_fun(*this, &DownloadList::activate_display), DISPLAY_DOWNLOAD_LIST);
}
// void
+2 -2
View File
@@ -128,7 +128,7 @@ ElementChunksSeen::receive_pagenext() {
if (m_window == NULL)
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);
if (scrollable == 0 || m_focus == scrollable)
@@ -146,7 +146,7 @@ ElementChunksSeen::receive_pageprev() {
if (m_window == NULL)
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);
if (m_focus > visible / 2)
+1
View File
@@ -55,6 +55,7 @@ ElementDownloadList::activate(display::Frame* frame) {
control->input()->push_front(&m_bindings);
m_window = new WDownloadList();
m_window->set_active(true);
m_window->set_view(m_view);
m_frame = frame;
+2 -2
View File
@@ -121,7 +121,7 @@ ElementFileList::receive_pagenext() {
if (m_window == NULL)
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())
m_focus += count;
@@ -143,7 +143,7 @@ ElementFileList::receive_pageprev() {
if (fl.size() == 0)
return;
unsigned int count = (m_window->get_height() - 1) / 2;
unsigned int count = (m_window->height() - 1) / 2;
if (m_focus > count)
m_focus -= count;
+1
View File
@@ -61,6 +61,7 @@ ElementLogComplete::activate(display::Frame* frame) {
control->input()->push_front(&m_bindings);
m_window = new WLogComplete(m_log);
m_window->set_active(true);
m_frame = frame;
m_frame->initialize_window(m_window);
+2 -2
View File
@@ -128,7 +128,7 @@ ElementTransferList::receive_pagenext() {
// if (m_window == NULL)
// 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);
// if (scrollable == 0 || m_focus == scrollable)
@@ -146,7 +146,7 @@ ElementTransferList::receive_pageprev() {
// if (m_window == NULL)
// 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);
// if (m_focus > visible / 2)
+6 -7
View File
@@ -83,16 +83,14 @@ Root::init(Control* c) {
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(2)->initialize_window(m_windowHttpQueue);
rootFrame->frame(3)->initialize_window(m_windowInput);
rootFrame->frame(4)->initialize_window(m_windowStatusbar);
m_control->display()->schedule(m_windowTitle, cachedTime);
m_control->display()->schedule(m_windowStatusbar, cachedTime);
m_windowInput->set_active(false);
m_windowTitle->set_active(true);
m_windowStatusbar->set_active(true);
setup_keys();
@@ -187,7 +185,7 @@ Root::adjust_up_throttle(int throttle) {
}
void
Root::enable_input(input::TextInput* input) {
Root::enable_input(const std::string& title, input::TextInput* input) {
if (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_windowInput->set_active(true);
m_windowInput->set_focus(true);
m_windowInput->set_input(input);
m_windowInput->set_title(title);
m_windowInput->set_focus(true);
control->input()->set_text_input(input);
control->display()->adjust_layout();
+1 -1
View File
@@ -84,7 +84,7 @@ public:
void adjust_down_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();
input::TextInput* current_input();