Revision: 4742 http://sourceforge.net/p/vexi/code/4742 Author: mkpg2 Date: 2014-10-31 00:47:56 +0000 (Fri, 31 Oct 2014) Log Message: ----------- Support multiple icon resource roots 'iconpath'.
Modified Paths: -------------- branches/vexi3/org.vexi-vexi.icons/src_main/vexi/conf/icon.t branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/lib/layout/icon.t branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/lib/role/surface.t Modified: branches/vexi3/org.vexi-vexi.icons/src_main/vexi/conf/icon.t =================================================================== --- branches/vexi3/org.vexi-vexi.icons/src_main/vexi/conf/icon.t 2014-10-28 08:32:22 UTC (rev 4741) +++ branches/vexi3/org.vexi-vexi.icons/src_main/vexi/conf/icon.t 2014-10-31 00:47:56 UTC (rev 4742) @@ -1,5 +1,5 @@ <!-- provides the location to look for icons --> <vexi xmlns:ui="vexi://ui"> <ui:box /> - static.location = vexi..org.vexi.crystal; + static.iconpath = [vexi..org.vexi.crystal]; </vexi> \ No newline at end of file Modified: branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/lib/layout/icon.t =================================================================== --- branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/lib/layout/icon.t 2014-10-28 08:32:22 UTC (rev 4741) +++ branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/lib/layout/icon.t 2014-10-31 00:47:56 UTC (rev 4742) @@ -1,8 +1,9 @@ <!-- Copyright 2014 - see COPYING for details [LGPL] --> <vexi xmlns:ui="vexi://ui" - xmlns:icon="vexi.icon"> + xmlns:icon="vexi.icon"> + <ui:box shrink="true"> <ui:box id="size" align="bottomright" layout="layer"> <ui:box id="image" shrink="true" /> @@ -22,7 +23,7 @@ if (!trapee.size) { return; } - trapee[0][1].fill = v ? icon["icon"+(trapee.size/2)][v] : null; + trapee[0][1].fill = v ? static.getIcon("icon"+trapee.size, v) : null; } /** sets the icon's image to the specified resource */ @@ -37,13 +38,7 @@ if (!trapee.size) { return; } - if (v and !static["listicon"+trapee.size][v] and typeof(v)=="string") { - if (vexi.debug) { - vexi.trace(new vexi.js.Exception("icon not found: "+v+" ("+trapee.size+")")); - } - v = "blank"; - } - trapee[0][0].fill = v ? icon["icon"+trapee.size][v] : null; + trapee[0][0].fill = v ? static.getIcon("icon"+trapee.size, v) : null; } /** sets the size, in pixels, of this icon */ @@ -60,36 +55,48 @@ } } - //////// - // icon name caching + const icons = {}; - static.listicon32 = {}; - static.listicon16 = {}; - static.listicon8 = {}; + static.iconpath ++= function(v){ + cascade = v; + // done like this because we cannot test easily if an icon exists or not (no method for this, and threading issues + // which don't exist for listing) + for(var i,subkey in ["icon8", "icon16", "icon32"]){ + const submap = icons[subkey] = {}; + for(var j,l in static.iconpath){ + const lsub = l[subkey]; + for(var k in lsub){ + var d = k.indexOf('.'); + if (d==0) { + // skips hidden dirs e.g. .svn + continue; + } + if (d>=1) { + // image files should have an extension e.g. image.png + k = k.substring(0, d); + } + submap[k] = lsub[k]; + } + } + } + }; - for (var k in icon.icon32) { - var d = k.indexOf('.'); - if (d==0) { - // skips hidden dirs e.g. .svn - continue; - } - if (d>=1) { - // image files should have an extension e.g. image.png - k = k.substring(0, d); - } - listicon32[k] = true; - } + - for (var k in icon.icon16) { - var d = k.indexOf('.'); - if (d==0) { - // skips hidden dirs e.g. .svn - continue; + const list = function(subdir){ + var r = (keysof icons[subdir]).toArray(); + r.sort(); + return r; + }; + + static.getIcon = function(subdir, name){ + const key = subdir+"."+name; + var r = icons[subdir][name]; + if(!r){ + vexi.log.warn("[WARNING] icon not found: "+name+" ("+subdir+")\n"+list(subdir).join("\n ")); + r = icon[subdir]["blank"]; } - if (d>=1) { - k = k.substring(0, d); - } - listicon16[k] = true; - } - + return r; + }; + </vexi> Modified: branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/lib/role/surface.t =================================================================== --- branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/lib/role/surface.t 2014-10-28 08:32:22 UTC (rev 4741) +++ branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/lib/role/surface.t 2014-10-31 00:47:56 UTC (rev 4742) @@ -110,9 +110,10 @@ vexi.log.debug("using theme "+(themename?" ("+str+")":str)); return themeres; } - + + /** access to the icon parameter setting */ - const getIcons = function() { + const getIconResource = function() { var iconstr = vexi.params["vexi.icon"]; var iconres = null; if (iconstr != null) { @@ -125,7 +126,7 @@ } if (iconres == null) { if (.conf.icon[""]!=null) { - iconres = .conf.icon..location; + iconres = .conf.icon..iconpath?[0]; } } if (iconres == null) { @@ -137,6 +138,12 @@ return iconres; } + static.getIcons = function(){ + var r = .conf.icon..iconpath; + if(r==null) return [getIconResource()]; + return r; + }; + /* * THEME HANDLING */ @@ -156,8 +163,9 @@ vexi.trace("Unable to apply theme"); vexi.trace(e); } - } + } + try { const theme = getThemeRes(vexi.params["vexi.theme"]); // theme specified @@ -168,11 +176,12 @@ } try { - var icons = getIcons(); + var icons = getIconResource(); // icons specified if (icons) { .icon ++= icons; } + vexi..org.vexi.lib.layout.icon..iconpath = getIcons(); } catch(e) { vexi.trace("Unable to establish icons"); vexi.trace(e); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn