b05a557f48
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request This PR implements the ability to drop directories/files on the '+' button which in turn will open the tab/pane/window in the given starting path. In order to do this, I refactored the click's lambda into a method and re-used it Sadly I wasn't able to add note about the alt/shift feature (any ideas how to do this?) Also most of the code is "look-a-like" from other places within the project, as I don't have much experience in windows development. <!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> ## References implements #10073 ## PR Checklist * [ ] Closes #10073 * [ ] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [ ] Tests added/passed ** tests were done manually both of the old feature (alt/shift+click) on the '+' and on the profiles * [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx ** no idea what to add there, if any. * [ ] Schema updated. * [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx ## Detailed Description of the Pull Request / Additional comments ## Validation Steps Performed tested manually.
75 lines
2.3 KiB
C++
75 lines
2.3 KiB
C++
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT license.
|
|
|
|
#include "pch.h"
|
|
#include "TabRowControl.h"
|
|
|
|
#include "TabRowControl.g.cpp"
|
|
#include <LibraryResources.h>
|
|
|
|
using namespace winrt::Windows::ApplicationModel::DataTransfer;
|
|
|
|
using namespace winrt;
|
|
using namespace winrt::Microsoft::UI::Xaml;
|
|
using namespace winrt::Windows::UI::Text;
|
|
|
|
namespace winrt
|
|
{
|
|
namespace MUX = Microsoft::UI::Xaml;
|
|
namespace WUX = Windows::UI::Xaml;
|
|
}
|
|
|
|
namespace winrt::TerminalApp::implementation
|
|
{
|
|
TabRowControl::TabRowControl()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
// Method Description:
|
|
// - Bound in the Xaml editor to the [+] button.
|
|
// Arguments:
|
|
// <unused>
|
|
void TabRowControl::OnNewTabButtonClick(IInspectable const&, Controls::SplitButtonClickEventArgs const&)
|
|
{
|
|
}
|
|
|
|
// Method Description:
|
|
// - Bound in Drag&Drop of the Xaml editor to the [+] button.
|
|
// Arguments:
|
|
// <unused>
|
|
void TabRowControl::OnNewTabButtonDrop(IInspectable const&, winrt::Windows::UI::Xaml::DragEventArgs const&)
|
|
{
|
|
}
|
|
|
|
// Method Description:
|
|
// - Bound in Drag-over of the Xaml editor to the [+] button.
|
|
// Allows drop of 'StorageItems' which will be used as StartingDirectory
|
|
// Arguments:
|
|
// - <unused>
|
|
// - e: DragEventArgs which hold the items
|
|
void TabRowControl::OnNewTabButtonDragOver(IInspectable const&, winrt::Windows::UI::Xaml::DragEventArgs const& e)
|
|
{
|
|
// We can only handle drag/dropping StorageItems (files).
|
|
// If the format on the clipboard is anything else, returning
|
|
// early here will prevent the drag/drop from doing anything.
|
|
if (!e.DataView().Contains(StandardDataFormats::StorageItems()))
|
|
{
|
|
return;
|
|
}
|
|
|
|
// Make sure to set the AcceptedOperation, so that we can later receive the path in the Drop event
|
|
e.AcceptedOperation(DataPackageOperation::Copy);
|
|
|
|
// Sets custom UI text
|
|
e.DragUIOverride().Caption(RS_(L"DropPathTabRun/Text"));
|
|
|
|
// Sets if the caption is visible
|
|
e.DragUIOverride().IsCaptionVisible(true);
|
|
// Sets if the dragged content is visible
|
|
e.DragUIOverride().IsContentVisible(false);
|
|
// Sets if the glyph is visible
|
|
e.DragUIOverride().IsGlyphVisible(false);
|
|
}
|
|
}
|