Browse Source

A few more light mode things

tags/22.09
falkTX 2 years ago
parent
commit
8cec74e966
10 changed files with 80 additions and 15 deletions
  1. +2
    -2
      plugins/Cardinal/src/Ildaeil.cpp
  2. +13
    -0
      plugins/Cardinal/src/ImGuiTextEditor.cpp
  3. +1
    -0
      plugins/Cardinal/src/ImGuiTextEditor.hpp
  4. +31
    -6
      plugins/Cardinal/src/ImGuiWidget.cpp
  5. +1
    -0
      plugins/Cardinal/src/ImGuiWidget.hpp
  6. +0
    -2
      plugins/Cardinal/src/ModuleWidgets.hpp
  7. +5
    -4
      plugins/Cardinal/src/TextEditor.cpp
  8. +21
    -0
      plugins/plugins.cpp
  9. +1
    -1
      src/custom/dep.cpp
  10. +5
    -0
      src/override/MenuBar.cpp

+ 2
- 2
plugins/Cardinal/src/Ildaeil.cpp View File

@@ -1750,8 +1750,8 @@ struct IldaeilModuleWidget : ModuleWidgetWithSideScrews<26> {
if (module == nullptr || module->pcontext != nullptr)
{
ildaeilWidget = new IldaeilWidget(module);
ildaeilWidget->box.pos = Vec(3 * RACK_GRID_WIDTH, 0);
ildaeilWidget->box.size = Vec(box.size.x - 6 * RACK_GRID_WIDTH, box.size.y);
ildaeilWidget->box.pos = Vec(3 * RACK_GRID_WIDTH + 1, 1);
ildaeilWidget->box.size = Vec(box.size.x - 6 * RACK_GRID_WIDTH - 2, box.size.y - 2);
addChild(ildaeilWidget);
}



+ 13
- 0
plugins/Cardinal/src/ImGuiTextEditor.cpp View File

@@ -32,6 +32,7 @@
struct ImGuiTextEditor::PrivateData {
TextEditor editor;
std::string file;
bool darkMode = true;
};

// --------------------------------------------------------------------------------------------------------------------
@@ -230,3 +231,15 @@ void ImGuiTextEditor::onHoverScroll(const HoverScrollEvent& e)
// if there is a scrollbar, handle the event
ImGuiWidget::onHoverScroll(e);
}

void ImGuiTextEditor::step()
{
if (pData->darkMode != settings::darkMode)
{
pData->darkMode = settings::darkMode;
pData->editor.SetPalette(settings::darkMode ? TextEditor::GetDarkPalette()
: TextEditor::GetLightPalette());
}

ImGuiWidget::step();
}

+ 1
- 0
plugins/Cardinal/src/ImGuiTextEditor.hpp View File

@@ -73,4 +73,5 @@ protected:
void drawImGui() override;
void onButton(const ButtonEvent& e) override;
void onHoverScroll(const HoverScrollEvent& e) override;
void step() override;
};

+ 31
- 6
plugins/Cardinal/src/ImGuiWidget.cpp View File

@@ -16,6 +16,7 @@
*/

#include "ImGuiWidget.hpp"
#include "DearImGui/imgui.h"
#include "DistrhoUtils.hpp"

#ifndef DGL_NO_SHARED_RESOURCES
@@ -75,6 +76,7 @@ static void setupIO()
struct ImGuiWidget::PrivateData {
ImGuiContext* context = nullptr;
bool created = false;
bool darkMode = true;
bool fontGenerated = false;
bool useMonospacedFont = false;
float originalScaleFactor = 0.0f;
@@ -205,13 +207,13 @@ struct ImGuiWidget::PrivateData {
style.FrameRounding = 4;
style.ScaleAllSizes(scaleFactor);

const ImVec4 color_Cardinal(0.76f, 0.11f, 0.22f, 1.00f);
const ImVec4 color_DimCardinal(171.0 / 255.0, 54.0 / 255.0, 73.0 / 255.0, 1.00f);
const ImVec4 color_Cardinal(0.76f, 0.11f, 0.22f, 1.f);
const ImVec4 color_DimCardinal(171.f / 255.f, 54.f / 255.f, 73.f / 255.f, 1.f);

ImVec4* const colors = style.Colors;
colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
colors[ImGuiCol_WindowBg] = ImVec4(0.101f, 0.101f, 0.101f, 0.94f);
colors[ImGuiCol_Text] = ImVec4(1.f, 1.f, 1.f, 1.f);
colors[ImGuiCol_TextDisabled] = ImVec4(0.5f, 0.5f, 0.5f, 1.f);
colors[ImGuiCol_WindowBg] = ImVec4(0.099f, 0.099f, 0.099f, 1.f);
colors[ImGuiCol_FrameBg] = ImVec4(0.20f, 0.21f, 0.22f, 0.54f);
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.40f, 0.40f, 0.40f, 0.40f);
colors[ImGuiCol_FrameBgActive] = ImVec4(0.18f, 0.18f, 0.18f, 0.67f);
@@ -223,9 +225,21 @@ struct ImGuiWidget::PrivateData {
colors[ImGuiCol_ButtonHovered] = color_Cardinal;
colors[ImGuiCol_ButtonActive] = color_Cardinal;
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.87f, 0.87f, 0.87f, 0.35f);
colors[ImGuiCol_Header] = ImVec4(0.44f, 0.44f, 0.44f, 0.40f);
colors[ImGuiCol_Header] = ImVec4(0.44f, 0.44f, 0.44f, 0.4f);
colors[ImGuiCol_HeaderHovered] = color_DimCardinal;
colors[ImGuiCol_HeaderActive] = color_Cardinal;

if (!settings::darkMode)
{
for (int c = 0; c < ImGuiCol_COUNT; ++c)
{
if (std::memcmp(&colors[c], &color_Cardinal, sizeof(color_Cardinal)) == 0)
continue;
if (std::memcmp(&colors[c], &color_DimCardinal, sizeof(color_DimCardinal)) == 0)
continue;
colors[c] = ImVec4(1.f - colors[c].x, 1.f - colors[c].y, 1.f - colors[c].z, colors[c].w);
}
}
}
};

@@ -416,6 +430,17 @@ void ImGuiWidget::onSelectText(const SelectTextEvent& e)
e.consume(this);
}

void ImGuiWidget::step()
{
if (imData->darkMode != settings::darkMode)
{
imData->darkMode = settings::darkMode;
imData->resetEverything(true);
}

OpenGlWidgetWithBrowserPreview::step();
}

void ImGuiWidget::drawFramebuffer()
{
const float scaleFactor = APP->window->pixelRatio * std::max(1.0f, APP->scene->rack->getAbsoluteZoom());


+ 1
- 0
plugins/Cardinal/src/ImGuiWidget.hpp View File

@@ -39,6 +39,7 @@ protected:
void onButton(const ButtonEvent& e) override;
void onSelectKey(const SelectKeyEvent& e) override;
void onSelectText(const SelectTextEvent& e) override;
void step() override;

void setAsCurrentContext();
void setUseMonospaceFont(bool useMonoFont = true);


+ 0
- 2
plugins/Cardinal/src/ModuleWidgets.hpp View File

@@ -17,9 +17,7 @@

#pragma once

#include "color.hpp"
#include "rack.hpp"
#include "settings.hpp"

#ifdef NDEBUG
# undef DEBUG


+ 5
- 4
plugins/Cardinal/src/TextEditor.cpp View File

@@ -324,7 +324,7 @@ struct ModuleResizeHandle : OpaqueWidget {
nvgMoveTo(args.vg, x + 0.5, margin + 0.5);
nvgLineTo(args.vg, x + 0.5, box.size.y - margin + 0.5);
nvgStrokeWidth(args.vg, 1.0);
nvgStrokeColor(args.vg, nvgRGBAf(0.5, 0.5, 0.5, 0.5));
nvgStrokeColor(args.vg, nvgRGBAf(0.5f, 0.5f, 0.5f, 0.5f));
nvgStroke(args.vg);
}
}
@@ -349,8 +349,8 @@ struct TextEditorModuleWidget : ModuleWidget {

textEditorModule = module;
textEditorWidget = new ImGuiTextEditor();
textEditorWidget->box.pos = Vec(RACK_GRID_WIDTH, 0);
textEditorWidget->box.size = Vec(box.size.x - 2 * RACK_GRID_WIDTH, box.size.y);
textEditorWidget->box.pos = Vec(RACK_GRID_WIDTH + 1, 1);
textEditorWidget->box.size = Vec(box.size.x - 2 * RACK_GRID_WIDTH - 2, box.size.y - 2);
addChild(textEditorWidget);

if (module != nullptr)
@@ -384,7 +384,8 @@ struct TextEditorModuleWidget : ModuleWidget {
{
nvgBeginPath(args.vg);
nvgRect(args.vg, 0.0, 0.0, box.size.x, box.size.y);
nvgFillColor(args.vg, nvgRGB(0x20, 0x20, 0x20));
nvgFillColor(args.vg, settings::darkMode ? nvgRGB(0x20, 0x20, 0x20)
: nvgRGB(0xe6, 0xe6, 0xe6));
nvgFill(args.vg);
ModuleWidget::draw(args);
}


+ 21
- 0
plugins/plugins.cpp View File

@@ -2777,5 +2777,26 @@ void destroyStaticPlugins()
plugins.clear();
}

void updateStaticPluginsDarkMode()
{
#ifndef NOPLUGINS
const bool darkMode = settings::darkMode;
// bogaudio
{
Skins& skins(Skins::skins());
skins._default = darkMode ? "dark" : "light";

std::lock_guard<std::mutex> lock(skins._defaultSkinListenersLock);
for (auto listener : skins._defaultSkinListeners) {
listener->defaultSkinChanged(skins._default);
}
}
// meander
{
panelTheme = darkMode ? 1 : 0;
}
#endif
}

}
}

+ 1
- 1
src/custom/dep.cpp View File

@@ -617,7 +617,7 @@ static void nsvg__duplicatePaint(NSVGpaint& dst, NSVGpaint& src)
if (dst.type == NSVG_PAINT_LINEAR_GRADIENT || dst.type == NSVG_PAINT_RADIAL_GRADIENT)
{
dst.gradient = static_cast<NSVGgradient*>(malloc(sizeof(NSVGgradient)));
std::memcpy(dst.gradient, src.gradient, sizeof(NSVGgradient));
std::memcpy(dst.gradient, src.gradient, sizeof(NSVGgradient));
}
}



+ 5
- 0
src/override/MenuBar.cpp View File

@@ -68,6 +68,10 @@ namespace asset {
std::string patchesPath();
}

namespace plugin {
void updateStaticPluginsDarkMode();
}

namespace app {
namespace menuBar {

@@ -522,6 +526,7 @@ struct ViewButton : MenuButton {
darkModeText = CHECKMARK_STRING;
menu->addChild(createMenuItem("Dark Mode", darkModeText, []() {
switchDarkMode(!settings::darkMode);
plugin::updateStaticPluginsDarkMode();
setAllFramebufferWidgetsDirty(APP->scene);
}));



Loading…
Cancel
Save