Compare commits

...

2 commits

Author SHA1 Message Date
Mike Griese eded53abe1 oh no the DPI scaling doesn't work for this at all 2019-08-10 18:00:01 -05:00
Mike Griese 25de1a2940 Some basic dragging hookup 2019-08-10 17:36:55 -05:00
2 changed files with 64 additions and 1 deletions

View file

@ -11,7 +11,7 @@ using namespace winrt::Microsoft::Terminal::Settings;
using namespace winrt::Microsoft::Terminal::TerminalControl;
using namespace winrt::TerminalApp;
static const int PaneSeparatorSize = 4;
static const int PaneSeparatorSize = 16;
static const float Half = 0.50f;
Pane::Pane(const GUID& profile, const TermControl& control, const bool lastFocused) :
@ -741,6 +741,66 @@ void Pane::_CreateSplitContent()
{
// Create the pane separator
_separatorRoot = Controls::Grid{};
// Controls::UserControl control{};
// _separatorRoot.Children().Append(control);
// _separatorRoot.ManipulationMode(winrt::Windows::UI::Xaml::Input::ManipulationModes::TranslateX
// | winrt::Windows::UI::Xaml::Input::ManipulationModes::TranslateY);
_separatorRoot.ManipulationMode(winrt::Windows::UI::Xaml::Input::ManipulationModes::All);
auto brush = Media::SolidColorBrush{};
brush.Color(winrt::Windows::UI::Colors::Transparent());
_separatorRoot.Background(brush);
_separatorRoot.ManipulationStarted([this](auto&&, auto& args) {
auto pos = args.Position();
pos;
cumulative = Point{ 0, 0 };
});
_separatorRoot.ManipulationDelta([this](auto&&, auto& args) {
auto pos = args.Position();
pos;
auto posCopy = pos;
auto transform = _root.TransformToVisual(nullptr);
auto inverse = transform.Inverse();
auto offset = transform.TransformPoint({ 0, 0 });
auto delta = args.Delta();
auto deltaTrans = delta.Translation;
// Turn the delta into a percentage
const Size actualSize{ gsl::narrow_cast<float>(_root.ActualWidth()),
gsl::narrow_cast<float>(_root.ActualHeight()) };
const bool changeWidth = _splitState == SplitState::Vertical;
auto actualDimension = changeWidth ? actualSize.Width : actualSize.Height;
actualDimension -= PaneSeparatorSize;
auto deltaPercent = deltaTrans.X / actualDimension;
_firstPercent = _firstPercent.value() + deltaPercent;
_secondPercent = 1.0f - _firstPercent.value();
// Resize our columns to match the new percentages.
ResizeContent(actualSize);
// auto trans = transform.try_as<Media::TranslateTransform>();
// auto transform = winrt::Windows::UI::Xaml::TransformToVisual(_root);
// auto rel = inverse.TransformPoint(posCopy);
// auto rootOrigin = _root.Position();
// auto relativePos = { pos.X - rootOrigin.X,
// pos.Y - rootOrigin.Y
// };
auto rel = { pos.X - offset.X, pos.Y - offset.Y };
cumulative.X += deltaTrans.X;
cumulative.Y += deltaTrans.Y;
auto theThing = cumulative;
auto a = 0;
a++;
a;
});
_separatorRoot.ManipulationCompleted([](auto&&, auto& args) {
auto pos = args.Position();
pos;
});
_separatorRoot.Width(PaneSeparatorSize);
// NaN is the special value XAML uses for "Auto" sizing.
_separatorRoot.Height(NAN);

View file

@ -96,6 +96,9 @@ private:
winrt::Windows::Foundation::Size _GetMinSize() const;
winrt::Windows::Foundation::Point cumulative{ 0, 0 };
float _overDrag = 0;
// Function Description:
// - Returns true if the given direction can be used with the given split
// type.