Repository navigation
Expand file tree
/
Copy pathview.mmpFormHelp.pas
More file actions
243 lines (201 loc) · 7.02 KB
/
Copy pathview.mmpFormHelp.pas
File metadata and controls
243 lines (201 loc) · 7.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
{ MMP: Minimalist Media Player
Copyright (C) 2021-2099 Baz Cuda
https://github.com/BazzaCuda/MinimalistMediaPlayerX
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
}
unit view.mmpFormHelp;
interface
uses
{$ifopt D+}
{$define designTime} // comment out when not designing this form
{$endif}
{$define designTime} // temporary until we sort out the uses clause
{$ifdef designTime}
winApi.messages, winApi.windows,
system.classes, system.sysUtils, system.variants,
vcl.controls, vcl.stdCtrls, vcl.extCtrls, vcl.forms,
{$endif}
HTMLUn2, HtmlView, MarkDownViewerComponents,
mmpNotify.notices, mmpNotify.notifier, mmpNotify.subscriber,
mmpAction, mmpConsts;
type
IHelpForm = interface
end;
{$REGION}
// this should be in the implementation section but that would cause problems with the IDE
THelpForm = class(TForm)
backPanel: TPanel;
buttonPanel: TPanel;
shiftLabel: TLabel;
helpLabel: TLabel;
procedure FormResize(Sender: TObject);
protected
constructor Create(const aHeight: integer; const aHelpType: THelpType); reintroduce;
procedure CreateParams(var Params: TCreateParams); reintroduce;
public
end;
{$ENDREGION}
implementation
uses
winApi.shellAPI, system.strUtils,
bazCmd,
mmpGlobalState, mmpMarkDownUtils,
view.mmpFormStreamList,
_debugWindow;
type
// There were problems in D11 if we put the interface on a TForm, so an intermediary was used
THelpFormProxy = class(TInterfacedObject, IHelpForm)
strict private
FHelpForm: THelpForm;
FSubscriber: ISubscriber;
private
function onNotify(const aNotice: INotice): INotice;
protected
function createForm(const wr: TWndRec): THelpForm;
function moveForm(const wr: TWndRec): TVoid;
function showForm: TVoid;
function shutForm: TVoid;
public
constructor Create;
destructor Destroy; override;
function notify(const aNotice: INotice): INotice;
end;
function HW: IHelpForm;
{$J+} const gHelpFormProxy: IHelpForm = NIL; {$J-}
begin
case gHelpFormProxy = NIL of TRUE: gHelpFormProxy := THelpFormProxy.create; end;
result := gHelpFormProxy;
end;
{$R *.dfm}
{ THelpForm }
constructor THelpForm.Create(const aHeight: integer; const aHelpType: THelpType);
begin
inherited Create(NIL);
var md1 := TMarkdownViewer.create(backPanel);
var md2 := TMarkdownViewer.create(backPanel);
var md3 := TMarkdownViewer.create(backPanel);
md1.parent := backPanel;
md2.parent := backPanel;
md3.parent := backPanel;
mmpInitMarkDownViewer(md1);
mmpInitMarkDownViewer(md2);
mmpInitMarkDownViewer(md3);
md1.defFontSize := 10;
md2.defFontSize := 10;
md3.defFontSize := 10;
md1.align := alLeft;
md3.align := alRight;
md2.align := alClient;
md1.noSelect := TRUE;
md2.noSelect := TRUE;
md3.noSelect := TRUE;
md1.cursor := crDefault;
md2.cursor := crDefault;
md3.cursor := crDefault;
SELF.width := 600;
case aHeight > UI_DEFAULT_AUDIO_HEIGHT of TRUE: SELF.height := aHeight;
FALSE: SELF.height := 600; end;
md1.width := SELF.width div 3;
md2.width := SELF.width div 3;
md3.width := SELF.width div 3;
md1.margins.top := 6;
md2.margins.top := 6;
md3.margins.top := 6;
buttonPanel.margins.bottom := 4;
case aHelpType of htMain: begin
mmpLoadMarkDownFromResource(md1, 'resource_mdHelp1');
mmpLoadMarkDownFromResource(md2, 'resource_mdHelp2');
mmpLoadMarkDownFromResource(md3, 'resource_mdHelp3'); end;
htIATB: begin
mmpLoadMarkDownFromResource(md1, 'resource_mdImages1');
mmpLoadMarkDownFromResource(md2, 'resource_mdImages2');
mmpLoadMarkDownFromResource(md3, 'resource_mdImages3'); end;
end;
setWindowLong(handle, GWL_STYLE, getWindowLong(handle, GWL_STYLE) OR WS_CAPTION AND (NOT (WS_BORDER)));
color := DARK_MODE_DARK;
end;
procedure THelpForm.CreateParams(var Params: TCreateParams);
// no taskbar icon for the app
begin
inherited;
params.exStyle := params.ExStyle or (WS_EX_APPWINDOW);
case GS.showingTimeline of TRUE: params.wndParent := mmpStreamListHandle;
FALSE: params.wndParent := GS.mainForm.HANDLE; end; // application.HANDLE;
end;
procedure THelpForm.FormResize(Sender: TObject);
begin
helpLabel.invalidate;
buttonPanel.invalidate;
end;
{ THelpProxy }
constructor THelpFormProxy.Create;
begin
inherited;
FSubscriber := appEvents.subscribe(newSubscriber(onNotify));
end;
function THelpFormProxy.createForm(const wr: TWndRec): THelpForm;
begin
result := FHelpForm;
case wr.createNew of FALSE: EXIT; end;
result := THelpForm.create(wr.height, wr.helpType);
end;
destructor THelpFormProxy.Destroy;
begin
appEvents.unsubscribe(FSubscriber);
// FSubscriber := NIL;
shutForm;
inherited;
end;
function THelpFormProxy.moveForm(const wr: TWndRec): TVoid;
begin
FHelpForm := createForm(wr);
case FHelpForm = NIL of TRUE: EXIT; end; // createNew = FALSE and there isn't a current playlist window. Used for repositioning the window when the main UI moves or resizes.
GS.notify(newNotice(evGSShowingHelp, TRUE));
case wr.height > UI_DEFAULT_AUDIO_HEIGHT of TRUE: FHelpForm.height := wr.height; end;
screen.cursor := crDefault;
mmp.cmd(evHelpShowHelp);
winAPI.windows.setWindowPos(FHelpForm.handle, HWND_TOP, wr.pt.X, wr.pt.Y, 0, 0, SWP_SHOWWINDOW + SWP_NOSIZE);
setForegroundWindow(wr.HWND);
mmp.cmd(evGSWidthHelp, FHelpForm.width);
end;
function THelpFormProxy.notify(const aNotice: INotice): INotice;
begin
result := onNotify(aNotice);
end;
function THelpFormProxy.onNotify(const aNotice: INotice): INotice;
begin
result := aNotice;
case aNotice = NIL of TRUE: EXIT; end;
case aNotice.event of
evHelpMoveHelp: moveForm(aNotice.wndRec);
evHelpShutHelp: shutForm;
evHelpShowHelp: showForm;
end;
end;
function THelpFormProxy.showForm: TVoid;
begin
case FHelpForm = NIL of TRUE: EXIT; end;
FHelpForm.show;
end;
function THelpFormProxy.shutForm: TVoid;
begin
case FHelpForm = NIL of TRUE: EXIT; end;
FHelpForm.close;
FHelpForm.Free;
FHelpForm := NIL;
mmp.cmd(evGSWidthHelp, 0);
GS.notify(newNotice(evGSShowingHelp, FALSE));
end;
initialization
HW; // to create the appEvents.subscriber
end.