Own size for active /inactive panel?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Surya
Posts: 27
Joined: 05 Jul 2020 22:17

Own size for active /inactive panel?

Post by Surya »

Hello,
years ago I had a filemanager with 2 panels, which resized the panels by active /inactive. I am not sure, think it was dolphin under linux. It was great!
I would love to have such a feature in XYplorer again :-)

I have some scripts, doing a bit similar things, but not the same:

Activated by own button, makes the left panel small & the right panel wide.

Code: Select all

"Adjust Pane Size"
  if (!get("#800")) { #800; }	
  if (Get('#800')) {
  $current = SetLayout();
  $dim = Get('#801', 'Height', 'Width');
  $size = RegexMatches($current, 'Pane[12]' . $dim . '=\d+', '+');
  $size = RegexReplace($size, 'Pane[12]' . $dim . '=');
  $size = Eval($size) ;//+ GetKey('SplitterWidth', 'General');
  $sum = 30;
  if ($sum>100 OR $sum<5) {echo "not a viable percentage"; end 1==1;}    
  }
  $sum = 100 / $sum; 
  $percent = Floor($size / $sum);
  $remainder= $size - $percent;
  SetLayout("Pane1$dim=$percent,Pane2$dim=$remainder");  //msg $percent<crlf>$remainder;

  Status "First Pane resized to a $dim of $percent px.",, 'ready';
(and another own button with the opposite script doing the opposite). Works, but disadvantage that I always have to tick the buttons, it's not automated by active /inactive panel.

And another one:
Under settings >own event reactions >change panel

Code: Select all

"Adjust Pane Size"
  if (!get("#800")) { #800; }	
  if (Get('#800')) {
  $current = SetLayout();
  $dim = Get('#801', 'Height', 'Width');
  $size = RegexMatches($current, 'Pane[12]' . $dim . '=\d+', '+');
  $size = RegexReplace($size, 'Pane[12]' . $dim . '=');
  $size = Eval($size) ;//+ GetKey('SplitterWidth', 'General');
  $sum = 30;
  if ($sum>100 OR $sum<5) {echo "not a viable percentage"; end 1==1;}    
  }
  $sum = 100 / $sum; 
  $percent = Floor($size / $sum);
  $remainder= $size - $percent;
  SetLayout("Pane1$dim=$percent,Pane2$dim=$remainder");  //msg $percent<crlf>$remainder;

  Status "First Pane resized to a $dim of $percent px.",, 'ready';
Works too. Advantage: It's automatic, but when I click in the left panel, it changes the size the same like if I click in the right panel- so then the left panel is much too small.

How can I write a script, which automatically changes the panelsize by activating the panel? Mean, when clicking in the left panel, the size of the left panel gets 70% (and the right panel 30%). And clicking in the right panel, the size of the right panel gets 70% (and the left panel 30%).
Since a week I am searching here, Google, XY-help and so on and experimenting with scripts. But without success.

Please help :-)
And... Because it leeds to wrong clicking when the size immediately changes, I would like to put inside the script a waiting command or similar, is that possible too?

I'll give you kisses for your help ;-)
Surya

highend
Posts: 14925
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Own size for active /inactive panel?

Post by highend »

Custom Event Actions has a switch panes event...

And a waiting command... wait [msecs]^^
One of my scripts helped you out? Please donate via Paypal

Surya
Posts: 27
Joined: 05 Jul 2020 22:17

Re: Own size for active /inactive panel?

Post by Surya »

That is the location where I wrote the other script mentioned in the 2. code-window.
This script has the disadvantage, that it changes always the size of the right panel to wide size- doesn't matter to which panel I switch.
So that's my major question: How to make such a script smart? Means: When I click in left panel, make left panel wide. When I click in right panel, then make the right panel wide.

Thanks nevertheless for the waiting command :-)

highend
Posts: 14925
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Own size for active /inactive panel?

Post by highend »

I'd say by coding it smart? :masked:

Code: Select all

    $largeSize = 60; // Percent

    if (!get("#800") || $largeSize >= 100 || $largeSize <= 0) { end true; }
    $current     = setlayout();
    $dpType      = get("#801", "Height", "Width");
    $size        = regexmatches($current, "Pane[12]" . $dpType . "=\d+", "+");
    $size        = regexreplace($size, "Pane[12]" . $dpType . "=");
    $size        = eval($size) + getkey("SplitterWidth", "General");
    $largeSizePx = floor($largeSize / 100 * $size);
    $smallSizePx = $size - $largeSizePx;

    if (get("Pane") == 1) {
        setlayout("Pane1" . $dpType . "=" . $largeSizePx . ",Pane2" . $dpType . "=" . $smallSizePx);
    } else {
        setlayout("Pane1" . $dpType . "=" . $smallSizePx . ",Pane2" . $dpType . "=" . $largeSizePx);
    }
One of my scripts helped you out? Please donate via Paypal

Surya
Posts: 27
Joined: 05 Jul 2020 22:17

Re: Own size for active /inactive panel?

Post by Surya »

Coooool, it works :-))) THANKS A LOT!!!

Where should I now insert the wait command?

highend
Posts: 14925
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Own size for active /inactive panel?

Post by highend »

How about the first line? oO
One of my scripts helped you out? Please donate via Paypal

Surya
Posts: 27
Joined: 05 Jul 2020 22:17

Re: Own size for active /inactive panel?

Post by Surya »

This script with wait doesn't work. Where is the mistake?:

Code: Select all

    $largeSize = 70; // Percent

wait 2000;

    if (!get("#800") || $largeSize >= 100 || $largeSize <= 0) { end true; }
    $current     = setlayout();
    $dpType      = get("#801", "Height", "Width");
    $size        = regexmatches($current, "Pane[12]" . $dpType . "=\d+", "+");
    $size        = regexreplace($size, "Pane[12]" . $dpType . "=");
    $size        = eval($size) + getkey("SplitterWidth", "General");
    $largeSizePx = floor($largeSize / 100 * $size);
    $smallSizePx = $size - $largeSizePx;

    if (get("Pane") == 1) {
        setlayout("Pane1" . $dpType . "=" . $largeSizePx . ",Pane2" . $dpType . "=" . $smallSizePx);
    } else {
        setlayout("Pane1" . $dpType . "=" . $smallSizePx . ",Pane2" . $dpType . "=" . $largeSizePx);
    }
And also this one doesn't work:

Code: Select all

wait 2000;

    $largeSize = 70; // Percent

    if (!get("#800") || $largeSize >= 100 || $largeSize <= 0) { end true; }
    $current     = setlayout();
    $dpType      = get("#801", "Height", "Width");
    $size        = regexmatches($current, "Pane[12]" . $dpType . "=\d+", "+");
    $size        = regexreplace($size, "Pane[12]" . $dpType . "=");
    $size        = eval($size) + getkey("SplitterWidth", "General");
    $largeSizePx = floor($largeSize / 100 * $size);
    $smallSizePx = $size - $largeSizePx;

    if (get("Pane") == 1) {
        setlayout("Pane1" . $dpType . "=" . $largeSizePx . ",Pane2" . $dpType . "=" . $smallSizePx);
    } else {
        setlayout("Pane1" . $dpType . "=" . $smallSizePx . ",Pane2" . $dpType . "=" . $largeSizePx);
    }
Sorry, that I do not understand how to do it exactly. And sorry also for my not perfect english.

highend
Posts: 14925
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Own size for active /inactive panel?

Post by highend »

Adding a wait 2000; as the first line works perfectly fine here
One of my scripts helped you out? Please donate via Paypal

Surya
Posts: 27
Joined: 05 Jul 2020 22:17

Re: Own size for active /inactive panel?

Post by Surya »

This one works now fine :-) (adjusted the waiting time)

Code: Select all

    $largeSize = 70; // Percent

    wait 500; if (!get("#800") || $largeSize >= 100 || $largeSize <= 0) { end true; }
    $current     = setlayout();
    $dpType      = get("#801", "Height", "Width");
    $size        = regexmatches($current, "Pane[12]" . $dpType . "=\d+", "+");
    $size        = regexreplace($size, "Pane[12]" . $dpType . "=");
    $size        = eval($size) + getkey("SplitterWidth", "General");
    $largeSizePx = floor($largeSize / 100 * $size);
    $smallSizePx = $size - $largeSizePx;

    if (get("Pane") == 1) {
        setlayout("Pane1" . $dpType . "=" . $largeSizePx . ",Pane2" . $dpType . "=" . $smallSizePx);
    } else {
        setlayout("Pane1" . $dpType . "=" . $smallSizePx . ",Pane2" . $dpType . "=" . $largeSizePx);
    }
Thankyou highend for your help!

Post Reply