forked from danilw/nanogui-GLES-wasm
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy paththeme.cpp
93 lines (78 loc) · 3.94 KB
/
theme.cpp
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
/*
src/theme.cpp -- Storage class for basic theme-related properties
The text box widget was contributed by Christian Schueller.
NanoGUI was developed by Wenzel Jakob <wenzel.jakob@epfl.ch>.
The widget drawing code is based on the NanoVG demo application
by Mikko Mononen.
All rights reserved. Use of this source code is governed by a
BSD-style license that can be found in the LICENSE.txt file.
*/
#include <nanogui/theme.h>
#include <nanogui/opengl.h>
#include <nanogui/entypo.h>
#include <nanogui_resources.h>
NAMESPACE_BEGIN(nanogui)
Theme::Theme(NVGcontext *ctx) {
mStandardFontSize = 16;
mButtonFontSize = 20;
mTextBoxFontSize = 20;
mIconScale = 0.77f;
mWindowCornerRadius = 2;
mWindowHeaderHeight = 30;
mWindowDropShadowSize = 10;
mButtonCornerRadius = 2;
mTabBorderWidth = 0.75f;
mTabInnerMargin = 5;
mTabMinButtonWidth = 20;
mTabMaxButtonWidth = 160;
mTabControlWidth = 20;
mTabButtonHorizontalPadding = 10;
mTabButtonVerticalPadding = 2;
mDropShadow = Color(0, 128);
mTransparent = Color(0, 0);
mBorderDark = Color(29, 255);
mBorderLight = Color(92, 255);
mBorderMedium = Color(35, 255);
mTextColor = Color(255, 160);
mDisabledTextColor = Color(255, 80);
mTextColorShadow = Color(0, 160);
mIconColor = mTextColor;
mButtonGradientTopFocused = Color(64, 255);
mButtonGradientBotFocused = Color(48, 255);
mButtonGradientTopUnfocused = Color(74, 255);
mButtonGradientBotUnfocused = Color(58, 255);
mButtonGradientTopPushed = Color(41, 255);
mButtonGradientBotPushed = Color(29, 255);
/* Window-related */
mWindowFillUnfocused = Color(43, 230);
mWindowFillFocused = Color(45, 230);
mWindowTitleUnfocused = Color(220, 160);
mWindowTitleFocused = Color(255, 190);
mWindowHeaderGradientTop = mButtonGradientTopUnfocused;
mWindowHeaderGradientBot = mButtonGradientBotUnfocused;
mWindowHeaderSepTop = mBorderLight;
mWindowHeaderSepBot = mBorderDark;
mWindowPopup = Color(50, 255);
mWindowPopupTransparent = Color(50, 0);
mCheckBoxIcon = ENTYPO_ICON_CHECK;
mMessageInformationIcon = ENTYPO_ICON_INFO_WITH_CIRCLE;
mMessageQuestionIcon = ENTYPO_ICON_HELP_WITH_CIRCLE;
mMessageWarningIcon = ENTYPO_ICON_WARNING;
mMessageAltButtonIcon = ENTYPO_ICON_CIRCLE_WITH_CROSS;
mMessagePrimaryButtonIcon = ENTYPO_ICON_CHECK;
mPopupChevronRightIcon = ENTYPO_ICON_CHEVRON_RIGHT;
mPopupChevronLeftIcon = ENTYPO_ICON_CHEVRON_LEFT;
mTabHeaderLeftIcon = ENTYPO_ICON_ARROW_BOLD_LEFT;
mTabHeaderRightIcon = ENTYPO_ICON_ARROW_BOLD_RIGHT;
mTextBoxUpIcon = ENTYPO_ICON_CHEVRON_UP;
mTextBoxDownIcon = ENTYPO_ICON_CHEVRON_DOWN;
mFontNormal = nvgCreateFontMem(ctx, "sans", roboto_regular_ttf,
roboto_regular_ttf_size, 0);
mFontBold = nvgCreateFontMem(ctx, "sans-bold", roboto_bold_ttf,
roboto_bold_ttf_size, 0);
mFontIcons = nvgCreateFontMem(ctx, "icons", entypo_ttf,
entypo_ttf_size, 0);
if (mFontNormal == -1 || mFontBold == -1 || mFontIcons == -1)
throw std::runtime_error("Could not load fonts!");
}
NAMESPACE_END(nanogui)