MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / SetClientBounds

Method SetClientBounds

Source/Engine/Platform/Windows/WindowsWindow.cpp:395–449  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

393}
394
395void WindowsWindow::SetClientBounds(const Rectangle& clientArea)
396{
397 ASSERT(HasHWND());
398
399 // Check if position or/and size will change
400 const auto rect = GetClientBounds();
401 const bool changeLocation = !Float2::NearEqual(rect.Location, clientArea.Location);
402 const bool changeSize = !Float2::NearEqual(rect.Size, clientArea.Size);
403 if (!changeLocation && !changeSize)
404 return;
405
406 // Get values data
407 int32 x = (int32)clientArea.GetX();
408 int32 y = (int32)clientArea.GetY();
409 int32 width = (int32)clientArea.GetWidth();
410 int32 height = (int32)clientArea.GetHeight();
411
412 if (changeSize)
413 {
414 _clientSize = clientArea.Size;
415
416 // Update GUI
417 OnResize(width, height);
418 }
419
420 // Check if need to adjust window rectangle
421 if (_settings.HasBorder)
422 {
423 // Get window info
424 WINDOWINFO winInfo;
425 Platform::MemoryClear(&winInfo, sizeof(WINDOWINFO));
426 winInfo.cbSize = sizeof(winInfo);
427 GetWindowInfo(_handle, &winInfo);
428
429 // Adjust rectangle from client size to window size
430 RECT winRect = { 0, 0, width, height };
431 AdjustWindowRectEx(&winRect, winInfo.dwStyle, FALSE, winInfo.dwExStyle);
432 width = winRect.right - winRect.left;
433 height = winRect.bottom - winRect.top;
434
435 // Little hack but works great
436 winRect = { x, y, width, height };
437 AdjustWindowRectEx(&winRect, winInfo.dwStyle, FALSE, winInfo.dwExStyle);
438 x = winRect.left;
439 y = winRect.top;
440 }
441
442 // Change window size and location
443 SetWindowPos(_handle, nullptr, x, y, width, height, SWP_NOZORDER | SWP_NOACTIVATE);
444
445 if (changeSize)
446 {
447 UpdateRegion();
448 }
449}
450
451void WindowsWindow::SetPosition(const Float2& position)
452{

Callers

nothing calls this directly

Calls 7

MemoryClearFunction · 0.85
GetXMethod · 0.80
GetYMethod · 0.80
GetWidthMethod · 0.80
HasHWNDFunction · 0.70
NearEqualFunction · 0.50
GetHeightMethod · 0.45

Tested by

no test coverage detected