GUI colors constants

This commit is contained in:
redtide 2023-04-11 14:23:43 +02:00
parent 5c681d849d
commit a64ec5baea
6 changed files with 134 additions and 65 deletions

View file

@ -31,8 +31,12 @@ set(EDITOR_RESOURCES
Fonts/Roboto-Regular.ttf
Themes/Default/theme.xml
Themes/Dark/theme.xml
PARENT_SCOPE)
PARENT_SCOPE
)
set(UI_RESOURCES
resources/Themes/Default/theme.xml
resources/Themes/Dark/theme.xml
)
function(copy_editor_resources TARGET SOURCE_DIR DESTINATION_DIR)
set(_deps)
foreach(res ${EDITOR_RESOURCES})
@ -51,6 +55,7 @@ endfunction()
set(UI_FILES layout/main.fl layout/about.fl)
source_group("Editor UI" FILES ${UI_FILES})
source_group("Editor Resources" FILES ${UI_RESOURCES})
# editor
add_library(sfizz_editor STATIC EXCLUDE_FROM_ALL
@ -63,6 +68,8 @@ add_library(sfizz_editor STATIC EXCLUDE_FROM_ALL
src/editor/EditorController.h
src/editor/GUIComponents.h
src/editor/GUIComponents.cpp
src/editor/GUIDefs.h
src/editor/GUIDefs.cpp
src/editor/GUIHelpers.h
src/editor/GUIHelpers.cpp
src/editor/GUIPiano.h
@ -83,7 +90,9 @@ add_library(sfizz_editor STATIC EXCLUDE_FROM_ALL
src/editor/layout/about.hpp
src/editor/utility/vstgui_after.h
src/editor/utility/vstgui_before.h
${UI_FILES})
${UI_FILES}
${UI_RESOURCES}
)
add_library(sfizz::editor ALIAS sfizz_editor)
target_include_directories(sfizz_editor PUBLIC "src")
target_link_libraries(sfizz_editor PUBLIC sfizz::messaging sfizz::plugins-common)

View file

@ -6,6 +6,7 @@
#include "DlgAbout.h"
#include "GUIComponents.h"
#include "GUIDefs.h"
#include "GitBuildId.h"
#include "NativeHelpers.h"
@ -15,23 +16,25 @@
#include <absl/strings/str_cat.h>
using namespace gui;
SAboutDialog::SAboutDialog(const CRect& bounds)
: CViewContainer(bounds)
{
SharedPointer<CBitmap> logo = owned(new CBitmap("logo_orange.png"));
setBackgroundColor(CColor(0x00, 0x00, 0x00, 0xc0));
setBackgroundColor(kColorControlsScroller);
CView* aboutView = nullptr;
{
auto createaboutView = [](const CRect& bounds, int, const char*, CHoriTxtAlign, int) {
CViewContainer* container = new CViewContainer(bounds);
container->setBackgroundColor(CColor(0x00, 0x00, 0x00, 0x00));
container->setBackgroundColor(kColorTransparent);
return container;
};
auto createLogo = [&logo](const CRect& bounds, int, const char*, CHoriTxtAlign, int) {
CViewContainer* container = new CViewContainer(bounds);
container->setBackgroundColor(CColor(0x00, 0x00, 0x00, 0x00));
container->setBackgroundColor(kColorTransparent);
container->setBackground(logo);
return container;
};
@ -40,9 +43,9 @@ SAboutDialog::SAboutDialog(const CRect& bounds)
CMultiLineTextLabel* lbl = new CMultiLineTextLabel(bounds);
auto font = makeOwned<CFontDesc>("Roboto", fontsize);
lbl->setFont(font);
lbl->setFontColor(CColor(0xff, 0xff, 0xff, 0xff));
lbl->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
lbl->setBackColor(CColor(0x00, 0x00, 0x00, 0x00));
lbl->setFontColor(kWhiteCColor);
lbl->setFrameColor(kColorTransparent);
lbl->setBackColor(kColorTransparent);
lbl->setHoriAlign(align);
const char* version = SFIZZ_VERSION;
@ -62,9 +65,9 @@ SAboutDialog::SAboutDialog(const CRect& bounds)
CMultiLineTextLabel* lbl = new CMultiLineTextLabel(bounds);
auto font = makeOwned<CFontDesc>("Roboto", fontsize);
lbl->setFont(font);
lbl->setFontColor(CColor(0xff, 0xff, 0xff, 0xff));
lbl->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
lbl->setBackColor(CColor(0x00, 0x00, 0x00, 0x00));
lbl->setFontColor(kWhiteCColor);
lbl->setFrameColor(kColorTransparent);
lbl->setBackColor(kColorTransparent);
lbl->setHoriAlign(align);
lbl->setText(absl::StrCat(
u8"Maintainers: Paul Ferrand, Jean-Pierre Cimalando\n"
@ -77,9 +80,9 @@ SAboutDialog::SAboutDialog(const CRect& bounds)
auto createHoverBox = [](const CRect& bounds, int, const char* label, CHoriTxtAlign align, int fontsize) {
CTextLabel* lbl = new CTextLabel(bounds, label);
auto font = makeOwned<CFontDesc>("Roboto", fontsize);
lbl->setFontColor(CColor(0xfd, 0x98, 0x00, 0xff));
lbl->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
lbl->setBackColor(CColor(0x00, 0x00, 0x00, 0x00));
lbl->setFontColor(kColorOrange);
lbl->setFrameColor(kColorTransparent);
lbl->setBackColor(kColorTransparent);
lbl->setHoriAlign(align);
lbl->setFont(font);
return lbl;
@ -89,9 +92,9 @@ SAboutDialog::SAboutDialog(const CRect& bounds)
CMultiLineTextLabel* lbl = new CMultiLineTextLabel(bounds);
auto font = makeOwned<CFontDesc>("Roboto", fontsize, kBoldFace);
lbl->setFont(font);
lbl->setFontColor(CColor(0xfd, 0x98, 0x00, 0xff));
lbl->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
lbl->setBackColor(CColor(0x00, 0x00, 0x00, 0x00));
lbl->setFontColor(kColorOrange);
lbl->setFrameColor(kColorTransparent);
lbl->setBackColor(kColorTransparent);
lbl->setHoriAlign(align);
lbl->setText(label);
return lbl;
@ -101,9 +104,9 @@ SAboutDialog::SAboutDialog(const CRect& bounds)
CMultiLineTextLabel* lbl = new CMultiLineTextLabel(bounds);
auto font = makeOwned<CFontDesc>("Roboto", fontsize);
lbl->setFont(font);
lbl->setFontColor(CColor(0xff, 0xff, 0xff, 0xff));
lbl->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
lbl->setBackColor(CColor(0x00, 0x00, 0x00, 0x00));
lbl->setFontColor(kWhiteCColor);
lbl->setFrameColor(kColorTransparent);
lbl->setBackColor(kColorTransparent);
lbl->setHoriAlign(align);
lbl->setText(label);
return lbl;
@ -113,9 +116,9 @@ SAboutDialog::SAboutDialog(const CRect& bounds)
STextButton* btn = new STextButton(bounds, this, tag, glyph);
btn->setFont(makeOwned<CFontDesc>("Sfizz Misc Icons", fontsize));
btn->setTextColor(kWhiteCColor);
btn->setHighlightColor(CColor(0xfd, 0x98, 0x00, 0xff));
btn->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
btn->setFrameColorHighlighted(CColor(0x00, 0x00, 0x00, 0x00));
btn->setHighlightColor(kColorOrange);
btn->setFrameColor(kColorTransparent);
btn->setFrameColorHighlighted(kColorTransparent);
btn->setGradient(nullptr);
btn->setGradientHighlighted(nullptr);
return btn;

View file

@ -7,6 +7,7 @@
#include "Editor.h"
#include "EditorController.h"
#include "EditIds.h"
#include "GUIDefs.h"
#include "GUIComponents.h"
#include "GUIHelpers.h"
#include "GUIPiano.h"
@ -44,6 +45,7 @@
#include "utility/vstgui_after.h"
using namespace VSTGUI;
using namespace gui;
const int Editor::viewWidth { 800 };
const int Editor::viewHeight { 475 };
@ -366,9 +368,9 @@ void Editor::close()
SLevelMeter* Editor::Impl::createVMeter(const CRect& bounds, int, const char*, CHoriTxtAlign, int) {
SLevelMeter* meter = new SLevelMeter(bounds);
Palette* palette = &theme_->invertedPalette;
meter->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
meter->setNormalFillColor(CColor(0x00, 0xaa, 0x11));
meter->setDangerFillColor(CColor(0xaa, 0x00, 0x00));
meter->setFrameColor(kColorTransparent);
meter->setNormalFillColor(kColorMeterNormal);
meter->setDangerFillColor(kColorMeterDanger);
meter->setBackColor(palette->knobInactiveTrack);
return meter;
};
@ -742,7 +744,7 @@ void Editor::Impl::createFrameContents()
auto createLogicalGroup = [](const CRect& bounds, int, const char*, CHoriTxtAlign, int) {
CViewContainer* container = new CViewContainer(bounds);
container->setBackgroundColor(CColor(0x00, 0x00, 0x00, 0x00));
container->setBackgroundColor(kColorTransparent);
return container;
};
auto createRoundedGroup = [this, &palette](const CRect& bounds, int, const char*, CHoriTxtAlign, int) {
@ -783,8 +785,8 @@ void Editor::Impl::createFrameContents()
};
auto createLabel = [this, &palette](const CRect& bounds, int, const char* label, CHoriTxtAlign align, int fontsize) {
CTextLabel* lbl = new CTextLabel(bounds, label);
lbl->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
lbl->setBackColor(CColor(0x00, 0x00, 0x00, 0x00));
lbl->setFrameColor(kColorTransparent);
lbl->setBackColor(kColorTransparent);
OnThemeChanged.push_back([lbl, palette]() {
lbl->setFontColor(palette->text);
});
@ -795,8 +797,8 @@ void Editor::Impl::createFrameContents()
};
auto createInactiveLabel = [this, &palette](const CRect& bounds, int, const char* label, CHoriTxtAlign align, int fontsize) {
CTextLabel* lbl = new CTextLabel(bounds, label);
lbl->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
lbl->setBackColor(CColor(0x00, 0x00, 0x00, 0x00));
lbl->setFrameColor(kColorTransparent);
lbl->setBackColor(kColorTransparent);
OnThemeChanged.push_back([lbl, palette]() {
lbl->setFontColor(palette->inactiveText);
});
@ -816,8 +818,8 @@ void Editor::Impl::createFrameContents()
};
auto createValueLabel = [this, &palette](const CRect& bounds, int, const char* label, CHoriTxtAlign align, int fontsize) {
CTextLabel* lbl = new CTextLabel(bounds, label);
lbl->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
lbl->setBackColor(CColor(0x00, 0x00, 0x00, 0x00));
lbl->setFrameColor(kColorTransparent);
lbl->setBackColor(kColorTransparent);
OnThemeChanged.push_back([lbl, palette]() {
lbl->setFontColor(palette->text);
});
@ -828,7 +830,7 @@ void Editor::Impl::createFrameContents()
};
auto createBadge = [this, &palette](const CRect& bounds, int, const char* label, CHoriTxtAlign align, int fontsize) {
CTextLabel* lbl = new CTextLabel(bounds, label);
lbl->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
lbl->setFrameColor(kColorTransparent);
OnThemeChanged.push_back([lbl, palette]() {
lbl->setBackColor(palette->valueBackground);
lbl->setFontColor(palette->valueText);
@ -851,9 +853,9 @@ void Editor::Impl::createFrameContents()
button->setInactiveColor(palette->inactiveText);
button->setHighlightColor(palette->highlightedText);
});
button->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
button->setFrameColorHighlighted(CColor(0x00, 0x00, 0x00, 0x00));
SharedPointer<CGradient> gradient = owned(CGradient::create(0.0, 1.0, CColor(0x00, 0x00, 0x00, 0x00), CColor(0x00, 0x00, 0x00, 0x00)));
button->setFrameColor(kColorTransparent);
button->setFrameColorHighlighted(kColorTransparent);
SharedPointer<CGradient> gradient = owned(CGradient::create(0.0, 1.0, kColorTransparent, kColorTransparent));
button->setGradient(gradient);
button->setGradientHighlighted(gradient);
return button;
@ -871,8 +873,8 @@ void Editor::Impl::createFrameContents()
button->setGradient(gradient);
button->setGradientHighlighted(gradient);
});
button->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
button->setFrameColorHighlighted(CColor(0x00, 0x00, 0x00, 0x00));
button->setFrameColor(kColorTransparent);
button->setFrameColorHighlighted(kColorTransparent);
return button;
};
auto createValueMenu = [this, &palette](const CRect& bounds, int tag, const char*, CHoriTxtAlign align, int fontsize) {
@ -884,7 +886,7 @@ void Editor::Impl::createFrameContents()
vm->setFontColor(palette->valueText);
vm->setBackColor(palette->valueBackground);
});
vm->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
vm->setFrameColor(kColorTransparent);
vm->setStyle(CParamDisplay::kRoundRectStyle);
vm->setRoundRectRadius(5.0);
return vm;
@ -898,7 +900,7 @@ void Editor::Impl::createFrameContents()
cb->setFontColor(palette->valueText);
cb->setBackColor(palette->valueBackground);
});
cb->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
cb->setFrameColor(kColorTransparent);
cb->setStyle(CParamDisplay::kRoundRectStyle);
cb->setRoundRectRadius(5.0);
return cb;
@ -923,8 +925,8 @@ void Editor::Impl::createFrameContents()
btn->setTextColor(palette->icon);
btn->setHighlightColor(palette->iconHighlight);
});
btn->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
btn->setFrameColorHighlighted(CColor(0x00, 0x00, 0x00, 0x00));
btn->setFrameColor(kColorTransparent);
btn->setFrameColorHighlighted(kColorTransparent);
btn->setGradient(nullptr);
btn->setGradientHighlighted(nullptr);
return btn;
@ -990,8 +992,8 @@ void Editor::Impl::createFrameContents()
menu->setFontColor(palette->icon);
menu->setHoverColor(palette->iconHighlight);
});
menu->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
menu->setBackColor(CColor(0x00, 0x00, 0x00, 0x00));
menu->setFrameColor(kColorTransparent);
menu->setBackColor(kColorTransparent);
return menu;
};
auto createChevronValueDropDown = [this, &palette](const CRect& bounds, int tag, const char*, CHoriTxtAlign, int fontsize) {
@ -1005,8 +1007,8 @@ void Editor::Impl::createFrameContents()
menu->setFontColor(palette->icon);
menu->setHoverColor(palette->iconHighlight);
});
menu->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
menu->setBackColor(CColor(0x00, 0x00, 0x00, 0x00));
menu->setFrameColor(kColorTransparent);
menu->setBackColor(kColorTransparent);
return menu;
};
auto createKnob48 = [this, &knob48](const CRect& bounds, int tag, const char*, CHoriTxtAlign, int) {
@ -1081,7 +1083,7 @@ void Editor::Impl::createFrameContents()
auto font = makeOwned<CFontDesc>("Roboto", fontsize);
edit->setFont(font);
edit->setHoriAlign(align);
edit->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
edit->setFrameColor(kColorTransparent);
edit->setStyle(CParamDisplay::kRoundRectStyle);
edit->setRoundRectRadius(5.0);
OnThemeChanged.push_back([edit, palette]() {
@ -1112,7 +1114,7 @@ void Editor::Impl::createFrameContents()
CViewContainer* box = new CViewContainer(bounds);
mainView->addView(box);
box->setBackgroundColor(CColor(0x00, 0x00, 0x00, 0xc0));
box->setBackgroundColor(kColorTransparentDark);
CRect textSize = CRect(0, 0, 400, 80).centerInside(bounds);
CMultiLineTextLabel* textLabel = new CMultiLineTextLabel(textSize);

View file

@ -4,6 +4,7 @@
// license. You should have receive a LICENSE.md file along with the code.
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
#include "GUIDefs.h"
#include "GUIComponents.h"
#include "ColorHelpers.h"
#include <complex>
@ -17,11 +18,13 @@
#include "utility/vstgui_after.h"
#include "absl/strings/numbers.h"
using namespace gui;
///
SBoxContainer::SBoxContainer(const CRect& size)
: CViewContainer(size)
{
CViewContainer::setBackgroundColor(CColor(0, 0, 0, 0));
CViewContainer::setBackgroundColor(kColorTransparent);
}
void SBoxContainer::setCornerRadius(CCoord radius)
@ -644,24 +647,24 @@ SKnobCCBox::SKnobCCBox(const CRect& size, IControlListener* listener, int32_t ta
menuEntry_(makeOwned<CMenuItem>("Use HDCC", tag)),
menuListener_(owned(new MenuListener(*this)))
{
setBackgroundColor(CColor(0x00, 0x00, 0x00, 0x00));
setBackgroundColor(kColorTransparent);
label_->setText("Parameter");
label_->setBackColor(CColor(0x00, 0x00, 0x00, 0x00));
label_->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
label_->setFontColor(CColor(0x00, 0x00, 0x00, 0xff));
label_->setBackColor(kColorTransparent);
label_->setFrameColor(kColorTransparent);
label_->setFontColor(kBlackCColor);
knob_->setLineIndicatorColor(CColor(0x00, 0x00, 0x00, 0xff));
knob_->setLineIndicatorColor(kBlackCColor);
ccLabel_->setText("CC 1");
ccLabel_->setStyle(CParamDisplay::kRoundRectStyle);
ccLabel_->setRoundRectRadius(5.0);
ccLabel_->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
ccLabel_->setFontColor(CColor(0xff, 0xff, 0xff));
ccLabel_->setFrameColor(kColorTransparent);
ccLabel_->setFontColor(kWhiteCColor);
valueEdit_->setBackColor(CColor(0x00, 0x00, 0x00, 0x00));
valueEdit_->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
valueEdit_->setFontColor(CColor(0x00, 0x00, 0x00, 0xff));
valueEdit_->setBackColor(kColorTransparent);
valueEdit_->setFrameColor(kColorTransparent);
valueEdit_->setFontColor(kBlackCColor);
valueEdit_->registerViewListener(this);
setHDMode(false);
valueEdit_->setVisible(false);
@ -882,7 +885,7 @@ SControlsPanel::SControlsPanel(const CRect& size)
// slot 0 always exists, keep the default style on the views there
getOrCreateSlot(0);
setBackgroundColor(CColor(0x00, 0x00, 0x00, 0x00));
setBackgroundColor(kColorTransparent);
setScrollbarWidth(10.0);
@ -1055,9 +1058,9 @@ void SControlsPanel::recalculateSubViews()
// maybe the operation just created the scroll bar
if (CScrollbar* vsb = getVerticalScrollbar()) {
// update scrollbar style
vsb->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
vsb->setBackgroundColor(CColor(0x00, 0x00, 0x00, 0x00));
vsb->setScrollerColor(CColor(0x00, 0x00, 0x00, 0x80));
vsb->setFrameColor(kColorTransparent);
vsb->setBackgroundColor(kColorTransparent);
vsb->setScrollerColor(kColorControlsScroller);
}
}

View file

@ -0,0 +1,25 @@
// SPDX-License-Identifier: BSD-2-Clause
// This code is part of the sfizz library and is licensed under a BSD 2-clause
// license. You should have receive a LICENSE.md file along with the code.
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
#include "GUIDefs.h"
#include "utility/vstgui_before.h"
#include "vstgui/lib/ccolor.h"
#include "utility/vstgui_after.h"
namespace gui {
const CColor kColorSemiTransparent { CColor(0x00, 0x00, 0x00, 0x99) };
const CColor kColorTransparent { CColor(0x00, 0x00, 0x00, 0x00) };
const CColor kColorTransparentDark { CColor(0x00, 0x00, 0x00, 0xc0) };
const CColor kColorOrange { CColor(0xfd, 0x98, 0x00, 0xff) };
const CColor kColorControlsScroller { CColor(0x00, 0x00, 0x00, 0x80) };
const CColor kColorMeterDanger { CColor(0x00, 0xaa, 0x11) };
const CColor kColorMeterNormal { CColor(0xaa, 0x00, 0x00) };
const CColor kColorTooltipBackground { CColor(0xff, 0xff, 0xd2, 0xff) };
}

View file

@ -0,0 +1,27 @@
// SPDX-License-Identifier: BSD-2-Clause
// This code is part of the sfizz library and is licensed under a BSD 2-clause
// license. You should have receive a LICENSE.md file along with the code.
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
#pragma once
#include "utility/vstgui_before.h"
#include "vstgui/lib/vstguifwd.h"
#include "utility/vstgui_after.h"
using VSTGUI::CColor;
namespace gui {
extern const CColor kColorSemiTransparent;
extern const CColor kColorTransparent;
extern const CColor kColorTransparentDark;
extern const CColor kColorOrange;
extern const CColor kColorControlsScroller;
extern const CColor kColorMeterDanger;
extern const CColor kColorMeterNormal;
extern const CColor kColorTooltipBackground;
}