Search in sources :

Example 26 with ImageLoader

use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.

the class Utils method setMenuItemImage.

public static void setMenuItemImage(final com.biglybt.pif.ui.menus.MenuItem item, final String repoKey) {
    if (Constants.isOSX || repoKey == null) {
        return;
    }
    if (Utils.isSWTThread()) {
        ImageLoader imageLoader = ImageLoader.getInstance();
        Graphic graphic = new UISWTGraphicImpl(imageLoader.getImage(repoKey));
        item.setGraphic(graphic);
    } else {
        execSWTThread(new Runnable() {

            @Override
            public void run() {
                ImageLoader imageLoader = ImageLoader.getInstance();
                Graphic graphic = new UISWTGraphicImpl(imageLoader.getImage(repoKey));
                item.setGraphic(graphic);
            }
        });
    }
}
Also used : UISWTGraphicImpl(com.biglybt.ui.swt.pifimpl.UISWTGraphicImpl) Graphic(com.biglybt.pif.ui.Graphic) SWTRunnable(com.biglybt.ui.swt.utils.SWTRunnable) ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader)

Example 27 with ImageLoader

use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.

the class Utils method setMenuItemImage.

public static void setMenuItemImage(CLabel item, final String repoKey) {
    if (Constants.isOSX || repoKey == null) {
        return;
    }
    ImageLoader imageLoader = ImageLoader.getInstance();
    item.setImage(imageLoader.getImage(repoKey));
    item.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            ImageLoader imageLoader = ImageLoader.getInstance();
            imageLoader.releaseImage(repoKey);
        }
    });
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Example 28 with ImageLoader

use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.

the class Utils method setShellIcon.

/**
 * Sets the shell's Icon(s) to the default App icon.  OSX doesn't require
 * an icon, so they are skipped
 *
 * @param shell
 */
public static void setShellIcon(Shell shell) {
    if (Constants.isOSX) {
        if (true) {
            return;
        }
        if (icon128 == null) {
            ImageLoader imageLoader = ImageLoader.getInstance();
            icon128 = imageLoader.getImage("logo128");
            if (Constants.isCVSVersion()) {
                final int border = 9;
                Image image = Utils.createAlphaImage(shell.getDisplay(), 128 + (border * 2), 128 + (border * 2));
                image = blitImage(shell.getDisplay(), icon128, null, image, new Point(border, border + 1));
                imageLoader.releaseImage("logo128");
                icon128 = image;
            // GC gc = new GC(icon128);
            // gc.setTextAntialias(SWT.ON);
            // gc.setForeground(Colors.getSystemColor(shell.getDisplay(), SWT.COLOR_YELLOW));
            // Font font = getFontWithHeight(gc.getFont(), gc, 20, SWT.BOLD);
            // gc.setFont(font);
            // GCStringPrinter.printString(gc, Constants.AZUREUS_VERSION,
            // new Rectangle(0, 0, 128, 128), false, false, SWT.CENTER
            // | SWT.BOTTOM);
            // gc.dispose();
            // font.dispose();
            }
        }
        shell.setImage(icon128);
        return;
    }
    try {
        if (shellIcons == null) {
            String[] shellIconNames;
            if (Constants.isWindows) {
                // Windows, SWT sets ICON_SMALL (used for titlebar) and ICON_BIG
                // (used for alt-tab).  It doesn't pick the best size for ICON_SMALL
                float ratio = getScaleRatio();
                if (ratio <= 1) {
                    shellIconNames = new String[] { "logo16", "logo128" };
                } else if (ratio <= 2) {
                    shellIconNames = new String[] { "logo32", "logo128" };
                }
                if (ratio <= 4) {
                    shellIconNames = new String[] { "logo64", "logo128" };
                } else {
                    shellIconNames = new String[] { "logo128", "logo128" };
                }
            } else {
                shellIconNames = new String[] { "logo16", "logo32", "logo64", "logo128" };
            }
            ArrayList<Image> listShellIcons = new ArrayList<>(shellIconNames.length);
            ImageLoader imageLoader = ImageLoader.getInstance();
            for (int i = 0; i < shellIconNames.length; i++) {
                // never release images since they are always used and stored
                // in an array
                Image image = imageLoader.getImage(shellIconNames[i]);
                if (ImageLoader.isRealImage(image)) {
                    listShellIcons.add(image);
                }
            }
            shellIcons = listShellIcons.toArray(new Image[listShellIcons.size()]);
        }
        shell.setImages(shellIcons);
    } catch (NoSuchMethodError e) {
    // SWT < 3.0
    }
}
Also used : ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader)

Example 29 with ImageLoader

use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.

the class ColumnSubscriptionName method cellPaint.

@Override
public void cellPaint(GC gc, TableCellSWT cell) {
    Rectangle bounds = cell.getBounds();
    ImageLoader imageLoader = ImageLoader.getInstance();
    Image viewImage = imageLoader.getImage("ic_view");
    if (imageWidth == -1 || imageHeight == -1) {
        imageWidth = viewImage.getBounds().width;
        imageHeight = viewImage.getBounds().height;
    }
    bounds.width -= (imageWidth + 5);
    GCStringPrinter.printString(gc, cell.getSortValue().toString(), bounds, true, false, SWT.LEFT);
    Subscription sub = (Subscription) cell.getDataSource();
    if (sub != null && !sub.isSearchTemplate()) {
        gc.drawImage(viewImage, bounds.x + bounds.width, bounds.y + bounds.height / 2 - imageHeight / 2);
    }
    imageLoader.releaseImage("ic_view");
// gc.drawText(cell.getText(), bounds.x,bounds.y);
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle) ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader) Image(org.eclipse.swt.graphics.Image) Subscription(com.biglybt.core.subs.Subscription)

Example 30 with ImageLoader

use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.

the class SBC_SearchResultsView method skinObjectInitialShow.

public Object skinObjectInitialShow(SWTSkinObject skinObject, Object params) {
    image_loader = new ImageLoader(null, null);
    CoreFactory.addCoreRunningListener(new CoreRunningListener() {

        @Override
        public void coreRunning(Core core) {
            initColumns(core);
        }
    });
    SWTSkinObjectTextbox soFilterBox = (SWTSkinObjectTextbox) getSkinObject("filterbox");
    if (soFilterBox != null) {
        txtFilter = soFilterBox.getTextControl();
    }
    if (vitality_images == null) {
        ImageLoader loader = ImageLoader.getInstance();
        vitality_images = loader.getImages("image.sidebar.vitality.dots");
        ok_image = loader.getImage("tick_mark");
        fail_image = loader.getImage("progress_cancel");
        auth_image = loader.getImage("image.sidebar.vitality.auth");
    }
    final SWTSkinObject soFilterArea = getSkinObject("filterarea");
    if (soFilterArea != null) {
        SWTSkinObjectToggle soFilterButton = (SWTSkinObjectToggle) getSkinObject("filter-button");
        if (soFilterButton != null) {
            boolean toggled = COConfigurationManager.getBooleanParameter("Search View Filter Options Expanded", false);
            if (toggled) {
                soFilterButton.setToggled(true);
                soFilterArea.setVisible(true);
            }
            soFilterButton.addSelectionListener(new SWTSkinToggleListener() {

                @Override
                public void toggleChanged(SWTSkinObjectToggle so, boolean toggled) {
                    COConfigurationManager.setParameter("Search View Filter Options Expanded", toggled);
                    soFilterArea.setVisible(toggled);
                    Utils.relayout(soFilterArea.getControl().getParent());
                }
            });
        }
        Composite parent = (Composite) soFilterArea.getControl();
        Composite filter_area = new Composite(parent, SWT.NONE);
        FormData fd = Utils.getFilledFormData();
        filter_area.setLayoutData(fd);
        GridLayout layout = new GridLayout();
        layout.marginBottom = layout.marginTop = layout.marginLeft = layout.marginRight = 0;
        filter_area.setLayout(layout);
        Label label;
        int sepHeight = 20;
        Composite cRow = new Composite(filter_area, SWT.NONE);
        cRow.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        RowLayout rowLayout = new RowLayout(SWT.HORIZONTAL);
        rowLayout.spacing = 5;
        rowLayout.marginBottom = rowLayout.marginTop = rowLayout.marginLeft = rowLayout.marginRight = 0;
        rowLayout.center = true;
        cRow.setLayout(rowLayout);
        // with/without keywords
        ImageLoader imageLoader = ImageLoader.getInstance();
        for (int i = 0; i < 2; i++) {
            final boolean with = i == 0;
            if (!with) {
                label = new Label(cRow, SWT.VERTICAL | SWT.SEPARATOR);
                label.setLayoutData(new RowData(-1, sepHeight));
            }
            Composite cWithKW = new Composite(cRow, SWT.NONE);
            layout = new GridLayout(2, false);
            layout.marginWidth = 0;
            layout.marginBottom = layout.marginTop = layout.marginLeft = layout.marginRight = 0;
            cWithKW.setLayout(layout);
            // Label lblWithKW = new Label(cWithKW, SWT.NONE);
            // lblWithKW.setText(MessageText.getString(with?"SubscriptionResults.filter.with.words":"SubscriptionResults.filter.without.words"));
            Label lblWithKWImg = new Label(cWithKW, SWT.NONE);
            lblWithKWImg.setImage(imageLoader.getImage(with ? "icon_filter_plus" : "icon_filter_minus"));
            final Text textWidget = new Text(cWithKW, SWT.BORDER);
            if (with) {
                textWithKW = textWidget;
            } else {
                textWithoutKW = textWidget;
            }
            textWidget.setMessage(MessageText.getString(with ? "SubscriptionResults.filter.with.words" : "SubscriptionResults.filter.without.words"));
            GridData gd = new GridData();
            gd.widthHint = Utils.adjustPXForDPI(100);
            textWidget.setLayoutData(gd);
            textWidget.addModifyListener(new ModifyListener() {

                @Override
                public void modifyText(ModifyEvent e) {
                    String text = textWidget.getText().toLowerCase(Locale.US);
                    String[] bits = text.split("\\s+");
                    Set<String> temp = new HashSet<>();
                    for (String bit : bits) {
                        bit = bit.trim();
                        if (bit.length() > 0) {
                            temp.add(bit);
                        }
                    }
                    String[] words = temp.toArray(new String[temp.size()]);
                    synchronized (filter_lock) {
                        if (with) {
                            with_keywords = words;
                        } else {
                            without_keywords = words;
                        }
                    }
                    refilter_dispatcher.dispatch();
                }
            });
        }
        // min size
        label = new Label(cRow, SWT.VERTICAL | SWT.SEPARATOR);
        label.setLayoutData(new RowData(-1, sepHeight));
        Composite cMinSize = new Composite(cRow, SWT.NONE);
        layout = new GridLayout(2, false);
        layout.marginWidth = 0;
        layout.marginBottom = layout.marginTop = layout.marginLeft = layout.marginRight = 0;
        cMinSize.setLayout(layout);
        Label lblMinSize = new Label(cMinSize, SWT.NONE);
        lblMinSize.setText(MessageText.getString("SubscriptionResults.filter.min_size"));
        spinMinSize = new Spinner(cMinSize, SWT.BORDER);
        spinMinSize.setMinimum(0);
        // 100 TB should do...
        spinMinSize.setMaximum(100 * 1024 * 1024);
        spinMinSize.setSelection(minSize);
        spinMinSize.addListener(SWT.Selection, new Listener() {

            @Override
            public void handleEvent(Event event) {
                minSize = ((Spinner) event.widget).getSelection();
                refilter();
            }
        });
        // max size
        label = new Label(cRow, SWT.VERTICAL | SWT.SEPARATOR);
        label.setLayoutData(new RowData(-1, sepHeight));
        Composite cMaxSize = new Composite(cRow, SWT.NONE);
        layout = new GridLayout(2, false);
        layout.marginWidth = 0;
        layout.marginBottom = layout.marginTop = layout.marginLeft = layout.marginRight = 0;
        cMaxSize.setLayout(layout);
        Label lblMaxSize = new Label(cMaxSize, SWT.NONE);
        lblMaxSize.setText(MessageText.getString("SubscriptionResults.filter.max_size"));
        spinMaxSize = new Spinner(cMaxSize, SWT.BORDER);
        spinMaxSize.setMinimum(0);
        // 100 TB should do...
        spinMaxSize.setMaximum(100 * 1024 * 1024);
        spinMaxSize.setSelection(maxSize);
        spinMaxSize.addListener(SWT.Selection, new Listener() {

            @Override
            public void handleEvent(Event event) {
                maxSize = ((Spinner) event.widget).getSelection();
                refilter();
            }
        });
        engine_area = new Composite(filter_area, SWT.NONE);
        engine_area.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        buildEngineArea(null);
        parent.layout(true);
    }
    return null;
}
Also used : VuzeMessageBoxListener(com.biglybt.ui.swt.views.skin.VuzeMessageBoxListener) UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) SWTSkinCheckboxListener(com.biglybt.ui.swt.skin.SWTSkinCheckboxListener) ImageDownloaderListener(com.biglybt.ui.swt.imageloader.ImageLoader.ImageDownloaderListener) TableViewSWTMenuFillListener(com.biglybt.ui.swt.views.table.TableViewSWTMenuFillListener) ResultListener(com.biglybt.core.metasearch.ResultListener) TableColumnCreationListener(com.biglybt.pif.ui.tables.TableColumnCreationListener) Listener(org.eclipse.swt.widgets.Listener) SWTSkinToggleListener(com.biglybt.ui.swt.skin.SWTSkinToggleListener) CoreRunningListener(com.biglybt.core.CoreRunningListener) MetaSearchListener(com.biglybt.core.metasearch.MetaSearchListener) SWTSkinObjectToggle(com.biglybt.ui.swt.skin.SWTSkinObjectToggle) Spinner(org.eclipse.swt.widgets.Spinner) Label(org.eclipse.swt.widgets.Label) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) GridLayout(org.eclipse.swt.layout.GridLayout) RowData(org.eclipse.swt.layout.RowData) SWTSkinObjectTextbox(com.biglybt.ui.swt.skin.SWTSkinObjectTextbox) RowLayout(org.eclipse.swt.layout.RowLayout) CoreRunningListener(com.biglybt.core.CoreRunningListener) SWTSkinToggleListener(com.biglybt.ui.swt.skin.SWTSkinToggleListener) Core(com.biglybt.core.Core) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) Text(org.eclipse.swt.widgets.Text) MessageText(com.biglybt.core.internat.MessageText) SWTSkinObjectText(com.biglybt.ui.swt.skin.SWTSkinObjectText) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader)

Aggregations

ImageLoader (com.biglybt.ui.swt.imageloader.ImageLoader)71 Image (org.eclipse.swt.graphics.Image)18 GridData (org.eclipse.swt.layout.GridData)14 GridLayout (org.eclipse.swt.layout.GridLayout)14 CoreRunningListener (com.biglybt.core.CoreRunningListener)5 MessageText (com.biglybt.core.internat.MessageText)5 AERunnable (com.biglybt.core.util.AERunnable)5 UserPrompterResultListener (com.biglybt.ui.UserPrompterResultListener)5 ArrayList (java.util.ArrayList)5 Rectangle (org.eclipse.swt.graphics.Rectangle)5 Core (com.biglybt.core.Core)4 LinkLabel (com.biglybt.ui.swt.components.LinkLabel)4 MessageBoxShell (com.biglybt.ui.swt.shells.MessageBoxShell)4 File (java.io.File)4 DisposeEvent (org.eclipse.swt.events.DisposeEvent)4 DisposeListener (org.eclipse.swt.events.DisposeListener)4 MouseAdapter (org.eclipse.swt.events.MouseAdapter)4 MouseEvent (org.eclipse.swt.events.MouseEvent)4 FormData (org.eclipse.swt.layout.FormData)4 TableColumnCreationListener (com.biglybt.pif.ui.tables.TableColumnCreationListener)3