Compile Time Changes

Searchable dropdown popup.

There are two parameters that are affecting this search function in constructor of DropDownTreeView which are searchable and searchThreshold.

  • searchable, the search function will only be enabled if true is passed in, won't be enabled otherwise.
  • searchThreshold, the search function will only be enabled if the count of TreeViewItem in this drop down is larger than the threshold, won't be enabled otherwise.
public class DropDownTreeView extends BasicTreeView {
    public constructor(Window parent,
               ...
		       bool searchable=false, // Added flag to control the search. 
		       int searchThreshold=10, // Threshold when to start the search.
               ...

Added method enableSearch() in 14.0 to DropDownTreeViewPopup, which can be used to toggle search window.

    /**
     * Enable search field.
     */
    extend public void enableSearch(bool searchable=true, int searchThreshold=10) {
	    this.searchable = searchable;
	    if (searchable) {
	        this.searchThreshold = searchThreshold;
	        searchField = defaultSearchField();
	    }
    }

New function to load DIB image from MemoryStream.

There was previously no way to load DIB images from a stream, which forced the developer to first write the image to file and then loading with the URL. Now that shouldn't be a problem anymore with this new function.

/**
 * Load the stream of a jpg or png image to DibImage.
 * 
 * stream       - The sequence of bytes that holds the image, it
 *                should be formatted as a jpg or png file.
 * inlineStream - Write the URL to the image object?
 * props        - The properties on how to read the image.
 *                The stream can be formatted in many ways, this
 *		  object tells the reader how to interpret the data.
 * use          - Is the image going to be used after the current thread
 *                has run its course? Then you should set this to true.
 */
public DibImage dibImage(Stream stream, bool inlineStream=false,
			 ReadImageProps props=dibImageProps,
			 bool use=false) {

    if (!stream) return null;

    if (!props.dibPadding) props = props + ReadImageProps(dibPadding=true);

    ReadImageResult readResult;
    try {
	lastLoadImageErrorCode = 0;
	readResult = imageMagick.read(stream.array,
				      byteCount=stream.count(),
				      pixels=true, blob=false,
				      props=props);

    } catch (OutOfMemory e) {
	lastLoadImageErrorCode = 3;
	return null;
    } catch (Exception e) {
	lastLoadImageErrorCode = 4;
	return null;
    }

    if (!readResult) return null;

    // Not including this test as we still need to read the stream to know the pixel count,
    // so we've already paid the price to performance if we have a gigantic image
    //if (imageAreaLimit > 0 and fileReadable and url.imageSize.area() > imageAreaLimit) throw ImageTooBigException();

    Dib dib();
    if (createDibImageFromDibBytes(readResult.pixels.array,
				   readResult.size.w, readResult.size.h,
				   readResult.channels, dib)) {
	DibImage image(alpha=props.alpha);
	
	image.dib = dib;

	if (!inlineStream) image.file = stream.path;
	
	image.setSize(image.dib.size);
	image.bitDepth = image.dib.bitDepth();
	
	if (use) image.use();
	return image;
    }
    
    return null;
}

Runtime/Behavior Changes

PaneTreeNode

Nullcheck in PaneTreeNode.toS() preventing access violation.

Loading icons behavior changed in developMode to reflect releaseMode.

If the directory path used to access icons from file didn't have '/' at the end they would appear to work in developMode, but fail in releaseMode. They now fail in developMode as well, to prevent surprises at build.

/**
 * Put icon database finder extension directory if necessary.
 * 
 * k   - Key differentiating icons of different systems.
 *       Typically this is the package of the extension
 *	 that is registering a directory.
 * dir - Path where icons are located.
 *       Typically this looks something like
 *	 "custom/extension-name/res/images/".
 *	 
 *	 NOTE: The directory must end with "/" or it isn't
 *	 going to work in releaseMode.
 */
public void putIconDbExtensionDir(symbol k, str dir) {
    if (k !in iconDB) {

	// This will make the behavior like releaseMode.
	if (developMode and !dir.endsWith('/')) return;

	Url[] locations = cmInstalledAll(dir);
	if (locations.any) {
	    for (l in locations) {
	} else {
	    iconDB.finder(k, cmNative(dir));
	}
	
	//Url completeDir = iconDbExtensionDir(dir);
	//iconDB.finder(k, completeDir);
    }
}