void ProjucerLookAndFeel::drawTabButton (TabBarButton& button, Graphics& g, bool isMouseOver, bool isMouseDown) { const auto area = button.getActiveArea(); auto backgroundColour = findColour (button.isFrontTab() ? secondaryBackgroundColourId : inactiveTabBackgroundColourId); auto iconColour = findColour (button.isFrontTab() ? activeTabIconColourId : inactiveTabIconColourId); g.setColour (backgroundColour); g.fillRect (area); const auto alpha = button.isEnabled() ? ((isMouseOver || isMouseDown) ? 1.0f : 0.8f) : 0.3f; #ifndef BUILDING_JUCE_COMPILEENGINE if (button.getName() == "Project") { auto icon = Icon (getIcons().closedFolder, iconColour.withMultipliedAlpha (alpha)); icon.draw (g, button.getTextArea().reduced (8, 8).toFloat(), false); } else if (button.getName() == "Build") { auto icon = Icon (getIcons().buildTab, iconColour.withMultipliedAlpha (alpha)); icon.draw (g, button.getTextArea().reduced (8, 8).toFloat(), false); } else #endif { auto textColour = findColour (defaultTextColourId).withMultipliedAlpha (alpha); TextLayout textLayout; LookAndFeel_V3::createTabTextLayout (button, (float) area.getWidth(), (float) area.getHeight(), textColour, textLayout); textLayout.draw (g, button.getTextArea().toFloat()); } }
WeatherPlugin::WeatherPlugin(unsigned base, bool bInit, Buffer *config) : Plugin(base) { load_data(weatherData, &data, config); BarWeather = registerType(); CmdWeather = registerType(); EventWeather = registerType(); m_icons = getIcons()->addIconSet("icons/weather.jisp", true); Event eBar(EventToolbarCreate, (void*)BarWeather); eBar.process(); Command cmd; cmd->id = CmdWeather; cmd->text = I18N_NOOP("Not connected"); cmd->icon = "weather"; cmd->bar_id = BarWeather; cmd->bar_grp = 0x1000; cmd->flags = BTN_PICT | BTN_DIV; Event eCmd(EventCommandCreate, cmd); eCmd.process(); m_bar = NULL; if (!bInit){ showBar(); if (m_bar) m_bar->show(); } }
WeatherPlugin::~WeatherPlugin() { if (m_bar) delete m_bar; Event eCmd(EventCommandRemove, (void*)CmdWeather); Event eBar(EventToolbarRemove, (void*)BarWeather); free_data(weatherData, &data); getIcons()->removeIconSet(m_icons); }
void UnquoteParser::tag_start(const QString &tag, const list<QString> &options) { if (tag == "pre"){ if (!m_bPre) res += "\n"; }else if (tag == "br"){ res += "\n"; }else if (tag == "hr"){ if (!res.isEmpty() && (res[(int)(res.length() - 1)] != '\n')) res += "\n"; res += "---------------------------------------------------\n"; }else if (tag == "td"){ if (m_bTD){ res += "\t"; m_bTD = false; } }else if (tag == "tr"){ if (m_bTR){ res += "\n"; m_bTR = false; } }else if (tag == "p"){ if (m_bPar){ res += "\n"; m_bPar = false; } }else if (tag == "img"){ QString src; QString alt; for (list<QString>::const_iterator it = options.begin(); it != options.end(); ++it){ QString opt = *it; ++it; QString value = *it; if (opt == "src") src = value; if (opt == "alt") alt = value; } if (!alt.isEmpty()){ res += unquoteString(alt); return; } if (src.left(5) == "icon:"){ list<string> smiles = getIcons()->getSmile(src.mid(5).latin1()); if (!smiles.empty()){ res += QString::fromUtf8(smiles.front().c_str()); return; } } text(alt); } }
Icon Project::Item::getIcon() const { const Icons& icons = getIcons(); if (isFile()) { if (isImageFile()) return Icon (icons.imageDoc, Colours::blue); return Icon (icons.document, Colours::yellow); } if (isMainGroup()) return Icon (icons.juceLogo, Colours::orange); return Icon (icons.folder, Colours::darkgrey); }
void HeaderComponent::initialiseButtons() noexcept { auto& icons = getIcons(); addAndMakeVisible (projectSettingsButton = new IconButton ("Project Settings", &icons.settings)); projectSettingsButton->onClick = [this] { sendProjectButtonAnalyticsEvent ("Project Settings"); if (auto* pcc = findParentComponentOfClass<ProjectContentComponent>()) pcc->showProjectSettings(); }; addAndMakeVisible (saveAndOpenInIDEButton = new IconButton ("Save and Open in IDE", nullptr)); saveAndOpenInIDEButton->isIDEButton = true; saveAndOpenInIDEButton->onClick = [this] { sendProjectButtonAnalyticsEvent ("Save and Open in IDE (" + exporterBox.getText() + ")"); if (auto* pcc = findParentComponentOfClass<ProjectContentComponent>()) pcc->openInSelectedIDE (true); }; addAndMakeVisible (userSettingsButton = new IconButton ("User Settings", &icons.user)); userSettingsButton->isUserButton = true; userSettingsButton->onClick = [this] { sendProjectButtonAnalyticsEvent ("User Settings"); if (auto* pcc = findParentComponentOfClass<ProjectContentComponent>()) showUserSettings(); }; addAndMakeVisible (runAppButton = new IconButton ("Run Application", &icons.play)); runAppButton->onClick = [this] { sendProjectButtonAnalyticsEvent ("Run Application"); if (childProcess != nullptr) childProcess->launchApp(); }; updateExporterButton(); updateUserAvatar(); }
void ViewParser::text(const QString &text) { if (text.isEmpty()) return; if (m_bInParagraph) m_bParagraphEmpty = false; if (m_bInParagraph && (m_paragraphDir == DirAuto)) { /* text isn't (unicode)-NULL terminated so we can't check for c->isNull! */ for(unsigned int i = 0; ((i < text.length()) && (m_paragraphDir == DirAuto)); i++) { const QChar c = text.unicode()[i]; // Note: Qt expects ltr/rtl to be lower-case. switch(c.direction()) { case QChar::DirL: res.insert(m_paraDirInsertionPos, " dir=\"ltr\""); m_paragraphDir = DirLTR; break; case QChar::DirR: res.insert(m_paraDirInsertionPos, " dir=\"rtl\""); m_paragraphDir = DirRTL; break; default: // avoid gcc warning break; } } } if (!m_bUseSmiles || m_bInLink) { res += quoteString(text); return; } m_bFirst = false; if (m_bUseSmiles) { QString r = getIcons()->parseSmiles(text); res += r; } else { res += quoteString(text); } }
void ViewParser::text(const QString &text) { if (text.isEmpty()) return; if (m_bInParagraph && (m_paragraphDir == DirAuto)) { for(const QChar* c = text.unicode(); !c->isNull() && (m_paragraphDir == DirAuto); ++c) { // Note: Qt expects ltr/rtl to be lower-case. switch(c->direction()) { case QChar::DirL: res.insert(m_paraDirInsertionPos, " dir=\"ltr\""); m_paragraphDir = DirLTR; break; case QChar::DirR: res.insert(m_paraDirInsertionPos, " dir=\"rtl\""); m_paragraphDir = DirRTL; break; default: // avoid gcc warning break; } } } if (!m_bUseSmiles || m_bInLink){ res += quoteString(text); return; } m_bFirst = false; if (m_bUseSmiles){ QString r = getIcons()->parseSmiles(text); res += r; }else{ res += quoteString(text); } }
void ViewParser::tag_start(const QString &tag, const list<QString> &attrs) { // the tag that will be actually written out QString oTag = tag; if (m_bInHead) return; QString style; if (tag == "img"){ QString src; for (list<QString>::const_iterator it = attrs.begin(); it != attrs.end(); ++it){ QString name = (*it).lower(); ++it; QString value = *it; if (name == "src"){ src = value; break; } } if (src.left(10) == "icon:smile"){ bool bOK; unsigned nSmile = src.mid(10).toUInt(&bOK, 16); if (bOK && (nSmile < 26)){ QString s = def_smiles[nSmile]; res += getIcons()->parseSmiles(s); return; } } }else if (tag == "a"){ m_bInLink = true; }else if (tag == "p"){ m_bInParagraph = true; m_paragraphDir = DirAuto; }else if (tag == "html"){ // we display as a part of a larger document return; }else if (tag == "head"){ m_bInHead = 1; return; }else if (tag == "body"){ // we display as a part of a larger document oTag = "span"; } QString tagText; tagText += "<"; tagText += oTag; if (tag == "p") { m_paraDirInsertionPos = res.length() + tagText.length(); } for (list<QString>::const_iterator it = attrs.begin(); it != attrs.end(); ++it){ QString name = (*it).lower(); ++it; QString value = *it; // Handling for attributes of specific tags. if (tag == "body"){ if (name == "bgcolor"){ style += "background-color:" + value + ";"; continue; } }else if (tag == "p"){ if (name == "dir"){ QString dir = value.lower(); if (dir == "ltr") m_paragraphDir = DirLTR; else if (dir == "rtl") m_paragraphDir = DirRTL; else m_paragraphDir = DirUnknown; } }else if (tag == "font"){ if (name == "color" && m_bIgnoreColors) continue; } // Handle for generic attributes. if (name == "style"){ style += value; continue; } tagText += " "; tagText += name; if (!value.isEmpty()){ tagText += "=\""; tagText += value; tagText += "\""; } } // Quite crude but working CSS to remove color styling. // It won't filter out colors as part of 'background', but life's tough. // (If it's any comfort, Qt probably won't display it either.) if (!style.isEmpty()){ if (m_bIgnoreColors){ list<QString> opt = parseStyle(style); list<QString> new_opt; for (list<QString>::iterator it = opt.begin(); it != opt.end(); ++it){ QString name = *it; it++; if (it == opt.end()) break; QString value = *it; if ((name == "color") || (name == "background-color") || (name == "font-size") || (name == "font-style") || (name == "font-weight") || (name == "font-family")) continue; new_opt.push_back(name); new_opt.push_back(value); } style = makeStyle(new_opt); } if (!style.isEmpty()) tagText += " style=\"" + style + "\""; } tagText += ">"; res += tagText; }