mIRC Home    About    Download    Register    News    Help

Print Thread
Window layout / packer manager #233363 07/08/11 01:54 PM
Joined: Apr 2010
Posts: 59
A
ascription Offline OP
Babel fish
OP Offline
Babel fish
A
Joined: Apr 2010
Posts: 59
Hello,

I would like some simple arrangements of windows made available by keyboard. What are the arguments to the /mdi command please?

One example is arranging the windows in two or more columns, with different divisions in each. A candidate syntax is:
/arrange -vh [windows per column/row list]
The -v or -h switch indicates vertical or horizontal arrangement. The list is separated with spaces.

Re: Window layout / packer manager [Re: ascription] #234081 05/10/11 10:44 AM
Joined: Apr 2010
Posts: 59
A
ascription Offline OP
Babel fish
OP Offline
Babel fish
A
Joined: Apr 2010
Posts: 59
Hi,

I didn't get any replies to my post, which is a little mysterious. I'm a programmer, so I'm aware that the devs might just be burned out on the issue; so I'm trying again.

Window layout is a pretty complicated topic. The 'wxWidgets' GUI package, for example, has a number of options (BoxSizers, GridSizers, FlexGridSizers, GridBagSizers) for addressing the task. Obviously, I'm interested in a solution that is a good balance of the devs' time and energy with the desired effect.

It's also possible that the task is more involved than I'm aware, depending on how much the MDI control does, and how much the devs have done by hand. I just spent a couple hours grappling with exporting __stdcall functions with the MinGW compiler. No luck unfortunately, and it's not obvious the effect would be possible with that strategy anyway; I'd have to call EnumChildWindows, and recall the DLL function every time the window changed size, which is yet another problem. Another form of interprocess communication might be just as effective, such as controlling layout with a second process via sockets. But I digress.

I can think of two obvious usages of a potential "/arrange" command.

1) Specify number of windows (channels, status window, custom window) per column/row, which will then be evenly spaced.
2) Specify the number of "positions" a window should occupy in the column/row.

Do people think this would be useful? Would an illustration be useful? Do the devs like it, or want more of the specifics on the command?

Re: Window layout / packer manager [Re: ascription] #234082 05/10/11 11:12 AM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
There is only one developer, Khaled. He typically does not comment on feature requests, but he does read them. If he thinks they are worthwhile, he'll add them to his list of things to do. Keep in mind that the placement on the list may be at the bottom depending on how important he thinks it is. There are items that have been at the bottom for years.

As to not receiving replies, with feature requests, if no one has any real interest in the suggestion and no real problem with the suggestion, then they often will not reply.

If the suggestion is a good one, it will most likely be added at some point in the future. If not, then it most likely will not be added. In almost all cases, you won't ever know until/if it gets added.

My take on this is that it's probably not worth the effort. Most people aren't doing a lot of moving of windows and what is currently available works well for them. If you keep your windows in the same layout, you can save each window's position and then won't have to worry about it again. If not, most people are happy with the normal tile/cascade/and maximized options, which are what you see in most applications anyhow. On the other hand, I don't really care either way, which is why I didn't reply before... and is also probably why no one else did.


Invision Support
#Invision on irc.irchighway.net
Re: Window layout / packer manager [Re: ascription] #234087 05/10/11 02:32 PM
Joined: Jun 2003
Posts: 81
T
TRT Offline
Babel fish
Offline
Babel fish
T
Joined: Jun 2003
Posts: 81
Another reason might be that this is a feature request that can already easily be implemented by using the builtin scripting.
You probably overlooked that while getting stuck at the DLL path.

Re: Window layout / packer manager [Re: TRT] #234098 05/10/11 06:48 PM
Joined: Apr 2010
Posts: 59
A
ascription Offline OP
Babel fish
OP Offline
Babel fish
A
Joined: Apr 2010
Posts: 59
If I understand correctly, the minimum requirements would be the SetWindowPos command and ON RESIZE event, which I did not find in the docs. Are they unlisted, or what?

Also, I should advise readers, I haven't formulated the proposed layout algorithms completely; they may be really hard or worse, approximate or undefined.

That said, I'm not interested in defining them if other people aren't, especially since I'm not one of the devs.

Re: Window layout / packer manager [Re: ascription] #234099 05/10/11 07:41 PM
Joined: Jun 2003
Posts: 81
T
TRT Offline
Babel fish
Offline
Babel fish
T
Joined: Jun 2003
Posts: 81
Use the /window command to resize windows.
There is no internal event that is fired each time the user resizes a window, you could use a timer and check in short intervals but preventing the resizing of individual windows doesn't make sense anyway.

Re: Window layout / packer manager [Re: TRT] #234101 05/10/11 08:04 PM
Joined: Apr 2010
Posts: 59
A
ascription Offline OP
Babel fish
OP Offline
Babel fish
A
Joined: Apr 2010
Posts: 59
Ok, that makes sense. That structure almost makes the command more similar to object syntax than top-level functions.

As for ON RESIZE, I'm not imagining an internal event; it would have to be in response to the WM_SETSIZE event. It doesn't obviously make sense to forbid setting sizes with the mouse, but one of the arguments to ON RESIZE could indicate if it was the master window or the document windows that was being resized. For example, if the target was a document window, the script could perform snap-to-grid actions. If so, we may want to include the WM_SETPOS event as well, since setting the master window position could be relevant, and setting document window positions definitely would be.

Edit:

I don't know if the command isn't implemented completely, or the docs are just incomplete, but I can't guess how to set the xy/wh of the status window.

The docs say:
"@name window name (must prefix with a @)"

That omits the case of specifying a channel window, which is apparently just the name of the channel; there is no mention of the status window; and no mention of how to specify the same channel with more than one nick or the status window for different connections.

Also, $window doesn't seem to accept a numeric parameter for anything but the status window, or at least the 'title' property is undefined, and the count of windows as given by $window(0) is '1'. However, "$window(freenode, castironpi).h" for example, at least returns 0 instead of a null value.

Also, maybe I'm missing something obvious, or something that should be intuitive, or is intuitive for the devs or other users.

Last edited by ascription; 05/10/11 08:27 PM.
Re: Window layout / packer manager [Re: ascription] #234105 05/10/11 08:51 PM
Joined: Apr 2010
Posts: 943
F
FroggieDaFrog Offline
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 943
To change the status windows XYWH for the active connection:
Code:
/window "status window" x y w h


If you want to change the XYWH for a connection other than the active read the help file on /scid and/or /scon


I am SReject
My Stuff
Re: Window layout / packer manager [Re: FroggieDaFrog] #234107 05/10/11 09:04 PM
Joined: Apr 2010
Posts: 59
A
ascription Offline OP
Babel fish
OP Offline
Babel fish
A
Joined: Apr 2010
Posts: 59
Ok, that worked. Then $window(status window) returns the properties, no quotes. You can discover that information yourself by doing "//echo -s $active" in the status window, but I didn't discover the latter fact until searching the docs for "status window", which didn't reveal the first command either, by the way.

Thanks! On to muddling through the layout script.

Re: Window layout / packer manager [Re: ascription] #234121 07/10/11 07:41 AM
Joined: Apr 2010
Posts: 59
A
ascription Offline OP
Babel fish
OP Offline
Babel fish
A
Joined: Apr 2010
Posts: 59
Well, I have a script for a layout. The status window gets 200px vertically in the 1st column; the "@dev" window, a combined window I use, gets the rest. The 1st column has 1.1 times the width of the channels column if there's only one channels column, and 1.2 times the width (of each) if there's more than one. The case with 0 chans appears to work, but may cause a silent error. Only the chan windows in the 'normal' state are counted. The formula for assigning chans per column is hard-coded for only 3 rows.

The code is not polished. 'echo' statements are commented. You're invited to take a look. I'd welcome suggestions on trimming down lines, or generalizing the 'chans per column' formula. Also, someone suggested executing the command at short (0.1 sec) intervals instead of executing it when you exchange which windows are open (not minimized), or resize the master window.

Regarding the usefulness, communication is important, and layout is important to effective information display. That much goes unsaid often, and "the literature" on information display is scant, especially effective digital display, not to mention interface controls additionally. One example I was introduced to is:

http://www.edwardtufte.com/tufte/
http://en.wikipedia.org/wiki/Edward_Tufte

Notably, Tufte is critical of MS PowerPoint, which I agree with.

Code:
alias layout {
  var %numrows = 3
  var %numchans = 0
  var %j = 1
  while (%j <= $chan(0)) {
    if ($window($chan(%j)).state == normal) {
      inc %numchans
    }
    inc %j
  }
  var %numcols = $ceil($calc(%numchans / %numrows))
  var %col0prop = $iif(%numcols > 1, 1.2, 1.1)

  var %col0px = $int($calc(%col0prop * $window(-3).w / (%numcols + 1)))
  window "status window" 0 0 %col0px 300
  var %x = $window(-3).h - $window(status window).h
  %x = %x - 2
  window @dev 0 $window(status window).h %col0px %x

  var %colNpx = $int($calc(($window(-3).w - %col0px) / %numcols))
  ;echo -s %numchans %numcols %numrows $window(-3).w %col0px %colNpx


  %x = %col0px
  var %yI = 0, %xI = 0
  var %chanN = 0
  var %h0, %h, %y
  %j = 0
  while (%chanN < $chan(0)) {
    inc %chanN
    ;echo -s $chan(%chanN) $window($chan(%chanN)) $window($chan(%chanN)).state
    if ($window($chan(%chanN)).state == normal) {
      %h0 = $calc( (%numrows - (%numchans % %numrows)) % %numrows)
      ;echo -s %h0
      %h0 = $iif(%xI < %h0, %numrows - 1, %numrows)
      if (%numchans < %numrows) {
        %h0 = %numchans
      }
      ;echo -s %h0 $window(-3).h $calc($window(-3).h / 3)
      %h = $int($calc($window(-3).h / %h0))
      %x = $calc(%col0px + %xI * %colNpx)
      %y = %yI * %h
      window $window($chan(%chanN)) %x %y %colNpx %h
      ;echo -s %yI %h0 %h %col0px %xI %colNpx $window($chan(%chanN)) %x %y %colNpx %h
      inc %yI
      inc %j
      if (%yI >= %h0) {
        inc %xI
        %yI = 0
      }
    }
  }
  ;echo -s _
}


Regarding the 'chans per column' formula, I tabulated the results I would expect. It's somewhat mysterious. I don't know how the app does it, or what other ways there might be.

Code:
     3          4        5
	       
1    1          1        1
2    2          2        2
3    3          3        3
4    22         4        4
5    23         23       5
6    33         33       33
7    223        34       34
8    233        44       44
9    333        333      45
10   2233       334      55
11   2333       344      344
12   3333       444      444
13   22333      3334     445
14   23333      3344     455
15   33333      3444     555
16   223333     4444     4444
17   233333     33344    4445
18   333333     33444    4455
19   2233333    34444    4555
20   2333333    44444    5555
21   3333333    333444   44445
22   22333333   334444   44455


Re: Window layout / packer manager [Re: ascription] #234328 17/10/11 01:31 PM
Joined: Apr 2010
Posts: 59
A
ascription Offline OP
Babel fish
OP Offline
Babel fish
A
Joined: Apr 2010
Posts: 59
For anyone still reading this thread, or who stumbles across it later, here is the formula in a different language. It's much more concise, and we might even be able to make sense of it.

For R = # of rows, N = # of windows, we have:

Code:
WpC= [ ]
cols= int( math.ceil( float( N )/ R ) )
while N> 0:
    rows0= int( math.ceil( float( N )/ cols ) )
    WpC.append( rows0 )
    cols-= 1
    N-= rows0
WpC= WpC[ ::-1 ]


It's no Bresenham, but it might do the trick. It generates the table above. The result is a list of number of windows per column (WpC). The same formula would apply for determining windows per row, I imagine. If you want squares, just pick R = floor or ceil of sqrt( N ).

The language it's in is Python. The last statement reverses the list. Lately I learned that the MDI Window control in Linux doesn't offer 'Tile' capabilities, horizontal, vertical, or otherwise. It should.

Re: Window layout / packer manager [Re: ascription] #234343 18/10/11 04:42 PM
Joined: Apr 2010
Posts: 59
A
ascription Offline OP
Babel fish
OP Offline
Babel fish
A
Joined: Apr 2010
Posts: 59
I developed a still shorter version. Obviously, the procedure which it and the previous describe are composed of distinct concepts; one or the other may be more intuitive for any given programmer. This formula can be used directly in an expression, rather than requiring a loop; it has no side effects.

Again, for R = # of rows, N = # of windows, we have:

Code:
cols= int( math.ceil( float( N )/ R ) )
rows0= int( math.floor( float( N )/ cols ) )
remainder= N% ( rows0* cols )
WpC= [ rows0 ]* ( cols- remainder )+ [ rows0+ 1 ]* remainder


The 'rows' variable is distinguished by a '0' because there are really two 'rows' quantities involved: rows0 and rows0+ 1. Specifically, the smaller value begins the list, repeated 'cols- remainder' number of times; then the larger value is repeated 'remainder' number of times.

We notice 'rows0' has already incremented to the next larger value for N equal to an integral multiple of R, with no remainder!