Revision: 4442
          http://vexi.svn.sourceforge.net/vexi/?rev=4442&view=rev
Author:   clrg
Date:     2012-10-04 09:39:24 +0000 (Thu, 04 Oct 2012)
Log Message:
-----------
Split toggle behaviour out from button in to separate toggle button widget
- could not postapply button as it was blocking action
- allows for theme-specific decorations of toggle buttons

Modified Paths:
--------------
    trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/button.t
    trunk/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/button.t
    trunk/org.vexi-vexi.widgets/src_main/vexi/widget/button.t

Added Paths:
-----------
    trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/togglebutton.t
    trunk/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/togglebutton.t
    trunk/org.vexi-vexi.widgets/src_main/vexi/widget/togglebutton.t

Modified: trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/button.t
===================================================================
--- trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/button.t   
2012-10-03 11:44:36 UTC (rev 4441)
+++ trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/button.t   
2012-10-04 09:39:24 UTC (rev 4442)
@@ -1,31 +1,7 @@
-<!-- Copyright 2009 - see COPYING for details [LGPL] -->
+<!-- Copyright 2012 - see COPYING for details [LGPL] -->
 
-<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns="org.vexi.lib.role">
-    <meta:doc>
-        <author>Charles Goodwin</author>
-    </meta:doc>
-    
+<vexi xmlns="org.vexi.lib.role">
     <clickable />
     <focusable />
-    <selectable />
     <tooltipable />
-    <ui:box>
-        
-        // textalign property managed by lib.layout.container
-        // and defaults to the default align value ("center")
-        
-        thisbox.Press1 ++= static.pressEvent;
-        thisbox.action ++= static.actionWrite;
-        
-    </ui:box>
-    
-    /** override selectable action implementation */
-    static.actionWrite = function(v) { return; }
-        
-    /** select if in a group otherwise defer to clickable Press1 */
-    static.pressEvent = function(v) {
-        if (trapee.v_group) trapee.selected = true;
-        else cascade = v;
-    }
-    
 </vexi>

Added: trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/togglebutton.t
===================================================================
--- trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/togglebutton.t     
                        (rev 0)
+++ trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/togglebutton.t     
2012-10-04 09:39:24 UTC (rev 4442)
@@ -0,0 +1,29 @@
+<!-- Copyright 2012 - see COPYING for details [LGPL] -->
+
+<vexi xmlns:ui="vexi://ui"
+      xmlns:meta="vexi://meta"
+      xmlns="org.vexi.lib">
+      
+    <meta:doc>
+        <author>Charles Goodwin</author>
+    </meta:doc>
+    
+    <widget.button />
+    <role.selectable />
+    <ui:box>
+        
+        thisbox.Press1 ++= static.pressEvent;
+        thisbox.action ++= static.actionWrite;
+        
+    </ui:box>
+    
+    /** override selectable action implementation */
+    static.actionWrite = function(v) { return; }
+        
+    /** select if in a group otherwise defer to clickable Press1 */
+    static.pressEvent = function(v) {
+        if (trapee.v_group) trapee.selected = true;
+        else cascade = v;
+    }
+    
+</vexi>

Modified: trunk/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/button.t
===================================================================
--- trunk/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/button.t        
2012-10-03 11:44:36 UTC (rev 4441)
+++ trunk/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/button.t        
2012-10-04 09:39:24 UTC (rev 4442)
@@ -18,7 +18,6 @@
         focused  ++= .lib.focusborder..focusWrite;
         hover    ++= static.normalWrite;
         normal   ++= static.normalWrite;
-        selected ++= static.normalWrite;
         
     </bevel>
     

Added: 
trunk/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/togglebutton.t
===================================================================
--- trunk/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/togglebutton.t  
                        (rev 0)
+++ trunk/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/togglebutton.t  
2012-10-04 09:39:24 UTC (rev 4442)
@@ -0,0 +1,33 @@
+<!-- Copyright 2011 - see COPYING for details [LGPL] -->
+
+<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns="vexi.theme"
+    xmlns:lib="org.vexi.lib.widget">
+    
+    <lib:togglebutton />
+    <bevel redirect=":$content" margin="3" padding="5 10" shrink="true">
+        <lib.focusborder id="focus" fill=":.settings..buttonfill">
+            <ui:box id="content" />
+        </lib.focusborder>
+        
+        thisbox.th_focus = $focus;
+        
+        active   ++= static.activeWrite;
+        enabled  ++= static.enableWrite;
+        enabled  ++= static.normalWrite;
+        hover    ++= static.normalWrite;
+        focused  ++= .lib.focusborder..focusWrite;
+        hover    ++= static.normalWrite;
+        normal   ++= static.normalWrite;
+        selected ++= static.normalWrite;
+        
+    </bevel>
+    
+    static.enableWrite = function(v) {
+        cascade = v;
+        trapee.textcolor = trapee.enabled ? .settings..textcolor : 
.settings..textcolor_disabled;
+    }
+    
+    static.activeWrite = function(v) { cascade = v; trapee.form = "down"; }
+    static.normalWrite = function(v) { cascade = v; trapee.form = 
trapee.enabled ? (trapee.selected ? "down" : "up") : "thinup"; }
+    
+</vexi>

Modified: trunk/org.vexi-vexi.widgets/src_main/vexi/widget/button.t
===================================================================
--- trunk/org.vexi-vexi.widgets/src_main/vexi/widget/button.t   2012-10-03 
11:44:36 UTC (rev 4441)
+++ trunk/org.vexi-vexi.widgets/src_main/vexi/widget/button.t   2012-10-04 
09:39:24 UTC (rev 4442)
@@ -4,15 +4,14 @@
     xmlns="org.vexi.lib.layout">
     <meta:doc>
         <author>Charles Goodwin</author>
-        <name>Basic Button</name>
-        <desc>Creates a button widget that can optionally toggle</desc>
+        <name>Button</name>
+        <desc>The traditional button widget that depresses when clicked</desc>
         <usage>
             Put to the text property of a button for single-line text,
-            or simply wrap the button around more complex content
-        
-            To make a button a toggle button, make it part of a group
-            with some other buttons like so:
-                $button1.group = $button2.group;
+            or simply wrap the button around more complex content.
+            
+            Trap on 'action' to know when the button has been clicked:
+                $button1.action ++= function(v) { /* clicked! */ }
         </usage>
     </meta:doc>
     

Added: trunk/org.vexi-vexi.widgets/src_main/vexi/widget/togglebutton.t
===================================================================
--- trunk/org.vexi-vexi.widgets/src_main/vexi/widget/togglebutton.t             
                (rev 0)
+++ trunk/org.vexi-vexi.widgets/src_main/vexi/widget/togglebutton.t     
2012-10-04 09:39:24 UTC (rev 4442)
@@ -0,0 +1,27 @@
+<!-- Copyright 2009 - see COPYING for details [LGPL] -->
+
+<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns:theme="vexi.theme"
+    xmlns="org.vexi.lib.layout">
+    <meta:doc>
+        <author>Charles Goodwin</author>
+        <name>Toggle Button</name>
+        <desc>A button widget that toggles between up/down</desc>
+        <usage>
+            Put to the text property of a button for single-line text,
+            or simply wrap the button around more complex content.
+        
+            A toggle button needs to be part of a group of buttons like so:
+                $button1.group = $button2.group;
+            
+            Trap on 'selected' to know when the button is toggled:
+                $button1.selected ++= function(v) {
+                    if (v == true) { /* selected */ }
+                }
+        </usage>
+    </meta:doc>
+    
+    <margin />
+    <theme:togglebutton />
+    <pad />
+    <container />
+</vexi>

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to