Jump to content

How to set up IndirectUI rules: 1 Boolean, and any of three dropdown option to activate?


Reptillian
 Share

Recommended Posts

  

Let's say I have a plugin option. The plugin option should only activates if a boolean option is checked off, and any of three dropdown option.

 

Here's what I have:

 

            propRules.Add(new ReadOnlyBoundToNameValuesRule(PropertyNames.Points,true,
                (PropertyNames.Use_clipboard_as_tile, false),
                (PropertyNames.Pretile_mode, Pretile_modeOptions.Pretile_modeOption18),
                (PropertyNames.Pretile_mode, Pretile_modeOptions.Pretile_modeOption21),
                (PropertyNames.Pretile_mode, Pretile_modeOptions.Pretile_modeOption22)
                ));

 

I want PropertyNames.Point to be only activated if clipboard option is set to false, and when the dropdown option is set to any of these option. Otherwise, it is grayed out.

 

I don't know how to explain this better, but hopefully, this gets the idea.

 

Also, from the other thread, this always is true:

 

            propRules.Add(new ReadOnlyBoundToNameValuesRule(PropertyNames.Thickness, true, new TupleStruct<object, object>[] {
                new TupleStruct<object, object>(PropertyNames.Use_clipboard_as_tile, false),
                new TupleStruct<object, object>(PropertyNames.Pretile_mode,Pretile_modeOptions.Pretile_modeOption22)
            }));

 

Edited by Reptillian

G'MIC Filter Developer

Link to comment
Share on other sites

You want the control enabled (NOT Readonly) if (the checkbox is NOT checked) AND (any one of the three list selections is made).

 

Therefore, you want the control disabled (Readonly) if (the checkbox is checked) OR (none of the three list selections is made).

 

Therefore, you want the control disabled if (the checkbox is checked) OR (any of the list selections is made that's not one of the three).

 

So the Invert flag in ReadOnlyBoundToNameValuesRule should not be set, and the list of conditions should be:

Checkbox is TRUE

The list-selections of all the selections EXCEPT the three for which the control should be enabled.

 

That is, as far as I know, the only way to achieve what you want. Your current method won't work because the listed conditions in the ReadOnlyBoundToNameValuesRule call are all ORed together. For what you have, the checkbox condition would need to be ANDed to the list conditions.

 

EDIT: Reversed checkbox state, because I misunderstood the desired state when I originally posted the comment.

Link to comment
Share on other sites

I do have a earlier code that works, however, it involves separate propRules. It works, however at the start, some controls are enabled until I change options and that is when behavior is correct. Changing the defaults is the easiest solution.

 

I wanted the control if (the checkbox is not checked) AND (any one of the three list selections is made).

 

As I'm new to indirectui as I barely use it except in rare cases, I would like a example of what you mean.

G'MIC Filter Developer

Link to comment
Share on other sites

5 hours ago, Reptillian said:

I do have a earlier code that works, however, it involves separate propRules.

 

If I correctly interpret what you're saying, that doesn't work. You can't properly enable a control by having, say, separate checkbox and list rules. The control will be enabled and disabled by the last control that's changed, without regard to the state of the other control.

 

EDIT: I should have been less certain in stating the exact effect of having a control enabled separately by more than one control. The conclusion in my original comment is based of an experiment I did, from which I concluded it was the last-changed control the determined the enabling or disabling. I'm not sure how careful and systematic I was, since my main objective was to find out if it it would work, not to analyze why it didn't. In any case, it didn't work how I hoped it would work -- and it can't always work the way one would wish it would work, because for some situations the enabling should be determined by ORing the enabling controls' states, and in others by ANDing  them. The situation in my test case was very similar to yours, where I hoped to have a checkbox enable a group of controls, then have a list control within that group enable or disable another of those controls.

Link to comment
Share on other sites

@MJW told the correct story ;-).

 

Maybe try to do it step by step and write down the condition first.

 

Too make it simple let's assume Pretile_mode can take the values mode1, mode2, mode3, mode4, mode5. mode2 and mode3 are the modes which should allow active.
    
Points.enabled =     (!Use_clipboard_as_tile && ((Pretile_mode == mode2) || (Pretile_mode == mode3))

 

You have to negate the condition to set the Readonly property of Points.

 

Points.Readonly =     ! (!Use_clipboard_as_tile && ((Pretile_mode == mode2) || (Pretile_mode == mode3))

 

Simplify the condition

 

Points.Readonly =     Use_clipboard_as_tile || ! ((Pretile_mode == mode2) || (Pretile_mode == mode3))

Points.Readonly =     Use_clipboard_as_tile || ((Pretile_mode != mode2) && (Pretile_mode != mode3))

 

ReadOnlyBoundToNameValuesRule can only handle OR, so enumerate all modes which are not 2 or 3

 

Points.Readonly =     Use_clipboard_as_tile || ((Pretile_mode == mode1) || (Pretile_mode == mode4) || (Pretile_mode == mode5))

 

 

 

midoras signature.gif

Link to comment
Share on other sites

I get that part, but I don't know how to write it:

 

            propRules.Add(new ReadOnlyBoundToNameValuesRule(PropertyNames.Points,false,
                ((PropertyNames.Use_clipboard_as_tile)||(PropertyNames.Pretile_mode, Pretile_modeOptions.Pretile_modeOption22))

                ));

 

This test code doesn't seem to work.

G'MIC Filter Developer

Link to comment
Share on other sites

Pretile_modenew ReadOnlyBoundToNameValuesRule(PropertyNames.Points, false,
                        (PropertyNames.Use_clipboard_as_tile, true),
                        (PropertyNames.Pretile_mode, Pretile_modeOptions.mode1),
                        (PropertyNames.Mode, Pretile_modeOptions.mode4),
                        (PropertyNames.Mode, Pretile_modeOptions.mode5)

midoras signature.gif

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...