about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-11-15 22:59:13 +0000
committerJames Booth <boothj5@gmail.com>2014-11-15 22:59:13 +0000
commit3a778cc974a2a561f96d926178ce18c9cc6627cb (patch)
treeb4a3f288fc2f3ea027ba2b365e3454592b613749 /src/ui
parent36427971468ff81a55b77e3f75ab5dd36f2bd9a6 (diff)
downloadprofani-tty-3a778cc974a2a561f96d926178ce18c9cc6627cb.tar.gz
Added seperate values for roster and occupants win sizes
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/window.c26
-rw-r--r--src/ui/window.h1
-rw-r--r--src/ui/windows.c31
3 files changed, 40 insertions, 18 deletions
diff --git a/src/ui/window.c b/src/ui/window.c
index dbb3a25c..13b84b73 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -54,6 +54,7 @@
 #define CEILING(X) (X-(int)(X) > 0 ? (int)(X+1) : (int)(X))
 
 static int roster_win_percent = 20;
+static int occupants_win_percent = 20;
 
 static void _win_print(ProfWin *window, const char show_char, const char * const date_fmt,
     int flags, int attrs, const char * const from, const char * const message);
@@ -66,6 +67,13 @@ win_roster_cols(void)
     return CEILING( (((double)cols) / 100) * roster_win_percent);
 }
 
+int
+win_occpuants_cols(void)
+{
+    int cols = getmaxx(stdscr);
+    return CEILING( (((double)cols) / 100) * occupants_win_percent);
+}
+
 ProfWin*
 win_create(const char * const title, win_type_t type)
 {
@@ -74,7 +82,7 @@ win_create(const char * const title, win_type_t type)
     int cols = getmaxx(stdscr);
 
     if (type == WIN_MUC && prefs_get_boolean(PREF_OCCUPANTS)) {
-        int subwin_cols = win_roster_cols();
+        int subwin_cols = win_occpuants_cols();
         new_win->win = newpad(PAD_SIZE, cols - subwin_cols);
         wbkgd(new_win->win, COLOUR_TEXT);
 
@@ -121,7 +129,12 @@ win_show_subwin(ProfWin *window)
 {
     if (!window->subwin) {
         int cols = getmaxx(stdscr);
-        int subwin_cols = win_roster_cols();
+        int subwin_cols = 0;
+        if (window->type == WIN_CONSOLE) {
+            subwin_cols = win_roster_cols();
+        } else if (window->type == WIN_MUC) {
+            subwin_cols = win_occpuants_cols();
+        }
 
         window->subwin = newpad(PAD_SIZE, subwin_cols);
         wbkgd(window->subwin, COLOUR_TEXT);
@@ -149,9 +162,14 @@ win_update_virtual(ProfWin *window)
 {
     int rows, cols;
     getmaxyx(stdscr, rows, cols);
-    int subwin_cols = win_roster_cols();
 
-    if (((window->type == WIN_MUC) || (window->type == WIN_CONSOLE)) && (window->subwin)) {
+    if (window->subwin) {
+        int subwin_cols = 0;
+        if (window->type == WIN_MUC) {
+            subwin_cols = win_occpuants_cols();
+        } else if (window->type == WIN_CONSOLE) {
+            subwin_cols = win_roster_cols();
+        }
         pnoutrefresh(window->win, window->y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1);
         pnoutrefresh(window->subwin, window->sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1);
     } else {
diff --git a/src/ui/window.h b/src/ui/window.h
index e635f221..b512c521 100644
--- a/src/ui/window.h
+++ b/src/ui/window.h
@@ -105,6 +105,7 @@ void win_redraw(ProfWin *window);
 void win_hide_subwin(ProfWin *window);
 void win_show_subwin(ProfWin *window);
 int win_roster_cols(void);
+int win_occpuants_cols(void);
 void win_printline_nowrap(WINDOW *win, char *msg);
 
 #endif
diff --git a/src/ui/windows.c b/src/ui/windows.c
index 81e02965..643118af 100644
--- a/src/ui/windows.c
+++ b/src/ui/windows.c
@@ -285,20 +285,23 @@ wins_get_total_unread(void)
 void
 wins_resize_all(void)
 {
-    int rows, cols;
-    getmaxyx(stdscr, rows, cols);
-    int roster_cols = win_roster_cols();
+    int cols = getmaxx(stdscr);
 
     GList *values = g_hash_table_get_values(windows);
     GList *curr = values;
     while (curr != NULL) {
         ProfWin *window = curr->data;
         if (((window->type == WIN_MUC) || (window->type == WIN_CONSOLE)) && (window->subwin)) {
-            wresize(window->win, PAD_SIZE, cols - roster_cols);
-            wresize(window->subwin, PAD_SIZE, roster_cols);
+            int subwin_cols = 0;
             if (window->type == WIN_MUC) {
+                subwin_cols = win_occpuants_cols();
+                wresize(window->win, PAD_SIZE, cols - subwin_cols);
+                wresize(window->subwin, PAD_SIZE, subwin_cols);
                 ui_muc_roster(window->from);
             } else if (window->type == WIN_CONSOLE) {
+                subwin_cols = win_roster_cols();
+                wresize(window->win, PAD_SIZE, cols - subwin_cols);
+                wresize(window->subwin, PAD_SIZE, subwin_cols);
                 ui_roster();
             }
         } else {
@@ -310,12 +313,7 @@ wins_resize_all(void)
     g_list_free(values);
 
     ProfWin *current_win = wins_get_current();
-    if (((current_win->type == WIN_MUC) || (current_win->type == WIN_CONSOLE)) && (current_win->subwin)) {
-        pnoutrefresh(current_win->win, current_win->y_pos, 0, 1, 0, rows-3, (cols-roster_cols)-1);
-        pnoutrefresh(current_win->subwin, current_win->sub_y_pos, 0, 1, (cols-roster_cols), rows-3, cols-1);
-    } else {
-        pnoutrefresh(current_win->win, current_win->y_pos, 0, 1, 0, rows-3, cols-1);
-    }
+    win_update_virtual(current_win);
 }
 
 void
@@ -337,14 +335,19 @@ wins_show_subwin(ProfWin *window)
 {
     int rows, cols;
     getmaxyx(stdscr, rows, cols);
-    int roster_cols = win_roster_cols();
+    int subwin_cols = 0;
 
     win_show_subwin(window);
 
     ProfWin *current_win = wins_get_current();
+    if (current_win->type == WIN_MUC) {
+        subwin_cols = win_occpuants_cols();
+    } else if (current_win->type == WIN_CONSOLE) {
+        subwin_cols = win_roster_cols();
+    }
     if ((current_win->type == WIN_MUC) || (current_win->type == WIN_CONSOLE)) {
-        pnoutrefresh(current_win->win, current_win->y_pos, 0, 1, 0, rows-3, (cols-roster_cols)-1);
-        pnoutrefresh(current_win->subwin, current_win->sub_y_pos, 0, 1, (cols-roster_cols), rows-3, cols-1);
+        pnoutrefresh(current_win->win, current_win->y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1);
+        pnoutrefresh(current_win->subwin, current_win->sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1);
     }
 }