Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch: Add window shading functionality to Open TTD #2943

Closed
DorpsGek opened this issue Jun 1, 2009 · 9 comments
Closed

Patch: Add window shading functionality to Open TTD #2943

DorpsGek opened this issue Jun 1, 2009 · 9 comments
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay

Comments

@DorpsGek
Copy link
Member

DorpsGek commented Jun 1, 2009

erikjanp opened the ticket and wrote:

In Linux, most window managers can "shade" windows. That is, it can roll up the entire window into the title bar, so it takes up less space but isn't closed or minimized to the taskbar.
In OpenTTD this would be handy as well: for taking a quick peek behind a window; for rolling up a big window that you want to monitor every now and then or that just got popped up where you were laying track; for organizing train windows; etc.

I've added an extra button to most windows (to some windows it doesn't make sense to shade it, like the title window). Click it and the window disappears into its title bar. Click it again and it goes back to full size.
You can also use the scrollwheel of your mouse on the title bar of the window with the same result. The behavior of the scroll wheel is configurable in 'Advanced settings -> Interface -> Interaction'.

As an extra, clicking a window with middle mouse button also shades the window. Because a third mouse button is new to OpenTTD (and not all platforms support this), I've put this in an extra patch. The behavior of the third mouse button is also configurable.

Three patches:
- shade-code.patch: this patch adds the basic shading functionality to OpenTTD.
- shade-windowdefs.patch: this patch modifies a lot of window definitions to give them shade buttons and keep them from drawing anything below the titlebar.
- shade-code-add-middle.patch: this patch adds middle mouse button functionality to OpenTTD. This patch should be applied after the shade-code.patch.

The patches are against svn-trunk, revision 16492. Backporting to 0.7 would be difficult for the windowdefs.patch because some window definitions have changed since then.

Also needed: a newgrf for the new shade/unshade buttons.

See also http://www.tt-forums.net/viewtopic.php?f=33&t=43595

Attachments

Reported version: trunk
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/2943
@DorpsGek
Copy link
Member Author

erikjanp wrote:

Update r16571: update to windowdefs and code-patches.
- Updated the code so now it also works with the new nested widgets alberth is introducing in trunk
- Updated to svn-r16571.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/2943#comment6210

@DorpsGek
Copy link
Member Author

Alberth wrote:

Nice to see you updated your patch.
You seem to have copied the approach of not rendering anything below a certain y coordinate to the nested widgets. At this time, I am not quite convinced that such an approach is the best solution, I would like to do a few experiments with a new widget type that can switch between pages first. I will get back to you when I have some conclusions about that experiment.

While browsing through the code, I noticed that you add a lot of unneeded parentheses; around boolean variables, around +, around ==, and around != (and maybe a few other places as well).
(I don't think it is useful to fix that now, and release a new version, before I have some idea about that new widget type. I thought I'd mention it so you can fix it the next time.)

Edit: Removed comment about line length.


This comment was imported from FlySpray: https://bugs.openttd.org/task/2943#comment6211

@DorpsGek
Copy link
Member Author

erikjanp wrote:

Yes, I've kept the don't-draw-below-certain-y approach for now. It was the simplest way too keep the patch working with trunk, but with the new nested widgets it really is a bit of a hack.

I've been experimenting a bit with a function SetShadeLevel in the nested widget defs, just like SetMinimalSize etc. It specifies to with shade level a widget or container belongs, so only the correct widgets are drawn when a window has a certain shade level.
Right now it is still hard for me to understand all the widget code, so it is mostly learning... And it doesn't solve the problems of all the non-widget drawing that is done in the OnPaint functions.

I'll update the patch every now and then in the original approach, but I'll be looking forward to your experiments to see what I can do with that.

For the parentheses: I'll see what I can remove in the next version.


This comment was imported from FlySpray: https://bugs.openttd.org/task/2943#comment6213

@DorpsGek
Copy link
Member Author

Alberth wrote:

OnPaint() will only contain this->DrawWidgets(), possibly with an pre-fixed 'SetDParam()'.

All drawing code in OnPaint will be moved to "Window::DrawWidget(const Rect &r, int widget) const" and executed as part of the widget rendering (DrawWidgets takes the window as parameter, so it is easy to forward the call to DrawWidget() at a few strategic places).

All code in OnPaint() that does something else than rendering should be moved to other locations in the class, usually a new method called from the constructor, OnClick, OnResize, and/or OnInvalidateData.

In short, you can safely ignore the OnPaint() code.


This comment was imported from FlySpray: https://bugs.openttd.org/task/2943#comment6214

@DorpsGek
Copy link
Member Author

erikjanp wrote:

Update to svn-r16883.
No changes to coding style...

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/2943#comment6345

@DorpsGek
Copy link
Member Author

erikjanp wrote:

Update r16943: update to windowdefs and code-patches.
- Updated to svn-r16943
- Fixed coding style
- Removed hardcoded values for the size of the shadebox

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/2943#comment6382

@DorpsGek
Copy link
Member Author

DorpsGek commented Sep 6, 2009

erikjanp wrote:

Update r17434: update to windowdefs and code-patches.
- Updated to svn-17434. Recently, a lot of changes were done in trunk to the window and widget code, so I hope I got all the changes correctly and didn't leave any old stuff.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/2943#comment6597

@DorpsGek
Copy link
Member Author

Alberth wrote:

Update: In r17573, NWidgetStacked was extended to switch between different planes to display. In r17755, the stacked widget was extended with the ability to have a zero-size child, thus hiding its sub-tree.
The 'defining shade levels for each widget' approach proposed in the forum topic is more flexible in the sense that many arbitrary window layouts can be defined. It is however less flexible in the sense that several independent local decisions about hiding/showing window parts are more difficult to implement (since they must be combined to a single window shade level).

The simplest way forward for this functionality seems to add a NWidgetStacked widget between the header and the window body, and control that widget.
Rather than adding the 'shade' icon and the above widget to each window, it may be better to generalize the window nested widget construction, by deleting the header widgets from each window, and instead generate the header from the (possibly extended) WindowDesc::flags. Note that there are some windows that will not fit in this pattern. Those need a way around the header generation system such that they still can benefit from it.


This comment was imported from FlySpray: https://bugs.openttd.org/task/2943#comment6802

@DorpsGek
Copy link
Member Author

Alberth closed the ticket.

Reason for closing: Implemented

in r18588


This comment was imported from FlySpray: https://bugs.openttd.org/task/2943

@DorpsGek DorpsGek added Core flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay
Projects
None yet
Development

No branches or pull requests

1 participant