diff --git a/plugins/editor/CMakeLists.txt b/plugins/editor/CMakeLists.txt index 7b5e32bd..12f6bcc0 100644 --- a/plugins/editor/CMakeLists.txt +++ b/plugins/editor/CMakeLists.txt @@ -19,6 +19,8 @@ set(EDITOR_RESOURCES logo_text_shaded@2x.png background.png background@2x.png + background_button_about.png + background_button_about@2x.png icon_white.png icon_white@2x.png knob48.png diff --git a/plugins/editor/layout/main.fl b/plugins/editor/layout/main.fl index bc4eeaf0..492817f9 100644 --- a/plugins/editor/layout/main.fl +++ b/plugins/editor/layout/main.fl @@ -430,12 +430,6 @@ widget_class mainView {open xywh {695 310 60 25} labelsize 12 class TextEdit } - Fl_Button settingsAboutButton_ { - label {About sfizz} - comment {tag=kTagAbout} - xywh {610 205 115 25} labelsize 12 - class ValueButton - } Fl_Box {} { label {... when freewheeling} xywh {290 220 145 25} labelsize 12 align 20 diff --git a/plugins/editor/resources/background_button_about.png b/plugins/editor/resources/background_button_about.png new file mode 100644 index 00000000..d6e4c19b Binary files /dev/null and b/plugins/editor/resources/background_button_about.png differ diff --git a/plugins/editor/resources/background_button_about@2x.png b/plugins/editor/resources/background_button_about@2x.png new file mode 100644 index 00000000..7ae71e8f Binary files /dev/null and b/plugins/editor/resources/background_button_about@2x.png differ diff --git a/plugins/editor/resources/logo_shaded.svg b/plugins/editor/resources/logo_shaded.svg new file mode 100644 index 00000000..5e21ed04 --- /dev/null +++ b/plugins/editor/resources/logo_shaded.svg @@ -0,0 +1,246 @@ + + + sfizz logo + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + sfizz logo + 2020-05-16 + + + Tobiasz 'unfa' KaroĊ„ + + + + + CC-0 + + + + + + + + + + + + + + + diff --git a/plugins/editor/src/editor/Editor.cpp b/plugins/editor/src/editor/Editor.cpp index 38a6e5c7..f20c6bbd 100644 --- a/plugins/editor/src/editor/Editor.cpp +++ b/plugins/editor/src/editor/Editor.cpp @@ -127,7 +127,6 @@ struct Editor::Impl : EditorController::Receiver, CTextLabel* scalaRootKeyLabel_ = nullptr; SValueMenu* tuningFrequencyDropdown_ = nullptr; CTextEdit* tuningFrequencyEdit_ = nullptr; - STextButton *settingsAboutButton_ = nullptr; CTextLabel* tuningFrequencyLabel_ = nullptr; CControl *stretchedTuningSlider_ = nullptr; CTextLabel* stretchedTuningLabel_ = nullptr; @@ -701,9 +700,11 @@ void Editor::Impl::createFrameContents() CViewContainer* mainView; Theme* theme; - SharedPointer iconShaded = owned(new CBitmap("logo_text_shaded.png")); + SharedPointer backgroundAbout = owned(new CBitmap("background_button_about.png")); SharedPointer background = owned(new CBitmap("background.png")); SharedPointer knob48 = owned(new CBitmap("knob48.png")); + + // TODO: is this used somewhere? SharedPointer logoText = owned(new CBitmap("logo_text.png")); defaultBackgroundBitmap_ = background; @@ -749,8 +750,12 @@ void Editor::Impl::createFrameContents() return box; }; #endif - auto createAboutButton = [this, &iconShaded](const CRect& bounds, int tag, const char*, CHoriTxtAlign, int) { - return new CKickButton(bounds, this, tag, 0.0f, iconShaded); + auto createAboutButton = [this, &backgroundAbout]( + const CRect& bounds, int tag, const char*, CHoriTxtAlign, int) { + SHoverButton* btn = new SHoverButton(bounds, this, tag, backgroundAbout); + btn->OnHoverEnter = [this, btn]() { buttonHoverEnter(btn, "About sfizz..."); }; + btn->OnHoverLeave = [this, btn]() { buttonHoverLeave(btn); }; + return btn; }; auto createLabel = [this, &palette](const CRect& bounds, int, const char* label, CHoriTxtAlign align, int fontsize) { CTextLabel* lbl = new CTextLabel(bounds, label); diff --git a/plugins/editor/src/editor/GUIComponents.cpp b/plugins/editor/src/editor/GUIComponents.cpp index 752e6b7e..3751df81 100644 --- a/plugins/editor/src/editor/GUIComponents.cpp +++ b/plugins/editor/src/editor/GUIComponents.cpp @@ -415,6 +415,33 @@ void SActionMenu::onItemClicked(int32_t index) listener->valueChanged(this); } +/// +CMouseEventResult SHoverButton::onMouseEntered(CPoint& where, const CButtonState& buttons) { + hovered_ = true; + if (OnHoverEnter) + OnHoverEnter(); + invalid(); + return CKickButton::onMouseEntered(where, buttons); +} + +CMouseEventResult SHoverButton::onMouseExited(CPoint& where, const CButtonState& buttons) { + hovered_ = false; + if (OnHoverLeave) + OnHoverLeave(); + invalid(); + return CKickButton::onMouseExited(where, buttons); +} + +void SHoverButton::draw(CDrawContext* dc) { + CPoint where(offset.x, offset.y); + bounceValue(); + if (hovered_) + where.y += heightOfOneImage; + if (getDrawBackground()) + getDrawBackground()->draw(dc, getViewSize(), where); + setDirty(false); +} + /// void STextButton::setHighlightColor(const CColor& color) { diff --git a/plugins/editor/src/editor/GUIComponents.h b/plugins/editor/src/editor/GUIComponents.h index c8cbd162..9cbca704 100644 --- a/plugins/editor/src/editor/GUIComponents.h +++ b/plugins/editor/src/editor/GUIComponents.h @@ -182,6 +182,29 @@ private: }; }; +/// +class SHoverButton : public CKickButton { +public: + SHoverButton( + const CRect& size, + IControlListener* listener, + int32_t tag, + CBitmap* background, + const CPoint& offset = CPoint (0, 0)) + : CKickButton(size, listener, tag, background, offset) + {} + + CMouseEventResult onMouseEntered(CPoint&, const CButtonState&) override; + CMouseEventResult onMouseExited(CPoint&, const CButtonState&) override; + void draw(CDrawContext*) override; + + std::function OnHoverEnter; + std::function OnHoverLeave; + +private: + bool hovered_ { false }; +}; + /// class STextButton: public CTextButton { public: diff --git a/plugins/editor/src/editor/layout/main.hpp b/plugins/editor/src/editor/layout/main.hpp index 09229775..19a2ef8e 100644 --- a/plugins/editor/src/editor/layout/main.hpp +++ b/plugins/editor/src/editor/layout/main.hpp @@ -223,24 +223,21 @@ view__49->addView(view__85); auto* const view__86 = createTextEdit(CRect(690, 200, 750, 225), kTagSetTuningFrequency, "", kCenterText, 12); tuningFrequencyEdit_ = view__86; view__49->addView(view__86); -auto* const view__87 = createValueButton(CRect(605, 95, 720, 120), kTagAbout, "About sfizz", kCenterText, 12); -settingsAboutButton_ = view__87; +auto* const view__87 = createLabel(CRect(285, 110, 430, 135), -1, "... when freewheeling", kLeftText, 12); view__49->addView(view__87); -auto* const view__88 = createLabel(CRect(285, 110, 430, 135), -1, "... when freewheeling", kLeftText, 12); +auto* const view__88 = createValueMenu(CRect(430, 110, 510, 135), kTagSetFreewheelingOscillatorQuality, "", kCenterText, 12); +freewheelingOscillatorQualitySlider_ = view__88; view__49->addView(view__88); -auto* const view__89 = createValueMenu(CRect(430, 110, 510, 135), kTagSetFreewheelingOscillatorQuality, "", kCenterText, 12); -freewheelingOscillatorQualitySlider_ = view__89; -view__49->addView(view__89); -auto* const view__90 = createPiano(CRect(5, 400, 795, 470), -1, "", kCenterText, 12); -piano_ = view__90; +auto* const view__89 = createPiano(CRect(5, 400, 795, 470), -1, "", kCenterText, 12); +piano_ = view__89; +view__0->addView(view__89); +auto* const view__90 = createLogicalGroup(CRect(5, 110, 795, 395), -1, "", kCenterText, 14); +subPanels_[kPanelGeneral] = view__90; view__0->addView(view__90); -auto* const view__91 = createLogicalGroup(CRect(5, 110, 795, 395), -1, "", kCenterText, 14); -subPanels_[kPanelGeneral] = view__91; +view__90->setVisible(false); +enterPalette(invertedPalette); +auto* const view__91 = createHoverBox(CRect(5, 105, 175, 130), -1, "", kCenterText, 12); +lblHover_ = view__91; view__0->addView(view__91); view__91->setVisible(false); -enterPalette(invertedPalette); -auto* const view__92 = createHoverBox(CRect(5, 105, 175, 130), -1, "", kCenterText, 12); -lblHover_ = view__92; -view__0->addView(view__92); -view__92->setVisible(false); enterPalette(defaultPalette);