Procházet zdrojové kódy

Merge branch '#4_images_sizes' of Veronie/BggToolAnother into master

pull/21/head
Veronie před 4 roky
rodič
revize
5efceb0ac9
1 změnil soubory, kde provedl 47 přidání a 25 odebrání
  1. +47
    -25
      xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/BatMain.java

+ 47
- 25
xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/BatMain.java Zobrazit soubor

@@ -21,17 +21,22 @@ import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.OwnerDrawLabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
@@ -44,19 +49,6 @@ import xyz.veronie.bgg.types.EventConstants;
import xyz.veronie.bgg.ui.helpers.BatColors;
import xyz.veronie.bgg.ui.helpers.BatLayouts;
// TODO: import result.txt from bggtool
// TODO: image sizes in result table
// TODO: fix encoding
// TODO: fetch details from BGG
// TODO: export to results.txt format
// TODO: generate PDF with nandeck
// TODO: handle thing list overwrite
// TODO: Display selection details on game
// TODO: cache family/geeklist descriptions
// TODO: allow different screen scalings
// TODO: handle existing name
@SuppressWarnings("restriction")
public class BatMain {
private static final String UNNAMED_LIST = "(unsaved list)";
@@ -231,19 +223,49 @@ public class BatMain {
TableViewerColumn colThumbnail = createTableViewerColumn(Thing.ThumbHeader, 120, 0);
colThumbnail.setLabelProvider(new ColumnLabelProvider() {
@Override
public Image getImage(Object element) {
Thing t = (Thing) element;
// colThumbnail.setLabelProvider(new ColumnLabelProvider() {
// @Override
// public Image getImage(Object element) {
// Thing t = (Thing) element;
// Image img = t.getThumbnail();
// return img;
// }
//
// @Override
// public String getText(Object element) {
// return "";
// }
//
// });
colThumbnail.setLabelProvider(new OwnerDrawLabelProvider() {
@Override
protected void measure(Event event, Object element) {
Thing t = (Thing) element;
Image img = t.getThumbnail();
return img;
}
@Override
public String getText(Object element) {
return "";
}
Rectangle rectangle = img.getBounds();
event.setBounds(new Rectangle(
event.x,
event.y,
rectangle.width/2,
rectangle.height/2));
}
@Override
protected void paint(Event event, Object element) {
Thing t = (Thing) element;
Image img = t.getThumbnail();
final int width = img.getBounds().width;
final int height = img.getBounds().height;
final Image scaled050 = new Image(event.display, (int)(width*0.5),(int)(height*0.5));
GC gc = new GC(scaled050);
gc.drawImage(img, 0, 0, width, height, 0, 0, (int)(width*0.5), (int)(height*0.5));
gc.dispose();
event.gc.drawImage(scaled050, event.x, event.y);
}
});
TableViewerColumn colName = createTableViewerColumn(Thing.NameHeader, 400, 1);


Načítá se…
Zrušit
Uložit