Page 1 of 1

Menubar in 0.8

Posted: Mon Feb 11, 2019 17:46
by Masadow

I'm looking forward to implement a Menubar, so to make things the easiest as possible, I'm using the TaharezLook where it's already implemented.

I've put in my layout the following :

Code: Select all

<?xml version="1.0" ?>
<GUILayout version="4">
    <Window type="TaharezLook/Menubar" name="building_menu" >
        <Property name="MaxSize" value="{{1,0},{1,0}}" />
        <Property name="Position" value="{ {0.3, 0}, {1, -30} }" />
        <Property name="Size" value="{ {0.7, -250}, {0, 30} }" />
        <Property name="ItemSpacing" value="10" />

        <Window type="TaharezLook/MenuItem" name="Root/FrameWindow/Menubar/Storage" >
            <Property name="Text" value="Storage" />
            <Property name="TooltipText" value="Buildings that can be used to store resources, equipment etc." />
            <Property name="MaxSize" value="{{1,0},{1,0}}" />
            <Property name="Area" value="{{0,7},{0,0},{0,30},{0,21}}" />
            <Property name="VerticalAlignment" value="Centre" />
            <Window type="TaharezLook/PopupMenu" name="Root/FrameWindow/Menubar/Storage/AutoPopup" >
                <Property name="Visible" value="False" />
                <Property name="FadeInTime" value="0" />
                <Property name="FadeOutTime" value="0" />
                <Property name="ItemSpacing" value="2" />
                <Property name="MaxSize" value="{{1,0},{1,0}}" />
                <Property name="ClippedByParent" value="False" />
                <Property name="Area" value="{{0,0},{0,-40},{0,42},{0,120}}" />
                <Property name="AutoResizeEnabled" value="True" />
                <Window type="TaharezLook/MenuItem" name="Root/FrameWindow/Menubar/Storage/Storage" >
                    <Property name="Text" value="Storage" />
                    <Property name="TooltipText" value="Basic general storage" />
                    <Property name="MaxSize" value="{{1,0},{1,0}}" />
                    <Property name="Area" value="{{0,2},{0,2},{0,39},{0,23}}" />

I've managed to get it working somehow even though the subitem placement is weird and I had to handle the mouse enter/leave behaviour by myself like in 0.5. Is there any better way to use it ? I can't figure out how does it works in the demo.

Re: Menubar in 0.8

Posted: Mon Feb 11, 2019 19:08
by Ident
Why can't you figure it out based on the demo? Is something unclear there?

Re: Menubar in 0.8

Posted: Tue Feb 12, 2019 15:31
by Masadow
Well, I can figure out how the menubar should be layed out easily in the TaharezOverview sample, but then, in the code, I can't find where the logic lie to handle the mouse. I thought it would be automatic then but I can see in the wiki that in old 0.5, it had to be manually handled. However, 0.5 code is outdated and porting it kind of work but there's some glitches / functions that doesn't work (like openPopupMenu does nothing for me whereas getPopupMenu()->show() do show the menu.)

Then, I was wondering whether I was looking at the right place or not to get it working on my own.

I tried to look at samples_framework but didn't find a place where it would be handled.

Re: Menubar in 0.8

Posted: Tue Feb 12, 2019 20:21
by Ident
I think there might not just be a better way. The menu bar has always been a bit odd, but functional.

If the demos do not show the usage sufficiently, a demo should be added.

I briefly looked and you are right, there is no specific usage in any of the demo files. For some reason I feel like this was never necessary though and you should be able to just register to click events of the actual menuitems to handle these. The rest should just work.

The hierarchy is:
Menubar > (1...*) MenuItem(s) > PopupMenu > (1...*) MenuItem(s)
which is the same as what you just have shown us.

On the default branch the TaharezLookOverview.layout file has this and it just works, I just tried it. No code needed to pop them open and close them.

Re: Menubar in 0.8

Posted: Tue Feb 12, 2019 20:24
by Ident
Did you try compiling and running the samples framework?

Re: Menubar in 0.8

Posted: Tue Feb 12, 2019 22:00
by Masadow

I did not try to compile and run the demo, just copy pasted in a clean project but I'll try to build the demo then to see what I've missed.

Thanks for your help.

Btw, I might better start a new thread for that but is there any documentation on editing the looknfeel ?

I've ran into this article : but I feel like there is a lot of explanation missing as somes concepts seems to be quite obvious for the write. (For example what's <PropertyDefinition name="SelectionBrush" initialValue="set:WindowsLook image:Background" redrawOnWrite="true" /> this ?)

Re: Menubar in 0.8

Posted: Wed Feb 13, 2019 07:26
by Ident
new topic new thread :)