-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockProps.cs
402 lines (336 loc) · 12.5 KB
/
DockProps.cs
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
// <copyright file="DockProps.cs" company="Pixel Precision LLC">
// Copyright (c) 2020 All Rights Reserved
// </copyright>
// <author>William Leu</author>
// <date>04/12/2020</date>
// <summary>
// The properties of windows and docks of the UIDock system.
// </summary>
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace PxPre.UIDock
{
[CreateAssetMenu(menuName = "PxPre/DockProps")]
public class DockProps : ScriptableObject
{
/// <summary>
/// A struct coupling a sprite and color.
/// </summary>
[System.Serializable]
public struct SpriteAndColor
{
/// <summary>
/// The sprite.
/// </summary>
public Sprite sprite;
/// <summary>
/// The color.
/// </summary>
public Color color;
/// <summary>
/// Apply the pair properties to an image and also set the image to
/// show the sprite as a simple type.
/// </summary>
/// <param name="img">The image to apply to.</param>
public void ApplySimple(UnityEngine.UI.Image img)
{
this.Apply(img, UnityEngine.UI.Image.Type.Simple);
}
/// <summary>
/// Apply the pair properties to an image and also set the image to
/// show the sprite as a sliced type.
/// </summary>
/// <param name="img">The image to apply to.</param>
public void ApplySliced(UnityEngine.UI.Image img)
{
this.Apply(img, UnityEngine.UI.Image.Type.Sliced);
}
/// <summary>
/// Apple the pair properties to an image.
/// </summary>
/// <param name="img">The image to apply to.</param>
public void Apply(UnityEngine.UI.Image img)
{
img.sprite = this.sprite;
img.color = this.color;
}
/// <summary>
/// Apple the pair properties to an image and also set the image type.
/// </summary>
/// <param name="img">The image to apply to.</param>
/// <param name="type">The image type to apply on the image.</param>
public void Apply(UnityEngine.UI.Image img, UnityEngine.UI.Image.Type type)
{
this.Apply(img);
img.type = type;
}
}
/// <summary>
/// The setting for the window that change based on
/// different
/// </summary>
[System.Serializable]
public class WindowSetting
{
/// <summary>
/// The sprite for the plate of buttons.
/// </summary>
public SpriteAndColor spriteBtnPlate;
/// <summary>
/// The sprite for the frame of the windows.
/// </summary>
public SpriteAndColor spriteFrame;
/// <summary>
/// The width of the sizes of the window -
/// for floating windows, this is also the hitbox
/// for drag regions.
/// </summary>
public float splitterWidth = 10.0f;
/// <summary>
/// The width of titlebar buttons.
/// </summary>
public float btnWidth = 20.0f;
/// <summary>
/// The height of titlebar buttons.
/// </summary>
public float btnHeight = 20.0f;
/// <summary>
/// The height of the titlebar.
/// </summary>
public float titlebarHeight = 24.0f;
}
/// <summary>
/// The various types of windows that WindowSetting
/// is meant to represent.
/// </summary>
public enum WinType
{
/// <summary>
/// Undocked windows that are floating.
/// </summary>
Float,
/// <summary>
/// No window shoould be visible. Used to hide the window
/// when tabbed.
/// </summary>
BorderlessTabChild,
/// <summary>
/// Windows that aren't docked tabs that have the same style.
/// For now this is only locked windows.
/// </summary>
Borderless,
/// <summary>
/// Docked windows.
/// </summary>
Docked,
/// <summary>
/// The window that is maximized.
/// </summary>
Maximized
}
/// <summary>
/// Assets for docked notebook tabs.
/// These are put into a class that will be instanced only once in DockProps.
/// This is done for organizational reasons, to categorize all the notebook
/// tab assets and values outside of the other DockProp assets.
/// </summary>
[System.Serializable]
public class TabProperties
{
/// <summary>
/// The height of the area alloted to dock regions.
/// </summary>
public float rgnHeight = 20.0f;
/// <summary>
/// The left arrow to navigate compacted tabs.
/// </summary>
public Sprite leftCompactedTabs;
/// <summary>
/// The right arrow to navigate compacted tabs.
/// </summary>
public Sprite rightCompactedTabs;
/// <summary>
/// The button for compacted tabs.
/// </summary>
public Sprite compactedButtonPlate;
public Sprite closeWindowIcon;
/// <summary>
/// The width of the left and right compacted buttons.
/// </summary>
public float compactButtonWidth = 30.0f;
/// <summary>
/// The sprite for tabs.
/// </summary>
public Sprite tabPlate;
/// <summary>
/// The floor for tabs.
/// </summary>
public Sprite tabFloor;
/// <summary>
/// The close button plate.
/// </summary>
public Sprite innerTabBtn;
/// <summary>
/// The font used for tab text.
/// </summary>
public Font tabFont;
/// <summary>
/// The tab text font color.
/// </summary>
public Color tabFontColor;
/// <summary>
/// The tab text font size.
/// </summary>
public int tabFontSize;
/// <summary>
/// The maximum width of a tab.
/// </summary>
public float maxWidth = 100.0f;
/// <summary>
/// The minimum width of a tab.
/// </summary>
public float minWidth = 10.0f;
// The threshold of when a tab width transitions from normal to compact.
public float compactThreshold = 20.0f;
/// <summary>
/// The border of the close button on the top and bottom.
/// </summary>
public float closeBorderVert = 3.0f;
/// <summary>
/// The width of the close button.
/// </summary>
public float closeWidth = 20.0f;
/// <summary>
/// The border of the close button from the right.
/// </summary>
public float closeBorderRight = 5.0f;
}
/// <summary>
/// The titlebar icon sprite for the close button.
/// </summary>
public SpriteAndColor spriteBtnClose;
/// <summary>
/// The titlebar icon sprite for the restore button.
/// </summary>
public SpriteAndColor spriteBtnRestore;
/// <summary>
/// The titlebar icon sprite for the maximize button.
/// </summary>
public SpriteAndColor spriteBtnMax;
/// <summary>
/// The titlebar icon sprite for dropdowns.
/// </summary>
public SpriteAndColor spriteBtnPull;
/// <summary>
/// The titlebar icon sprite for undocking.
/// </summary>
public SpriteAndColor spriteBtnPin;
/// <summary>
/// The properties for floating windows.
/// </summary>
public WindowSetting floatWin = new WindowSetting();
/// <summary>
/// The properties for docked windows.
/// </summary>
public WindowSetting dockWin = new WindowSetting();
/// <summary>
/// The properties for maximuzed windows.
/// </summary>
public WindowSetting maximizeWin = new WindowSetting();
/// <summary>
/// The width for the padding of windows. For floating windows,
/// this is also the
/// </summary>
public float winPadding = 5.0f;
/// <summary>
/// The sprite for the shadow of floating windows.
/// </summary>
public SpriteAndColor shadow;
/// <summary>
/// The offset of the shadow to the window, for floating windows.
/// </summary>
public Vector2 shadowOffset = new Vector2(10.0f, 10.0f);
/// <summary>
/// The modulating color of the shadow.
/// </summary>
public Color shadowColor = Color.black;
/// <summary>
/// Sprite info for sashes.
/// </summary>
public SpriteAndColor sashSprite;
/// <summary>
/// The width of the sashes.
/// </summary>
public float sashWidth = 10;
/// <summary>
/// The font for titles.
/// </summary>
public Font titleFont;
/// <summary>
/// The font color for titles.
/// </summary>
public Color titleLabelColor = Color.black;
/// <summary>
/// the font size for titles.
/// </summary>
public int titleFontSize = 14;
/// <summary>
/// The size of the square in the center of a window
/// for the hitbox for docking into a window.
/// </summary>
public float dockIntoDim = 40.0f;
/// <summary>
/// The width of the hitbox for docking to the side
/// of a window.
/// </summary>
public float dockSideDim = 20.0f;
/// <summary>
/// The color of dock previews that are shown but not
/// being hovered over.
/// </summary>
public Color dockUnhover = new Color(1.0f, 0.5f, 0.25f);
/// <summary>
/// The color of dock previews that are shown and being
/// hovered over.
/// </summary>
public Color dockHover = new Color(0.0f, 1.0f, 0.0f);
/// <summary>
/// The time between clicks of titlebars to count as a double click.
/// </summary>
public float doubleClickRate = 0.5f;
/// <summary>
/// Includes frame decoration.
/// </summary>
public Vector2 minsizeWindow = new Vector2(50.0f, 50.0f);
/// <summary>
/// Includes frame decoration.
/// </summary>
public Vector2 minsizeTabs = new Vector2(50.0f, 50.0f);
public TabProperties tabs = new TabProperties();
/// <summary>
/// Get the window setting based off a style enum.
/// </summary>
/// <param name="wt">The style enum.</param>
/// <returns>The window setting matching the style enum.</returns>
public WindowSetting GetWindowSetting(WinType wt)
{
switch(wt)
{
case WinType.Docked:
return this.dockWin;
case WinType.Borderless:
case WinType.BorderlessTabChild:
// There really are no settings for borderless, but we return
// *something* to avoid null exceptions or having ensure null
// checks are wrapped where needed.
return this.dockWin;
case WinType.Float:
return this.floatWin;
case WinType.Maximized:
return this.maximizeWin;
}
return null;
}
}
}