use of com.biglybt.ui.swt.debug.ObfuscateImage in project BiglyBT by BiglySoftware.
the class SWTSkinObjectContainer method obfuscatedImage.
// @see SWTSkinObjectBasic#obfuscatedImage(org.eclipse.swt.graphics.Image, org.eclipse.swt.graphics.Point)
@Override
public Image obfuscatedImage(Image image) {
if (!isVisible()) {
return image;
}
if (getSkinView() instanceof ObfuscateImage) {
image = ((ObfuscateImage) getSkinView()).obfuscatedImage(image);
}
Control[] swtChildren = ((Composite) control).getChildren();
for (int i = 0; i < swtChildren.length; i++) {
Control childControl = swtChildren[i];
SWTSkinObject so = (SWTSkinObject) childControl.getData("SkinObject");
if (so instanceof ObfuscateImage) {
ObfuscateImage oi = (ObfuscateImage) so;
oi.obfuscatedImage(image);
} else if (so == null) {
ObfuscateImage oi = (ObfuscateImage) childControl.getData("ObfuscateImage");
if (oi != null) {
oi.obfuscatedImage(image);
continue;
}
if (childControl instanceof Composite) {
obfuscatedImage((Composite) childControl, image);
}
}
}
return super.obfuscatedImage(image);
}
use of com.biglybt.ui.swt.debug.ObfuscateImage in project BiglyBT by BiglySoftware.
the class TabbedMDI method obfuscatedImage.
// @see com.biglybt.ui.swt.debug.ObfuscateImage#obfuscatedImage(org.eclipse.swt.graphics.Image)
@Override
public Image obfuscatedImage(Image image) {
MdiEntry[] entries = getEntries();
for (MdiEntry entry : entries) {
if (entry instanceof ObfuscateImage) {
ObfuscateImage oi = (ObfuscateImage) entry;
image = oi.obfuscatedImage(image);
}
}
return image;
}
use of com.biglybt.ui.swt.debug.ObfuscateImage in project BiglyBT by BiglySoftware.
the class UISWTViewImpl method triggerBooleanEvent.
private boolean triggerBooleanEvent(int eventType, Object data) {
if (DEBUG_TRIGGERS) {
if (eventListener == null || eventType != UISWTViewEvent.TYPE_REFRESH) {
System.out.println(System.currentTimeMillis() + "." + padRight(id, 20) + "] " + "trigger " + padRight((eventType < UISWTViewEvent.DEBUG_TYPES.length ? UISWTViewEvent.DEBUG_TYPES[eventType] : "" + eventType), 6) + ", " + (eventListener == null ? "null" : "nonn") + ";data=" + (data instanceof Object[] ? Arrays.toString((Object[]) data) : data) + "/ds=" + (datasource instanceof Object[] ? Arrays.toString((Object[]) datasource) : datasource) + ";" + title + ";" + Debug.getCompressedStackTrace());
}
}
if (eventType == UISWTViewEvent.TYPE_LANGUAGEUPDATE) {
// put it back to how it was constructed
this.titleID = CFG_PREFIX + this.id + ".title";
if (!MessageText.keyExists(titleID) && MessageText.keyExists(this.id)) {
this.titleID = id;
} else if (id.contains(" ")) {
// hack to fix HD Video Player which is using the expanded name as the id at the moment :(
this.titleID = "!" + id + "!";
}
title = null;
if (setTitleID != null) {
setTitleID(setTitleID);
}
if (setTitle != null) {
setTitle(setTitle);
}
refreshTitle();
Messages.updateLanguageForControl(getComposite());
}
if (eventListener == null && eventType != UISWTViewEvent.TYPE_DATASOURCE_CHANGED) {
return false;
}
if (eventType == UISWTViewEvent.TYPE_INITIALIZE) {
if (haveSentInitialize) {
if (DEBUG_TRIGGERS) {
System.out.println(" -> already haveSentInitialize");
}
return false;
}
if (!created) {
// create will set DS changed
triggerBooleanEvent(UISWTViewEvent.TYPE_CREATE, this);
} else if (datasource != null) {
triggerBooleanEvent(UISWTViewEvent.TYPE_DATASOURCE_CHANGED, datasource);
}
haveSentInitialize = true;
}
if (eventType == UISWTViewEvent.TYPE_CREATE) {
created = true;
}
if (delayInitializeToFirstActivate && eventType == UISWTViewEvent.TYPE_FOCUSGAINED && !haveSentInitialize) {
swt_triggerInitialize();
}
// prevent double fire of focus gained/lost
if (eventType == UISWTViewEvent.TYPE_FOCUSGAINED && hasFocus != null && hasFocus) {
if (DEBUG_TRIGGERS) {
System.out.println(" -> already hasFocus");
}
return true;
}
if (eventType == UISWTViewEvent.TYPE_FOCUSLOST && hasFocus != null && !hasFocus) {
if (DEBUG_TRIGGERS) {
System.out.println(" -> already !hasFocus");
}
return true;
}
if (eventType == UISWTViewEvent.TYPE_DATASOURCE_CHANGED) {
Object newDataSource = PluginCoreUtils.convert(data, true);
if (datasource == newDataSource) {
if (DEBUG_TRIGGERS) {
System.out.println(" -> same DS, skip");
}
return true;
}
if (newDataSource instanceof Object[] && datasource instanceof Object[]) {
if (Arrays.equals((Object[]) newDataSource, (Object[]) datasource)) {
if (DEBUG_TRIGGERS) {
System.out.println(" -> same DS[], skip");
}
return true;
}
}
datasource = newDataSource;
data = PluginCoreUtils.convert(datasource, useCoreDataSource);
if (initialDatasource == null) {
initialDatasource = datasource;
} else if (datasource == null) {
// explicit clearing of datasource - we need to forget the initial one as it will be
// re-instated incorrectly if the view is subsequently switched to. This was happening in sub-tabs
// when a download was selected, then deselected (ctrl+click) - the active sub-tab view was cleared
// but the other ones still remembered the selection when switched to
initialDatasource = null;
}
if (eventListener == null) {
return true;
}
// TODO: What about triggering skinObject's EVENT_DATASOURCE_CHANGED?
} else if (eventType == UISWTViewEvent.TYPE_OBFUSCATE && (eventListener instanceof ObfuscateImage)) {
if (data instanceof Map) {
((ObfuscateImage) eventListener).obfuscatedImage((Image) MapUtils.getMapObject((Map<?, ?>) data, "image", null, Image.class));
}
} else if (eventType == UISWTViewEvent.TYPE_FOCUSGAINED) {
hasFocus = true;
if (!haveSentInitialize) {
swt_triggerInitialize();
}
} else if (eventType == UISWTViewEvent.TYPE_FOCUSLOST) {
hasFocus = false;
if (isDestroyOnDeactivate()) {
triggerEvent(UISWTViewEvent.TYPE_DESTROY, null);
}
} else if (eventType == UISWTViewEvent.TYPE_DESTROY) {
if (hasFocus != null && hasFocus) {
triggerEvent(UISWTViewEvent.TYPE_FOCUSLOST, null);
}
// focus lost may have destroyed us already
if (!created && !haveSentInitialize && getComposite() == null) {
return true;
}
}
boolean result = false;
try {
result = eventListener.eventOccurred(new UISWTViewEventImpl(parentViewID, this, eventType, data));
} catch (Throwable t) {
Debug.out("ViewID=" + id + "; EventID=" + UISWTViewEvent.DEBUG_TYPES[eventType] + "; data=" + data, t);
// throw (new UIRuntimeException("UISWTView.triggerEvent:: ViewID="
// + sViewID + "; EventID=" + eventType + "; data=" + data, t));
}
if (eventType == UISWTViewEvent.TYPE_DESTROY) {
if (masterComposite != null && !masterComposite.isDisposed()) {
Composite parent = masterComposite.getParent();
Utils.disposeComposite(masterComposite);
Utils.relayoutUp(parent);
}
masterComposite = null;
composite = null;
haveSentInitialize = false;
hasFocus = false;
created = false;
initialDatasource = datasource;
datasource = null;
} else if (eventType == UISWTViewEvent.TYPE_CREATE) {
if (eventListener instanceof UISWTViewEventListenerHolder) {
UISWTViewEventListenerHolder h = (UISWTViewEventListenerHolder) eventListener;
UISWTViewEventListener delegatedEventListener = h.getDelegatedEventListener(this);
if (delegatedEventListener != null) {
try {
setEventListener(delegatedEventListener, false);
} catch (UISWTViewEventCancelledException e) {
}
}
}
if (DEBUG_TRIGGERS) {
System.out.println(" -> raw DS Change");
}
triggerEventRaw(UISWTViewEvent.TYPE_DATASOURCE_CHANGED, PluginCoreUtils.convert(datasource, useCoreDataSource));
}
return result;
}
use of com.biglybt.ui.swt.debug.ObfuscateImage in project BiglyBT by BiglySoftware.
the class TabbedEntry method obfuscatedImage.
// @see com.biglybt.ui.swt.debug.ObfuscateImage#obfuscatedImage(org.eclipse.swt.graphics.Image)
@Override
public Image obfuscatedImage(Image image) {
Rectangle bounds = swtItem == null ? null : swtItem.getBounds();
if (bounds != null) {
boolean isActive = swtItem.getParent().getSelection() == swtItem;
boolean isHeaderVisible = swtItem.isShowing();
Point location = Utils.getLocationRelativeToShell(swtItem.getParent());
bounds.x += location.x;
bounds.y += location.y;
Map<String, Object> map = new HashMap<>();
map.put("image", image);
map.put("obfuscateTitle", false);
if (isActive) {
triggerEvent(UISWTViewEvent.TYPE_OBFUSCATE, map);
if (viewTitleInfo instanceof ObfuscateImage) {
((ObfuscateImage) viewTitleInfo).obfuscatedImage(image);
}
}
if (isHeaderVisible) {
if (viewTitleInfo instanceof ObfuscateTab) {
String header = ((ObfuscateTab) viewTitleInfo).getObfuscatedHeader();
if (header != null) {
UIDebugGenerator.obfuscateArea(image, bounds, header);
}
}
if (MapUtils.getMapBoolean(map, "obfuscateTitle", false)) {
UIDebugGenerator.obfuscateArea(image, bounds);
}
}
}
return image;
}
use of com.biglybt.ui.swt.debug.ObfuscateImage in project BiglyBT by BiglySoftware.
the class MainWindowImpl method attachSearchBox.
/**
* @param skinObject
*/
private void attachSearchBox(SWTSkinObject skinObject) {
Composite cArea = (Composite) skinObject.getControl();
if (Utils.isGTK3) {
// TextBox on GTK3/SWT will expand box to fit it's hugeness
// Workaround by creating a composite in a fixed height composite
// (Yes, both are needed..)
FormData filledFormData;
Composite c1 = new Composite(cArea, SWT.NONE);
filledFormData = Utils.getFilledFormData();
filledFormData.height = 24;
filledFormData.bottom = null;
c1.setLayoutData(filledFormData);
c1.setLayout(new FormLayout());
Composite c2 = new Composite(c1, SWT.NONE);
c2.setLayout(new FormLayout());
filledFormData = Utils.getFilledFormData();
c2.setLayoutData(filledFormData);
cArea = c2;
}
final Text text = new Text(cArea, SWT.NONE);
text.setMessage(MessageText.getString("v3.MainWindow.search.defaultText"));
FormData filledFormData = Utils.getFilledFormData();
text.setLayoutData(filledFormData);
text.setData("ObfuscateImage", new ObfuscateImage() {
@Override
public Image obfuscatedImage(Image image) {
Point location = Utils.getLocationRelativeToShell(text);
Point size = text.getSize();
UIDebugGenerator.obfuscateArea(image, new Rectangle(location.x, location.y, size.x, size.y));
return image;
}
});
text.addListener(SWT.Resize, new Listener() {
Font lastFont = null;
int lastHeight = -1;
@Override
public void handleEvent(Event event) {
Text text = (Text) event.widget;
int h = text.getClientArea().height - 2;
if (Utils.isGTK3) {
// GTK3 has border included in clientArea
h -= 5;
} else if (Utils.isGTK && h > 18) {
h = 18;
}
if (h == lastHeight) {
return;
}
lastHeight = h;
Font font = FontUtils.getFontWithHeight(text.getFont(), null, h);
if (font != null) {
text.setFont(font);
if (lastFont == null) {
text.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
Text text = (Text) e.widget;
text.setFont(null);
Utils.disposeSWTObjects(lastFont);
}
});
} else {
Utils.disposeSWTObjects(lastFont);
}
lastFont = font;
}
}
});
// URIs can get pretty long...
text.setTextLimit(2048);
if (Constants.isWindows) {
text.addListener(SWT.MouseDown, new Listener() {
@Override
public void handleEvent(Event event) {
if (event.count == 3) {
text.selectAll();
}
}
});
}
String tooltip = MessageText.getString("v3.MainWindow.search.tooltip");
text.setToolTipText(tooltip);
SWTSkinProperties properties = skinObject.getProperties();
Color colorSearchTextBG = properties.getColor("color.search.text.bg");
Color colorSearchTextFG = properties.getColor("color.search.text.fg");
if (colorSearchTextBG != null) {
text.setBackground(colorSearchTextBG);
}
final TextWithHistory twh = new TextWithHistory("mainwindow.search.history", text);
text.addKeyListener(new KeyListener() {
@Override
public void keyPressed(KeyEvent e) {
int key = e.character;
if (e.stateMask == SWT.MOD1) {
if (key <= 26 && key > 0) {
key += 'a' - 1;
}
if (key == 'a') {
text.selectAll();
}
}
}
@Override
public void keyReleased(KeyEvent arg0) {
// TODO Auto-generated method stub
}
});
text.addListener(SWT.KeyDown, new Listener() {
@Override
public void handleEvent(Event event) {
Text text = (Text) event.widget;
if (event.keyCode == SWT.ESC) {
text.setText("");
return;
}
if (event.character == SWT.CR || event.keyCode == SWT.KEYPAD_CR) {
if (event.doit) {
String expression = text.getText();
uiFunctions.doSearch(expression);
twh.addHistory(expression);
}
}
}
});
SWTSkinObject searchGo = skin.getSkinObject("search-go");
if (searchGo != null) {
SWTSkinButtonUtility btnGo = new SWTSkinButtonUtility(searchGo);
btnGo.addSelectionListener(new ButtonListenerAdapter() {
@Override
public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
String sSearchText = text.getText().trim();
uiFunctions.doSearch(sSearchText);
twh.addHistory(sSearchText);
}
});
}
SWTSkinObject so = skin.getSkinObject("search-dropdown");
if (so != null) {
SWTSkinButtonUtility btnSearchDD = new SWTSkinButtonUtility(so);
btnSearchDD.setTooltipID("v3.MainWindow.search.tooltip");
btnSearchDD.addSelectionListener(new ButtonListenerAdapter() {
@Override
public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int button, int stateMask) {
if (button == 1) {
String sSearchText = text.getText().trim();
uiFunctions.doSearch(sSearchText);
twh.addHistory(sSearchText);
}
}
});
}
}
Aggregations