Return-Path: X-Original-To: apmail-flex-dev-archive@www.apache.org Delivered-To: apmail-flex-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D1615CC0C for ; Mon, 3 Jun 2013 07:46:07 +0000 (UTC) Received: (qmail 30909 invoked by uid 500); 3 Jun 2013 07:46:07 -0000 Delivered-To: apmail-flex-dev-archive@flex.apache.org Received: (qmail 30889 invoked by uid 500); 3 Jun 2013 07:46:07 -0000 Mailing-List: contact dev-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list dev@flex.apache.org Received: (qmail 30881 invoked by uid 99); 3 Jun 2013 07:46:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Jun 2013 07:46:06 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of cosmacol@gmail.com designates 209.85.223.178 as permitted sender) Received: from [209.85.223.178] (HELO mail-ie0-f178.google.com) (209.85.223.178) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Jun 2013 07:46:01 +0000 Received: by mail-ie0-f178.google.com with SMTP id f4so9307656iea.23 for ; Mon, 03 Jun 2013 00:45:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=JiAxYnAO2On1T+F3gAQDGD1HFHUy/FruAWCOmkoWAqc=; b=TCVqwO/oK8GkVnnxDhssdfC8zR6BjLqD32HwdjLt4+2Ct7JX3SHNwqi1OmOqw6Slkq SeS+yUndVX9VM4SiM6gPOmxrUm5dERxTBoKvHFOcldOccPptCmtThN+b0ouGUyoTbddH fC5I9gnuECeWxK9+tZYYTj4X5a1Q4AjqGzSxk7OXqdnH4K1NXBZ5e85dwyxJ1Oa3iD7o DqhUyQTGGGhDYYfU1v1gctZZeiBsD0+lt6UNG2Ii+qXJtm55zcaFtEbLI0rr8D/jTSRg bcj1BMYvRE+6ZxAq829rKRBtSp+KJU3IpvUrNAkXOb3sqclIu79pjRy0Q6BcN6joLb0I 7SOA== X-Received: by 10.50.16.109 with SMTP id f13mr7040768igd.37.1370245540972; Mon, 03 Jun 2013 00:45:40 -0700 (PDT) MIME-Version: 1.0 Received: by 10.64.52.101 with HTTP; Mon, 3 Jun 2013 00:45:13 -0700 (PDT) In-Reply-To: References: From: Cosma Colanicchia Date: Mon, 3 Jun 2013 09:45:13 +0200 Message-ID: Subject: Re: Multidimensional States To: dev@flex.apache.org Content-Type: multipart/alternative; boundary=047d7bdc18d2b991f704de3b26b8 X-Virus-Checked: Checked by ClamAV on apache.org --047d7bdc18d2b991f704de3b26b8 Content-Type: text/plain; charset=UTF-8 Just trying to throw a quick thinking at it, in particular about the MXML declaration mess - to avoid cartesian multiplication of states, couldn't we just normalize them? I mean, grouping them in mutually exclusive groups, which is the typical scenario: This is different from the current freely assignable state groups, in that they define the mixing rules of the various base states - thus we implicitly expressed all the possible (and valid) combinations of the various base state (in this case, 3*2*2 = 12 possible valid states), instead of manually declaring a lot of states with long and unreadable names (like "overAndFocusedAndDefault"). The API should let specify multiple current states, as long as two mutually exclusive state are not specified, for example with a sintax like this: myComp.currentState = "up-focused-nonDefault" // VALID myComp.currentState = "up-down-nonDefault" // INVALID (to avoid confusion with current syntax, I think we should pick another separator different from "," to express these "state trails") We may also agree that the first state declared of each exclusive group is the default value of its group, so that we can write: myComp.currentState = "up" // same as "up-nonFocused-nonDefault" Then, current state groups and MXML syntax would kick in, it should just recognize the state trails: ... Or, we could also supports additional MXML like: ... In which more specific value assignment should win over more generic ones (something like that is already implemented, when you write alpha="0" alpha.over="1"). Finally, from a compatibility point of view, a component using an "old-style" states set could be just translated to a single mutually exclusive state group (in fact, it is one) - the compiler should just prevent mixing the two approaches. 2013/6/3 Alex Harui > Hi Max, > > Thanks for detailing it out. > > In the relatively few minutes I've spent thinking about the problem, I > pondered whether the answer is to expand on how s:State is used, or simply > allow you to have conditional attributes based on things other than > States. IMO, along with this set of States is code you have to write to > set currentState appropriately, and in many cases, it seems like you're > just going to wire it to some other property. For this Button example, we > don't really have a "isFocused" property, but we certainly could add one, > and the "Default" states are all tied to what is currently called the > 'emphasized' property. So why not some syntax that just lets you set a > property based on some other property? For sure there can be collisions, > or maybe it won't handle complex situations, but it seems like when I look > at the AS that we write when we give up on States, they are generally > simple expressions. So, while property.state implies the value of that > property when currentState is that State, maybe some other delimiter > besides '.' can be used to dictate the value of a property when some other > property is true or false or some simple expression. I'm going to use "(" > in this example, which may not be legal XML, but should give you an idea) > > Then the states are simply: > > > > > > > > And some widgets in the skin look like: > > > left(emphasized)=-2 left=-1 /> > color(currentState=="up"&&emphasized) > > Now, when I look at that, I wonder: why not just use binding? > > left="{emphasized ? -1 : -2}" /> > color="{(currentState=="up"&&emphasized) ? "red" : "blue"}" > > Yes, I know we told you not to use binding in skins for performance > reasons, but I am hoping to find ways to make databinding much faster in > FlexJS. > > > > And one final thought: In FlexJS, we may end up saying that you shouldn't > specify these visual aspects in the "skin". Instead, you might want to > use more CSS, and then we could implement attribute selectors on the AS > side since that CSS is going to work on the JS side. > > Then you just have: > > > > And CSS like: > > .buttonFocusBorder#focusBorder[emphasized] { > left: -2; > } > .buttonFocusBorder#focusBorder { > left: -1; > } > > .buttonBackground#background[emphasize] { > color: "blue"; > } > > .buttonBackground#background { > color: "red"; > } > > I'm not sure we can extend the set of attributes or not, but we can also > specify multiple class selector names, so we might be able to handle > custom properties that way. > > > -Alex > > On 6/2/13 10:45 AM, "Maxime Cowez" wrote: > > >I'd like to make this more concrete. Let's take Alex' Button example and > >compare the 'stateGroups' way to the 'multidimensional states' way. > >Here's what that Button's States might look like with 'stateGroups'. > > > > > > > > > > > > > > > > > > > > > > > > >stateGroups="upStates,default,focused"/> > > >stateGroups="downStates,default,focused"/> > > >stateGroups="overStates,default,focused"/> > > > > > >The states declaration looks heavy and is rather hard to decipher: -1 > > > >The actual component would look something like: > > > > > > >color.overStates="..."/> > > > >Easy to read, easy to use: +1 (I know Rect doesn't have a color attribute, > >but you get what I mean). > >But I haven't been entirely fair: what if I want a different background > >color scheme for the default states? I can't do: > > > > >color.overStates="..." > > color.upAndDefault="..." > >color.downAndDefault="..." color.overAndDefault="..."/> > > > >That will throw a compiler exception (because 'upAndDefault' is part of > >'upStates' group and thus I have a duplicate color declaration). I can fix > >this, but it would require even more stateGroups, e.g. normalUpStates, > >defaultUpstates, normalDownStates, etc.: -1 > >Or I could declare a color for every single base state, but that would be > >extremely verbose and have duplicate declarations of the same color. > > > >Conclusion: anything can be done, but it can become overly complex. > > > > > >Here's what the same Button's States would look like with > >'multidimensional > >states': > > > > > > > > > > > > > > > > > > > >Well that's extremely terse and clear: +2 > > > >The actual component would look something like: > > > > > > >color.over="..."/> > > > >I'm assuming a pressed default button that has focus would have its > >`currenState` set to ["default", "focused", "down"]. > >That's still better than the 'stateGroups' way: +1 > > > >But let's see what happens with the dual color scheme. Well it can't be > >done: -100 > >Unless we come up with something like this: > > > > >color.over="..." > > color.up.default="..." > >color.down.default="..." > >color.over.default="..."/> > > > >The more precise the state selector, the more precedence it takes. Doesn't > >look half bad. If it can be done technically, that is. > >A possible downside is that you can create situations where the developer > >doesn't provide a 'required' state. For instance with this Button example, > >if neither 'up', 'down' or 'over' are present in the 'currentState', the > >'background' would have no color. This can be remedied, but takes careful > >coding. > > > >Conclusion: with a new syntax this approach sure looks cleaner. > > > >I've been writing this as I was thinking about the subject, so I hope you > >can make heads and tails of it ;) > > > >Max > > > > > >On Sun, Jun 2, 2013 at 1:54 PM, Arnoud Bos > >wrote: > > > >> > >> Hi, > >> > >> I figure you can use some input from the community for this. I > >>personally > >> never use stategroups as i find them a bit confusing. > >> So I tend to structure my components the way that it's not needed and > >>use > >> the normal straightforward states. > >> > >> IMHO states are one of the key features of Flex, stateGroups we can live > >> without. > >> > >> just my 2 cents, > >> > >> Arnoud > >> > >> On 02-06-2013, at 08:49, Alex Harui wrote: > >> > >> >> I've been coming across more and more cases where it would be great > >>to > >> >> have > >> >> support for multidimensional states. What this looks like and how > >>it's > >> >> used > >> >> I'm not sure. Maybe we can discuss ideas. > >> > Yes, let's discuss. I'm actually finishing up getting simple states > >>to > >> > work in FlexJS. I haven't started work on StateGroup because I wasn't > >> sure > >> > how often they are used and whether they are considered the "right" > >> > solution by folks. > >> > > >> > >> Met vriendelijke groet, > >> > >> Arnoud Bos > >> Artim interactive > >> > >> E arnoud@artim-interactive.nl > >> W www.artim-interactive.nl > >> T +31 6 246 40 216 > >> A Elisabeth Wolffstraat 77-3 > >> 1053TT Amsterdam > >> > >> > >> > >> > >> > >> > > --047d7bdc18d2b991f704de3b26b8--