Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some upgrades on the sidebar and selections and so on #1065

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src-ui/components/multi/MappingPane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ struct MappingDisplay : juce::Component,

void resized() override
{
static constexpr int mapSize{620};
static constexpr int controlSize{140};
static constexpr int headerSize{20};

// Header
Expand All @@ -535,7 +535,7 @@ struct MappingDisplay : juce::Component,

// Mapping Display
auto z = b.withTrimmedTop(headerSize);
auto viewArea = z.withWidth(mapSize);
auto viewArea = z.withWidth(getWidth() - controlSize - 5);
mappingViewport->setBounds(viewArea);
auto kbdY = viewArea.getBottom() - mappingViewport->viewport->getScrollBarThickness() -
Keyboard::keyboardHeight;
Expand All @@ -546,7 +546,7 @@ struct MappingDisplay : juce::Component,
static constexpr int rowHeight{16}, rowMargin{4};
static constexpr int typeinWidth{32};
static constexpr int typeinPad{4}, typeinMargin{2};
auto r = z.withLeft(mapSize + 2);
auto r = z.withLeft(getWidth() - controlSize);
auto cr = r.withHeight(rowHeight);

auto co2 = [=](auto &c) {
Expand Down
19 changes: 12 additions & 7 deletions src-ui/components/multi/PartGroupSidebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ struct PartSidebar : juce::Component, HasEditor
}
};

template <typename T>
template <typename T, bool forZone>
struct GroupZoneSidebarBase : juce::Component, HasEditor, juce::DragAndDropContainer
{
PartGroupSidebar *partGroupSidebar{nullptr};
std::unique_ptr<juce::ListBox> listBox;
std::unique_ptr<detail::GroupZoneListBoxModel<T>> listBoxModel;
std::unique_ptr<detail::GroupZoneListBoxModel<T, forZone>> listBoxModel;
std::unique_ptr<jcmp::MenuButton> partSelector;

T *asT() { return static_cast<T *>(this); }
Expand All @@ -133,7 +133,7 @@ struct GroupZoneSidebarBase : juce::Component, HasEditor, juce::DragAndDropConta

void postInit()
{
listBoxModel = std::make_unique<detail::GroupZoneListBoxModel<T>>(asT());
listBoxModel = std::make_unique<detail::GroupZoneListBoxModel<T, forZone>>(asT());
listBoxModel->rebuild();
listBox = std::make_unique<juce::ListBox>();
listBox->setModel(listBoxModel.get());
Expand Down Expand Up @@ -230,10 +230,10 @@ struct GroupControls : juce::Component, HasEditor
}
};

struct GroupSidebar : GroupZoneSidebarBase<GroupSidebar>
struct GroupSidebar : GroupZoneSidebarBase<GroupSidebar, false>
{

GroupSidebar(PartGroupSidebar *p) : GroupZoneSidebarBase<GroupSidebar>(p)
GroupSidebar(PartGroupSidebar *p) : GroupZoneSidebarBase<GroupSidebar, false>(p)
{
groupControls = std::make_unique<GroupControls>(this);
addAndMakeVisible(*groupControls);
Expand Down Expand Up @@ -286,9 +286,9 @@ struct GroupSidebar : GroupZoneSidebarBase<GroupSidebar>
std::unique_ptr<GroupControls> groupControls;
};

struct ZoneSidebar : GroupZoneSidebarBase<ZoneSidebar>
struct ZoneSidebar : GroupZoneSidebarBase<ZoneSidebar, true>
{
ZoneSidebar(PartGroupSidebar *p) : GroupZoneSidebarBase<ZoneSidebar>(p) {}
ZoneSidebar(PartGroupSidebar *p) : GroupZoneSidebarBase<ZoneSidebar, true>(p) {}
~ZoneSidebar() = default;

void updateSelection()
Expand Down Expand Up @@ -411,6 +411,11 @@ PartGroupSidebar::PartGroupSidebar(SCXTEditor *e)

w->editor->multiScreen->setSelectionMode(g ? MultiScreen::SelectionMode::GROUP
: MultiScreen::SelectionMode::ZONE);

if (g)
w->editor->themeApplier.applyGroupMultiScreenTheme(w);
else
w->editor->themeApplier.applyZoneMultiScreenTheme(w);
};
resetTabState();

Expand Down
66 changes: 46 additions & 20 deletions src-ui/components/multi/detail/GroupZoneTreeControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ namespace scxt::ui::multi::detail
namespace jcmp = sst::jucegui::components;
namespace cmsg = scxt::messaging::client;

template <typename SidebarParent> struct GroupZoneListBoxModel : juce::ListBoxModel
template <typename SidebarParent, bool fz> struct GroupZoneListBoxModel : juce::ListBoxModel
{
static constexpr bool forZone{fz};
SidebarParent *sidebar{nullptr};
engine::Engine::pgzStructure_t thisGroup;
GroupZoneListBoxModel(SidebarParent *sb) : sidebar(sb) { rebuild(); }
Expand Down Expand Up @@ -81,7 +82,7 @@ template <typename SidebarParent> struct GroupZoneListBoxModel : juce::ListBoxMo
{
int rowNumber{-1};
bool isSelected{false};
GroupZoneListBoxModel<SidebarParent> *lbm{nullptr};
GroupZoneListBoxModel<SidebarParent, forZone> *lbm{nullptr};
SidebarParent *gsb{nullptr};

std::unique_ptr<juce::TextEditor> renameEditor;
Expand All @@ -92,7 +93,8 @@ template <typename SidebarParent> struct GroupZoneListBoxModel : juce::ListBoxMo
renameEditor->addListener(this);
}

int zonePad = 20;
int zonePad = 16;
int grouplabelPad = zonePad;

void paint(juce::Graphics &g) override
{
Expand All @@ -110,18 +112,42 @@ template <typename SidebarParent> struct GroupZoneListBoxModel : juce::ListBoxMo
g.setFont(st->getFont(jcmp::Label::Styles::styleClass, jcmp::Label::Styles::labelfont));

// TODO: Style all of these
auto borderColor = juce::Colour(0xFF, 0x90, 0x00).darker(0.4);
auto textColor = juce::Colour(190, 190, 190);
auto lowTextColor = textColor.darker(0.4);
auto fillColor = juce::Colour(0, 0, 0).withAlpha(0.f);

if (isSelected)
fillColor = juce::Colour(0x40, 0x20, 0x00);
if (isLeadZone)
auto editor = gsb->partGroupSidebar->editor;

auto borderColor = editor->themeColor(theme::ColorMap::accent_1b, 0.4);
auto textColor = editor->themeColor(theme::ColorMap::generic_content_medium);
auto lowTextColor = editor->themeColor(theme::ColorMap::generic_content_low);
auto fillColor = editor->themeColor(theme::ColorMap::bg_2);
if (!forZone || isGroup())
fillColor = editor->themeColor(theme::ColorMap::bg_3);

if (forZone)
{
if (isSelected && isZone())
{
fillColor = editor->themeColor(theme::ColorMap::accent_1b, 0.2);
textColor = editor->themeColor(theme::ColorMap::generic_content_high);
}
if (isLeadZone && isZone())
{
fillColor = editor->themeColor(theme::ColorMap::accent_1b, 0.3);
textColor = editor->themeColor(theme::ColorMap::generic_content_highest);
}
if (isGroup())
{
textColor = editor->themeColor(theme::ColorMap::generic_content_high);
}
}
else
{
fillColor = juce::Colour(0x15, 0x15, 0x50);
textColor = juce::Colour(170, 170, 220);
if (isSelected && isGroup())
{
fillColor = editor->themeColor(theme::ColorMap::accent_1b, 0.4);
textColor = editor->themeColor(theme::ColorMap::generic_content_highest);
lowTextColor = editor->themeColor(theme::ColorMap::accent_1a);
}
}

if (sg.first.zone < 0)
{
g.setColour(fillColor);
Expand All @@ -130,8 +156,8 @@ template <typename SidebarParent> struct GroupZoneListBoxModel : juce::ListBoxMo
g.setColour(borderColor);
g.drawLine(0, getHeight(), getWidth(), getHeight());

auto bx = getLocalBounds().withWidth(zonePad);
auto nb = getLocalBounds().withTrimmedLeft(zonePad);
auto bx = getLocalBounds().withWidth(grouplabelPad);
auto nb = getLocalBounds().withTrimmedLeft(grouplabelPad);
g.setColour(lowTextColor);
g.drawText(std::to_string(sg.first.group + 1), bx,
juce::Justification::centredLeft);
Expand All @@ -153,11 +179,11 @@ template <typename SidebarParent> struct GroupZoneListBoxModel : juce::ListBoxMo

if (isLeadZone)
{
g.drawText("*",
getLocalBounds()
.translated(zonePad + 2, 0)
.withWidth(getWidth() - zonePad - 5),
juce::Justification::centredRight);
auto b = getLocalBounds().withWidth(zonePad).withTrimmedLeft(2);
auto q = b.getHeight() - b.getWidth();
b = b.withTrimmedTop(q / 2).withTrimmedBottom(q / 2);
jcmp::GlyphPainter::paintGlyph(g, b, jcmp::GlyphPainter::JOG_RIGHT,
textColor.withAlpha(0.5f));
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion src-ui/theme/ThemeApplier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,12 @@ void ThemeApplier::applyZoneMultiScreenModulationTheme(juce::Component *toThis)
populateSharedGroupZoneMultiModulation(map);
map.applyMapTo(toThis);
}
void ThemeApplier::applyZoneMultiScreenTheme(juce::Component *toThis) {}
void ThemeApplier::applyZoneMultiScreenTheme(juce::Component *toThis)
{
jstl::CustomTypeMap map;
map.addCustomClass<jcmp::NamedPanel>(jcmp::NamedPanel::Styles::styleClass);
map.applyMapTo(toThis);
}

void ThemeApplier::applyGroupMultiScreenModulationTheme(juce::Component *toThis)
{
Expand Down
Loading