1/*
2 src/theme.cpp -- Storage class for basic theme-related properties
3
4 The text box widget was contributed by Christian Schueller.
5
6 NanoGUI was developed by Wenzel Jakob <wenzel.jakob@epfl.ch>.
7 The widget drawing code is based on the NanoVG demo application
8 by Mikko Mononen.
9
10 All rights reserved. Use of this source code is governed by a
11 BSD-style license that can be found in the LICENSE.txt file.
12*/
13
14#include <nanogui/theme.h>
15#include <nanogui/opengl.h>
16#include <nanogui/entypo.h>
17#include <nanogui_resources.h>
18
19NAMESPACE_BEGIN(nanogui)
20
21Theme::Theme(NVGcontext *ctx) {
22 mStandardFontSize = 16;
23 mButtonFontSize = 20;
24 mTextBoxFontSize = 20;
25 mIconScale = 0.77f;
26
27 mWindowCornerRadius = 2;
28 mWindowHeaderHeight = 30;
29 mWindowDropShadowSize = 10;
30 mButtonCornerRadius = 2;
31 mTabBorderWidth = 0.75f;
32 mTabInnerMargin = 5;
33 mTabMinButtonWidth = 20;
34 mTabMaxButtonWidth = 160;
35 mTabControlWidth = 20;
36 mTabButtonHorizontalPadding = 10;
37 mTabButtonVerticalPadding = 2;
38
39 mDropShadow = Color(0, 128);
40 mTransparent = Color(0, 0);
41 mBorderDark = Color(29, 255);
42 mBorderLight = Color(92, 255);
43 mBorderMedium = Color(35, 255);
44 mTextColor = Color(255, 160);
45 mDisabledTextColor = Color(255, 80);
46 mTextColorShadow = Color(0, 160);
47 mIconColor = mTextColor;
48
49 mButtonGradientTopFocused = Color(64, 255);
50 mButtonGradientBotFocused = Color(48, 255);
51 mButtonGradientTopUnfocused = Color(74, 255);
52 mButtonGradientBotUnfocused = Color(58, 255);
53 mButtonGradientTopPushed = Color(41, 255);
54 mButtonGradientBotPushed = Color(29, 255);
55
56 /* Window-related */
57 mWindowFillUnfocused = Color(43, 230);
58 mWindowFillFocused = Color(45, 230);
59 mWindowTitleUnfocused = Color(220, 160);
60 mWindowTitleFocused = Color(255, 190);
61
62 mWindowHeaderGradientTop = mButtonGradientTopUnfocused;
63 mWindowHeaderGradientBot = mButtonGradientBotUnfocused;
64 mWindowHeaderSepTop = mBorderLight;
65 mWindowHeaderSepBot = mBorderDark;
66
67 mWindowPopup = Color(50, 255);
68 mWindowPopupTransparent = Color(50, 0);
69
70 mCheckBoxIcon = ENTYPO_ICON_CHECK;
71 mMessageInformationIcon = ENTYPO_ICON_INFO_WITH_CIRCLE;
72 mMessageQuestionIcon = ENTYPO_ICON_HELP_WITH_CIRCLE;
73 mMessageWarningIcon = ENTYPO_ICON_WARNING;
74 mMessageAltButtonIcon = ENTYPO_ICON_CIRCLE_WITH_CROSS;
75 mMessagePrimaryButtonIcon = ENTYPO_ICON_CHECK;
76 mPopupChevronRightIcon = ENTYPO_ICON_CHEVRON_RIGHT;
77 mPopupChevronLeftIcon = ENTYPO_ICON_CHEVRON_LEFT;
78 mTabHeaderLeftIcon = ENTYPO_ICON_ARROW_BOLD_LEFT;
79 mTabHeaderRightIcon = ENTYPO_ICON_ARROW_BOLD_RIGHT;
80 mTextBoxUpIcon = ENTYPO_ICON_CHEVRON_UP;
81 mTextBoxDownIcon = ENTYPO_ICON_CHEVRON_DOWN;
82
83 mFontNormal = nvgCreateFontMem(ctx, "sans", roboto_regular_ttf,
84 roboto_regular_ttf_size, 0);
85 mFontBold = nvgCreateFontMem(ctx, "sans-bold", roboto_bold_ttf,
86 roboto_bold_ttf_size, 0);
87 mFontIcons = nvgCreateFontMem(ctx, "icons", entypo_ttf,
88 entypo_ttf_size, 0);
89 if (mFontNormal == -1 || mFontBold == -1 || mFontIcons == -1)
90 throw std::runtime_error("Could not load fonts!");
91}
92
93NAMESPACE_END(nanogui)
94