/* PaletteManager::loadCustomPalettes
 * Loads any files in the '<userdir>/palettes' directory as palettes,
 * with names from the files (minus the file extension)
 *******************************************************************/
bool PaletteManager::loadCustomPalettes()
{
	// If the directory doesn't exist create it
	if (!wxDirExists(appPath("palettes", DIR_USER)))
		wxMkdir(appPath("palettes", DIR_USER));

	// Open the custom palettes directory
	wxDir res_dir;
	res_dir.Open(appPath("palettes", DIR_USER));

	// Go through each file in the directory
	string filename = wxEmptyString;
	bool files = res_dir.GetFirst(&filename, wxEmptyString, wxDIR_FILES);
	while (files)
	{
		// Load palette data
		Palette8bit* pal = new Palette8bit();
		MemChunk mc;
		mc.importFile(res_dir.GetName() + "/" + filename);
		pal->loadMem(mc);

		// Add the palette
		wxFileName fn(filename);
		addPalette(pal, fn.GetName());

		// Next file
		files = res_dir.GetNext(&filename);
	}

	return true;
}
Exemple #2
0
/**
 * @brief shaderWidget::shaderWidget
 *        Default constructor
 */
shaderWidget::shaderWidget(QWidget *parent) :
    QWidget(parent)
{
    mCurrentPalette = 0;
    mPalette.clear();

#ifdef DEFAULT_PALETTE
    // Add a basic greyscale palette
    addPalette("Greyscale/0.0=0:0:0|1.0=255:255:255");
#endif
}
Exemple #3
0
bool PaletteBox::read(XmlReader& e)
      {
      while (e.readNextStartElement()) {
            const QStringRef& tag(e.name());
            if (tag == "Palette") {
                  Palette* p = new Palette();
                  QString name = e.attribute("name");
                  p->setName(name);
                  p->read(e);
                  addPalette(p);
                  connect(p, SIGNAL(displayMore(const QString&)),
                     SLOT(displayMore(const QString&)));
                  }
            else
                  e.unknown();
            }
      return true;
      }
/* PaletteManager::loadResourcePalettes
 * Loads any entries in the 'palettes' directory of SLADE.pk3 as
 * palettes, with names from the entries (minus the entry extension)
 *******************************************************************/
bool PaletteManager::loadResourcePalettes()
{
	// Get the 'palettes' directory of SLADE.pk3
	Archive* res_archive = theArchiveManager->programResourceArchive();
	ArchiveTreeNode* dir_palettes = res_archive->getDir("palettes/");

	// Check it exists
	if (!dir_palettes)
		return false;

	// Go through all entries in the directory
	for (size_t a = 0; a < dir_palettes->numEntries(); a++)
	{
		// Load palette data
		Palette8bit* pal = new Palette8bit();
		MemChunk mc(dir_palettes->getEntry(a)->getData(true), dir_palettes->getEntry(a)->getSize());
		pal->loadMem(mc);

		// Add the palette
		addPalette(pal, dir_palettes->getEntry(a)->getName(true));
	}

	return true;
}
Exemple #5
0
MasterPalette::MasterPalette(QWidget* parent)
   : QWidget(parent)
      {
      setupUi(this);

      addPalette(MuseScore::newGraceNotePalette());
      addPalette(MuseScore::newClefsPalette());
      stack->addWidget(new KeyEditor);

      timeDialog = new TimeDialog;
      stack->addWidget(timeDialog);

      addPalette(MuseScore::newBarLinePalette());
      addPalette(MuseScore::newLinesPalette());
      addPalette(MuseScore::newArpeggioPalette());
      addPalette(MuseScore::newBreathPalette());
      addPalette(MuseScore::newBracketsPalette());
      addPalette(MuseScore::newArticulationsPalette());

      addPalette(MuseScore::newAccidentalsPalette());

      addPalette(MuseScore::newDynamicsPalette());
      addPalette(MuseScore::newFingeringPalette());
      addPalette(MuseScore::newNoteHeadsPalette());
      addPalette(MuseScore::newTremoloPalette());
      addPalette(MuseScore::newRepeatsPalette());
      addPalette(MuseScore::newTempoPalette());
      addPalette(MuseScore::newTextPalette());
      addPalette(MuseScore::newBreaksPalette());
      addPalette(MuseScore::newBagpipeEmbellishmentPalette());
      addPalette(MuseScore::newBeamPalette());
      addPalette(MuseScore::newFramePalette());

      stack->addWidget(new SymbolDialog);
      }
MasterPalette::MasterPalette(QWidget* parent)
   : QWidget(parent, Qt::Dialog)
      {
      setupUi(this);
      setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);

      treeWidget->clear();

      addPalette(MuseScore::newGraceNotePalette(false));
      addPalette(MuseScore::newClefsPalette(false));
      keyEditor = new KeyEditor;

      keyItem = new QTreeWidgetItem();
      keyItem->setData(0, Qt::UserRole, stack->count());
      stack->addWidget(keyEditor);
      treeWidget->addTopLevelItem(keyItem);

      timeItem = new QTreeWidgetItem();
      timeItem->setData(0, Qt::UserRole, stack->count());
      timeDialog = new TimeDialog;
      stack->addWidget(timeDialog);
      treeWidget->addTopLevelItem(timeItem);

      addPalette(MuseScore::newBarLinePalette(false));
      addPalette(MuseScore::newLinesPalette(false));
      addPalette(MuseScore::newArpeggioPalette());
      addPalette(MuseScore::newBreathPalette());
      addPalette(MuseScore::newBracketsPalette());
      addPalette(MuseScore::newArticulationsPalette(false));

      addPalette(MuseScore::newAccidentalsPalette(false));

      addPalette(MuseScore::newDynamicsPalette(false, true));
      addPalette(MuseScore::newFingeringPalette());
      addPalette(MuseScore::newNoteHeadsPalette());
      addPalette(MuseScore::newTremoloPalette());
      addPalette(MuseScore::newRepeatsPalette());
      addPalette(MuseScore::newTempoPalette(false, true));
      addPalette(MuseScore::newTextPalette());
      addPalette(MuseScore::newBreaksPalette());
      addPalette(MuseScore::newBagpipeEmbellishmentPalette());
      addPalette(MuseScore::newBeamPalette(false));
      addPalette(MuseScore::newFramePalette());

      symbolItem = new QTreeWidgetItem();
      symbolItem->setData(0, Qt::UserRole, -1);
      treeWidget->addTopLevelItem(symbolItem);

      for (const QString& s : smuflRanges()->keys()) {
            QTreeWidgetItem* child = new QTreeWidgetItem(QStringList(s));
            child->setData(0, Qt::UserRole, stack->count());
            symbolItem->addChild(child);
            stack->addWidget(new SymbolDialog(s));
            }

      connect(treeWidget, &QTreeWidget::currentItemChanged, this, &MasterPalette::currentChanged);
      connect(treeWidget, &QTreeWidget::itemClicked, this, &MasterPalette::clicked);
      retranslate(true);
      }
MasterPalette::MasterPalette(QWidget* parent)
   : QWidget(parent, Qt::Dialog)
      {
      setupUi(this);
      setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
      setWindowFlags(this->windowFlags() | Qt::WindowStaysOnTopHint);

      addPalette(MuseScore::newGraceNotePalette(false));
      addPalette(MuseScore::newClefsPalette(false));
      keyEditor = new KeyEditor;
      stack->addWidget(keyEditor);

      timeDialog = new TimeDialog;
      stack->addWidget(timeDialog);

      addPalette(MuseScore::newBarLinePalette(false));
      addPalette(MuseScore::newLinesPalette(false));
      addPalette(MuseScore::newArpeggioPalette());
      addPalette(MuseScore::newBreathPalette());
      addPalette(MuseScore::newBracketsPalette());
      addPalette(MuseScore::newArticulationsPalette(false));

      addPalette(MuseScore::newAccidentalsPalette(false));

      addPalette(MuseScore::newDynamicsPalette(false, true));
      addPalette(MuseScore::newFingeringPalette());
      addPalette(MuseScore::newNoteHeadsPalette());
      addPalette(MuseScore::newTremoloPalette());
      addPalette(MuseScore::newRepeatsPalette());
      addPalette(MuseScore::newTempoPalette());
      addPalette(MuseScore::newTextPalette());
      addPalette(MuseScore::newBreaksPalette());
      addPalette(MuseScore::newBagpipeEmbellishmentPalette());
      addPalette(MuseScore::newBeamPalette(false));
      addPalette(MuseScore::newFramePalette());

      stack->addWidget(new SymbolDialog);
      }
Exemple #8
0
void Palette::addPalette(const char *filename, int toIndex, int count, int fromIndex) {
	addPalette(calcHash(filename), toIndex, count, fromIndex);
}