• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

CustomDraw elements - 2 issues

WebSimConnect

Resource contributor
Messages
154
To complete my FSX/P3D HTML5 tools, I want to include a component that will allow to merge XML gauges with HTML5 CustomDraw elements in the XML code.

I have questions to the ones who ever developed own CustomDraw element in C++ that can be used in the XML gauge. There are not so many samples and docs available on the topic so I am developing a bit blindly. I have successfully implemented HTML based CustomDraw element based on IGaugeCDrawable class and its virtual method Draw()

Code:
bool   Draw         (IGaugeCDrawableDrawParameters* pParameters, PIXPOINT size, HDC hdc, PIMAGE pImage);

as I was inspired by famous TrafficRadar example I use TAKES_DC flag that allows to Draw GDI+/DX11 based on the provided HDC parameter. Then I started to experiment with TAKES_PIMAGE flag which changes the way the CustomDraw is rendered. Instead of HDC, the Draw() method receives the pointer to PIMAGE structure. After few experiments I noted that you can use PIMAGE in 2 ways, either write directly to the image bits buffer or simply replace the bits buffer with your own bits buffer. The only problem I have is that the image created is always IMG_15_BIT, // 1555 format and changing the format had no effect. The CustomDraw element was always rendered the way it was initialized with IMG_15_BIT. I guess there must be a way to change the format of the IMAGE passed to the Draw() method. The question is how ? There is a virtual method
Code:
bool   SetupDraw       (PIXPOINT size, HDC hdc, PIMAGE pImage) of IGaugeCDrawable
which is called once the CustomDraw is initialized, however playing on IMAGE structure had on effect. Maybe there are some XML atributes that shall be set in XML code ?

The second issue is mouse input. C++ gauges have mouse_list_register fuction to capture mouse events. How about CustomDraw element, anything similar ?

any help highly appreciated

Marcin
 

WebSimConnect

Resource contributor
Messages
154
Flight sim doesn't use any other image format in gauges.

so when other image formats listed in gauge.h are used ? i.e.

Code:
// enum constants for IMAGE.format
typedef enum IMG_FORMAT
{
    IMG_8_BIT_MONOCHROME = 0,
    IMG_8_BIT_INDEXED,
    IMG_15_BIT,             // 1555
    IMG_16_BIT,             // 565
    IMG_16A_BIT,            // 4444
    IMG_24_BIT,             // 888
    IMG_32_BIT,             // 888
    IMG_32A_BIT,            // 8888
    IMG_DXT1,               // DirectX Texture Compression DXT1
    IMG_DXT3,               // DirectX Texture Compression DXT3
    IMG_DUDV,               // Pertubation data
    IMG_MAX                 // keep this last
} IMG_FORMAT, *PIMG_FORMAT, **PPIMG_FORMAT;
 

taguilo

Resource contributor
Messages
1,585
Country
argentina
which is called once the CustomDraw is initialized, however playing on IMAGE structure had on effect. Maybe there are some XML atributes that shall be set in XML code ?

The second issue is mouse input. C++ gauges have mouse_list_register fuction to capture mouse events. How about CustomDraw element, anything similar ?

As you may already know, <CustomDraw> XML attributes must be defined first in the C++ module as elements of IGaugeCDrawableDrawParameters* pParameters structure so they can be used in the XML gauge as tags (ie <Zoom>, <Latitude>, etc).

As for mouse events, AFAIK it is not possible to capture a mouse event placed over a <CustomDraw> area in a single XML gauge. To bypass this limitation a second gauge can be used, placed over the same <CustomDraw> area of the first one and including an empty <CustomDraw/> command.

For example,

First gauge:

Code:
<Element Name="CustomDraw">
    <Position X="59" Y="0"/>
    <CustomDraw Name="mycd:anything" X="275" Y="230" CenterX="137">
     ....etc
     ....etc
</CustomDraw>
</Element>

Second gauge:

Code:
<Element Name="CustomDraw">
    <Position X="59" Y="0"/>
    <CustomDraw/>
</Element>
.......
<Mouse>
   <Area Name="AREA" Left="59" Top="0" Width="275" Height="230">
        <Click>
            ***Any action ***
          </Click>
          <Cursor Type="Hand"/>
    </Area>
  </Mouse>

Now clicking on the <CustomDraw> display area will execute the action desired.

Tom
 
Messages
2,081
Country
us-ohio
so when other image formats listed in gauge.h are used ? i.e.

They aren't.

Look, all images use the 1555... it just is. If you create bitmaps that are anything higher, they get converted down... and the result is usually not very good.
 

JB3DG

Resource contributor
Messages
1,325
Country
southafrica
When using a C++ gauge, the IMAGE_USE_ALPHA flag can be set in the MAKE_STATIC macro to make the image use 32bit pixel format. I wouldn't know how that could translate to a XML gauge though.
 

WebSimConnect

Resource contributor
Messages
154
I wouldn't know how that could translate to a XML gauge though.

if it is supported, I guess through XML element attributes like Tom is pointing, however there are predefined parameters, like X and Y are. I have not found any documentation ... and have no time for guessing :)

What is interesting is that SetupDraw method is called only when flag is TAKES_PIMAGE. When I use TAKES_DC, this method is not called.

so for mouse capture it looks I need a trick, thanks Tom.

Marcin
 
Top