210 c.setAvailable(0);
211 }
212 }
213 resize = true;
214 }
215
216 previousSize = horizontal ? sw : sh;
217 } else {
218 previousSize = horizontal ? sw : sh;
219 }
220
221 // If the window is less than the min size we want to resize
222 // proportionally
223 double minSize = totalMinSize();
224 if (minSize > (horizontal ? w : h)) {
225 double percentage = 0;
226 for (int i = 0; i < contentRegions.size(); i++) {
227 Content c = contentRegions.get(i);
228 double min = horizontal ? c.minWidth(-1) : c.minHeight(-1);
229 percentage = min/minSize;
230 c.setArea(snapSpace(percentage * (horizontal ? w : h)));
231 c.setAvailable(0);
232 }
233 setupContentAndDividerForLayout();
234 layoutDividersAndContent(w, h);
235 resize = false;
236 return;
237 }
238
239 for(int trys = 0; trys < 10; trys++) {
240 // Compute the area in between each divider.
241 ContentDivider previousDivider = null;
242 ContentDivider divider = null;
243 for (int i = 0; i < contentRegions.size(); i++) {
244 double space = 0;
245 if (i < contentDividers.size()) {
246 divider = contentDividers.get(i);
247 if (divider.posExplicit) {
248 checkDividerPosition(divider, posToDividerPos(divider, divider.d.getPosition()),
249 divider.getDividerPos());
250 }
741 double size = totalMinSize();
742 if (horizontal) {
743 if (s.getWidth() > size) {
744 size = s.getWidth() - snappedLeftInset() - snappedRightInset();
745 }
746 } else {
747 if (s.getHeight() > size) {
748 size = s.getHeight() - snappedTopInset() - snappedBottomInset();
749 }
750 }
751 return size;
752 }
753
754 // Evenly distribute the size to the available list.
755 // size is the amount to distribute.
756 private double distributeTo(List<Content> available, double size) {
757 if (available.isEmpty()) {
758 return size;
759 }
760
761 size = snapSize(size);
762 int portion = (int)(size)/available.size();
763 int remainder;
764
765 while (size > 0 && !available.isEmpty()) {
766 Iterator<Content> i = available.iterator();
767 while (i.hasNext()) {
768 Content c = i.next();
769 double max = Math.min((horizontal ? c.maxWidth(-1) : c.maxHeight(-1)), Double.MAX_VALUE);
770 double min = horizontal ? c.minWidth(-1) : c.minHeight(-1);
771
772 // We have too much space
773 if (c.getArea() >= max) {
774 c.setAvailable(c.getArea() - min);
775 i.remove();
776 continue;
777 }
778 // Not enough space
779 if (portion >= (max - c.getArea())) {
780 size -= (max - c.getArea());
781 c.setArea(max);
795 // We reached the max size for everything just return
796 return size;
797 }
798 portion = (int)(size)/available.size();
799 remainder = (int)(size)%available.size();
800 if (portion == 0 && remainder != 0) {
801 portion = remainder;
802 remainder = 0;
803 }
804 }
805 return size;
806 }
807
808 // Evenly distribute the size from the available list.
809 // size is the amount to distribute.
810 private double distributeFrom(double size, List<Content> available) {
811 if (available.isEmpty()) {
812 return size;
813 }
814
815 size = snapSize(size);
816 int portion = (int)(size)/available.size();
817 int remainder;
818
819 while (size > 0 && !available.isEmpty()) {
820 Iterator<Content> i = available.iterator();
821 while (i.hasNext()) {
822 Content c = i.next();
823 //not enough space taking available and setting min
824 if (portion >= c.getAvailable()) {
825 c.setArea(c.getArea() - c.getAvailable()); // Min size
826 size -= c.getAvailable();
827 c.setAvailable(0);
828 i.remove();
829 } else {
830 //enough space
831 c.setArea(c.getArea() - portion);
832 c.setAvailable(c.getAvailable() - portion);
833 size -= portion;
834 }
835 if ((int)size == 0) {
|
210 c.setAvailable(0);
211 }
212 }
213 resize = true;
214 }
215
216 previousSize = horizontal ? sw : sh;
217 } else {
218 previousSize = horizontal ? sw : sh;
219 }
220
221 // If the window is less than the min size we want to resize
222 // proportionally
223 double minSize = totalMinSize();
224 if (minSize > (horizontal ? w : h)) {
225 double percentage = 0;
226 for (int i = 0; i < contentRegions.size(); i++) {
227 Content c = contentRegions.get(i);
228 double min = horizontal ? c.minWidth(-1) : c.minHeight(-1);
229 percentage = min/minSize;
230 if (horizontal) {
231 c.setArea(snapSpaceX(percentage * w));
232 } else {
233 c.setArea(snapSpaceY(percentage * h));
234 }
235 c.setAvailable(0);
236 }
237 setupContentAndDividerForLayout();
238 layoutDividersAndContent(w, h);
239 resize = false;
240 return;
241 }
242
243 for(int trys = 0; trys < 10; trys++) {
244 // Compute the area in between each divider.
245 ContentDivider previousDivider = null;
246 ContentDivider divider = null;
247 for (int i = 0; i < contentRegions.size(); i++) {
248 double space = 0;
249 if (i < contentDividers.size()) {
250 divider = contentDividers.get(i);
251 if (divider.posExplicit) {
252 checkDividerPosition(divider, posToDividerPos(divider, divider.d.getPosition()),
253 divider.getDividerPos());
254 }
745 double size = totalMinSize();
746 if (horizontal) {
747 if (s.getWidth() > size) {
748 size = s.getWidth() - snappedLeftInset() - snappedRightInset();
749 }
750 } else {
751 if (s.getHeight() > size) {
752 size = s.getHeight() - snappedTopInset() - snappedBottomInset();
753 }
754 }
755 return size;
756 }
757
758 // Evenly distribute the size to the available list.
759 // size is the amount to distribute.
760 private double distributeTo(List<Content> available, double size) {
761 if (available.isEmpty()) {
762 return size;
763 }
764
765 size = horizontal ? snapSizeX(size) : snapSizeY(size);
766 int portion = (int)(size)/available.size();
767 int remainder;
768
769 while (size > 0 && !available.isEmpty()) {
770 Iterator<Content> i = available.iterator();
771 while (i.hasNext()) {
772 Content c = i.next();
773 double max = Math.min((horizontal ? c.maxWidth(-1) : c.maxHeight(-1)), Double.MAX_VALUE);
774 double min = horizontal ? c.minWidth(-1) : c.minHeight(-1);
775
776 // We have too much space
777 if (c.getArea() >= max) {
778 c.setAvailable(c.getArea() - min);
779 i.remove();
780 continue;
781 }
782 // Not enough space
783 if (portion >= (max - c.getArea())) {
784 size -= (max - c.getArea());
785 c.setArea(max);
799 // We reached the max size for everything just return
800 return size;
801 }
802 portion = (int)(size)/available.size();
803 remainder = (int)(size)%available.size();
804 if (portion == 0 && remainder != 0) {
805 portion = remainder;
806 remainder = 0;
807 }
808 }
809 return size;
810 }
811
812 // Evenly distribute the size from the available list.
813 // size is the amount to distribute.
814 private double distributeFrom(double size, List<Content> available) {
815 if (available.isEmpty()) {
816 return size;
817 }
818
819 size = horizontal ? snapSizeX(size) : snapSizeY(size);
820 int portion = (int)(size)/available.size();
821 int remainder;
822
823 while (size > 0 && !available.isEmpty()) {
824 Iterator<Content> i = available.iterator();
825 while (i.hasNext()) {
826 Content c = i.next();
827 //not enough space taking available and setting min
828 if (portion >= c.getAvailable()) {
829 c.setArea(c.getArea() - c.getAvailable()); // Min size
830 size -= c.getAvailable();
831 c.setAvailable(0);
832 i.remove();
833 } else {
834 //enough space
835 c.setArea(c.getArea() - portion);
836 c.setAvailable(c.getAvailable() - portion);
837 size -= portion;
838 }
839 if ((int)size == 0) {
|