Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Bug reports ➜ WindowLine - drawing horizontal/vertical line at top/left edge

WindowLine - drawing horizontal/vertical line at top/left edge

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Worstje   Netherlands  (899 posts)  Bio
Date Wed 24 Sep 2008 03:40 PM (UTC)

Amended on Wed 24 Sep 2008 03:44 PM (UTC) by Worstje

Message
I can't draw a vertical line at the left-most column of pixels. Likewise, I can't draw a horizontal line at the top-most column. (This is using WindowLine - I'm not sure how many other functions are unintentionally affected.)

I personally assume it is due to the following shortcuts being used but by design locking out the first column and row of pixels from being used for their proper purpose.

Quote:
Rectangle coordinates

In many functions described below you specify the rectangle in which the shapes is to appear (including ellipses, circles, etc.). As a shorthand you can specify a negative number, or zero, for the bottom or right side. This is taken to be offset from the bottom or right edge of the containing miniwindow. For example:
Rectangle: 0,0,0,0 - the whole miniwindow

Rectangle: 2,2,-2,-2 - a rectangle offset by 2 from each edge

Rectangle: 20,40,0,0 - a rectangle starting 20 from the left, 40 from the top, and continuing the the right and bottom edges.

Source: http://www.gammon.com.au/mushclient/mw_shapes.htm

This conflicts with the following:

Quote:
The top-left corner of the miniwindow is 0,0 and then increases horizontally in the "x" direction and vertically in the "y" direction, as per this diagram:

Source: http://www.gammon.com.au/mushclient/mw_creation.htm

A better way to describe the issue is to say that I can't seem to use coordinates that involve a x=0 or y=0 equation.

For the time being, I am using the following workaround:

-- Draw a line on x=0 (topleft to bottomleft of mw)
WindowLine(win, 0, 0, -mw.width, mw.height, 0x0000FF, 0, 1)

-- instead of the more natural (but bugged):
WindowLine(win, 0, 0, 0, mw.height, 0x0000FF, 0, 1)


The above code could 'utilize' the special interpretation of zero to replace mw.height, but that would only clutter the example in my opinion. Or any code, for that matter.

This seems like a bug that should be rectified prior to 5.0 in my opinion. How about using -1 to denote the right-most/bottom-most pixel? I think that is how other libraries handle similar features.

While this is a useful feature in concept, the way I see it the current implementation will cause odd quirks to find that might even need working around on if values are calculated. Using -1 and lower for this purpose would not take away any options, but it would prevent people plenty of debugging problems later on. (I know I spent 30 minutes trying to figure out why my simple line was bugging out like it was.)
Top

Posted by Nick Gammon   Australia  (23,169 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 24 Sep 2008 09:10 PM (UTC)
Message
I must admit I hit a similar problem when drawing vertical lines, which strangely became diagonal at the very edge (as instead of going to 0 horizontally it went to the other side).

It is a toss-up about which is worse - having to always specify mw.width when drawing rectangles could be a pain.

One solution, which I thought made it easy to avoid this issue, is to confine yourself to drawing 1 pixel in from each edge (this is made somewhat simpler if you decide to have a border).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,169 posts)  Bio   Forum Administrator
Date Reply #2 on Wed 24 Sep 2008 09:13 PM (UTC)
Message
The other thing to remember is that the 0,0 behaviour only affects the bottom-right corner, not the top-left corner.

So, if you arrange your arguments so that the (potential) zero is in the top/left, not the bottom/right, the problem won't arise.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #3 on Wed 24 Sep 2008 10:10 PM (UTC)
Message
Still, it is highly counterintuitive. And rather than specifying mw.width or mw.height when drawing rectangles, you could just use -1. Not 0. Basically an off-by-one difference compared to the current situation, I think. Unless 0 and -1 already translate to the same value - I haven't had a chance to test just now.

It would make any code that has math with many factors applied to the arguments definately less quirkier (mw.width-padding-text1-spacing-text2, for example).
Top

Posted by Nick Gammon   Australia  (23,169 posts)  Bio   Forum Administrator
Date Reply #4 on Thu 25 Sep 2008 12:18 AM (UTC)
Message
I take your point about it being mathematically counterintuitive, but to change now would make virtually every plugin that relies upon 0,0,0,0 being the whole miniwindow not work. They would have to be changed to 0,0,-1,-1.

Perhaps as a compromise and for backwards compatibility, a flag on the WindowCreate function call could set the new behaviour you propose. That wouldn't be too hard to implement.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #5 on Thu 25 Sep 2008 09:57 AM (UTC)
Message
And then it would require knowing about that flag, which seems more like a workaround than a fix. I don't like it.

Mind you, I realize fully that backwards compatibility is a good thing. But I also recall that you wrote that you wanted to use the period prior to 5.00 to flush out any big/structural bugs before they became a pain to fix, while the miniwindows in 4.xx were more of a glorified and very stable beta.

I've been writing quite a bit of code to position stuff around, and I can precisely understand how much of a pain it is to calculate positions for some things while keeping resizing and such in mind. If you have to maintain two coordinate-specification systems, won't that wreak havoc on the clarity of the rest of your code also?

I can work with the workaround above, or the flag option. But after you switch to version 5, and reach 5.43 or whatever, it is silly to still have to cater to version 4.30-4.37 users while you have already started a new major version. (Hell, personally I am not against cleaning up the entire scripting interface a bit, but for now I'm content with not needlessly complicating things more than they already are.) ^_^
Top

Posted by Nick Gammon   Australia  (23,169 posts)  Bio   Forum Administrator
Date Reply #6 on Fri 26 Sep 2008 04:31 AM (UTC)
Message
Sympathetic as I am to the problem, I just think that changing now will cause mayhem amongst the existing users of miniwindows, some of whom may not be very technical.

You would effectively have 4 cases, only 2 of which would work:


  1. Old version of MUSHclient with old plugins
  2. New version of MUSHclient with new plugins


However these would fail spectacularly:


  1. Old version of MUSHclient with new plugins
  2. New version of MUSHclient with old plugins


I think a compromise might be to change the behaviour of WindowLine - I can see this as being the major problem function, so that the destination x,y position is simply the coordinates given, and 0 would have no special meaning.

This might break a couple of subtle places in plugins, but not to the extent that changing the way people are used to doing 0,0,0,0 to specify the whole rectangle at present.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by WillFa   USA  (525 posts)  Bio
Date Reply #7 on Fri 26 Sep 2008 06:48 AM (UTC)

Amended on Fri 26 Sep 2008 06:50 AM (UTC) by WillFa

Message
If I can chime in... I kinda agree with Worstje. Miniwindows are only a couple of months old, it's not like there are plugins out there that have been abandoned. I'd be surprised if anyone has seriously "released" a plugin to the wild yet, and if they have, then what's the probability of a non-coder downloading them? They'd still need to keep fairly current on new versions of MushClient to utilize them.

(Personally, I tend to avoid the 0,0,0,0 syntax since it's not very intuitive when re-reading code. 0,0,0,0 is the entire screen/window?)
Top

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #8 on Fri 26 Sep 2008 10:03 AM (UTC)
Message
Out of my experience right now, every new version has enough new functions added or other bugfixes put in place that necessitates upgrading to the latest version for my plugins. (New GetInfo() selectors, OnPluginWorldOutputResized, popup windows, etc.) Knowing you you will add another bunch of features by the time 5.00 comes out that plugin authors will want to use simply because it opens yet some more possibilities.

Also, I disagree with your two 'spectacular failures' cases. Only one would fail with odd behaviour. The other should have a proper version="4.39" or whatever specified, making sure old users upgrade prior to using said plugin.

Right now, all MUSH versions with miniwindows are only accessible through the forums and not on the main page. The people affected would be reading along with these forums, and know. The few non-scripting people that got the miniwindow-enabled versions through friends, probably got it because said friends wrote scripts using plugins. Either way, right now it can be fixed with a really small impact on existing plugins.

Again, I realize you do love backwards compatibility. So do I. But not correcting a flawed design while it is viable would just make MUSHclient end up like a certain other client out there in a few years from now... and I love MUSHclient a bit too much to see that happen. :)
Top

Posted by WillFa   USA  (525 posts)  Bio
Date Reply #9 on Fri 26 Sep 2008 01:56 PM (UTC)

Amended on Fri 26 Sep 2008 08:48 PM (UTC) by WillFa

Message
Hey Worstje, I think I came across a similar issue to you, but I just solved it differently...


local height, width = 100,100
local colourIwant = 0x333333
WindowCreate("Sample", 0,0, width, height, 7,0, GetInfo(278) )  --fixed typo
WindowRectOp("Sample", 2, 1,1,-1,-1, colourIwant, 0)


"Doctor, doctor! It hurts when I do this..." :)


The window's actual background color is the matting color, so your window doesn't look like it's right on top of the scroll bar. The RectOp immediately after has the advantage of not only setting the color you want, but making sure you are drawing on a clean canvas.

Top

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #10 on Fri 26 Sep 2008 05:56 PM (UTC)
Message
I am not exactly sure what problem you are trying to solve, WillFa. For one, GetInfo(279) does not output a color. You might have wanted to get 278 and made a typo? :)

Just to make clear: I understand that you leave a 1px border around the miniwindow. But there was never any issue with that. ^_^
Top

Posted by Nick Gammon   Australia  (23,169 posts)  Bio   Forum Administrator
Date Reply #11 on Sat 27 Sep 2008 07:16 AM (UTC)
Message
Quote:

I kinda agree with Worstje ...


Two against one, huh? That isn't fair. ;)

Seriously, if I were to change the behaviour of miniwindows so that -1 represented "from the other side" rather than 0, would anyone object?

I have a few plugins myself that would need changing, but that isn't a huge deal.

I think my minimap plugin for Aardwolf might be "in the wild" right now, I'm not too sure.

However I think that the problem only rears its head really with WindowLine - I can't think of a really good reason why you might want a rectangle or circle (or similar shape) that ends on 0,0 because that would effectively make it empty (or 0 on one coordinate but not the other).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #12 on Sat 27 Sep 2008 10:15 AM (UTC)
Message
True, I have to agree with that. However, I should also say that you have a knack for finding new useful things to implement. I wouldn't be amazed that in a few versions from now, such functions would actually exist. :)
Top

Posted by Nick Gammon   Australia  (23,169 posts)  Bio   Forum Administrator
Date Reply #13 on Sun 19 Oct 2008 09:00 PM (UTC)
Message
I have changed WindowLine in version 4.38 to simply draw to x2,y2 without translating those coordinates if they happen to be zero or negative.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


34,404 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.