diff --git a/pdex/Todo, GSoC 2013.txt b/pdex/Todo, GSoC 2013.txt index 91c8af92b..a9cd7c736 100644 --- a/pdex/Todo, GSoC 2013.txt +++ b/pdex/Todo, GSoC 2013.txt @@ -45,6 +45,7 @@ Finer details * Diamond operator isn't supported for now. Bummer. x Completion popup height is now dynamic, decreases to fit. +* Completion width can be dynamic, if really needed.. x Icons for completions? Or overkill right now? x 'Show Usage' menu item added x Show declaring class for completions diff --git a/pdex/src/processing/mode/experimental/CompletionPanel.java b/pdex/src/processing/mode/experimental/CompletionPanel.java index 62c367d3a..08fc06ac4 100644 --- a/pdex/src/processing/mode/experimental/CompletionPanel.java +++ b/pdex/src/processing/mode/experimental/CompletionPanel.java @@ -9,6 +9,7 @@ import java.awt.FontMetrics; import java.awt.Point; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.util.Iterator; import javax.swing.BorderFactory; import javax.swing.DefaultListModel; @@ -78,6 +79,20 @@ public class CompletionPanel { log("popup height " + Math.min(250,h)); return Math.min(250,(int)h); // popup menu height } + + /*TODO: Make width dynamic + protected int setWidth(){ + if(scrollPane.getVerticalScrollBar().isVisible()) return 280; + float min = 280; + FontMetrics fm = textarea.getFontMetrics(textarea.getFont()); + for (int i = 0; i < completionList.getModel().getSize(); i++) { + float h = fm.stringWidth(completionList.getModel().getElementAt(i).toString()); + min = Math.min(min, h); + } + min += fm.stringWidth(" "); + log("popup width " + Math.min(280,min)); + return Math.min(280,(int)min); // popup menu height + }*/ private JList createSuggestionList(final int position, final DefaultListModel items) {