aboutsummaryrefslogtreecommitdiff
path: root/src/Toolbar.cc
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-10-31 10:37:09 (GMT)
committerrathnor <rathnor>2003-10-31 10:37:09 (GMT)
commitb88f9b2a9e6a08cfb663b7177a9c037250d48fea (patch)
tree6c790fef10cbfdd1eab211572932d7bdf2425d13 /src/Toolbar.cc
parentd617c5288fe37972b474f86b653e5541553f93de (diff)
downloadfluxbox_pavel-b88f9b2a9e6a08cfb663b7177a9c037250d48fea.zip
fluxbox_pavel-b88f9b2a9e6a08cfb663b7177a9c037250d48fea.tar.bz2
fix a number of positioning and sizing issues
Diffstat (limited to 'src/Toolbar.cc')
-rw-r--r--src/Toolbar.cc42
1 files changed, 31 insertions, 11 deletions
diff --git a/src/Toolbar.cc b/src/Toolbar.cc
index ded81e2..9b76ed6 100644
--- a/src/Toolbar.cc
+++ b/src/Toolbar.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Toolbar.cc,v 1.125 2003/10/14 00:21:52 fluxgen Exp $ 25// $Id: Toolbar.cc,v 1.126 2003/10/31 10:37:09 rathnor Exp $
26 26
27#include "Toolbar.hh" 27#include "Toolbar.hh"
28 28
@@ -832,7 +832,7 @@ void Toolbar::saveOnHead(int head) {
832 832
833void Toolbar::rearrangeItems() { 833void Toolbar::rearrangeItems() {
834 if (m_resize_lock || screen().isShuttingdown() || 834 if (m_resize_lock || screen().isShuttingdown() ||
835 m_item_list.size() == 0) 835 m_item_list.empty())
836 return; 836 return;
837 // lock this 837 // lock this
838 m_resize_lock = true; 838 m_resize_lock = true;
@@ -841,37 +841,57 @@ void Toolbar::rearrangeItems() {
841 ItemList::iterator item_it_end = m_item_list.end(); 841 ItemList::iterator item_it_end = m_item_list.end();
842 int fixed_width = 0; // combined size of all fixed items 842 int fixed_width = 0; // combined size of all fixed items
843 int fixed_items = 0; // number of fixed items 843 int fixed_items = 0; // number of fixed items
844 int relative_items = 0;
844 for (; item_it != item_it_end; ++item_it) { 845 for (; item_it != item_it_end; ++item_it) {
845 if ((*item_it)->type() == ToolbarItem::FIXED) { 846 if ((*item_it)->type() == ToolbarItem::FIXED && (*item_it)->active()) {
846 fixed_width += (*item_it)->width() + (*item_it)->borderWidth()*2; 847 fixed_width += (*item_it)->width() + (*item_it)->borderWidth()*2;
847 fixed_items++; 848 fixed_items++;
849 } else if ((*item_it)->type() == ToolbarItem::RELATIVE && (*item_it)->active()) {
850 relative_items++;
848 } 851 }
849 } 852 }
850 // calculate what's going to be left over to the relative sized items 853
854 // calculate what's going to be le ft over to the relative sized items
851 int relative_width = 0; 855 int relative_width = 0;
856 int rounding_error = 0;
852 if (fixed_items == 0) // no fixed items, then the rest is the entire width 857 if (fixed_items == 0) // no fixed items, then the rest is the entire width
853 relative_width = width(); 858 relative_width = width();
854 else { 859 else {
855 const int relative_items = m_item_list.size() - fixed_items;
856 if (relative_items == 0) 860 if (relative_items == 0)
857 relative_width = 0; 861 relative_width = 0;
858 else // size left after fixed items / number of relative items 862 else { // size left after fixed items / number of relative items
859 relative_width = (width() - fixed_width)/relative_items; 863 relative_width = (width() - fixed_width)/relative_items;
864 rounding_error = width() - fixed_width - relative_items*relative_width;
865 }
860 } 866 }
861
862 // now move and resize the items 867 // now move and resize the items
863 int next_x = m_item_list.front()->borderWidth(); 868 int next_x = 0;
864 for (item_it = m_item_list.begin(); item_it != item_it_end; ++item_it) { 869 for (item_it = m_item_list.begin(); item_it != item_it_end; ++item_it) {
870 if (!(*item_it)->active()) {
871 (*item_it)->hide();
872 continue;
873 }
874
875 int borderW = (*item_it)->borderWidth();
876 (*item_it)->show();
865 if ((*item_it)->type() == ToolbarItem::RELATIVE) { 877 if ((*item_it)->type() == ToolbarItem::RELATIVE) {
866 (*item_it)->moveResize(next_x, 0, relative_width, height()); 878 int extra = 0;
879 if (rounding_error != 0) { // distribute rounding error over all relatives
880 extra = 1;
881 --rounding_error;
882 }
883
884 (*item_it)->moveResize(next_x, -borderW, extra + relative_width-2*borderW, height());
867 } else { // fixed size 885 } else { // fixed size
868 (*item_it)->moveResize(next_x, 0, 886 (*item_it)->moveResize(next_x, -borderW,
869 (*item_it)->width(), height()); 887 (*item_it)->width(), height());
870 } 888 }
871 next_x += (*item_it)->width() + (*item_it)->borderWidth()*2; 889 next_x += (*item_it)->width() + borderW*2;
872 } 890 }
873 // unlock 891 // unlock
874 m_resize_lock = false; 892 m_resize_lock = false;
893 frame.window.clear();
894
875} 895}
876 896
877void Toolbar::deleteItems() { 897void Toolbar::deleteItems() {