Base class for all drawables
solid borders (may be of different width) and, optionally, solid inner area
decoded raster images cache (png, jpeg) -- access by filenames
Custom drawing inside openGL
Drawable which is drawn depending on state (see http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList)
Text image drawable. Resource file extension: .tim Image format is JSON based. Sample: { text: [ "╔═╗", "║ ║", "╚═╝"], backgroundColor: [0x000080], textColor: [0xFF0000], ninepatch: [1,1,1,1] }
embed all resources from list
embed all resources from list
converts XML attribute name to State (see http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList)
load resource bytes from embedded resource or file
split string into lines, autodetect line endings
drawable cache singleton
drawable cache singleton
image cache singleton
image cache singleton
decode solid color / gradient / frame drawable from string like #AARRGGBB, e.g. #5599AA
Sample format: { text: [ "╔═╗", "║ ║", "╚═╝"], backgroundColor: [0x000080], // put more values for individual colors of cells textColor: [0xFF0000], // put more values for individual colors of cells ninepatch: [1,1,1,1] }
decode size string, e.g. 1px or 2 or 3pt
filename prefix for embedded resources
When your application uses custom resources, you can embed resources into executable and/or specify external resource directory(s).
To embed resources, put them into views/res directory, and create file views/resources.list with list of all files to embed.
Use following code to embed resources:
/// entry point for dlangui based application extern (C) int UIAppMain(string[] args) { // embed non-standard resources listed in views/resources.list into executable embeddedResourceList.addResources(embedResourcesFromList!("resources.list")()); ...
Resource list resources.list file may look similar to following:
res/i18n/en.ini res/i18n/ru.ini res/mdpi/cr3_logo.png res/mdpi/document-open.png res/mdpi/document-properties.png res/mdpi/document-save.png res/mdpi/edit-copy.png res/mdpi/edit-paste.png res/mdpi/edit-undo.png res/mdpi/tx_fabric.jpg res/theme_custom1.xml
As well you can specify list of external directories to get resources from.
/// entry point for dlangui based application extern (C) int UIAppMain(string[] args) { // resource directory search paths string[] resourceDirs = [ appendPath(exePath, "../../../res/"), // for Visual D and DUB builds appendPath(exePath, "../../../res/mdpi/"), // for Visual D and DUB builds appendPath(exePath, "../../../../res/"),// for Mono-D builds appendPath(exePath, "../../../../res/mdpi/"),// for Mono-D builds appendPath(exePath, "res/"), // when res dir is located at the same directory as executable appendPath(exePath, "../res/"), // when res dir is located at project directory appendPath(exePath, "../../res/"), // when res dir is located at the same directory as executable appendPath(exePath, "res/mdpi/"), // when res dir is located at the same directory as executable appendPath(exePath, "../res/mdpi/"), // when res dir is located at project directory appendPath(exePath, "../../res/mdpi/") // when res dir is located at the same directory as executable ]; // setup resource directories - will use only existing directories Platform.instance.resourceDirs = resourceDirs;
When same file exists in both embedded and external resources, one from external resource directory will be used - it's useful for developing and testing of resources.
Synopsis:
import dlangui.graphics.resources; // embed non-standard resources listed in views/resources.list into executable embeddedResourceList.addResources(embedResourcesFromList!("resources.list")());
Boost License 1.0
Vadim Lopatin, 2014
This module contains resource management and drawables implementation.
imageCache is RAM cache of decoded images (as DrawBuf).
drawableCache is cache of Drawables.
Supports nine-patch PNG images in .9.png files (like in Android).
Supports state drawables using XML files similar to ones in Android.