Search in sources :

Example 11 with SWTSkinObject

use of com.biglybt.ui.swt.skin.SWTSkinObject in project BiglyBT by BiglySoftware.

the class SBC_DevicesView method setAdditionalInfoTitle.

/**
 * @param newVisibility
 *
 * @since 4.1.0.5
 */
protected void setAdditionalInfoTitle(boolean newVisibility) {
    SWTSkinObject soArea = getSkinObject("advinfo-area");
    if (soArea != null) {
        soArea.setVisible(newVisibility);
    }
    SWTSkinObject soText = getSkinObject("advinfo-title");
    if (soText instanceof SWTSkinObjectText) {
        String s = (newVisibility ? "[-]" : "[+]");
        if (device != null) {
            s += "Additional Device Info and Settings";
        } else {
            s += "General Options";
        }
        ((SWTSkinObjectText) soText).setText(s);
    }
}
Also used : SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) SWTSkinObjectText(com.biglybt.ui.swt.skin.SWTSkinObjectText)

Example 12 with SWTSkinObject

use of com.biglybt.ui.swt.skin.SWTSkinObject in project BiglyBT by BiglySoftware.

the class SBC_DevicesView method skinObjectShown.

// @see SkinView#skinObjectShown(SWTSkinObject, java.lang.Object)
@Override
public Object skinObjectShown(SWTSkinObject skinObject, Object params) {
    super.skinObjectShown(skinObject, params);
    transcode_queue.addListener(this);
    if (transTarget != null) {
        transTarget.addListener(this);
    }
    SWTSkinObject soDeviceList = getSkinObject("device-list");
    if (soDeviceList != null) {
        initDeviceListTable((Composite) soDeviceList.getControl());
    }
    SWTSkinObject soTranscodeQueue = getSkinObject("transcode-queue");
    if (soTranscodeQueue != null) {
        initTranscodeQueueTable((Composite) soTranscodeQueue.getControl());
    }
    if (device != null) {
        device.addListener(this);
    }
    if (device instanceof TranscodeTarget) {
        createDragDrop(tvFiles != null ? tvFiles : tvDevices);
    }
    setAdditionalInfoTitle(false);
    // This is bad.  Example:
    // 1) Do a search
    // 2) Sidebar entry opens under Devices
    // 3) Close search sidebar
    // 4) Device entry gets auto-selected
    // 5) User gets ftux
    // 6) User says no, anger increases
    // 7) Go to 1
    // DevicesFTUX.ensureInstalled();
    updateSelectedContent();
    return null;
}
Also used : SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject)

Example 13 with SWTSkinObject

use of com.biglybt.ui.swt.skin.SWTSkinObject in project BiglyBT by BiglySoftware.

the class DeviceTemplateChooser method open.

public void open(DeviceTemplateClosedListener l) {
    this.listener = l;
    skinnedDialog = new SkinnedDialog("skin3_dlg_deviceadd_mfchooser", "shell", SWT.TITLE | SWT.BORDER);
    skinnedDialog.addCloseListener(new SkinnedDialogClosedListener() {

        @Override
        public void skinDialogClosed(SkinnedDialog dialog) {
            if (listener != null) {
                listener.deviceTemplateChooserClosed(selectedDeviceTemplate);
            }
        }
    });
    SWTSkin skin = skinnedDialog.getSkin();
    SWTSkinObject so = skin.getSkinObject("list");
    if (so instanceof SWTSkinObjectContainer) {
        SWTSkinObjectContainer soList = (SWTSkinObjectContainer) so;
        createDeviceTemplateList2(soList);
    }
    skinnedDialog.open();
}
Also used : SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) SkinnedDialog(com.biglybt.ui.swt.views.skin.SkinnedDialog) SkinnedDialogClosedListener(com.biglybt.ui.swt.views.skin.SkinnedDialog.SkinnedDialogClosedListener) SWTSkin(com.biglybt.ui.swt.skin.SWTSkin)

Example 14 with SWTSkinObject

use of com.biglybt.ui.swt.skin.SWTSkinObject in project BiglyBT by BiglySoftware.

the class UIDebugGenerator method generateObfuscatedImage.

public static Image generateObfuscatedImage(Shell shell) {
    // 3.2 TODO: Obfuscate! (esp advanced view)
    Rectangle shellBounds = shell.getBounds();
    Rectangle shellClientArea = shell.getClientArea();
    Display display = shell.getDisplay();
    if (display.isDisposed()) {
        return null;
    }
    Image fullImage = new Image(display, shellBounds.width, shellBounds.height);
    Image subImage = new Image(display, shellClientArea.width, shellClientArea.height);
    GC gc = new GC(display);
    try {
        gc.copyArea(fullImage, shellBounds.x, shellBounds.y);
    } finally {
        gc.dispose();
    }
    GC gcShell = new GC(shell);
    try {
        gcShell.copyArea(subImage, 0, 0);
    } finally {
        gcShell.dispose();
    }
    GC gcFullImage = new GC(fullImage);
    try {
        Point location = shell.toDisplay(0, 0);
        gcFullImage.drawImage(subImage, location.x - shellBounds.x, location.y - shellBounds.y);
    } finally {
        gcFullImage.dispose();
    }
    subImage.dispose();
    Control[] children = shell.getChildren();
    for (Control control : children) {
        SWTSkinObject so = (SWTSkinObject) control.getData("SkinObject");
        if (so instanceof ObfuscateImage) {
            ObfuscateImage oi = (ObfuscateImage) so;
            oi.obfuscatedImage(fullImage);
        }
    }
    Rectangle monitorClientArea = shell.getMonitor().getClientArea();
    Rectangle trimmedShellBounds = shellBounds.intersection(monitorClientArea);
    if (!trimmedShellBounds.equals(shellBounds)) {
        subImage = new Image(display, trimmedShellBounds.width, trimmedShellBounds.height);
        GC gcCrop = new GC(subImage);
        try {
            gcCrop.drawImage(fullImage, shellBounds.x - trimmedShellBounds.x, shellBounds.y - trimmedShellBounds.y);
        } finally {
            gcCrop.dispose();
            fullImage.dispose();
            fullImage = subImage;
        }
    }
    return fullImage;
}
Also used : SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject)

Example 15 with SWTSkinObject

use of com.biglybt.ui.swt.skin.SWTSkinObject in project BiglyBT by BiglySoftware.

the class MainMenuV3 method buildSimpleViewMenu.

/**
 * @param viewMenu
 *
 * @since 4.5.0.3
 */
private void buildSimpleViewMenu(final Menu viewMenu, int accelerator) {
    try {
        MenuFactory.addMenuItem(viewMenu, SWT.CHECK, PREFIX_V3 + ".view.sidebar", new Listener() {

            @Override
            public void handleEvent(Event event) {
                SideBar sidebar = (SideBar) SkinViewManager.getByClass(SideBar.class);
                if (sidebar != null) {
                    sidebar.flipSideBarVisibility();
                }
            }
        });
        if (COConfigurationManager.getIntParameter("User Mode") > 1) {
            SWTSkin skin = SWTSkinFactory.getInstance();
            SWTSkinObject plugin_bar = skin.getSkinObject(SkinConstants.VIEWID_PLUGINBAR);
            if (plugin_bar != null) {
                MenuItem mi = MainMenuV3.createViewMenuItem(skin, viewMenu, "v3.MainWindow.menu.view." + SkinConstants.VIEWID_PLUGINBAR, SkinConstants.VIEWID_PLUGINBAR + ".visible", SkinConstants.VIEWID_PLUGINBAR, true, -1);
                if (accelerator != -1 && mi.getAccelerator() == accelerator) {
                    Listener[] listeners = mi.getListeners(SWT.Selection);
                    for (Listener l : listeners) {
                        try {
                            l.handleEvent(null);
                        } catch (Throwable e) {
                        }
                    }
                }
            }
        }
        MenuFactory.addViewToolbarMenuItem(viewMenu);
        // ///////
        MenuItem itemStatusBar = MenuFactory.createTopLevelMenuItem(viewMenu, "v3.MainWindow.menu.view.statusbar");
        itemStatusBar.setText(itemStatusBar.getText());
        Menu menuStatusBar = itemStatusBar.getMenu();
        final String[] statusAreaLangs = { "ConfigView.section.style.status.show_sr", "ConfigView.section.style.status.show_nat", "ConfigView.section.style.status.show_ddb", "ConfigView.section.style.status.show_ipf" };
        final String[] statusAreaConfig = { "Status Area Show SR", "Status Area Show NAT", "Status Area Show DDB", "Status Area Show IPF" };
        for (int i = 0; i < statusAreaConfig.length; i++) {
            final String configID = statusAreaConfig[i];
            String langID = statusAreaLangs[i];
            final MenuItem item = new MenuItem(menuStatusBar, SWT.CHECK);
            Messages.setLanguageText(item, langID);
            item.addListener(SWT.Selection, new Listener() {

                @Override
                public void handleEvent(Event event) {
                    COConfigurationManager.setParameter(configID, !COConfigurationManager.getBooleanParameter(configID));
                }
            });
            menuStatusBar.addListener(SWT.Show, new Listener() {

                @Override
                public void handleEvent(Event event) {
                    item.setSelection(COConfigurationManager.getBooleanParameter(configID));
                }
            });
        }
        if (Constants.isWindows) {
            MenuFactory.addSeparatorMenuItem(viewMenu);
        }
        boolean needsSep = false;
        boolean enabled = COConfigurationManager.getBooleanParameter("Beta Programme Enabled");
        if (enabled) {
            MenuFactory.addMenuItem(viewMenu, SWT.CHECK, PREFIX_V2 + ".view.beta", new Listener() {

                @Override
                public void handleEvent(Event event) {
                    MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
                    if (mdi != null) {
                        mdi.showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_BETAPROGRAM);
                    }
                }
            });
            needsSep = true;
        }
        if (needsSep) {
            MenuFactory.addSeparatorMenuItem(viewMenu);
        }
        needsSep = PluginsMenuHelper.getInstance().buildViewMenu(viewMenu, viewMenu.getShell());
        if (COConfigurationManager.getBooleanParameter("Library.EnableSimpleView")) {
            if (needsSep) {
                MenuFactory.addSeparatorMenuItem(viewMenu);
            }
            // Ubuntu Unity (14.04) with SWT 4508 crashes when global View menu triggered as it appears
            // that radio menu items aren't supported
            // https://bugs.eclipse.org/bugs/show_bug.cgi?id=419729#c9
            int simple_advanced_menu_type = Constants.isLinux ? SWT.CHECK : SWT.RADIO;
            MenuFactory.addMenuItem(viewMenu, simple_advanced_menu_type, PREFIX_V3 + ".view.asSimpleList", new Listener() {

                @Override
                public void handleEvent(Event event) {
                    UIToolBarManager tb = UIToolBarManagerImpl.getInstance();
                    if (tb != null) {
                        UIToolBarItem item = tb.getToolBarItem("modeBig");
                        if (item != null) {
                            item.triggerToolBarItem(UIToolBarActivationListener.ACTIVATIONTYPE_NORMAL, SelectedContentManager.convertSelectedContentToObject(null));
                        }
                    }
                }
            });
            MenuFactory.addMenuItem(viewMenu, simple_advanced_menu_type, PREFIX_V3 + ".view.asAdvancedList", new Listener() {

                @Override
                public void handleEvent(Event event) {
                    UIToolBarManager tb = UIToolBarManagerImpl.getInstance();
                    if (tb != null) {
                        UIToolBarItem item = tb.getToolBarItem("modeSmall");
                        if (item != null) {
                            item.triggerToolBarItem(UIToolBarActivationListener.ACTIVATIONTYPE_NORMAL, SelectedContentManager.convertSelectedContentToObject(null));
                        }
                    }
                }
            });
        }
        viewMenu.addMenuListener(new MenuListener() {

            @Override
            public void menuShown(MenuEvent e) {
                MenuItem sidebarMenuItem = MenuFactory.findMenuItem(viewMenu, PREFIX_V3 + ".view.sidebar");
                if (sidebarMenuItem != null) {
                    MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
                    if (mdi != null) {
                        sidebarMenuItem.setSelection(mdi.isVisible());
                    }
                }
                if (COConfigurationManager.getBooleanParameter("Library.EnableSimpleView")) {
                    MenuItem itemShowAsSimple = MenuFactory.findMenuItem(viewMenu, PREFIX_V3 + ".view.asSimpleList");
                    if (itemShowAsSimple != null) {
                        UIToolBarManager tb = UIToolBarManagerImpl.getInstance();
                        if (tb != null) {
                            UIToolBarItem item = tb.getToolBarItem("modeBig");
                            long state = item == null ? 0 : item.getState();
                            itemShowAsSimple.setEnabled((state & UIToolBarItem.STATE_ENABLED) > 0);
                            itemShowAsSimple.setSelection((state & UIToolBarItem.STATE_DOWN) > 0);
                        }
                    }
                    MenuItem itemShowAsAdv = MenuFactory.findMenuItem(viewMenu, PREFIX_V3 + ".view.asAdvancedList");
                    if (itemShowAsAdv != null) {
                        UIToolBarManager tb = UIToolBarManagerImpl.getInstance();
                        if (tb != null) {
                            UIToolBarItem item = tb.getToolBarItem("modeSmall");
                            long state = item == null ? 0 : item.getState();
                            itemShowAsAdv.setEnabled((state & UIToolBarItem.STATE_ENABLED) > 0);
                            itemShowAsAdv.setSelection((state & UIToolBarItem.STATE_DOWN) > 0);
                        }
                    }
                }
            }

            @Override
            public void menuHidden(MenuEvent e) {
            }
        });
    } catch (Exception e) {
        Debug.out("Error creating View Menu", e);
    }
}
Also used : ParameterListener(com.biglybt.core.config.ParameterListener) UIToolBarActivationListener(com.biglybt.pif.ui.toolbar.UIToolBarActivationListener) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface) SWTSkin(com.biglybt.ui.swt.skin.SWTSkin) UIException(com.biglybt.pif.ui.UIException) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) UIToolBarManager(com.biglybt.pif.ui.toolbar.UIToolBarManager) IMainMenu(com.biglybt.ui.swt.mainwindow.IMainMenu) UIToolBarItem(com.biglybt.pif.ui.toolbar.UIToolBarItem) SideBar(com.biglybt.ui.swt.views.skin.sidebar.SideBar)

Aggregations

SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)53 SWTSkinObjectContainer (com.biglybt.ui.swt.skin.SWTSkinObjectContainer)15 GridLayout (org.eclipse.swt.layout.GridLayout)8 SWTSkinObjectListener (com.biglybt.ui.swt.skin.SWTSkinObjectListener)7 SWTSkinButtonUtility (com.biglybt.ui.swt.skin.SWTSkinButtonUtility)5 SWTSkinObjectText (com.biglybt.ui.swt.skin.SWTSkinObjectText)5 SWTSkinObjectTextbox (com.biglybt.ui.swt.skin.SWTSkinObjectTextbox)5 GridData (org.eclipse.swt.layout.GridData)5 CoreRunningListener (com.biglybt.core.CoreRunningListener)4 MultipleDocumentInterface (com.biglybt.ui.mdi.MultipleDocumentInterface)4 FormAttachment (org.eclipse.swt.layout.FormAttachment)4 FormData (org.eclipse.swt.layout.FormData)4 Core (com.biglybt.core.Core)3 ToolBarItem (com.biglybt.ui.common.ToolBarItem)3 UIUpdatable (com.biglybt.ui.common.updater.UIUpdatable)3 UIUpdater (com.biglybt.ui.common.updater.UIUpdater)3 MdiEntry (com.biglybt.ui.mdi.MdiEntry)3 PluginUISWTSkinObject (com.biglybt.ui.swt.pif.PluginUISWTSkinObject)3 Control (org.eclipse.swt.widgets.Control)3 ActivitiesEntry (com.biglybt.activities.ActivitiesEntry)2