Search in sources :

Example 1 with ToolBarItemSO

use of com.biglybt.ui.swt.toolbar.ToolBarItemSO in project BiglyBT by BiglySoftware.

the class ToolBarView method rebuild.

private void rebuild() {
    synchronized (itemMap) {
        if (rebuilding) {
            rebuild_pending = true;
            return;
        }
        rebuilding = true;
    }
    Utils.execSWTThread(() -> {
        synchronized (itemMap) {
            Set<String> groups = new HashSet<>();
            for (ToolBarItemSO so : itemMap.values()) {
                groups.add(so.getBase().getGroupID());
            }
            itemMap.clear();
            for (String group : groups) {
                SWTSkinObjectContainer groupSO = peekGroupSO(group);
                if (groupSO != null) {
                    SWTSkinObject[] children = groupSO.getChildren();
                    for (SWTSkinObject so : children) {
                        so.dispose();
                    }
                    groupSO.dispose();
                }
            }
        }
        Map<UIToolBarItem, ToolBarItemSO> newMap = new HashMap<>();
        try {
            skin.constructionStart();
            build(newMap);
        } finally {
            skin.constructionEnd();
        }
        Composite comp = (Composite) soMain.getControl();
        addMenus(comp);
        Utils.relayout(comp);
        synchronized (itemMap) {
            itemMap.putAll(newMap);
            rebuilding = false;
            if (rebuild_pending) {
                rebuild_pending = false;
                Utils.getOffOfSWTThread(() -> {
                    rebuild();
                });
            }
        }
    });
}
Also used : ToolBarItemSO(com.biglybt.ui.swt.toolbar.ToolBarItemSO) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) Composite(org.eclipse.swt.widgets.Composite)

Example 2 with ToolBarItemSO

use of com.biglybt.ui.swt.toolbar.ToolBarItemSO in project BiglyBT by BiglySoftware.

the class ToolBarView method createItemSO.

private void createItemSO(ToolBarItem item, String templatePrefix, int position) {
    ToolBarItemSO existingItemSO;
    synchronized (mapToolBarItemToSO) {
        existingItemSO = mapToolBarItemToSO.get(item);
    }
    if (existingItemSO != null) {
        SWTSkinObject so = existingItemSO.getSO();
        if (so != null) {
            so.dispose();
        }
    }
    String templateID = templatePrefix;
    if (position == SWT.RIGHT) {
        templateID += ".right";
    } else if (position == SWT.LEFT) {
        templateID += ".left";
    } else if (position == SWT.SINGLE) {
        templateID += ".lr";
    }
    Control attachToControl = getLastControl(item.getGroupID());
    String id = "toolbar:" + item.getID();
    SWTSkinObject so = skin.createSkinObject(id, templateID, getGroupSO(item.getGroupID()));
    if (so != null) {
        ToolBarItemSO itemSO;
        itemSO = new ToolBarItemSO((UIToolBarItemImpl) item, so);
        if (attachToControl != null) {
            FormData fd = (FormData) so.getControl().getLayoutData();
            fd.left = new FormAttachment(attachToControl);
        }
        initSO(so, itemSO);
        if (initComplete) {
            Utils.relayout(so.getControl().getParent());
        }
    }
}
Also used : FormData(org.eclipse.swt.layout.FormData) ToolBarItemSO(com.biglybt.ui.swt.toolbar.ToolBarItemSO) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) Control(org.eclipse.swt.widgets.Control) UIToolBarItemImpl(com.biglybt.ui.swt.pifimpl.UIToolBarItemImpl) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 3 with ToolBarItemSO

use of com.biglybt.ui.swt.toolbar.ToolBarItemSO in project BiglyBT by BiglySoftware.

the class ToolBarView method createItemSO.

private void createItemSO(Map<UIToolBarItem, ToolBarItemSO> newMap, ToolBarItem item, String templatePrefix, int position) {
    ToolBarItemSO existingItemSO = newMap.get(item);
    if (existingItemSO != null) {
        SWTSkinObject so = existingItemSO.getSO();
        if (so != null) {
            so.dispose();
        }
    }
    String templateID = templatePrefix;
    if (position == SWT.RIGHT) {
        templateID += ".right";
    } else if (position == SWT.LEFT) {
        templateID += ".left";
    } else if (position == SWT.SINGLE) {
        templateID += ".lr";
    }
    Control attachToControl = getLastControl(item.getGroupID());
    String id = "toolbar:" + item.getID();
    SWTSkinObject so = skin.createSkinObject(id, templateID, getGroupSO(item.getGroupID()));
    if (so != null) {
        ToolBarItemSO itemSO;
        itemSO = new ToolBarItemSO((UIToolBarItemImpl) item, so);
        if (attachToControl != null) {
            FormData fd = (FormData) so.getControl().getLayoutData();
            fd.left = new FormAttachment(attachToControl);
        }
        initSO(newMap, so, itemSO);
        if (initComplete) {
            Utils.relayout(so.getControl().getParent());
        }
    }
}
Also used : FormData(org.eclipse.swt.layout.FormData) ToolBarItemSO(com.biglybt.ui.swt.toolbar.ToolBarItemSO) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) Control(org.eclipse.swt.widgets.Control) UIToolBarItemImpl(com.biglybt.ui.swt.pifimpl.UIToolBarItemImpl) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Aggregations

SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)3 ToolBarItemSO (com.biglybt.ui.swt.toolbar.ToolBarItemSO)3 UIToolBarItemImpl (com.biglybt.ui.swt.pifimpl.UIToolBarItemImpl)2 FormAttachment (org.eclipse.swt.layout.FormAttachment)2 FormData (org.eclipse.swt.layout.FormData)2 Control (org.eclipse.swt.widgets.Control)2 SWTSkinObjectContainer (com.biglybt.ui.swt.skin.SWTSkinObjectContainer)1 Composite (org.eclipse.swt.widgets.Composite)1