Skip to content

Commit aa71291

Browse files
committed
Don't attempt to wrap cells that aren't deep enough
1 parent e6a4802 commit aa71291

File tree

3 files changed

+23
-33
lines changed

3 files changed

+23
-33
lines changed

uis/src/com/biglybt/ui/swt/shells/GCStringPrinter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,7 @@ private Point drawText(GC gc, String s, int x, int y, int height,
12471247
return textExtent;
12481248
}
12491249

1250-
private static Point
1250+
public static Point
12511251
stringExtent(
12521252
GC gc,
12531253
String text )

uis/src/com/biglybt/ui/swt/subscriptions/SubscriptionsView.java

+7-26
Original file line numberDiff line numberDiff line change
@@ -99,23 +99,19 @@ public class SubscriptionsView
9999

100100
private UISWTView swtView;
101101

102-
public SubscriptionsView() {
103-
102+
public
103+
SubscriptionsView()
104+
{
104105
}
105106

106107

107-
/* (non-Javadoc)
108-
* @see com.biglybt.core.subs.SubscriptionManagerListener#associationsChanged(byte[])
109-
*/
110108
@Override
111-
public void associationsChanged(byte[] association_hash) {
112-
// TODO Auto-generated method stub
113-
109+
public void
110+
associationsChanged(
111+
byte[] association_hash)
112+
{
114113
}
115114

116-
/* (non-Javadoc)
117-
* @see com.biglybt.core.subs.SubscriptionManagerListener#subscriptionSelected(com.biglybt.core.subs.Subscription)
118-
*/
119115
@Override
120116
public void
121117
subscriptionSelected(
@@ -131,28 +127,19 @@ public void associationsChanged(byte[] association_hash) {
131127
{
132128
}
133129

134-
/* (non-Javadoc)
135-
* @see com.biglybt.core.subs.SubscriptionManagerListener#subscriptionAdded(com.biglybt.core.subs.Subscription)
136-
*/
137130
@Override
138131
public void subscriptionAdded(Subscription subscription) {
139132
if ( subscription.isSubscribed()){
140133
view.addDataSource(subscription);
141134
}
142135
}
143136

144-
/* (non-Javadoc)
145-
* @see com.biglybt.core.subs.SubscriptionManagerListener#subscriptionRemoved(com.biglybt.core.subs.Subscription)
146-
*/
147137
@Override
148138
public void subscriptionRemoved(Subscription subscription) {
149139
view.removeDataSource(subscription);
150140

151141
}
152142

153-
/* (non-Javadoc)
154-
* @see com.biglybt.core.subs.SubscriptionManagerListener#subscriptionChanged(com.biglybt.core.subs.Subscription)
155-
*/
156143
@Override
157144
public void subscriptionChanged(Subscription subscription, int reason) {
158145
if ( !subscription.isSubscribed()){
@@ -173,9 +160,6 @@ public void subscriptionChanged(Subscription subscription, int reason) {
173160
}
174161
}
175162

176-
/* (non-Javadoc)
177-
* @see com.biglybt.pif.ui.UIPluginViewToolBarListener#refreshToolBarItems(java.util.Map)
178-
*/
179163
@Override
180164
public void refreshToolBarItems(Map<String, Long> list) {
181165
if ( view == null ){
@@ -186,9 +170,6 @@ public void refreshToolBarItems(Map<String, Long> list) {
186170
list.put("share", numRows == 1 ? UIToolBarItem.STATE_ENABLED : 0);
187171
}
188172

189-
/* (non-Javadoc)
190-
* @see com.biglybt.pif.ui.toolbar.UIToolBarActivationListener#toolBarItemActivated(ToolBarItem, long, java.lang.Object)
191-
*/
192173
@Override
193174
public boolean toolBarItemActivated(ToolBarItem item, long activationType,
194175
Object datasource) {

uis/src/com/biglybt/ui/swt/views/table/painted/TableRowPainted.java

+15-6
Original file line numberDiff line numberDiff line change
@@ -761,10 +761,6 @@ private boolean swt_paintCell(GC gc, Rectangle cellBounds,
761761
cellBounds.width -= ofs;
762762
}
763763
//System.out.println("PS " + getIndex() + ";" + cellBounds + ";" + cell.getText());
764-
int style = TableColumnSWTUtils.convertColumnAlignmentToSWT(column.getAlignment());
765-
if (cellBounds.height > 20) {
766-
style |= SWT.WRAP;
767-
}
768764
int textOpacity = cell.getTextAlpha();
769765
//gc.setFont(getRandomFont());
770766
//textOpacity = 130;
@@ -791,9 +787,22 @@ private boolean swt_paintCell(GC gc, Rectangle cellBounds,
791787
cellBounds.y += 2;
792788
cellBounds.height -= 4;
793789
if (!cellBounds.isEmpty()) {
794-
GCStringPrinter sp = new GCStringPrinter(gc, text, cellBounds, true,
795-
cellBounds.height > 20, style);
790+
791+
int singleLineHeight = GCStringPrinter.stringExtent( gc, text ).y;
792+
793+
boolean worthWrap = cellBounds.height >= singleLineHeight*2;
794+
795+
int style = TableColumnSWTUtils.convertColumnAlignmentToSWT(column.getAlignment());
796+
797+
if ( worthWrap ){
798+
799+
style |= SWT.WRAP;
800+
}
796801

802+
GCStringPrinter sp = new GCStringPrinter(gc, text, cellBounds, true, worthWrap, style);
803+
804+
sp.calculateMetrics();
805+
797806
if (shadowColor != null) {
798807
Color oldFG = gc.getForeground();
799808
gc.setForeground(shadowColor);

0 commit comments

Comments
 (0)