diff options
author | Andrzej Rybczak <electricityispower@gmail.com> | 2009-08-13 00:31:16 +0200 |
---|---|---|
committer | Andrzej Rybczak <electricityispower@gmail.com> | 2009-08-13 00:31:16 +0200 |
commit | abdc042b04ab78ee640c47a1336f30c99003391a (patch) | |
tree | ca7176ae5f0f6fe8c225548f1321827a2eba1a0c | |
parent | a6f3fa0c0cac4666ad5b92cd30ad868cbacb0cec (diff) |
fix possible issues with additinal windows due to too small screen size
-rw-r--r-- | src/ncmpcpp.cpp | 9 | ||||
-rw-r--r-- | src/playlist.cpp | 8 | ||||
-rw-r--r-- | src/tag_editor.cpp | 18 |
3 files changed, 23 insertions, 12 deletions
diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 63ae725f..fd3b6779 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -1538,11 +1538,16 @@ int main(int argc, char *argv[]) ShowMessage("No selected items!"); continue; } + if (MainHeight < 5) + { + ShowMessage("Screen is too small to display this window!"); + continue; + } const size_t dialog_width = COLS*0.8; - const size_t dialog_height = LINES*0.6; + const size_t dialog_height = std::min(size_t(LINES*0.6), MainHeight); - Menu<std::string> mDialog((COLS-dialog_width)/2, (LINES-dialog_height)/2, dialog_width, dialog_height, "Add selected items to...", Config.main_color, Config.window_border); + Menu<std::string> mDialog((COLS-dialog_width)/2, (MainHeight-dialog_height)/2+MainStartY, dialog_width, dialog_height, "Add selected items to...", Config.main_color, Config.window_border); mDialog.SetTimeout(ncmpcpp_window_timeout); mDialog.CyclicScrolling(Config.use_cyclic_scrolling); mDialog.SetItemDisplayer(Display::Generic); diff --git a/src/playlist.cpp b/src/playlist.cpp index 953d71d4..2c1cfec3 100644 --- a/src/playlist.cpp +++ b/src/playlist.cpp @@ -60,7 +60,7 @@ void Playlist::Init() SortDialogHeight = std::min(int(MainHeight-2), 18); - SortDialog = new Menu< std::pair<std::string, MPD::Song::GetFunction> >((COLS-SortDialogWidth)/2, (LINES-SortDialogHeight)/2, SortDialogWidth, SortDialogHeight, "Sort songs by...", Config.main_color, Config.window_border); + SortDialog = new Menu< std::pair<std::string, MPD::Song::GetFunction> >((COLS-SortDialogWidth)/2, (MainHeight-SortDialogHeight)/2+MainStartY, SortDialogWidth, SortDialogHeight, "Sort songs by...", Config.main_color, Config.window_border); SortDialog->SetTimeout(ncmpcpp_window_timeout); SortDialog->CyclicScrolling(Config.use_cyclic_scrolling); SortDialog->SetItemDisplayer(Display::Pairs); @@ -107,10 +107,10 @@ void Playlist::Resize() w->Resize(COLS, MainHeight); w->MoveTo(0, MainStartY); w->SetTitle(Config.columns_in_playlist ? Display::Columns() : ""); - SortDialogHeight = std::min(int(MainHeight-2), 18); - if (MainHeight > 6) + SortDialogHeight = std::min(int(MainHeight), 18); + if (MainHeight > 5) SortDialog->Resize(SortDialogWidth, SortDialogHeight); - SortDialog->MoveTo((COLS-SortDialogWidth)/2, (LINES-SortDialogHeight)/2); + SortDialog->MoveTo((COLS-SortDialogWidth)/2, (MainHeight-SortDialogHeight)/2+MainStartY); hasToBeResized = 0; } diff --git a/src/tag_editor.cpp b/src/tag_editor.cpp index 603ea941..59bd2c88 100644 --- a/src/tag_editor.cpp +++ b/src/tag_editor.cpp @@ -1250,12 +1250,18 @@ string TagEditor::ParseFilename(Song &s, string mask, bool preview) void TagEditor::DealWithFilenames(SongList &v) { - int width = 30; - int height = 6; + size_t width = 30; + size_t height = 6; + + if (size_t(COLS) < width || MainHeight < height) + { + ShowMessage("Screen is too small to display additional windows!"); + return; + } GetPatternList(); - Menu<string> *Main = new Menu<string>((COLS-width)/2, (LINES-height)/2, width, height, "", Config.main_color, Config.window_border); + Menu<string> *Main = new Menu<string>((COLS-width)/2, (MainHeight-height)/2+MainStartY, width, height, "", Config.main_color, Config.window_border); Main->SetTimeout(ncmpcpp_window_timeout); Main->CyclicScrolling(Config.use_cyclic_scrolling); Main->SetItemDisplayer(Display::Generic); @@ -1278,7 +1284,7 @@ void TagEditor::DealWithFilenames(SongList &v) } width = COLS*0.9; - height = LINES*0.8; + height = std::min(size_t(LINES*0.8), MainHeight); bool exit = 0; bool preview = 1; size_t choice = Main->Choice(); @@ -1295,7 +1301,7 @@ void TagEditor::DealWithFilenames(SongList &v) if (choice != 3) { - Legend = new Scrollpad((COLS-width)/2+one_width, (LINES-height)/2, two_width, height, "Legend", Config.main_color, Config.window_border); + Legend = new Scrollpad((COLS-width)/2+one_width, (MainHeight-height)/2+MainStartY, two_width, height, "Legend", Config.main_color, Config.window_border); Legend->SetTimeout(ncmpcpp_window_timeout); *Legend << "%a - artist\n"; *Legend << "%t - title\n"; @@ -1316,7 +1322,7 @@ void TagEditor::DealWithFilenames(SongList &v) Preview->SetTitle("Preview"); Preview->SetTimeout(ncmpcpp_window_timeout); - Main = new Menu<string>((COLS-width)/2, (LINES-height)/2, one_width, height, "", Config.main_color, Config.active_window_border); + Main = new Menu<string>((COLS-width)/2, (MainHeight-height)/2+MainStartY, one_width, height, "", Config.main_color, Config.active_window_border); Main->SetTimeout(ncmpcpp_window_timeout); Main->CyclicScrolling(Config.use_cyclic_scrolling); Main->SetItemDisplayer(Display::Generic); |