UWP: use a listview to build the console

This commit is contained in:
Paul Rouget 2020-06-18 12:21:29 +02:00
parent 1527afff17
commit 9de955f2cc
5 changed files with 79 additions and 33 deletions

View file

@ -5,6 +5,7 @@
#pragma once
#include "BrowserPage.g.h"
#include "ConsoleLog.g.h"
#include "ServoControl/ServoControl.h"
#include "Devtools/Client.h"
@ -14,6 +15,7 @@ using namespace winrt::Windows;
using namespace winrt::Windows::Data::Json;
using namespace winrt::Windows::Foundation;
using namespace winrt::Windows::UI::Xaml;
using namespace winrt::Windows::UI::Xaml::Media;
static const hstring SERVO_SCHEME = L"fxr";
static const hstring SERVO_SCHEME_SLASH_SLASH = L"fxr://";
@ -46,6 +48,7 @@ public:
void OnDevtoolsMessage(servo::DevtoolsMessageLevel, hstring, hstring);
void ClearConsole();
void OnDevtoolsDetached();
Collections::IObservableVector<IInspectable> ConsoleLogs() { return mLogs; };
private:
void UpdatePref(ServoApp::Pref, Controls::Control);
@ -54,9 +57,31 @@ private:
DevtoolsStatus mDevtoolsStatus = DevtoolsStatus::Stopped;
unsigned int mDevtoolsPort = 0;
std::unique_ptr<servo::DevtoolsClient> mDevtoolsClient;
Collections::IObservableVector<IInspectable> mLogs;
};
struct ConsoleLog : ConsoleLogT<ConsoleLog> {
public:
ConsoleLog(Windows::UI::Color fg, Windows::UI::Color bg, hstring b, hstring s)
: mSource(s), mBody(b) {
mFgColor = UI::Xaml::Media::SolidColorBrush(fg);
mBgColor = UI::Xaml::Media::SolidColorBrush(bg);
};
SolidColorBrush FgColor() { return mFgColor; };
SolidColorBrush BgColor() { return mBgColor; };
hstring Source() { return mSource; };
hstring Body() { return mBody; };
private:
SolidColorBrush mFgColor;
SolidColorBrush mBgColor;
hstring mSource;
hstring mBody;
};
} // namespace winrt::ServoApp::implementation
namespace winrt::ServoApp::factory_implementation {
struct BrowserPage : BrowserPageT<BrowserPage, implementation::BrowserPage> {};
struct ConsoleLog : ConsoleLogT<ConsoleLog, implementation::ConsoleLog> {};
} // namespace winrt::ServoApp::factory_implementation