Page 1 of 2

16.30 - "The Wall of Pictures"

Posted: 23 Feb 2016 19:52
by aurumdigitus
That Wall is an innovative feature; quite striking actually!

Would appreciate it if a knowledgeable scripter would convert those two short lines of code into an on/off toggle for a CTB.

(Have put them into the retained section of "Address Bar & Go To" but doing that way is well - - inelegant.)

BTW, Navigate All Files is insidiously clever and immensely useful. It deserves more publicity!

Re: 16.30 - "The Wall of Pictures"

Posted: 23 Feb 2016 20:10
by TheQwerty
How about?

Code: Select all

"Toggle Wall of Pics"
  $wallCfg = '0,1,0,0';  // Wall of Pics Config
  $defCfg = '1,0,4,2';  // Default Config

  // Store non-wall cfg so we can restore it.
  perm $P_PICWALL_RESTORE_CFG;

  $cfg = thumbsconf();

  if ($cfg != $wallCfg) {
    // Wall of Pics
    thumbsconf($wallCfg);
    $P_PICWALL_RESTORE_CFG = $cfg;

  } elseif ($P_PICWALL_RESTORE_CFG != '') {
    // Restore Previous
    thumbsconf($P_PICWALL_RESTORE_CFG);

  } else {
    // Use Default
    thumbsconf($defCfg);
  }

EDIT: Or if you want something a little smaller to just toggle between two settings without care for the current settings:

Code: Select all

thumbsconf((thumbsconf() == '0,1,0,0') ? '1,0,4,2' : '0,1,0,0');

Re: 16.30 - "The Wall of Pictures"

Posted: 23 Feb 2016 20:23
by admin
TheQwerty wrote:EDIT: Or if you want something a little smaller to just toggle between two settings without care for the current settings:

Code: Select all

thumbsconf((thumbsconf() == '0,1,0,0') ? '1,0,4,2' : '0,1,0,0');
Oh, cool, I'll add that to the website! :appl:

Re: 16.30 - "The Wall of Pictures"

Posted: 23 Feb 2016 20:31
by klownboy
It looks like your Edit short version using ternary conditional, is close in affect to what I had posted here the other day http://www.xyplorer.com/xyfc/viewtopic. ... 60#p135136 which is essentially toggling the thumbnail view based on whether the user has Zoom to Fill on or off. Though I suppose you could get fancier in a short version and apply different thumbnail setting depending on the current location as well.

Re: 16.30 - "The Wall of Pictures"

Posted: 23 Feb 2016 20:38
by m48tx
Please help. I am overcome with stupidity. When I enter thumbsconf("0,1,0,0"); in the address bar, I get an error message "Not Found: Location or Item". What am I doing wrong?

Re: 16.30 - "The Wall of Pictures"

Posted: 23 Feb 2016 20:41
by aurumdigitus
@ TheQwerty: As has been the case on numerous prior occasions, many thanks for the aid you have provided to myself and countless other XY aficionados. Maybe not Winston Churchill's "Blood, Toil, Tears and Sweat" but you time, knowledge and expertise.

Being one who is a firm believer in the scientific principle of Occam's Razor will adopt the one line version of your code - which has now garnered Don's imprimatur. :appl:

Re: 16.30 - "The Wall of Pictures"

Posted: 23 Feb 2016 20:43
by admin
m48tx wrote:Please help. I am overcome with stupidity. When I enter thumbsconf("0,1,0,0"); in the address bar, I get an error message "Not Found: Location or Item". What am I doing wrong?
Probably this tweak is set:

Code: Select all

ScriptSmartDetect=0
Change the 0 to a 1...

Re: 16.30 - "The Wall of Pictures"

Posted: 23 Feb 2016 20:59
by m48tx
admin wrote:
m48tx wrote:Please help. I am overcome with stupidity. When I enter thumbsconf("0,1,0,0"); in the address bar, I get an error message "Not Found: Location or Item". What am I doing wrong?
Probably this tweak is set:

Code: Select all

ScriptSmartDetect=0
Change the 0 to a 1...

Thank you Don! Also, I need to use thumbsconf("1,0,0,4"); to restore my thumbnail configuration.

Re: 16.30 - "The Wall of Pictures"

Posted: 23 Feb 2016 21:48
by aurumdigitus
"I'm not a Scripter but play one TV" - just kidding! :wink:

While not having the cerebral ability to write scripts find it endlessly fascinating to tinker with them. Below appears the script written and conducted by TheQwerty. Seven lines have been added to the top (which were purloined from elsewhere on the Board but cannot given an attribution) which toggle the CTB to a depressed/non-depressed state.

Given what the code does this addition is borderline superfluous. It was added to make the button operation uniform with the others.

To reiterate, this is the brainchild of TheQwerty not me.

Code: Select all

     // Toggle Button State
          if (ctbstate() == 1) {
            ctbstate(0);
          } else {
            ctbstate(1);
          };

     thumbsconf((thumbsconf() == '0,1,0,0') ? '1,0,4,2' : '0,1,0,0');

Re: 16.30 - "The Wall of Pictures"

Posted: 23 Feb 2016 22:02
by TheQwerty
Great idea! :appl:

Code: Select all

"CTB Toggle Wall of Pictures"
  $on = '0,1,0,0';
  $off = '1,0,4,2';
  ctbstate(thumbsconf((thumbsconf() == $on) ? $off : $on) != $on);
:whistle:

Re: 16.30 - "The Wall of Pictures"

Posted: 24 Feb 2016 02:55
by Nighted
This is cool. :ugeek:

Capitulation "The Wall of Pictures"

Posted: 24 Feb 2016 13:03
by aurumdigitus
What my code scribble did was by dint of brute fore. Without hesitation it is now hereby and forever recanted in order to yield to the polish and professionalism of Jedi Master TheQwerty's most recent exquisite implementation of the concept. :tup:

Code: Select all

    "CTB Toggle Wall of Pictures"
      $on = '0,1,0,0';
      $off = '1,0,4,2';
      ctbstate(thumbsconf((thumbsconf() == $on) ? $off : $on) != $on);

Re: 16.30 - "The Wall of Pictures"

Posted: 24 Feb 2016 13:20
by klownboy
Hi TheQwerty, your combining of thumbsconf and ctbstate into nearly a one liner is really slick. :appl: I was curious last night though if this could be expanded to include changing the icon itself as well a the state such that when the so-called "gallery wall" is in affect you see one icon and when it's not see another. I wasn't able to do it though without going to a separate line with another ternary or a standard conditional if /else. I don't know if it's possible to piggy back commands under ternary conditionals. I added one line as follows to your code above and it works but surely isn't as elegant.

Code: Select all

"CTB Toggle Wall of Pictures"
  $on = '0,1,0,0';
  $off = '1,0,4,2';
  ctbstate(thumbsconf((thumbsconf() == $on) ? $off : $on) != $on);
  ctbicon((ctbicon() == ":views" && ctbstate()) ? ":viewthumbs" : ":views");
  //***or using If/ Else***  if(ctbicon() == ":views" AND ctbstate()) {ctbicon(":viewthumbs")} else {ctbicon(":views");}
 
Of course they're isn't a pair of decent XY built-in icons to depict the 2 states, but you could use something else. Thanks TheQwerty and to you, aurumdigitus.

Edit: Though it is cycling, I just realized the icon change, is not tied to the ctbstate. I added a check for ctbstate and it appears to be cycling properly with state.

Re: 16.30 - "The Wall of Pictures"

Posted: 24 Feb 2016 15:49
by TheQwerty
We've reached the point where I don't think it's worth the debt to keep a single digit LOC.

This will allow you to cycle through configs and update the button name, icon, and state for each.

Unlike the previous scripts this determines the current state by the button name, which means you can make use of the finer aspects of ThumbsConf to toggle settings ('!') or modify some ('1,,0') instead of all. Though, in the context of cycling configs those don't make much sense. ;)

Code: Select all

"&Cycle Thumbnail Configs||1 : _cycleThumbConfig"
  // Allows specifying a new state by index.
  Global $G_NEW_STATE;

  // List of States in the format:
  // Name|Config|State|Icon
  // The first state is the defacto default state.
  $states = <<<'STATES'
Normal|1,0,4,2|0|:views
PicWall|0,1,0,0|1|:viewthumbs
Comfortable|0,0,4,7|0|:flatview
STATES;

  $stateCount = GetToken($states, 'Count', <crlf>);

  // Allow this script to continue to work outside a CTB.
  $inCTB = Get('Trigger', 'CTBIndex') > 0;
  if ($inCTB) {
    // Determine current state based on CTB name.
    // It might seem better to use the current ThumbsConf for this, as it cannot
    // be out of sync with the button itself. However, doing so means that the
    // user-specified config must account for all fields in ThumbsConf.
    // Using the name instead allows configs that only modify some settings or
    // the special toggle option ('!') and also future-proofs against ThumbsConf
    // gaining new settings.
    $idx = GetTokenIndex(CtbName() . '|*', $states, <crlf>);
  } else {
    // Outside of CTBs we must use the current config.
    // Could go about using a PV but meh.
    $idx = GetTokenIndex('*|' . ThumbsConf() . '|*', $states, <crlf>);
  }

  // Get new state.
  $idx = ($idx == $stateCount ? 1 : $idx+1);
  if ($G_NEW_STATE != '' && $G_NEW_STATE > 0 && $G_NEW_STATE <= $stateCount) {
    $idx = $G_NEW_STATE;
  }
  $newState = GetToken($states, $idx, <crlf>);

  // Update all the things.
  $name = GetToken($newState, 1, '|');
  ThumbsConf(GetToken($newState, 2, '|'));
  if ($inCTB) {
    CtbName($name);
    CtbState(GetToken($newState, 3, '|'));
    CtbIcon(GetToken($newState, 4, '|',,2));
  }

  Status "Activated thumb config: $name",,'ready';
I also included a global variable for specifying the new state's index, which can come in handy if you want to quickly access one of them via a right-click script. For example:

Code: Select all

"&Activate State 2 : reset"
  Global $G_NEW_STATE = 2;
  UserButton(Get('Trigger','ctbindex'), 1);

Re: 16.30 - "The Wall of Pictures"

Posted: 24 Feb 2016 16:53
by klownboy
TheQwerty wrote:We've reached the point where I don't think it's worth the debt to keep a single digit LOC.
Totally agree, I was starting to think that way also. I had attempted to do something along the lines of what you did, in that I was using a couple of variables with the thumbconf information pipe separated from the icon specification and then using gettoken but never got it fully functional. Thanks I'll give this a try.

Another method I've been using to determine if we are over the toolbar or the script is being executed elsewhere is something like this:

Code: Select all

 if(gettoken(controlatpos(),"1","|") != "TB") {...
Thanks again.