Merge pull request #1151 from redtide/about-label-button

Removed the text labeled button for displaying the About dialog
This commit is contained in:
redtide 2023-04-09 11:48:25 +02:00 committed by GitHub
commit 9b2b67a669
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 319 additions and 25 deletions

View file

@ -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

View file

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 16 KiB

View file

@ -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<CBitmap> iconShaded = owned(new CBitmap("logo_text_shaded.png"));
SharedPointer<CBitmap> backgroundAbout = owned(new CBitmap("background_button_about.png"));
SharedPointer<CBitmap> background = owned(new CBitmap("background.png"));
SharedPointer<CBitmap> knob48 = owned(new CBitmap("knob48.png"));
// TODO: is this used somewhere?
SharedPointer<CBitmap> 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);

View file

@ -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)
{

View file

@ -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<void()> OnHoverEnter;
std::function<void()> OnHoverLeave;
private:
bool hovered_ { false };
};
///
class STextButton: public CTextButton {
public:

View file

@ -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);