Revision: 3972 http://vexi.svn.sourceforge.net/vexi/?rev=3972&view=rev Author: clrg Date: 2010-12-17 00:26:29 +0000 (Fri, 17 Dec 2010)
Log Message: ----------- Make row fill effect customizable + fix some row fill issues Modified Paths: -------------- trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/body.t trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/row.t trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/table.t trunk/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/row.t Modified: trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/body.t =================================================================== --- trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/body.t 2010-12-11 02:00:59 UTC (rev 3971) +++ trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/body.t 2010-12-17 00:26:29 UTC (rev 3972) @@ -10,30 +10,36 @@ <ui:box> - var fill1 = null; - var fill2 = "#11000000"; - var startindex = 0; + // dynamic table + thisbox.displayindex = 0; // other properties thisbox.selected; thisbox.selectedindex; - var pressEvent = function(v) { - selected = trapee; - cascade = v; + // minor optimization since this function gets called quite frequently + var _fillEffect; + thisbox.fillEffect ++= function(v) { cascade = v; _fillEffect = v; } + + /** customizable effect on rows */ + thisbox.fillEffect = function(row, index) { + row.rowfill = index%2 ? null : "#11000000"; } /** update alternating row colors */ var updateFills = function() { - var n = thisbox.numchildren; - for (var i=startindex%2; n>i; i+=2) { - thisbox[i].rowfill = fill1; + var offset = displayindex%2; + for (var i,box in thisbox) { + _fillEffect(box, offset+i); } - for (var i=startindex+1%2; n>i; i+=2) { - thisbox[i].rowfill = fill2; - } } + /** applied to rows to invoke row selection on mouse presses */ + var pressEvent = function(v) { + selected = trapee; + cascade = v; + } + var rowindexRead = function() { return thisbox.indexof(selected); } /** done outside of loadData in-case data is loaded manually */ @@ -43,7 +49,7 @@ v.rowindex ++= rowindexRead; v.Press1 ++= pressEvent; if (!invalidates_fills) { - v.rowfill = (startindex+(trapname-1))%2 ? fill2 : fill1; + _fillEffect(v, displayindex+(trapname-1)); } } else { updatefills = true; Modified: trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/row.t =================================================================== --- trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/row.t 2010-12-11 02:00:59 UTC (rev 3971) +++ trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/row.t 2010-12-17 00:26:29 UTC (rev 3972) @@ -44,9 +44,7 @@ /** automatically set cell.v_head */ static.v_headWrite = function(v) { cascade = v; - var n = trapee.numchildren; - for (var i=0; n>i; i++) { - var c = trapee[i]; + for (var i,c in trapee) { if (v==null) { c.v_head = null; continue; @@ -60,33 +58,22 @@ } } - /** set the default fill for this row */ - static.fillWrite = function(v) { - cascade = v; - if (v == null) { - if (trapee.v_setfill) { - trapee.fill = trapee.v_setfill; - } else if (trapee.rowfill) { - trapee.fill = trapee.rowfill; - } - } - if (v != trapee.rowfill) { - trapee.v_setfill = v; - } - } - /** set an arbitrary fill for this row */ static.fillWrite = function(v) { - cascade = v; + cascade = v ? v : trapee.rowfill; if (trapee.v_setfill) { trapee.curfill = v; + if (trapee.selected) { + // selected usually alters fill + trapee.selected = true; + } } } /** set the default fill for this row */ static.rowfillWrite = function(v) { cascade = v; - if (!trapee.curfill) { + if (!trapee.curfill and !trapee.selected) { trapee.v_setfill = false; trapee.fill = v; trapee.v_setfill = true; Modified: trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/table.t =================================================================== --- trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/table.t 2010-12-11 02:00:59 UTC (rev 3971) +++ trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/table.t 2010-12-17 00:26:29 UTC (rev 3972) @@ -37,8 +37,6 @@ var activefinal; var fakeviewport; var realviewport; - var fill1 = null; - var fill2 = "#11000000"; thisbox.th_content; thisbox.th_head; @@ -117,6 +115,7 @@ if (count+index>viewfinal) { count = viewfinal-index+1; } + var fillEffect = th_body.fillEffect; for (var i=start; count>i; i++) { // assign new row var r_ind = index+i; @@ -125,7 +124,6 @@ r = rlen>0 ? rows[--rlen] : createRow(); r.v_head = th_head; r.rowindex = r_ind; - r.rowfill = (r_ind%2) ? fill2 : fill1; r.height = rowheight; r.y = viewoffset + (rowheight*(r_ind-viewindex)); // place row @@ -141,6 +139,8 @@ } } r.value = data[i]; + // custom fillEffect implementations may be row data dependent + fillEffect(r, r_ind); } // clear up unused rows while (rlen>0) { @@ -169,6 +169,7 @@ // establish the rows the table is attempting to view viewindex = max(floor(viewy / rowheight), 0); viewfinal = min(numrows-1, viewindex+floor(th_bodyport.height / rowheight)); + th_body.displayindex = viewindex; if (setViewInfo) { setViewInfo(viewindex, viewfinal-viewindex+1); } @@ -356,6 +357,7 @@ activeindex = 0; activefinal = 0; th_body.clear(); + th_body.displayindex = 0; } /***************************\ Modified: trunk/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/row.t =================================================================== --- trunk/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/row.t 2010-12-11 02:00:59 UTC (rev 3971) +++ trunk/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/row.t 2010-12-17 00:26:29 UTC (rev 3972) @@ -8,37 +8,39 @@ <lib:row vshrink="true"> - /** let selected trap handle focused effect */ - thisbox.focused ++= function(v) { - cascade = v; - if (selected) { - selected = true; - } - } + thisbox.focused ++= static.focusWrite; + thisbox.selected ++= static.selectWrite; - /** give appropriate visual feedback on selection and focus */ - thisbox.selected ++= function(v) { - cascade = v; - v_setfill = false; - if (v) { - fill = focused - ? .settings..fill_selected - : .settings..fill_selected_unfocused; - } else { - fill = curfill ? curfill : rowfill; - } - v_setfill = true; - // forward selected effect to cells - var n = numchildren; - for (var i=0; n>i; i++) { - thisbox[i].selected = v; - } - } - minheight = static.rowheight; </lib:row> + /** let selected trap handle focused effect */ + static.focusWrite = function(v) { + cascade = v; + if (trapee.selected) { + trapee.selected = true; + } + } + + /** give appropriate visual feedback on selection and focus */ + static.selectWrite = function(v) { + cascade = v; + if (v) { + trapee.v_setfill = false; + trapee.fill = trapee.focused + ? .settings..fill_selected + : .settings..fill_selected_unfocused; + trapee.v_setfill = true; + } else { + trapee.fill = trapee.curfill; + } + // forward selected effect to cells + for (var i,cell in trapee) { + cell.selected = v; + } + } + // the rowheight is required for dynamic tables static.rowheight = 6 + vexi.ui.font.height(vexi.ui.font.defaultstream, vexi.ui.fontsize.medium, "dy"); @@ -46,7 +48,7 @@ /** update the rowheight to adapt to default font height */ static.fontWrite = function(v) { cascade = v; - rowheight = 6 + + static.rowheight = 6 + vexi.ui.font.height(vexi.ui.font.defaultstream, vexi.ui.fontsize.medium, "dy"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Lotusphere 2011 Register now for Lotusphere 2011 and learn how to connect the dots, take your collaborative environment to the next level, and enter the era of Social Business. http://p.sf.net/sfu/lotusphere-d2d _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn