2019-05-03 00:29:04 +02:00
|
|
|
// Copyright (c) Microsoft Corporation.
|
|
|
|
// Licensed under the MIT license.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include <winrt/Microsoft.UI.Xaml.Controls.h>
|
2019-06-07 23:56:44 +02:00
|
|
|
#include "Pane.h"
|
2019-05-03 00:29:04 +02:00
|
|
|
|
|
|
|
class Tab
|
|
|
|
{
|
|
|
|
public:
|
2019-06-07 23:56:44 +02:00
|
|
|
Tab(const GUID& profile, const winrt::Microsoft::Terminal::TerminalControl::TermControl& control);
|
2019-05-03 00:29:04 +02:00
|
|
|
|
|
|
|
winrt::Microsoft::UI::Xaml::Controls::TabViewItem GetTabViewItem();
|
2019-06-07 23:56:44 +02:00
|
|
|
winrt::Windows::UI::Xaml::UIElement GetRootElement();
|
|
|
|
winrt::Microsoft::Terminal::TerminalControl::TermControl GetFocusedTerminalControl();
|
|
|
|
std::optional<GUID> GetFocusedProfile() const noexcept;
|
2019-05-03 00:29:04 +02:00
|
|
|
|
2019-06-07 23:56:44 +02:00
|
|
|
bool IsFocused() const noexcept;
|
|
|
|
void SetFocused(const bool focused);
|
2019-05-03 00:29:04 +02:00
|
|
|
|
2019-06-07 23:56:44 +02:00
|
|
|
void Scroll(const int delta);
|
2019-08-28 16:40:16 +02:00
|
|
|
|
|
|
|
bool CanSplitPane(Pane::SplitState splitType);
|
|
|
|
void SplitPane(Pane::SplitState splitType, const GUID& profile, winrt::Microsoft::Terminal::TerminalControl::TermControl& control);
|
2019-05-03 00:29:04 +02:00
|
|
|
|
2019-06-07 23:56:44 +02:00
|
|
|
void UpdateFocus();
|
2019-08-15 01:12:14 +02:00
|
|
|
void UpdateIcon(const winrt::hstring iconPath);
|
|
|
|
|
Enable resizing the panes with the keyboard. (#1207)
Adds the ability to resize panes with the keyboard.
This is accomplished by making the Column/RowDefinitions for a Pane use `GridLengthHelper::FromPixels` to set their size. We store a pair of floats that represents the relative amount that each pane takes out of the parent pane. When the window is resized, we use that percentage to figure out the new size of each child in pixels, and manually size each column.
Then, when the user presses the keybindings for resizePane{Left/Right/Up/Down}, we'll adjust those percentages, and resize the rows/cols as appropriate.
Currently, each pane adjusts the width/height by 5% of the total size at a time. I am not in love with this, but it works for now. I think when we get support for keybindings with arbitrary arg blobs, then we could do either a percent movement, or a number of characters at a time. The number of characters one would be trickier, because we'd have to get the focused control, and get the number of pixels per character, as adjacent panes might not have the same font sizes.
2019-07-10 15:27:12 +02:00
|
|
|
void ResizeContent(const winrt::Windows::Foundation::Size& newSize);
|
|
|
|
void ResizePane(const winrt::TerminalApp::Direction& direction);
|
2019-07-17 16:30:15 +02:00
|
|
|
void NavigateFocus(const winrt::TerminalApp::Direction& direction);
|
2019-06-07 23:56:44 +02:00
|
|
|
|
|
|
|
void UpdateSettings(const winrt::Microsoft::Terminal::Settings::TerminalSettings& settings, const GUID& profile);
|
|
|
|
winrt::hstring GetFocusedTitle() const;
|
|
|
|
void SetTabText(const winrt::hstring& text);
|
|
|
|
|
2019-07-19 02:23:40 +02:00
|
|
|
void ClosePane();
|
|
|
|
|
2019-06-07 23:56:44 +02:00
|
|
|
DECLARE_EVENT(Closed, _closedHandlers, winrt::Microsoft::Terminal::TerminalControl::ConnectionClosedEventArgs);
|
2019-05-03 00:29:04 +02:00
|
|
|
|
|
|
|
private:
|
2019-06-07 23:56:44 +02:00
|
|
|
std::shared_ptr<Pane> _rootPane{ nullptr };
|
2019-08-15 01:12:14 +02:00
|
|
|
winrt::hstring _lastIconPath{};
|
2019-06-07 23:56:44 +02:00
|
|
|
|
|
|
|
bool _focused{ false };
|
|
|
|
winrt::Microsoft::UI::Xaml::Controls::TabViewItem _tabViewItem{ nullptr };
|
2019-05-03 00:29:04 +02:00
|
|
|
|
|
|
|
void _MakeTabViewItem();
|
|
|
|
void _Focus();
|
|
|
|
};
|