Author Topic: Early WIP on v2.55  (Read 132955 times)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Early WIP on v2.55
« Reply #180 on: November 14, 2018, 10:39:54 pm »
Here is the OR_patch.zip with the missing files, sorry  ???

The Toast button should show the ToastWindow, as long as you have used first
WCHAR UseIcon[MAX_PATH] = { 0 }; Path_Combine(UseIcon, skSkinFolder(), L"bulb.png");
ToastWindow(UseIcon, L"Caption", L"first text line.\nsecond text line very long, very very long, i said very long!\netc.");
see line 2912 of my Main.cpp

zToast.png is the composited image build from memory, see line 82 of TestWindow.h
and read the CHM documentation

ZI_CreateImageComposited  

Create a GDImage composited image from a ZOBJECT array.

This is powerful feature that allows you to create on the fly a new image composed from any number of overlapping layers.
Each of the object layer being defined first in a ZOBJECT array, using any GDImage object type.
The order of the array will match the z-order of the final composited bitmap, starting from bottom to top.

You have the choice to create a new disk file to save the composited image, or to create a memory bitmap that you can use into a GDImage control or into a provided DC (GDI32).


FUNCTION ZI_CreateImageComposited ( _
zImageDest AS ASCIIZ, _          ' OPTIONAL name to save the resulting composited image to file.
BYVAL xW AS LONG, _              ' Bound Width of the resulting composited image.
BYVAL yH AS LONG, _              ' Bound Height of the resulting composited image.
BYVAL pSprite AS ZOBJECT PTR, _  ' Pointer to the ZOBJECT array structure
BYVAL N AS LONG _                ' The ZOBJECT array count.
) LONG

Return:
A GDI32 bitmap handle if  zImageDest = "", else Null.

Remark:
If you assign the memory bitmap to a GDI32 DC, then it is up to you to delete the bitmap when you don't need it anymore.

 
« Last Edit: November 14, 2018, 10:49:13 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #181 on: November 14, 2018, 11:15:36 pm »
Thanks for updating the patch, Patrice!

The Toast button should show the ToastWindow, as long as you have used first
WCHAR UseIcon[MAX_PATH] = { 0 }; Path_Combine(UseIcon, skSkinFolder(), L"bulb.png");
ToastWindow(UseIcon, L"Caption", L"first text line.\nsecond text line very long, very very long, i said very long!\netc.");
see line 2912 of my Main.cpp

:o

I'm telling you, until you sent me the updated patch, I was using my arbitrary value for IDC_BTN_TOAST in my constants.h:

#defineIDC_BTN_TOAST 50116

because that was the next free numeric value at the bottom of the file.

Believe it or not, the Toast button click was never fired in WndProc() with that ID! But with a small ID of 126 it does fire now! :o

Is it somehow related to

#define IDC_GRAPHIC_CARD 127 // PAT: 02-17-2018
#define IDC_LAST IDC_GRAPHIC_CARD // PAT: 02-17-2018
  ?

What do we need such a restriction on the ID values for?
« Last Edit: November 15, 2018, 01:07:00 pm by Michael Lobko-Lobanovsky »
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #182 on: November 14, 2018, 11:49:25 pm »
The toast window is beautiful! :D

I've just taken the liberty of deleting most of the shadow from under the bulb. It looked pretty much like ordinary borderline smear against dark backgrounds... ???

Do you agree to use my modded image instead?
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #183 on: November 15, 2018, 01:43:38 am »
Most of your skinned controls usually have one and the same parent in a common main window. Why wouldn't you use a single call to Begin/EndDeferWindowPos() in response to their parent resize event, instead of numerous individual MoveWindow() actions that cause multiple redraw in the parent window?

Successive MoveWindow() calls make the controls follow the parent visibly one by one while a common Begin/EndDeferWindowPos() call will move all of the included child control windows to their respective new places in just one draw call.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Early WIP on v2.55
« Reply #184 on: November 15, 2018, 09:50:50 am »
Mike

1 - When using new ID for button controls, it is very important to use a value lower than the IDC_LAST, for the code used in ToggleFullScreen
aka:
for (K = IDC_FIRST; K <= IDC_LAST; K++) {
    ShowWindow(GetDlgItem(gP.hMain, K), SW_HIDE);
}

Anyway this button was there, just for test purpose, and it will be removed as soon as the test is completed :)

2 - Bulb.png
Do you agree to use my modded image instead? YES ;)

3 - About Begin/EndDeferWindowPos()
Now that we have several control to resize that is worth a try, even if most of the time these related controls are kept hidden.

Here is the one i was using in my old PB's zSkin.inc
Code: [Select]
FUNCTION zBeginDeferWindowPos(BYVAL hWnd AS LONG, BYVAL nWindowCount AS LONG) AS LONG
    CALL LockWindowUpdate(hWnd)
    CALL SendMessage(hWnd, %WM_SETREDRAW, 0, 0)
    IF nWindowCount = < 128 THEN nWindowCount = 128
    FUNCTION = BeginDeferWindowPos(nWindowCount)
END FUNCTION

SUB zEndDeferWindowPos(BYVAL hWnd AS LONG, lRes AS LONG)
    CALL EndDeferWindowPos(lRes)
    CALL SendMessage(hWnd, %WM_SETREDRAW, 1, 0)
    CALL LockWindowUpdate(0)
END SUB

    CASE %WM_SIZE
         IF zComposited() THEN lRes& = zBeginDeferWindowPos(hWnd, 0)
         CALL zDrawBackground()
         CALL EnumChildWindows(hWnd, CODEPTR(AnchorEnum), lRes&)
         IF glRC THEN
            CALL ResizeGLwindow(zGetMainItem(%ID_OpenGL))
            CALL RenderOpenGL(zGetMainItem(%ID_OpenGL))
         END IF
         'CALL zUpdateWindow(hWnd, 0)
         IF zComposited() THEN CALL zEndDeferWindowPos(hWnd, lRes&)
Do you agree with it?
« Last Edit: November 15, 2018, 10:13:34 am by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #185 on: November 15, 2018, 10:25:55 am »
1. Got it!

2. Fine! :)

3. That code doesn't reveal the DeferWindowPos() calls proper but logically I'm assuming they reside in the EnumChildWindows() enumeration.

Since you used that code in PB already, I guess everything's all right with the deferrals and the setup works as expected, otherwise the controls simply wouldn't move anywhere. So why not use it in 64 bits as well? That's the best of what WinAPI can offer in the way of handling multiple resizes/moves of the child windows that belong to strictly the same parent window.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #186 on: November 15, 2018, 10:48:12 am »
Just one practical objection.

LockWindowUpdate() is redundant in the presence of WM_SETREDRAW/FALSE. The matter is that LockWindowUpdate() is very rough visually when later on it is used with (0) to unlock the updates. It then causes the entire desktop to redraw, and this is irritating to see on every main window resize.

WM_SETREDRAW/FALSE/TRUE with a subsequent UpdateWindow() call should be sufficient and very neat visually. :)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Early WIP on v2.55
« Reply #187 on: November 15, 2018, 10:56:03 am »
Code: [Select]
That's the best of what WinAPI can offer in the way of handling multiple resizes/moves of the child windows that belong to strictly the same parent window.To say the thruth i haven't used it for more than a decade, since it seems to be useless when working in DWM compositing mode.
But if DWM is turned off, that could be handy.

It is my undertsanding than when using DWM compositing, all drawing are sent to the DirectX hidden surface to compose the desktop screen preserving the z-order of all windows as well as their child controls, then bliting everything in one go.

But you can try to use deferwindowpos if you have a way to check it, then there will be probably no harm to use it with DWM?

Did you hear the sound played while poping up the Toast window?

You can easily change the font style, for example at line 73 in ToastWindow.h, we could use this
ZI_CreateTextObject(arrayobj[3], UseCaption, 4 + bmW + 4, 4, CaptionW + 8, CaptionH + 8, ZD_ARGB(255, 255,240,140), zFont, 18, ZS_VISIBLE, 1, StringAlignmentNear, FontStyleUnderline);
« Last Edit: November 15, 2018, 11:10:58 am by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #188 on: November 15, 2018, 12:54:42 pm »
... it seems to be useless when working in DWM compositing mode ... when using DWM compositing, all drawing are sent to the DirectX hidden surface to compose the desktop screen preserving the z-order of all windows as well as their child controls, then bliting everything in one go.

There can't be "one go" if you're dealing with atomic MoveWindow() calls. Re-compositing and re-blitting will be done after each move, and if you're attentive enough and there are, say, a dozen child controls to move, then you'll notice all the dozen redraws as Windows moves each control to its new place and/or size one by one, re-compositing and re-blitting the form in the process after each move. Now imagine what it's gonna look like if there are five dozens child controls on the parent form, which isn't a rare case at all in modern professional looking GUIs. ;)

OTOH it is not so with Begin/End/DeferWindowPos(). All resizing/repositioning is recalc'ed on the spot but deferred (i.e. postponed) -- BTW regardless of WM_SETREDRAW -- until the OS sees the EndDeferWindowPos() call, whereby it redraws the parent window immediately with all its child windows in their new places/sizes in just one blitting operation, DWM or no DWM.

Quote
Did you hear the sound played while poping up the Toast window?

Yes, I noticed it, and I think it's a good idea to alert the user to the hint popping up on the screen. Of course there should be an option in the rightmost Help menu to enable/disable the toast window option for beginners or experienced users, respectively.

And thanks for the font hint to customize the toast window's appearance. I'm going to fiddle with it today and try to adjust it to our needs. :)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Early WIP on v2.55
« Reply #189 on: November 15, 2018, 04:02:29 pm »
BTW, the Toast button is not anchored ;)
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #190 on: November 15, 2018, 04:22:10 pm »
Yours wasn't but mine is. ;D
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #191 on: November 15, 2018, 06:16:43 pm »
That's very elegant and so französisch! ;D

But a little too burlesque for our purposes I think. :)

Toast window timing built around the timer func callback fired after 10 secs to close the popup works perfectly fine. I'm currently populating the code with popup help. 8)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #192 on: November 15, 2018, 06:56:16 pm »
Some more TODOs pending... (see below)

I think when we fix them all and add FBO for post-processing, we are going to be ready to release OR v3.0. :)

BTW item #2 in this menu's gonna be a very very exciting and advanced thing to implement. Then we'll be able to create and save collages like your DreadRoamer+butterfly (The Beauty & The Beast(c) LOL) directly in OR. 8)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Early WIP on v2.55
« Reply #193 on: November 15, 2018, 08:44:35 pm »
Here is the code to add a close button into the ToastWindow

Code: [Select]
LRESULT CALLBACK ToastCallBack(IN HWND hWnd, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam) {
    LRESULT nRet = FALSE; // Do not stop the event processing in GDImage.

    long nID = ZI_MouseOverObjectID();

    switch (uMsg) {

    case WM_LBUTTONUP:
        if (nID == ID_TOAST_HIDE) { HideToast(); }
        break;
    }
    return nRet;
}

void ToastWindow(IN WCHAR* UseIcon, IN WCHAR* UseCaption, IN WCHAR* UseComment) { //IN HWND hParent, IN HINSTANCE hInstance) {
    if (gP.hToast) { DestroyWindow(gP.hToast); }

    WCHAR zFont[MAX_PATH]; ClearMemory(zFont, sizeof(zFont));
    Path_Combine(zFont, skSkinFolder(), L"trebuc.ttf");

    // We compute the correct size
    long CommentW = 0, CommentH = 0;
    ZD_GetTextBound(UseComment, zFont, 14, CommentW, CommentH, ZD_TextHorzUp, FontStyleRegular); // We use horizontal orientation
    long UseW = CommentW + 4;
    long UseH = CommentH;
    long CaptionW = 0, CaptionH = 0;
    ZD_GetTextBound(UseCaption, zFont, 18, CaptionW, CaptionH, ZD_TextHorzUp, FontStyleRegular); // We use horizontal orientation
    UseW = max(UseW, CaptionW + 4);
    UseH += CaptionH;
    long bmW = 0, bmH = 0;
    HBITMAP hBitmap = ZI_CreateBitmapFromFile(UseIcon, bmW, bmH);
    UseW = 4 + bmW + 4 + UseW + 4;
    UseH = 4 + max(bmH, UseH) + 4 + 4;

    // Here we create the compositing array
    // Note: The z-order composition will match the array order, the lower indice at the bottom, the higher on top.
    const long nCount = 5;
    ZOBJECT arrayobj[nCount]; ClearMemory(&arrayobj[0], sizeof(arrayobj));

    ZI_CreateBitmapObject(arrayobj[2], 4, 4, hBitmap, ZD_ARGB(255, 0,0,0), ZS_VISIBLE);
    ZI_CreateTextObject(arrayobj[3], UseCaption, 4 + bmW + 4, 4, CaptionW + 8, CaptionH + 8, ZD_ARGB(255, 255,240,140), zFont, 18, ZS_VISIBLE, 1, StringAlignmentNear, FontStyleRegular);
    ZI_CreateTextObject(arrayobj[4], UseComment, 4 + bmW + 4, 4 + CaptionH + 4, CommentW + 8, CommentH + 8, ZD_ARGB(255, 255,213,83), zFont, 14, ZS_VISIBLE, 1, StringAlignmentNear, FontStyleRegular);

    ZI_CreateRectangleObject(arrayobj[1], 1, 1, UseW - 3, UseH - 3, ZD_ARGB(255, 255,240,140), 1, ZS_VISIBLE | ZS_DRAFT, ZD_DRAW_OUTLINE, 0);
    ZI_CreateRectangleObject(arrayobj[0], 0, 0, UseW, UseH, ZD_ARGB(128, 128,128,128), 0, ZS_VISIBLE | ZS_DRAFT, ZD_DRAW_FILLED, 0);

    WCHAR zFile[MAX_PATH]; ClearMemory(zFile, sizeof(zFile));
    Path_Combine(zFile, zGetTempPath(), L"zToast.png");
    //Path_Combine(zFile, EXEpath(), L"zToast.png");
    ZI_CreateImageComposited(zFile, UseW, UseH, arrayobj, nCount);

    RECT rw; GetWindowRect(gP.hGL, &rw);
    long x = rw.right - UseW;
    long y = rw.bottom - UseH;
    // This API requires the use of a file name, rather than a bitmap handle. It can create/use a region on the fly.
    HWND hWnd = ZI_CreateWindowFromImage(WS_POPUP, zFile, x, y, gP.hGL, 0, 0, 0);
    if (IsWindow(hWnd)) {
        ZI_DwmEnable(hWnd);
        WCHAR zResource[MAX_PATH]; ClearMemory(zResource, sizeof(zResource));
        Path_Combine(zResource, skSkinFolder(), L"T_Close.png");
        long w = 0, h = 0;
        hBitmap = ZI_CreateBitmapFromFile(zResource, w, h);
        x = UseW - w - 8; y = 8;
        long nID = ID_TOAST_HIDE;
        ZD_DrawBitmapToCtrl(hWnd, x, y, hBitmap, ZD_ColorARGB(255, 0), nID, ZS_VISIBLE);
        ZD_SetObjectLocked(nID, TRUE);
        //MonitorMessages(hWnd, (LONG_PTR) ToastCallBack);
        ZI_EventMessageEx(hWnd, (LONG_PTR) ToastCallBack, WM_LBUTTONUP, TRUE);
        gP.hToast = hWnd;
    }
    zKillFile(zFile);
}

The new close button is attached to this post (to put into the Reader folder).

Add the new constant below line 131 in constants.h
#define ID_LAST                 ID_GAUGE_GPU
#define ID_TOAST_HIDE           ID_LAST + 1

« Last Edit: November 15, 2018, 08:47:56 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #194 on: November 15, 2018, 09:18:51 pm »
Added:
Here is how it looks with the new close button

Are you in fact teasing me with all those futuristic gadgets and constructs? ;D
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)