2021-11-03 15:11:55 +01:00
|
|
|
// Copyright (c) Microsoft Corporation.
|
Enable dragging with the entire titlebar (#1948)
* This definitely works for getting shadow, pointy corners back
Don't do anything in NCPAINT. If you do, you have to do everything. But the
whole point of DwmExtendFrameIntoClientArea is to let you paint the NC area in
your normal paint. So just do that dummy.
* This doesn't transition across monitors.
* This has a window style change I think is wrong.
* I'm not sure the margins change is important.
* The window style was _not_ important
* Still getting a black xaml islands area (the HRGN) when we switch to high DPI
* I don't know if this affects anything.
* heyo this works.
I'm not entirely sure why. But if we only update the titlebar drag region when
that actually changes, it's a _lot_ smoother. I'm not super happy with the
duplicated work in _UpdateDragRegion and OnSize, but checking this in in case
I can't figure that out.
* Add more comments and cleanup
* Try making the button RightCustomContent
* * Make the MinMaxClose's drag bar's min size the same as a caption button
* Make the new tab button transparent, to see how that looks
* Make sure the TabView doesn't push the MMC off the window
* Create a TitlebarControl
* The TitlebarControl is owned by the NCIW. It consists of a Content, DragBar,
and MMCControl.
* The App instatntiates a TabRowControl at runtime, and either places it in
the UI (for tabs below titlebar) or hangs on to it, and gives it to the NCIW
when the NCIW creates its UI.
* When the NCIW is created, it creates a grid with two rows, one for the
titlebar and one for the app content.
* The MMCControl is only responsible for Min Max Close now, and is closer to
the window implementation.
* The drag bar takes up all the space from the right of the TabRow to the left
of the MMC
* Things that **DON'T** work:
- When you add tabs, the drag bar doesn't update it's size. It only updates
OnSize
- The MMCControl's Min and Max buttons don't seem to work anymore.
- They should probably just expose their OnMinimizeClick and
OnMaximizeClick events for the Titlebar to handle minimizing and
maximizing.
- The drag bar is Magenta (#ff00ff) currently.
- I'm not _sure_ we need a TabRowControl. We could probably get away with
removing it from the UI tree, I was just being dumb before.
* Fix the MMC buttons not working
I forgot to plumb the window handle through
* Make the titlebar less magenta
* Resize the drag region as we add/remove tabs
* Move the actual MMC handling to the TitlebarControl
* Some PR nits, fix the titlebar painting on maximize
* Put the TabRow in our XAML
* Remove dead code in preparation for review
* Horrifyingly try Gdi Plus as a solution, that is _wrong_ though
* Revert "Horrifyingly try Gdi Plus as a solution, that is _wrong_ though"
This reverts commit e038b5d9216c6710c2a7f81840d76f8130cd73b8.
* This fixes the bottom border but breaks the titlebar painting
* Fix the NC bottom border
* A bunch of the more minor PR nits
* Add a MinimizeClick event to the MMCControl
This works for Minimize. This is what I wanted to do originally.
* Add events for _all_ of the buttons, not just the Minimize btn
* Change hoe setting the titlebar content works
Now the app triggers a callcack on the host to set the content, instead of the host querying the app.
* Move the tab row to the bottom of it's available space
* Fix the theme reloading
* PR nits from @miniksa
* Update src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp
Co-Authored-By: Michael Niksa <miniksa@microsoft.com>
* This needed to be fixed, was missed in other PR nits
* runformat
wait _what_
* Does this fix the CI build?
2019-07-19 00:21:33 +02:00
|
|
|
// Licensed under the MIT license.
|
2019-06-25 22:06:11 +02:00
|
|
|
|
|
|
|
#include "pch.h"
|
|
|
|
|
|
|
|
#include "MinMaxCloseControl.h"
|
|
|
|
#include "MinMaxCloseControl.g.cpp"
|
2021-03-09 18:41:29 +01:00
|
|
|
#include <LibraryResources.h>
|
|
|
|
|
Enable dragging with the entire titlebar (#1948)
* This definitely works for getting shadow, pointy corners back
Don't do anything in NCPAINT. If you do, you have to do everything. But the
whole point of DwmExtendFrameIntoClientArea is to let you paint the NC area in
your normal paint. So just do that dummy.
* This doesn't transition across monitors.
* This has a window style change I think is wrong.
* I'm not sure the margins change is important.
* The window style was _not_ important
* Still getting a black xaml islands area (the HRGN) when we switch to high DPI
* I don't know if this affects anything.
* heyo this works.
I'm not entirely sure why. But if we only update the titlebar drag region when
that actually changes, it's a _lot_ smoother. I'm not super happy with the
duplicated work in _UpdateDragRegion and OnSize, but checking this in in case
I can't figure that out.
* Add more comments and cleanup
* Try making the button RightCustomContent
* * Make the MinMaxClose's drag bar's min size the same as a caption button
* Make the new tab button transparent, to see how that looks
* Make sure the TabView doesn't push the MMC off the window
* Create a TitlebarControl
* The TitlebarControl is owned by the NCIW. It consists of a Content, DragBar,
and MMCControl.
* The App instatntiates a TabRowControl at runtime, and either places it in
the UI (for tabs below titlebar) or hangs on to it, and gives it to the NCIW
when the NCIW creates its UI.
* When the NCIW is created, it creates a grid with two rows, one for the
titlebar and one for the app content.
* The MMCControl is only responsible for Min Max Close now, and is closer to
the window implementation.
* The drag bar takes up all the space from the right of the TabRow to the left
of the MMC
* Things that **DON'T** work:
- When you add tabs, the drag bar doesn't update it's size. It only updates
OnSize
- The MMCControl's Min and Max buttons don't seem to work anymore.
- They should probably just expose their OnMinimizeClick and
OnMaximizeClick events for the Titlebar to handle minimizing and
maximizing.
- The drag bar is Magenta (#ff00ff) currently.
- I'm not _sure_ we need a TabRowControl. We could probably get away with
removing it from the UI tree, I was just being dumb before.
* Fix the MMC buttons not working
I forgot to plumb the window handle through
* Make the titlebar less magenta
* Resize the drag region as we add/remove tabs
* Move the actual MMC handling to the TitlebarControl
* Some PR nits, fix the titlebar painting on maximize
* Put the TabRow in our XAML
* Remove dead code in preparation for review
* Horrifyingly try Gdi Plus as a solution, that is _wrong_ though
* Revert "Horrifyingly try Gdi Plus as a solution, that is _wrong_ though"
This reverts commit e038b5d9216c6710c2a7f81840d76f8130cd73b8.
* This fixes the bottom border but breaks the titlebar painting
* Fix the NC bottom border
* A bunch of the more minor PR nits
* Add a MinimizeClick event to the MMCControl
This works for Minimize. This is what I wanted to do originally.
* Add events for _all_ of the buttons, not just the Minimize btn
* Change hoe setting the titlebar content works
Now the app triggers a callcack on the host to set the content, instead of the host querying the app.
* Move the tab row to the bottom of it's available space
* Fix the theme reloading
* PR nits from @miniksa
* Update src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp
Co-Authored-By: Michael Niksa <miniksa@microsoft.com>
* This needed to be fixed, was missed in other PR nits
* runformat
wait _what_
* Does this fix the CI build?
2019-07-19 00:21:33 +02:00
|
|
|
using namespace winrt::Windows::UI::Xaml;
|
2019-06-25 22:06:11 +02:00
|
|
|
|
|
|
|
namespace winrt::TerminalApp::implementation
|
|
|
|
{
|
2021-11-16 20:18:22 +01:00
|
|
|
static void closeToolTipForButton(const Controls::Button& button)
|
2021-11-03 21:34:31 +01:00
|
|
|
{
|
|
|
|
if (auto tt{ Controls::ToolTipService::GetToolTip(button) })
|
|
|
|
{
|
|
|
|
if (auto tooltip{ tt.try_as<Controls::ToolTip>() })
|
|
|
|
{
|
2021-11-04 17:14:05 +01:00
|
|
|
tooltip.IsOpen(false);
|
2021-11-03 21:34:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-09 23:47:30 +02:00
|
|
|
MinMaxCloseControl::MinMaxCloseControl()
|
2019-06-25 22:06:11 +02:00
|
|
|
{
|
2021-11-03 21:34:31 +01:00
|
|
|
// Get our dispatcher. This will get us the same dispatcher as
|
|
|
|
// Dispatcher(), but it's a DispatcherQueue, so we can use it with
|
|
|
|
// ThrottledFunc
|
|
|
|
auto dispatcher = winrt::Windows::System::DispatcherQueue::GetForCurrentThread();
|
|
|
|
|
2019-07-13 00:21:45 +02:00
|
|
|
InitializeComponent();
|
2021-11-04 14:49:57 +01:00
|
|
|
|
2021-11-04 17:14:05 +01:00
|
|
|
// Get the tooltip hover time from the system, or default to 400ms
|
|
|
|
// (which should be the default, see:
|
|
|
|
// https://docs.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-trackmouseevent#remarks)
|
|
|
|
unsigned int hoverTimeoutMillis{ 400 };
|
|
|
|
LOG_IF_WIN32_BOOL_FALSE(SystemParametersInfoW(SPI_GETMOUSEHOVERTIME, 0, &hoverTimeoutMillis, 0));
|
|
|
|
const auto toolTipInterval = std::chrono::milliseconds(hoverTimeoutMillis);
|
|
|
|
|
|
|
|
// Create a ThrottledFunc for opening the tooltip after the hover
|
|
|
|
// timeout. If we hover another button, we should make sure to call
|
|
|
|
// Run() with the new button. Calling `_displayToolTip.Run(nullptr)`,
|
|
|
|
// which will cause us to not display a tooltip, which is used when we
|
|
|
|
// leave the control entirely.
|
|
|
|
_displayToolTip = std::make_shared<ThrottledFuncTrailing<Controls::Button>>(
|
2021-11-03 21:49:46 +01:00
|
|
|
dispatcher,
|
2021-11-04 17:14:05 +01:00
|
|
|
toolTipInterval,
|
2021-11-04 14:49:57 +01:00
|
|
|
[weakThis = get_weak()](Controls::Button button) {
|
2021-11-04 17:14:05 +01:00
|
|
|
// If we provide a button, then open the tooltip on that button.
|
|
|
|
// We can "dismiss" this throttled func by calling it with null,
|
|
|
|
// which will cause us to do nothing at the end of the timeout
|
|
|
|
// instead.
|
2021-11-04 14:49:57 +01:00
|
|
|
if (button)
|
|
|
|
{
|
|
|
|
if (auto tt{ Controls::ToolTipService::GetToolTip(button) })
|
|
|
|
{
|
|
|
|
if (auto tooltip{ tt.try_as<Controls::ToolTip>() })
|
|
|
|
{
|
|
|
|
tooltip.IsOpen(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2019-06-25 22:06:11 +02:00
|
|
|
}
|
|
|
|
|
Enable dragging with the entire titlebar (#1948)
* This definitely works for getting shadow, pointy corners back
Don't do anything in NCPAINT. If you do, you have to do everything. But the
whole point of DwmExtendFrameIntoClientArea is to let you paint the NC area in
your normal paint. So just do that dummy.
* This doesn't transition across monitors.
* This has a window style change I think is wrong.
* I'm not sure the margins change is important.
* The window style was _not_ important
* Still getting a black xaml islands area (the HRGN) when we switch to high DPI
* I don't know if this affects anything.
* heyo this works.
I'm not entirely sure why. But if we only update the titlebar drag region when
that actually changes, it's a _lot_ smoother. I'm not super happy with the
duplicated work in _UpdateDragRegion and OnSize, but checking this in in case
I can't figure that out.
* Add more comments and cleanup
* Try making the button RightCustomContent
* * Make the MinMaxClose's drag bar's min size the same as a caption button
* Make the new tab button transparent, to see how that looks
* Make sure the TabView doesn't push the MMC off the window
* Create a TitlebarControl
* The TitlebarControl is owned by the NCIW. It consists of a Content, DragBar,
and MMCControl.
* The App instatntiates a TabRowControl at runtime, and either places it in
the UI (for tabs below titlebar) or hangs on to it, and gives it to the NCIW
when the NCIW creates its UI.
* When the NCIW is created, it creates a grid with two rows, one for the
titlebar and one for the app content.
* The MMCControl is only responsible for Min Max Close now, and is closer to
the window implementation.
* The drag bar takes up all the space from the right of the TabRow to the left
of the MMC
* Things that **DON'T** work:
- When you add tabs, the drag bar doesn't update it's size. It only updates
OnSize
- The MMCControl's Min and Max buttons don't seem to work anymore.
- They should probably just expose their OnMinimizeClick and
OnMaximizeClick events for the Titlebar to handle minimizing and
maximizing.
- The drag bar is Magenta (#ff00ff) currently.
- I'm not _sure_ we need a TabRowControl. We could probably get away with
removing it from the UI tree, I was just being dumb before.
* Fix the MMC buttons not working
I forgot to plumb the window handle through
* Make the titlebar less magenta
* Resize the drag region as we add/remove tabs
* Move the actual MMC handling to the TitlebarControl
* Some PR nits, fix the titlebar painting on maximize
* Put the TabRow in our XAML
* Remove dead code in preparation for review
* Horrifyingly try Gdi Plus as a solution, that is _wrong_ though
* Revert "Horrifyingly try Gdi Plus as a solution, that is _wrong_ though"
This reverts commit e038b5d9216c6710c2a7f81840d76f8130cd73b8.
* This fixes the bottom border but breaks the titlebar painting
* Fix the NC bottom border
* A bunch of the more minor PR nits
* Add a MinimizeClick event to the MMCControl
This works for Minimize. This is what I wanted to do originally.
* Add events for _all_ of the buttons, not just the Minimize btn
* Change hoe setting the titlebar content works
Now the app triggers a callcack on the host to set the content, instead of the host querying the app.
* Move the tab row to the bottom of it's available space
* Fix the theme reloading
* PR nits from @miniksa
* Update src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp
Co-Authored-By: Michael Niksa <miniksa@microsoft.com>
* This needed to be fixed, was missed in other PR nits
* runformat
wait _what_
* Does this fix the CI build?
2019-07-19 00:21:33 +02:00
|
|
|
// These event handlers simply forward each buttons click events up to the
|
|
|
|
// events we've exposed.
|
2019-11-05 23:29:11 +01:00
|
|
|
void MinMaxCloseControl::_MinimizeClick(winrt::Windows::Foundation::IInspectable const& /*sender*/,
|
Enable dragging with the entire titlebar (#1948)
* This definitely works for getting shadow, pointy corners back
Don't do anything in NCPAINT. If you do, you have to do everything. But the
whole point of DwmExtendFrameIntoClientArea is to let you paint the NC area in
your normal paint. So just do that dummy.
* This doesn't transition across monitors.
* This has a window style change I think is wrong.
* I'm not sure the margins change is important.
* The window style was _not_ important
* Still getting a black xaml islands area (the HRGN) when we switch to high DPI
* I don't know if this affects anything.
* heyo this works.
I'm not entirely sure why. But if we only update the titlebar drag region when
that actually changes, it's a _lot_ smoother. I'm not super happy with the
duplicated work in _UpdateDragRegion and OnSize, but checking this in in case
I can't figure that out.
* Add more comments and cleanup
* Try making the button RightCustomContent
* * Make the MinMaxClose's drag bar's min size the same as a caption button
* Make the new tab button transparent, to see how that looks
* Make sure the TabView doesn't push the MMC off the window
* Create a TitlebarControl
* The TitlebarControl is owned by the NCIW. It consists of a Content, DragBar,
and MMCControl.
* The App instatntiates a TabRowControl at runtime, and either places it in
the UI (for tabs below titlebar) or hangs on to it, and gives it to the NCIW
when the NCIW creates its UI.
* When the NCIW is created, it creates a grid with two rows, one for the
titlebar and one for the app content.
* The MMCControl is only responsible for Min Max Close now, and is closer to
the window implementation.
* The drag bar takes up all the space from the right of the TabRow to the left
of the MMC
* Things that **DON'T** work:
- When you add tabs, the drag bar doesn't update it's size. It only updates
OnSize
- The MMCControl's Min and Max buttons don't seem to work anymore.
- They should probably just expose their OnMinimizeClick and
OnMaximizeClick events for the Titlebar to handle minimizing and
maximizing.
- The drag bar is Magenta (#ff00ff) currently.
- I'm not _sure_ we need a TabRowControl. We could probably get away with
removing it from the UI tree, I was just being dumb before.
* Fix the MMC buttons not working
I forgot to plumb the window handle through
* Make the titlebar less magenta
* Resize the drag region as we add/remove tabs
* Move the actual MMC handling to the TitlebarControl
* Some PR nits, fix the titlebar painting on maximize
* Put the TabRow in our XAML
* Remove dead code in preparation for review
* Horrifyingly try Gdi Plus as a solution, that is _wrong_ though
* Revert "Horrifyingly try Gdi Plus as a solution, that is _wrong_ though"
This reverts commit e038b5d9216c6710c2a7f81840d76f8130cd73b8.
* This fixes the bottom border but breaks the titlebar painting
* Fix the NC bottom border
* A bunch of the more minor PR nits
* Add a MinimizeClick event to the MMCControl
This works for Minimize. This is what I wanted to do originally.
* Add events for _all_ of the buttons, not just the Minimize btn
* Change hoe setting the titlebar content works
Now the app triggers a callcack on the host to set the content, instead of the host querying the app.
* Move the tab row to the bottom of it's available space
* Fix the theme reloading
* PR nits from @miniksa
* Update src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp
Co-Authored-By: Michael Niksa <miniksa@microsoft.com>
* This needed to be fixed, was missed in other PR nits
* runformat
wait _what_
* Does this fix the CI build?
2019-07-19 00:21:33 +02:00
|
|
|
RoutedEventArgs const& e)
|
2019-06-25 22:06:11 +02:00
|
|
|
{
|
2021-03-18 23:02:39 +01:00
|
|
|
_MinimizeClickHandlers(*this, e);
|
2019-06-25 22:06:11 +02:00
|
|
|
}
|
|
|
|
|
2019-11-05 23:29:11 +01:00
|
|
|
void MinMaxCloseControl::_MaximizeClick(winrt::Windows::Foundation::IInspectable const& /*sender*/,
|
Enable dragging with the entire titlebar (#1948)
* This definitely works for getting shadow, pointy corners back
Don't do anything in NCPAINT. If you do, you have to do everything. But the
whole point of DwmExtendFrameIntoClientArea is to let you paint the NC area in
your normal paint. So just do that dummy.
* This doesn't transition across monitors.
* This has a window style change I think is wrong.
* I'm not sure the margins change is important.
* The window style was _not_ important
* Still getting a black xaml islands area (the HRGN) when we switch to high DPI
* I don't know if this affects anything.
* heyo this works.
I'm not entirely sure why. But if we only update the titlebar drag region when
that actually changes, it's a _lot_ smoother. I'm not super happy with the
duplicated work in _UpdateDragRegion and OnSize, but checking this in in case
I can't figure that out.
* Add more comments and cleanup
* Try making the button RightCustomContent
* * Make the MinMaxClose's drag bar's min size the same as a caption button
* Make the new tab button transparent, to see how that looks
* Make sure the TabView doesn't push the MMC off the window
* Create a TitlebarControl
* The TitlebarControl is owned by the NCIW. It consists of a Content, DragBar,
and MMCControl.
* The App instatntiates a TabRowControl at runtime, and either places it in
the UI (for tabs below titlebar) or hangs on to it, and gives it to the NCIW
when the NCIW creates its UI.
* When the NCIW is created, it creates a grid with two rows, one for the
titlebar and one for the app content.
* The MMCControl is only responsible for Min Max Close now, and is closer to
the window implementation.
* The drag bar takes up all the space from the right of the TabRow to the left
of the MMC
* Things that **DON'T** work:
- When you add tabs, the drag bar doesn't update it's size. It only updates
OnSize
- The MMCControl's Min and Max buttons don't seem to work anymore.
- They should probably just expose their OnMinimizeClick and
OnMaximizeClick events for the Titlebar to handle minimizing and
maximizing.
- The drag bar is Magenta (#ff00ff) currently.
- I'm not _sure_ we need a TabRowControl. We could probably get away with
removing it from the UI tree, I was just being dumb before.
* Fix the MMC buttons not working
I forgot to plumb the window handle through
* Make the titlebar less magenta
* Resize the drag region as we add/remove tabs
* Move the actual MMC handling to the TitlebarControl
* Some PR nits, fix the titlebar painting on maximize
* Put the TabRow in our XAML
* Remove dead code in preparation for review
* Horrifyingly try Gdi Plus as a solution, that is _wrong_ though
* Revert "Horrifyingly try Gdi Plus as a solution, that is _wrong_ though"
This reverts commit e038b5d9216c6710c2a7f81840d76f8130cd73b8.
* This fixes the bottom border but breaks the titlebar painting
* Fix the NC bottom border
* A bunch of the more minor PR nits
* Add a MinimizeClick event to the MMCControl
This works for Minimize. This is what I wanted to do originally.
* Add events for _all_ of the buttons, not just the Minimize btn
* Change hoe setting the titlebar content works
Now the app triggers a callcack on the host to set the content, instead of the host querying the app.
* Move the tab row to the bottom of it's available space
* Fix the theme reloading
* PR nits from @miniksa
* Update src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp
Co-Authored-By: Michael Niksa <miniksa@microsoft.com>
* This needed to be fixed, was missed in other PR nits
* runformat
wait _what_
* Does this fix the CI build?
2019-07-19 00:21:33 +02:00
|
|
|
RoutedEventArgs const& e)
|
2019-06-25 22:06:11 +02:00
|
|
|
{
|
2021-03-18 23:02:39 +01:00
|
|
|
_MaximizeClickHandlers(*this, e);
|
2019-06-25 22:06:11 +02:00
|
|
|
}
|
2019-11-05 23:29:11 +01:00
|
|
|
void MinMaxCloseControl::_CloseClick(winrt::Windows::Foundation::IInspectable const& /*sender*/,
|
Enable dragging with the entire titlebar (#1948)
* This definitely works for getting shadow, pointy corners back
Don't do anything in NCPAINT. If you do, you have to do everything. But the
whole point of DwmExtendFrameIntoClientArea is to let you paint the NC area in
your normal paint. So just do that dummy.
* This doesn't transition across monitors.
* This has a window style change I think is wrong.
* I'm not sure the margins change is important.
* The window style was _not_ important
* Still getting a black xaml islands area (the HRGN) when we switch to high DPI
* I don't know if this affects anything.
* heyo this works.
I'm not entirely sure why. But if we only update the titlebar drag region when
that actually changes, it's a _lot_ smoother. I'm not super happy with the
duplicated work in _UpdateDragRegion and OnSize, but checking this in in case
I can't figure that out.
* Add more comments and cleanup
* Try making the button RightCustomContent
* * Make the MinMaxClose's drag bar's min size the same as a caption button
* Make the new tab button transparent, to see how that looks
* Make sure the TabView doesn't push the MMC off the window
* Create a TitlebarControl
* The TitlebarControl is owned by the NCIW. It consists of a Content, DragBar,
and MMCControl.
* The App instatntiates a TabRowControl at runtime, and either places it in
the UI (for tabs below titlebar) or hangs on to it, and gives it to the NCIW
when the NCIW creates its UI.
* When the NCIW is created, it creates a grid with two rows, one for the
titlebar and one for the app content.
* The MMCControl is only responsible for Min Max Close now, and is closer to
the window implementation.
* The drag bar takes up all the space from the right of the TabRow to the left
of the MMC
* Things that **DON'T** work:
- When you add tabs, the drag bar doesn't update it's size. It only updates
OnSize
- The MMCControl's Min and Max buttons don't seem to work anymore.
- They should probably just expose their OnMinimizeClick and
OnMaximizeClick events for the Titlebar to handle minimizing and
maximizing.
- The drag bar is Magenta (#ff00ff) currently.
- I'm not _sure_ we need a TabRowControl. We could probably get away with
removing it from the UI tree, I was just being dumb before.
* Fix the MMC buttons not working
I forgot to plumb the window handle through
* Make the titlebar less magenta
* Resize the drag region as we add/remove tabs
* Move the actual MMC handling to the TitlebarControl
* Some PR nits, fix the titlebar painting on maximize
* Put the TabRow in our XAML
* Remove dead code in preparation for review
* Horrifyingly try Gdi Plus as a solution, that is _wrong_ though
* Revert "Horrifyingly try Gdi Plus as a solution, that is _wrong_ though"
This reverts commit e038b5d9216c6710c2a7f81840d76f8130cd73b8.
* This fixes the bottom border but breaks the titlebar painting
* Fix the NC bottom border
* A bunch of the more minor PR nits
* Add a MinimizeClick event to the MMCControl
This works for Minimize. This is what I wanted to do originally.
* Add events for _all_ of the buttons, not just the Minimize btn
* Change hoe setting the titlebar content works
Now the app triggers a callcack on the host to set the content, instead of the host querying the app.
* Move the tab row to the bottom of it's available space
* Fix the theme reloading
* PR nits from @miniksa
* Update src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp
Co-Authored-By: Michael Niksa <miniksa@microsoft.com>
* This needed to be fixed, was missed in other PR nits
* runformat
wait _what_
* Does this fix the CI build?
2019-07-19 00:21:33 +02:00
|
|
|
RoutedEventArgs const& e)
|
2019-06-25 22:06:11 +02:00
|
|
|
{
|
2021-03-18 23:02:39 +01:00
|
|
|
_CloseClickHandlers(*this, e);
|
2019-06-25 22:06:11 +02:00
|
|
|
}
|
|
|
|
|
2019-10-02 19:27:07 +02:00
|
|
|
void MinMaxCloseControl::SetWindowVisualState(WindowVisualState visualState)
|
|
|
|
{
|
Get rid of the padding above the tab row when maximized (#5881)
## Summary of the Pull Request
When we maximize the window, shrink the caption buttons (the min, max, close buttons) down to 32px tall, to be the same height as the `TabRowControl`. This way, the tabs will be flush with the top of the display.
## PR Checklist
* [x] Closes #2541
* [x] I work here
* [ ] Tests added/passed
* [n/a] Requires documentation to be updated
## Detailed Description of the Pull Request / Additional comments
I tried for a couple hours this morning to do this as a `VisualState`. First I tried doing it as one on the TabRow, which I had very little success with. Then, I eventually realized that the TabRow wasn't even responsible for the padding there, it was being created by the fact that the caption buttons were too tall. Again, I tried to use the existing `VisualState`s they have defined for this, but I couldn't figure out how to do that.
I think the visual state solution would be _cleaner_, so if someone knows how to do that instead, please let me know.
## Validation Steps Performed
* Maximized/restored the Terminal on my display with the taskbar on the bottom
* Maximized/restored the Terminal on my display with the taskbar on the top
2020-05-22 00:26:37 +02:00
|
|
|
// Look up the heights we should use for the caption buttons from our
|
|
|
|
// XAML resources. "CaptionButtonHeightWindowed" and
|
|
|
|
// "CaptionButtonHeightMaximized" define the size we should use for the
|
|
|
|
// caption buttons height for the windowed and maximized states,
|
|
|
|
// respectively.
|
|
|
|
//
|
|
|
|
// use C++11 magic statics to make sure we only do this once.
|
|
|
|
static auto heights = [this]() {
|
|
|
|
const auto res = Resources();
|
|
|
|
const auto windowedHeightKey = winrt::box_value(L"CaptionButtonHeightWindowed");
|
|
|
|
const auto maximizedHeightKey = winrt::box_value(L"CaptionButtonHeightMaximized");
|
|
|
|
|
|
|
|
auto windowedHeight = 0.0;
|
|
|
|
auto maximizedHeight = 0.0;
|
|
|
|
if (res.HasKey(windowedHeightKey))
|
|
|
|
{
|
|
|
|
const auto valFromResources = res.Lookup(windowedHeightKey);
|
|
|
|
windowedHeight = winrt::unbox_value_or<double>(valFromResources, 0.0);
|
|
|
|
}
|
|
|
|
if (res.HasKey(maximizedHeightKey))
|
|
|
|
{
|
|
|
|
const auto valFromResources = res.Lookup(maximizedHeightKey);
|
|
|
|
maximizedHeight = winrt::unbox_value_or<double>(valFromResources, 0.0);
|
|
|
|
}
|
|
|
|
return std::tuple<double, double>{ windowedHeight, maximizedHeight };
|
|
|
|
}();
|
|
|
|
static const auto windowedHeight = std::get<0>(heights);
|
|
|
|
static const auto maximizedHeight = std::get<1>(heights);
|
|
|
|
|
2019-10-02 19:27:07 +02:00
|
|
|
switch (visualState)
|
|
|
|
{
|
|
|
|
case WindowVisualState::WindowVisualStateMaximized:
|
Get rid of the padding above the tab row when maximized (#5881)
## Summary of the Pull Request
When we maximize the window, shrink the caption buttons (the min, max, close buttons) down to 32px tall, to be the same height as the `TabRowControl`. This way, the tabs will be flush with the top of the display.
## PR Checklist
* [x] Closes #2541
* [x] I work here
* [ ] Tests added/passed
* [n/a] Requires documentation to be updated
## Detailed Description of the Pull Request / Additional comments
I tried for a couple hours this morning to do this as a `VisualState`. First I tried doing it as one on the TabRow, which I had very little success with. Then, I eventually realized that the TabRow wasn't even responsible for the padding there, it was being created by the fact that the caption buttons were too tall. Again, I tried to use the existing `VisualState`s they have defined for this, but I couldn't figure out how to do that.
I think the visual state solution would be _cleaner_, so if someone knows how to do that instead, please let me know.
## Validation Steps Performed
* Maximized/restored the Terminal on my display with the taskbar on the bottom
* Maximized/restored the Terminal on my display with the taskbar on the top
2020-05-22 00:26:37 +02:00
|
|
|
VisualStateManager::GoToState(MaximizeButton(), L"WindowStateMaximized", false);
|
|
|
|
|
|
|
|
MinimizeButton().Height(maximizedHeight);
|
|
|
|
MaximizeButton().Height(maximizedHeight);
|
|
|
|
CloseButton().Height(maximizedHeight);
|
2021-03-09 18:41:29 +01:00
|
|
|
MaximizeToolTip().Text(RS_(L"WindowRestoreDownButtonToolTip"));
|
2019-10-02 19:27:07 +02:00
|
|
|
break;
|
Get rid of the padding above the tab row when maximized (#5881)
## Summary of the Pull Request
When we maximize the window, shrink the caption buttons (the min, max, close buttons) down to 32px tall, to be the same height as the `TabRowControl`. This way, the tabs will be flush with the top of the display.
## PR Checklist
* [x] Closes #2541
* [x] I work here
* [ ] Tests added/passed
* [n/a] Requires documentation to be updated
## Detailed Description of the Pull Request / Additional comments
I tried for a couple hours this morning to do this as a `VisualState`. First I tried doing it as one on the TabRow, which I had very little success with. Then, I eventually realized that the TabRow wasn't even responsible for the padding there, it was being created by the fact that the caption buttons were too tall. Again, I tried to use the existing `VisualState`s they have defined for this, but I couldn't figure out how to do that.
I think the visual state solution would be _cleaner_, so if someone knows how to do that instead, please let me know.
## Validation Steps Performed
* Maximized/restored the Terminal on my display with the taskbar on the bottom
* Maximized/restored the Terminal on my display with the taskbar on the top
2020-05-22 00:26:37 +02:00
|
|
|
|
2019-10-02 19:27:07 +02:00
|
|
|
case WindowVisualState::WindowVisualStateNormal:
|
|
|
|
case WindowVisualState::WindowVisualStateIconified:
|
|
|
|
default:
|
Get rid of the padding above the tab row when maximized (#5881)
## Summary of the Pull Request
When we maximize the window, shrink the caption buttons (the min, max, close buttons) down to 32px tall, to be the same height as the `TabRowControl`. This way, the tabs will be flush with the top of the display.
## PR Checklist
* [x] Closes #2541
* [x] I work here
* [ ] Tests added/passed
* [n/a] Requires documentation to be updated
## Detailed Description of the Pull Request / Additional comments
I tried for a couple hours this morning to do this as a `VisualState`. First I tried doing it as one on the TabRow, which I had very little success with. Then, I eventually realized that the TabRow wasn't even responsible for the padding there, it was being created by the fact that the caption buttons were too tall. Again, I tried to use the existing `VisualState`s they have defined for this, but I couldn't figure out how to do that.
I think the visual state solution would be _cleaner_, so if someone knows how to do that instead, please let me know.
## Validation Steps Performed
* Maximized/restored the Terminal on my display with the taskbar on the bottom
* Maximized/restored the Terminal on my display with the taskbar on the top
2020-05-22 00:26:37 +02:00
|
|
|
VisualStateManager::GoToState(MaximizeButton(), L"WindowStateNormal", false);
|
|
|
|
|
|
|
|
MinimizeButton().Height(windowedHeight);
|
|
|
|
MaximizeButton().Height(windowedHeight);
|
|
|
|
CloseButton().Height(windowedHeight);
|
2021-03-09 18:41:29 +01:00
|
|
|
MaximizeToolTip().Text(RS_(L"WindowMaximizeButtonToolTip"));
|
2019-10-02 19:27:07 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-11-03 15:11:55 +01:00
|
|
|
|
2021-11-04 17:14:05 +01:00
|
|
|
// Method Description:
|
|
|
|
// - Called when the mouse hovers a button.
|
|
|
|
// - Transition that button to `PointerOver`
|
|
|
|
// - run the throttled func with this button, to display the tooltip after
|
|
|
|
// a timeout
|
|
|
|
// - dismiss any open tooltips on other buttons.
|
|
|
|
// Arguments:
|
|
|
|
// - button: the button that was hovered
|
2021-11-03 15:11:55 +01:00
|
|
|
void MinMaxCloseControl::HoverButton(CaptionButton button)
|
|
|
|
{
|
2021-11-16 19:49:23 +01:00
|
|
|
// Keep track of the button that's been pressed. we get a mouse move
|
|
|
|
// message when we open the tooltip. If we move the mouse on top of this
|
|
|
|
// button, that we've already pressed, then no need to move to the
|
|
|
|
// "hovered" state, we should stay in the pressed state.
|
|
|
|
if (_lastPressedButton && _lastPressedButton.value() == button)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-11-03 15:11:55 +01:00
|
|
|
switch (button)
|
|
|
|
{
|
2021-11-16 20:16:04 +01:00
|
|
|
// Make sure to use true for the useTransitions parameter, to
|
|
|
|
// animate the fade in/out transition between colors.
|
2021-11-03 15:11:55 +01:00
|
|
|
case CaptionButton::Minimize:
|
2021-11-16 20:16:04 +01:00
|
|
|
VisualStateManager::GoToState(MinimizeButton(), L"PointerOver", true);
|
|
|
|
VisualStateManager::GoToState(MaximizeButton(), L"Normal", true);
|
|
|
|
VisualStateManager::GoToState(CloseButton(), L"Normal", true);
|
2021-11-04 14:49:57 +01:00
|
|
|
|
2021-11-04 17:14:05 +01:00
|
|
|
_displayToolTip->Run(MinimizeButton());
|
2021-11-16 20:18:22 +01:00
|
|
|
closeToolTipForButton(MaximizeButton());
|
|
|
|
closeToolTipForButton(CloseButton());
|
2021-11-03 15:11:55 +01:00
|
|
|
break;
|
|
|
|
case CaptionButton::Maximize:
|
2021-11-16 20:16:04 +01:00
|
|
|
VisualStateManager::GoToState(MinimizeButton(), L"Normal", true);
|
|
|
|
VisualStateManager::GoToState(MaximizeButton(), L"PointerOver", true);
|
|
|
|
VisualStateManager::GoToState(CloseButton(), L"Normal", true);
|
2021-11-04 17:14:05 +01:00
|
|
|
|
2021-11-16 20:18:22 +01:00
|
|
|
closeToolTipForButton(MinimizeButton());
|
2021-11-04 17:14:05 +01:00
|
|
|
_displayToolTip->Run(MaximizeButton());
|
2021-11-16 20:18:22 +01:00
|
|
|
closeToolTipForButton(CloseButton());
|
2021-11-03 15:11:55 +01:00
|
|
|
break;
|
|
|
|
case CaptionButton::Close:
|
2021-11-16 20:16:04 +01:00
|
|
|
VisualStateManager::GoToState(MinimizeButton(), L"Normal", true);
|
|
|
|
VisualStateManager::GoToState(MaximizeButton(), L"Normal", true);
|
|
|
|
VisualStateManager::GoToState(CloseButton(), L"PointerOver", true);
|
2021-11-04 17:14:05 +01:00
|
|
|
|
2021-11-16 20:18:22 +01:00
|
|
|
closeToolTipForButton(MinimizeButton());
|
|
|
|
closeToolTipForButton(MaximizeButton());
|
2021-11-04 17:14:05 +01:00
|
|
|
_displayToolTip->Run(CloseButton());
|
2021-11-03 15:11:55 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-11-03 21:15:43 +01:00
|
|
|
|
2021-11-04 17:14:05 +01:00
|
|
|
// Method Description:
|
|
|
|
// - Called when the mouse presses down on a button. NOT when it is
|
|
|
|
// released. That's handled one level above, in
|
|
|
|
// TitleBarControl::ReleaseButtons
|
|
|
|
// - Transition that button to `Pressed`
|
|
|
|
// Arguments:
|
|
|
|
// - button: the button that was pressed
|
2021-11-03 15:11:55 +01:00
|
|
|
void MinMaxCloseControl::PressButton(CaptionButton button)
|
|
|
|
{
|
|
|
|
switch (button)
|
|
|
|
{
|
|
|
|
case CaptionButton::Minimize:
|
2021-11-16 20:16:04 +01:00
|
|
|
VisualStateManager::GoToState(MinimizeButton(), L"Pressed", true);
|
|
|
|
VisualStateManager::GoToState(MaximizeButton(), L"Normal", true);
|
|
|
|
VisualStateManager::GoToState(CloseButton(), L"Normal", true);
|
2021-11-03 15:11:55 +01:00
|
|
|
break;
|
|
|
|
case CaptionButton::Maximize:
|
2021-11-16 20:16:04 +01:00
|
|
|
VisualStateManager::GoToState(MinimizeButton(), L"Normal", true);
|
|
|
|
VisualStateManager::GoToState(MaximizeButton(), L"Pressed", true);
|
|
|
|
VisualStateManager::GoToState(CloseButton(), L"Normal", true);
|
2021-11-03 15:11:55 +01:00
|
|
|
break;
|
|
|
|
case CaptionButton::Close:
|
2021-11-16 20:16:04 +01:00
|
|
|
VisualStateManager::GoToState(MinimizeButton(), L"Normal", true);
|
|
|
|
VisualStateManager::GoToState(MaximizeButton(), L"Normal", true);
|
|
|
|
VisualStateManager::GoToState(CloseButton(), L"Pressed", true);
|
2021-11-03 15:11:55 +01:00
|
|
|
break;
|
|
|
|
}
|
2021-11-16 19:49:23 +01:00
|
|
|
_lastPressedButton = button;
|
2021-11-03 15:11:55 +01:00
|
|
|
}
|
2021-11-03 21:15:43 +01:00
|
|
|
|
2021-11-04 17:14:05 +01:00
|
|
|
// Method Description:
|
|
|
|
// - Called when buttons are no longer hovered or pressed. Return them all
|
|
|
|
// to the normal state, and dismiss the tooltips.
|
2021-11-03 18:12:38 +01:00
|
|
|
void MinMaxCloseControl::ReleaseButtons()
|
2021-11-03 15:11:55 +01:00
|
|
|
{
|
2021-11-04 17:14:05 +01:00
|
|
|
_displayToolTip->Run(nullptr);
|
2021-11-16 20:16:04 +01:00
|
|
|
VisualStateManager::GoToState(MinimizeButton(), L"Normal", true);
|
|
|
|
VisualStateManager::GoToState(MaximizeButton(), L"Normal", true);
|
|
|
|
VisualStateManager::GoToState(CloseButton(), L"Normal", true);
|
2021-11-04 17:14:05 +01:00
|
|
|
|
2021-11-16 20:18:22 +01:00
|
|
|
closeToolTipForButton(MinimizeButton());
|
|
|
|
closeToolTipForButton(MaximizeButton());
|
|
|
|
closeToolTipForButton(CloseButton());
|
2021-11-16 19:49:23 +01:00
|
|
|
|
|
|
|
_lastPressedButton = std::nullopt;
|
2021-11-03 15:11:55 +01:00
|
|
|
}
|
2019-06-25 22:06:11 +02:00
|
|
|
}
|