Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
stenzek
GitHub Repository: stenzek/duckstation
Path: blob/master/src/updater/cocoa_progress_callback.h
4243 views
1
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <[email protected]>
2
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
3
4
#pragma once
5
6
#include "common/progress_callback.h"
7
8
#include <AppKit/AppKit.h>
9
#include <Cocoa/Cocoa.h>
10
11
#ifndef __OBJC__
12
#error This file needs to be compiled with Objective C++.
13
#endif
14
15
#if __has_feature(objc_arc)
16
#error ARC should not be enabled.
17
#endif
18
19
class CocoaProgressCallback final : public ProgressCallback
20
{
21
public:
22
CocoaProgressCallback();
23
~CocoaProgressCallback();
24
25
void PushState() override;
26
void PopState() override;
27
28
void SetCancellable(bool cancellable) override;
29
void SetTitle(const std::string_view title) override;
30
void SetStatusText(const std::string_view text) override;
31
void SetProgressRange(u32 range) override;
32
void SetProgressValue(u32 value) override;
33
34
void DisplayError(const std::string_view message) override;
35
void DisplayWarning(const std::string_view message) override;
36
void DisplayInformation(const std::string_view message) override;
37
void DisplayDebugMessage(const std::string_view message) override;
38
39
void ModalError(const std::string_view message) override;
40
bool ModalConfirmation(const std::string_view message) override;
41
void ModalInformation(const std::string_view message) override;
42
43
private:
44
enum : int
45
{
46
WINDOW_WIDTH = 600,
47
WINDOW_HEIGHT = 300,
48
WINDOW_MARGIN = 20,
49
SUBWINDOW_PADDING = 10,
50
SUBWINDOW_WIDTH = WINDOW_WIDTH - WINDOW_MARGIN - WINDOW_MARGIN,
51
};
52
53
bool Create();
54
void Destroy();
55
void UpdateProgress();
56
void AppendMessage(const std::string_view message);
57
58
NSWindow* m_window = nil;
59
NSView* m_view = nil;
60
NSTextField* m_status = nil;
61
NSProgressIndicator* m_progress = nil;
62
NSScrollView* m_text_scroll = nil;
63
NSTextView* m_text = nil;
64
};
65
66