本文整理汇总了C++中Palette类的典型用法代码示例。如果您正苦于以下问题:C++ Palette类的具体用法?C++ Palette怎么用?C++ Palette使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Palette类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: newRepeatsPalette
Palette* MuseScore::newRepeatsPalette()
{
Palette* sp = new Palette;
sp->setName(QT_TRANSLATE_NOOP("Palette", "Repeats"));
sp->setMag(0.65);
sp->setGrid(84, 28);
sp->setDrawGrid(true);
RepeatMeasure* rm = new RepeatMeasure(gscore);
sp->append(rm, tr("Repeat measure sign"));
Marker* mk = new Marker(gscore);
mk->setMarkerType(MarkerType::SEGNO);
sp->append(mk, tr("Segno"));
mk = new Marker(gscore);
mk->setMarkerType(MarkerType::VARSEGNO);
sp->append(mk, tr("Segno Variation"));
mk = new Marker(gscore);
mk->setMarkerType(MarkerType::CODA);
sp->append(mk, tr("Coda"));
mk = new Marker(gscore);
mk->setMarkerType(MarkerType::VARCODA);
sp->append(mk, tr("Varied coda"));
/* mk = new Marker(gscore); // not in smufl
mk->setMarkerType(MarkerType::CODETTA);
sp->append(mk, tr("Codetta"));
*/
mk = new Marker(gscore);
mk->setMarkerType(MarkerType::FINE);
sp->append(mk, tr("Fine"));
Jump* jp = new Jump(gscore);
jp->setJumpType(JumpType::DC);
sp->append(jp, tr("Da Capo"));
jp = new Jump(gscore);
jp->setJumpType(JumpType::DC_AL_FINE);
sp->append(jp, tr("Da Capo al Fine"));
jp = new Jump(gscore);
jp->setJumpType(JumpType::DC_AL_CODA);
sp->append(jp, tr("Da Capo al Coda"));
jp = new Jump(gscore);
jp->setJumpType(JumpType::DS_AL_CODA);
sp->append(jp, tr("D.S. al Coda"));
jp = new Jump(gscore);
jp->setJumpType(JumpType::DS_AL_FINE);
sp->append(jp, tr("D.S. al Fine"));
jp = new Jump(gscore);
jp->setJumpType(JumpType::DS);
sp->append(jp, tr("D.S."));
mk = new Marker(gscore);
mk->setMarkerType(MarkerType::TOCODA);
sp->append(mk, tr("To Coda"));
return sp;
}
示例2: Slur
Palette* MuseScore::newLinesPalette()
{
Palette* sp = new Palette;
sp->setName(QT_TRANSLATE_NOOP("Palette", "Lines"));
sp->setMag(.8);
sp->setGrid(82, 35);
sp->setDrawGrid(true);
qreal w = gscore->spatium() * 8;
Slur* slur = new Slur(gscore);
slur->setId(0);
sp->append(slur, qApp->translate("lines", "Slur"));
Hairpin* gabel0 = new Hairpin(gscore);
gabel0->setHairpinType(Hairpin::CRESCENDO);
gabel0->setLen(w);
sp->append(gabel0, qApp->translate("lines", "Crescendo"));
Hairpin* gabel1 = new Hairpin(gscore);
gabel1->setHairpinType(Hairpin::DECRESCENDO);
gabel1->setLen(w);
sp->append(gabel1, QT_TRANSLATE_NOOP("Palette", "Diminuendo"));
Volta* volta = new Volta(gscore);
volta->setVoltaType(VoltaType::CLOSED);
volta->setLen(w);
volta->setText("1.");
QList<int> il;
il.append(1);
volta->setEndings(il);
sp->append(volta, QT_TRANSLATE_NOOP("Palette", "Prima volta"));
volta = new Volta(gscore);
volta->setVoltaType(VoltaType::CLOSED);
volta->setLen(w);
volta->setText("2.");
il.clear();
il.append(2);
volta->setEndings(il);
sp->append(volta, QT_TRANSLATE_NOOP("Palette", "Seconda volta"));
volta = new Volta(gscore);
volta->setVoltaType(VoltaType::CLOSED);
volta->setLen(w);
volta->setText("3.");
il.clear();
il.append(3);
volta->setEndings(il);
sp->append(volta, QT_TRANSLATE_NOOP("Palette", "Terza volta"));
volta = new Volta(gscore);
volta->setVoltaType(VoltaType::OPEN);
volta->setLen(w);
volta->setText("2.");
il.clear();
il.append(2);
volta->setEndings(il);
sp->append(volta, QT_TRANSLATE_NOOP("Palette", "Seconda volta 2"));
Ottava* ottava = new Ottava(gscore);
ottava->setOttavaType(OttavaType::OTTAVA_8VA);
ottava->setLen(w);
sp->append(ottava, QT_TRANSLATE_NOOP("Palette", "8va"));
ottava = new Ottava(gscore);
ottava->setOttavaType(OttavaType::OTTAVA_8VB);
ottava->setLen(w);
ottava->setPlacement(Element::BELOW);
sp->append(ottava, QT_TRANSLATE_NOOP("Palette", "8vb"));
ottava = new Ottava(gscore);
ottava->setOttavaType(OttavaType::OTTAVA_15MA);
ottava->setLen(w);
sp->append(ottava, QT_TRANSLATE_NOOP("Palette", "15ma"));
ottava = new Ottava(gscore);
ottava->setOttavaType(OttavaType::OTTAVA_15MB);
ottava->setLen(w);
ottava->setPlacement(Element::BELOW);
sp->append(ottava, QT_TRANSLATE_NOOP("Palette", "15mb"));
ottava = new Ottava(gscore);
ottava->setOttavaType(OttavaType::OTTAVA_22MA);
ottava->setLen(w);
sp->append(ottava, QT_TRANSLATE_NOOP("Palette", "22ma"));
ottava = new Ottava(gscore);
ottava->setOttavaType(OttavaType::OTTAVA_22MB);
ottava->setLen(w);
sp->append(ottava, QT_TRANSLATE_NOOP("Palette", "22mb"));
Pedal* pedal = new Pedal(gscore);
pedal->setLen(w);
sp->append(pedal, QT_TRANSLATE_NOOP("Palette", "Pedal"));
pedal = new Pedal(gscore);
pedal->setLen(w);
pedal->setEndHookType(HOOK_45);
//.........这里部分代码省略.........
示例3: Q_ASSERT
ObjectPtr CSDDialog::createNewDataObject() const {
Q_ASSERT(_document && _document->objectStore());
ObjectTag tag = _document->objectStore()->suggestObjectTag<CSD>(tagString(), ObjectTag::globalTagContext);
CSDPtr csd = _document->objectStore()->createObject<CSD>(tag);
csd->setVector(_CSDTab->vector());
csd->setFreq(_CSDTab->FFTOptionsWidget()->sampleRate());
csd->setAverage(_CSDTab->FFTOptionsWidget()->interleavedAverage());
csd->setRemoveMean(_CSDTab->FFTOptionsWidget()->removeMean());
csd->setApodize(_CSDTab->FFTOptionsWidget()->apodize());
csd->setApodizeFxn(_CSDTab->FFTOptionsWidget()->apodizeFunction());
csd->setWindowSize(_CSDTab->windowSize());
csd->setLength(_CSDTab->FFTOptionsWidget()->FFTLength());
csd->setGaussianSigma(_CSDTab->FFTOptionsWidget()->sigma());
csd->setOutput(_CSDTab->FFTOptionsWidget()->output());
csd->setVectorUnits(_CSDTab->FFTOptionsWidget()->vectorUnits());
csd->setRateUnits(_CSDTab->FFTOptionsWidget()->rateUnits());
csd->writeLock();
csd->update(0);
csd->unlock();
Palette* newPalette = new Palette(_CSDTab->colorPalette()->selectedPalette());
tag = _document->objectStore()->suggestObjectTag<Image>(csd->tag().tagString(), ObjectTag::globalTagContext);
ImagePtr image = _document->objectStore()->createObject<Image>(tag);
image->changeToColorOnly(csd->outputMatrix(), 0, 1, true, newPalette->paletteData());
image->writeLock();
image->update(0);
image->unlock();
PlotItem *plotItem = 0;
switch (_CSDTab->curvePlacement()->place()) {
case CurvePlacement::NoPlot:
break;
case CurvePlacement::ExistingPlot:
{
plotItem = static_cast<PlotItem*>(_CSDTab->curvePlacement()->existingPlot());
break;
}
case CurvePlacement::NewPlot:
{
CreatePlotForCurve *cmd = new CreatePlotForCurve(
_CSDTab->curvePlacement()->createLayout(),
_CSDTab->curvePlacement()->appendToLayout());
cmd->createItem();
plotItem = static_cast<PlotItem*>(cmd->item());
break;
}
default:
break;
}
PlotRenderItem *renderItem = plotItem->renderItem(PlotRenderItem::Cartesian);
//TODO Adam, is this the correct way to draw an image? It runs very slow.
renderItem->addRelation(kst_cast<Relation>(image));
plotItem->update();
return ObjectPtr(image.data());
}
示例4: StaffState
void MuseScore::setAdvancedPalette()
{
mscore->getPaletteBox();
paletteBox->clear();
paletteBox->addPalette(newGraceNotePalette());
paletteBox->addPalette(newClefsPalette());
paletteBox->addPalette(newKeySigPalette());
paletteBox->addPalette(newTimePalette());
paletteBox->addPalette(newBarLinePalette());
paletteBox->addPalette(newLinesPalette());
paletteBox->addPalette(newArpeggioPalette());
paletteBox->addPalette(newBreathPalette());
paletteBox->addPalette(newBracketsPalette());
paletteBox->addPalette(newArticulationsPalette());
paletteBox->addPalette(newAccidentalsPalette());
paletteBox->addPalette(newDynamicsPalette());
paletteBox->addPalette(newFingeringPalette());
paletteBox->addPalette(newNoteHeadsPalette());
paletteBox->addPalette(newTremoloPalette());
paletteBox->addPalette(newRepeatsPalette());
paletteBox->addPalette(newTempoPalette());
paletteBox->addPalette(newTextPalette());
paletteBox->addPalette(newBreaksPalette());
paletteBox->addPalette(newBagpipeEmbellishmentPalette());
//-----------------------------------
// staff state changes
//-----------------------------------
#if 0
sp = new Palette;
sp->setName(QT_TRANSLATE_NOOP("Palette", "Staff Changes"));
sp->setMag(.7);
sp->setGrid(42, 36);
sp->setDrawGrid(true);
StaffState* st = new StaffState(gscore);
st->setSubtype(STAFF_STATE_VISIBLE);
sp->append(st, tr("set visible"));
st = new StaffState(gscore);
st->setSubtype(STAFF_STATE_INVISIBLE);
sp->append(st, tr("set invisible"));
st = new StaffState(gscore);
st->setSubtype(STAFF_STATE_TYPE);
sp->append(st, tr("change staff type"));
st = new StaffState(gscore);
st->setSubtype(STAFF_STATE_INSTRUMENT);
sp->append(st, tr("change instrument"));
paletteBox->addPalette(sp);
#endif
paletteBox->addPalette(newBeamPalette());
paletteBox->addPalette(newFramePalette());
//-----------------------------------
// Symbols
//-----------------------------------
Palette* sp = new Palette;
sp->setName(QT_TRANSLATE_NOOP("Palette", "Symbols"));
sp->setGrid(42, 45);
sp->setDrawGrid(true);
/* sp->append(SymId(accDiscantSym));
sp->append(SymId(accDotSym));
sp->append(SymId(accFreebaseSym));
sp->append(SymId(accStdbaseSym));
sp->append(SymId(accBayanbaseSym));
sp->append(SymId(accOldEESym));
sp->append(SymId(accpushSym));
sp->append(SymId(accpullSym));
*/
FretDiagram* fret = new FretDiagram(gscore);
fret->setDot(5, 1);
fret->setDot(2, 2);
fret->setDot(1, 3);
fret->setMarker(0, 'X');
fret->setMarker(3, 'O');
fret->setMarker(4, 'O');
sp->append(fret, tr("Fretboard Diagram"));
paletteBox->addPalette(sp);
}
示例5: getPicks
void PaletteEntryEditor::setAbsolutePaletteEntryChannel(ColorSliders::Channel channel, const app::Color& color)
{
PalettePicks entries;
getPicks(entries);
int picksCount = entries.picks();
uint32_t src_color;
int r, g, b;
Palette* palette = get_current_palette();
for (int c=0; c<palette->size(); c++) {
if (!entries[c])
continue;
// Get the current RGB values of the palette entry
src_color = palette->getEntry(c);
r = rgba_getr(src_color);
g = rgba_getg(src_color);
b = rgba_getb(src_color);
switch (m_type) {
case app::Color::RgbType:
// Modify one entry
if (picksCount == 1) {
r = color.getRed();
g = color.getGreen();
b = color.getBlue();
}
// Modify one channel a set of entries
else {
// Setup the new RGB values depending of the modified channel.
switch (channel) {
case ColorSliders::Red:
r = color.getRed();
case ColorSliders::Green:
g = color.getGreen();
break;
case ColorSliders::Blue:
b = color.getBlue();
break;
}
}
break;
case app::Color::HsvType:
{
Hsv hsv;
// Modify one entry
if (picksCount == 1) {
hsv.hue(color.getHue());
hsv.saturation(double(color.getSaturation()) / 100.0);
hsv.value(double(color.getValue()) / 100.0);
}
// Modify one channel a set of entries
else {
// Convert RGB to HSV
hsv = Hsv(Rgb(r, g, b));
// Only modify the desired HSV channel
switch (channel) {
case ColorSliders::Hue:
hsv.hue(color.getHue());
break;
case ColorSliders::Saturation:
hsv.saturation(double(color.getSaturation()) / 100.0);
break;
case ColorSliders::Value:
hsv.value(double(color.getValue()) / 100.0);
break;
}
}
// Convert HSV back to RGB
Rgb rgb(hsv);
r = rgb.red();
g = rgb.green();
b = rgb.blue();
}
break;
}
palette->setEntry(c, doc::rgba(r, g, b, 255));
}
}
示例6: switch
Bool PaletteSubDialog::Command(Int32 id,const BaseContainer &msg)
{
GeDynamicArray<Palette> pals;
Palette pal;
Filename fn;
switch (id)
{
case 3:
switch(msg.GetInt32(BFM_ACTION_VALUE)){
case ACTION_NEW:
pal.SetColor(0, Color(0.f, 0.f, 0.f).SetSource(COLOR_SOURCE_DISPLAY));
id = Palette::AddPalette(pal);
m_controlsShown = FALSE;
LoadPalette(id);
SaveSettings();
Palette::UpdateAll();
return TRUE;
case ACTION_LOAD:
if(fn.FileSelect(FILESELECTTYPE_ANYTHING, FILESELECT_LOAD, "Load")){
String s = fn.GetString();
if(Palette::LoadASEFile(s, pal)){
id = Palette::AddPalette(pal);
m_controlsShown = FALSE;
LoadPalette(id);
SaveSettings();
Palette::UpdateAll();
}
}
return TRUE;
case ACTION_SAVE:
if(fn.FileSelect(FILESELECTTYPE_ANYTHING, FILESELECT_SAVE, "Save", "ase")){
String s = fn.GetString();
Palette::SaveASEFile(s, m_palette);
}
return TRUE;
case ACTION_LABEL:
ShowControls(!m_showControls);
return TRUE;
}
if(msg.GetInt32(BFM_ACTION_VALUE) >= ACTION_COUNT){
m_controlsShown = FALSE;
LoadPalette(msg.GetInt32(BFM_ACTION_VALUE)-ACTION_COUNT);
SaveSettings();
}
return TRUE;
case IDC_LAYOUT_DIRECTION:
m_controlsShown = FALSE;
LoadPalette(m_paletteID);
SaveSettings();
break;
case IDC_ROWS:
PaletteLayout();
SaveSettings();
break;
case IDC_LABELCHECKBOX:
GetBool(m_labelCheckArea, m_showLabel);
LoadPalette(m_paletteID);
SaveSettings();
break;
case IDC_NAME:
if(m_nameArea != NULL){
GetString(m_nameArea, m_palette.m_name);
Palette::SetPaletteName(m_paletteID, m_palette.m_name);
LoadPalette(m_paletteID);
}
break;
case IDC_HIDE:
ShowControls(FALSE);
break;
case IDC_SEARCHTEXT:
PaletteLayout();
SaveSettings();
break;
case IDC_CREATEMATERIAL:
{
Bool linkColors;
GetBool(m_linkColor,linkColors);
for(Int32 i=m_palette.m_colors.GetCount()-1;i>=0;--i){
BaseMaterial *mat = BaseMaterial::Alloc(Mmaterial);
String name = "PaletteMaterial";
if(m_palette[i].m_name != ""){
name = m_palette[i].m_name;
}
mat->SetName(name);
if(mat != nullptr){
BaseChannel *chan = mat->GetChannel(CHANNEL_COLOR);
if(chan != nullptr){
BaseContainer bc;
if(linkColors){
bc.SetInt32(BASECHANNEL_SHADERID, PALETTE_SHADER_ID);
chan->SetData(bc);
BaseShader *bs = chan->GetShader();
BaseContainer* data = bs->GetDataInstance();
data->SetInt32(PALETTESHADER_PALETTE_ID, 1+m_paletteID);
data->SetInt32(PALETTESHADER_COLOR_ID, 1+i);
} else {
// Color Shader ID: 5832
bc.SetInt32(BASECHANNEL_SHADERID, 5832);
chan->SetData(bc);
//.........这里部分代码省略.........
示例7: switch
bool PaletteView::onProcessMessage(Message* msg)
{
switch (msg->type) {
case JM_REQSIZE:
request_size(&msg->reqsize.w, &msg->reqsize.h);
return true;
case JM_DRAW: {
div_t d = div(Palette::MaxColors, m_columns);
int cols = m_columns;
int rows = d.quot + ((d.rem)? 1: 0);
int x, y, u, v;
int c, color;
BITMAP *bmp;
Palette* palette = get_current_palette();
int bordercolor = makecol(255, 255, 255);
bmp = create_bitmap(jrect_w(this->rc), jrect_h(this->rc));
clear_to_color(bmp, makecol(0 , 0, 0));
y = this->border_width.t;
c = 0;
for (v=0; v<rows; v++) {
x = this->border_width.l;
for (u=0; u<cols; u++) {
if (c >= palette->size())
break;
if (bitmap_color_depth(ji_screen) == 8)
color = c;
else
color = makecol_depth
(bitmap_color_depth(ji_screen),
_rgba_getr(palette->getEntry(c)),
_rgba_getg(palette->getEntry(c)),
_rgba_getb(palette->getEntry(c)));
rectfill(bmp, x, y, x+m_boxsize-1, y+m_boxsize-1, color);
if (m_selectedEntries[c]) {
const int max = Palette::MaxColors;
bool top = (c >= m_columns && c-m_columns >= 0 ? m_selectedEntries[c-m_columns]: false);
bool bottom = (c < max-m_columns && c+m_columns < max ? m_selectedEntries[c+m_columns]: false);
bool left = ((c%m_columns)>0 && c-1 >= 0 ? m_selectedEntries[c-1]: false);
bool right = ((c%m_columns)<m_columns-1 && c+1 < max ? m_selectedEntries[c+1]: false);
if (!top) hline(bmp, x-1, y-1, x+m_boxsize, bordercolor);
if (!bottom) hline(bmp, x-1, y+m_boxsize, x+m_boxsize, bordercolor);
if (!left) vline(bmp, x-1, y-1, y+m_boxsize, bordercolor);
if (!right) vline(bmp, x+m_boxsize, y-1, y+m_boxsize, bordercolor);
}
x += m_boxsize+this->child_spacing;
c++;
}
y += m_boxsize+this->child_spacing;
}
blit(bmp, ji_screen,
0, 0, this->rc->x1, this->rc->y1, bmp->w, bmp->h);
destroy_bitmap(bmp);
return true;
}
case JM_BUTTONPRESSED:
captureMouse();
/* continue... */
case JM_MOTION: {
JRect cpos = jwidget_get_child_rect(this);
int req_w, req_h;
request_size(&req_w, &req_h);
int mouse_x = MID(cpos->x1, msg->mouse.x, cpos->x1+req_w-this->border_width.r-1);
int mouse_y = MID(cpos->y1, msg->mouse.y, cpos->y1+req_h-this->border_width.b-1);
jrect_free(cpos);
Color color = getColorByPosition(mouse_x, mouse_y);
if (color.getType() == Color::IndexType) {
int idx = color.getIndex();
app_get_statusbar()->showColor(0, "", color, 255);
if (hasCapture() && idx != m_currentEntry) {
if (!(msg->any.shifts & KB_CTRL_FLAG))
clearSelection();
if (msg->any.shifts & KB_SHIFT_FLAG)
selectRange(m_rangeAnchor, idx);
else
selectColor(idx);
// Emit signals
jwidget_emit_signal(this, SIGNAL_PALETTE_EDITOR_CHANGE);
//.........这里部分代码省略.........
示例8: r
/** Draws the Control on the Output Display */
void WorldMapControl::Draw(unsigned short XWin, unsigned short YWin)
{
WorldMap* worldmap = core->GetWorldMap();
if (!Width || !Height) {
return;
}
if(!Changed)
return;
Changed = false;
Video* video = core->GetVideoDriver();
Region r( XWin+XPos, YWin+YPos, Width, Height );
Region clipbackup;
video->GetClipRect(clipbackup);
video->SetClipRect(&r);
video->BlitSprite( worldmap->GetMapMOS(), MAP_TO_SCREENX(0), MAP_TO_SCREENY(0), true, &r );
unsigned int i;
unsigned int ec = worldmap->GetEntryCount();
for(i=0;i<ec;i++) {
WMPAreaEntry *m = worldmap->GetEntry(i);
if (! (m->GetAreaStatus() & WMP_ENTRY_VISIBLE)) continue;
int xOffs = MAP_TO_SCREENX(m->X);
int yOffs = MAP_TO_SCREENY(m->Y);
Sprite2D* icon = m->GetMapIcon(worldmap->bam);
if( icon ) {
if (m == Area) {
Palette *pal = icon->GetPalette();
icon->SetPalette(pal_selected);
video->BlitSprite( icon, xOffs, yOffs, true, &r );
icon->SetPalette(pal);
pal->Release();
} else {
video->BlitSprite( icon, xOffs, yOffs, true, &r );
}
video->FreeSprite( icon );
}
if (AnimPicture && !strnicmp(m->AreaResRef, currentArea, 8) ) {
video->BlitSprite( AnimPicture, xOffs, yOffs, true, &r );
}
}
// Draw WMP entry labels
if (ftext==NULL) {
video->SetClipRect(&clipbackup);
return;
}
for(i=0;i<ec;i++) {
WMPAreaEntry *m = worldmap->GetEntry(i);
if (! (m->GetAreaStatus() & WMP_ENTRY_VISIBLE)) continue;
Sprite2D *icon=m->GetMapIcon(worldmap->bam);
int h=0,w=0,xpos=0,ypos=0;
if (icon) {
h=icon->Height;
w=icon->Width;
xpos=icon->XPos;
ypos=icon->YPos;
video->FreeSprite( icon );
}
Region r2 = Region( MAP_TO_SCREENX(m->X-xpos), MAP_TO_SCREENY(m->Y-ypos), w, h );
if (!m->GetCaption())
continue;
int tw = ftext->CalcStringWidth( (unsigned char*)m->GetCaption() ) + 5;
int th = ftext->maxHeight;
Palette* text_pal = pal_normal;
if (Area == m) {
text_pal = pal_selected;
} else {
if (! (m->GetAreaStatus() & WMP_ENTRY_VISITED)) {
text_pal = pal_notvisited;
}
}
ftext->Print( Region( r2.x + (r2.w - tw)/2, r2.y + r2.h, tw, th ),
( const unsigned char * ) m->GetCaption(), text_pal, 0, true );
}
video->SetClipRect(&clipbackup);
}
示例9: MAKE_VERSION
/* loads a COL file (Animator and Animator Pro format) */
Palette *load_col_file(const char *filename)
{
#if (MAKE_VERSION(4, 2, 1) >= MAKE_VERSION(ALLEGRO_VERSION, \
ALLEGRO_SUB_VERSION, \
ALLEGRO_WIP_VERSION))
int size = file_size(filename);
#else
int size = file_size_ex(filename);
#endif
int pro = (size == 768)? false: true; /* is Animator Pro format? */
div_t d = div(size-8, 3);
Palette *pal = NULL;
int c, r, g, b;
FILE *f;
if (!(size) || (pro && d.rem)) /* invalid format */
return NULL;
f = fopen(filename, "rb");
if (!f)
return NULL;
/* Animator format */
if (!pro) {
pal = new Palette(FrameNumber(0), 256);
for (c=0; c<256; c++) {
r = fgetc(f);
g = fgetc(f);
b = fgetc(f);
if (ferror(f))
break;
pal->setEntry(c, _rgba(_rgb_scale_6[MID(0, r, 63)],
_rgb_scale_6[MID(0, g, 63)],
_rgb_scale_6[MID(0, b, 63)], 255));
}
}
/* Animator Pro format */
else {
int magic, version;
fgetl(f); /* skip file size */
magic = fgetw(f); /* file format identifier */
version = fgetw(f); /* version file */
/* unknown format */
if (magic != PROCOL_MAGIC_NUMBER || version != 0) {
fclose(f);
return NULL;
}
pal = new Palette(FrameNumber(0), MIN(d.quot, 256));
for (c=0; c<pal->size(); c++) {
r = fgetc(f);
g = fgetc(f);
b = fgetc(f);
if (ferror(f))
break;
pal->setEntry(c, _rgba(MID(0, r, 255),
MID(0, g, 255),
MID(0, b, 255), 255));
}
}
fclose(f);
return pal;
}
示例10: size
bool Palette::operator==(const Palette &rhs) const {
return size() == rhs.size() && memcmp(data(), rhs.data(), size()) == 0;
}
示例11: Palette
void MuseScore::lineMenu()
{
if (linePalette == 0) {
Palette* sp = new Palette();
sp->resize(400, 300);
linePalette = new PaletteScrollArea(sp);
linePalette->setRestrictHeight(false);
linePalette->setWindowTitle(tr("MuseScore: Lines"));
sp->setGrid(100, 30);
double l = gscore->spatium() * 8;
Slur* slur = new Slur(gscore);
slur->setId(0);
sp->append(slur, tr("Slur"));
Hairpin* gabel0 = new Hairpin(gscore);
gabel0->setSubtype(0);
gabel0->setLen(l);
sp->append(gabel0, tr("Crescendo"));
Hairpin* gabel1 = new Hairpin(gscore);
gabel1->setSubtype(1);
gabel1->setLen(l);
sp->append(gabel1, tr("Diminuendo"));
Volta* volta = new Volta(gscore);
volta->setLen(l);
volta->setText("1.");
QList<int> il;
il.clear();
il.append(1);
volta->setEndings(il);
volta->setSubtype(VOLTA_CLOSED);
sp->append(volta, tr("Prima volta"));
volta = new Volta(gscore);
volta->setLen(l);
volta->setText("2.");
il.clear();
il.append(2);
volta->setEndings(il);
volta->setSubtype(VOLTA_CLOSED);
sp->append(volta, tr("Seconda volta"));
volta = new Volta(gscore);
volta->setLen(l);
volta->setText("3.");
il.clear();
il.append(3);
volta->setEndings(il);
volta->setSubtype(VOLTA_CLOSED);
sp->append(volta, tr("Terza volta"));
volta = new Volta(gscore);
volta->setLen(l);
volta->setText("2.");
il.clear();
il.append(2);
volta->setEndings(il);
volta->setSubtype(VOLTA_OPEN);
sp->append(volta, tr("Seconda volta"));
//--------
Ottava* ottava = new Ottava(gscore);
ottava->setSubtype(0);
ottava->setLen(l);
sp->append(ottava, tr("8va"));
ottava = new Ottava(gscore);
ottava->setSubtype(1);
ottava->setLen(l);
sp->append(ottava, tr("15ma"));
ottava = new Ottava(gscore);
ottava->setSubtype(2);
ottava->setLen(l);
sp->append(ottava, tr("8vb"));
ottava = new Ottava(gscore);
ottava->setSubtype(3);
ottava->setLen(l);
sp->append(ottava, tr("15mb"));
//-------
Pedal* pedal = new Pedal(gscore);
pedal->setLen(l);
sp->append(pedal, tr("Pedal"));
pedal = new Pedal(gscore);
pedal->setLen(l);
pedal->setEndHookType(HOOK_45);
sp->append(pedal, tr("Pedal"));
pedal = new Pedal(gscore);
pedal->setLen(l);
pedal->setBeginSymbol(-1);
//.........这里部分代码省略.........
示例12: populateIconPalette
void MuseScore::populatePalette()
{
//-----------------------------------
// notes
//-----------------------------------
Palette* notePalette = new Palette;
notePalette->setName(tr("Grace Notes"));
notePalette->setGrid(32, 40);
notePalette->setDrawGrid(true);
static const IconAction gna[] = {
{ ICON_ACCIACCATURA, "acciaccatura" },
{ ICON_APPOGGIATURA, "appoggiatura" },
{ ICON_GRACE4, "grace4" },
{ ICON_GRACE16, "grace16" },
{ ICON_GRACE32, "grace32" },
{ -1, "" }
};
populateIconPalette(notePalette, gna);
paletteBox->addPalette(notePalette);
//-----------------------------------
// clefs
//-----------------------------------
Palette* sp = new Palette;
sp->setName(tr("Clefs"));
sp->setMag(0.8);
sp->setGrid(33, 60);
sp->setYOffset(1.0);
static const ClefType clefs[21] = {
CLEF_G, CLEF_G1, CLEF_G2, CLEF_G3, CLEF_G4,
CLEF_C1, CLEF_C2, CLEF_C3, CLEF_C4, CLEF_C5,
CLEF_F, CLEF_F_8VA, CLEF_F_15MA, CLEF_F8, CLEF_F15, CLEF_F_B, CLEF_F_C,
CLEF_PERC, CLEF_TAB, CLEF_TAB2, CLEF_PERC2
};
for (int i = 0; i < 20; ++i) {
ClefType j = clefs[i];
Clef* k = new ::Clef(gscore);
k->setClefType(ClefTypeList(j, j));
sp->append(k, qApp->translate("clefTable", clefTable[j].name));
}
paletteBox->addPalette(sp);
//-----------------------------------
// key signatures
//-----------------------------------
sp = newKeySigPalette();
paletteBox->addPalette(sp);
//-----------------------------------
// Time
//-----------------------------------
sp = new Palette;
sp->setName(tr("Time Signatures"));
sp->setMag(.8);
sp->setGrid(42, 38);
TimeSig* ts;
ts = new TimeSig(gscore);
ts->setSig(2, 2);
sp->append(ts, "2/2");
sp->append(new TimeSig(gscore, 2, 4), "2/4");
sp->append(new TimeSig(gscore, 3, 4), "3/4");
sp->append(new TimeSig(gscore, 4, 4), "4/4");
sp->append(new TimeSig(gscore, 5, 4), "5/4");
sp->append(new TimeSig(gscore, 6, 4), "6/4");
sp->append(new TimeSig(gscore, 3, 8), "3/8");
sp->append(new TimeSig(gscore, 6, 8), "6/8");
sp->append(new TimeSig(gscore, 9, 8), "9/8");
sp->append(new TimeSig(gscore, 12, 8), "12/8");
sp->append(new TimeSig(gscore, TSIG_FOUR_FOUR), tr("4/4 common time"));
sp->append(new TimeSig(gscore, TSIG_ALLA_BREVE), tr("2/2 alla breve"));
paletteBox->addPalette(sp);
//-----------------------------------
// Bar Lines
//-----------------------------------
sp = new Palette;
sp->setName(tr("Barlines"));
sp->setMag(0.8);
sp->setGrid(42, 38);
struct {
BarLineType type;
const char* name;
} t[] = {
{ NORMAL_BAR, QT_TR_NOOP("Normal") },
{ BROKEN_BAR, QT_TR_NOOP("Dashed") },
{ END_BAR, QT_TR_NOOP("End Bar") },
{ DOUBLE_BAR, QT_TR_NOOP("Double Bar") },
{ START_REPEAT, QT_TR_NOOP("Start Repeat") },
{ END_REPEAT, QT_TR_NOOP("End Repeat") },
//.........这里部分代码省略.........
示例13: QColor
QwtCompass *DataWidget::createCompass(int pos)
{
int c;
Palette colorGroup;
for ( c = 0; c < Palette::NColorRoles; c++ )
colorGroup.setColor((Palette::ColorRole)c, QColor());
#if QT_VERSION < 0x040000
colorGroup.setColor(Palette::Base, backgroundColor().light(120));
#else
colorGroup.setColor(Palette::Base,
palette().color(backgroundRole()).light(120));
#endif
colorGroup.setColor(Palette::Foreground,
colorGroup.color(Palette::Base));
QwtCompass *compass = new QwtCompass(this);
compass->setLineWidth(4);
compass->setFrameShadow(
pos <= 2 ? QwtCompass::Sunken : QwtCompass::Raised);
switch(pos)
{
case 0:
{
/*
A windrose, with a scale indicating the main directions only
*/
QMap<double, QString> map;
map.insert(0.0, "N");
map.insert(90.0, "E");
map.insert(180.0, "S");
map.insert(270.0, "W");
compass->setLabelMap(map);
QwtSimpleCompassRose *rose = new QwtSimpleCompassRose(4, 1);
compass->setRose(rose);
compass->setNeedle(
new QwtCompassWindArrow(QwtCompassWindArrow::Style2));
compass->setValue(60.0);
break;
}
case 1:
{
/*
A compass showing another needle
*/
QMap<double, QString> map;
map.insert(0.0, "");
map.insert(90.0, "");
map.insert(180.0, "");
map.insert(270.0, "");
compass->setLabelMap(map);
compass->setScaleOptions(QwtDial::ScaleTicks | QwtDial::ScaleLabel);
compass->setScaleTicks(0, 0, 3);
compass->setNeedle(new QwtCompassMagnetNeedle(
QwtCompassMagnetNeedle::TriangleStyle, Qt::white, Qt::red));
compass->setValue(220.0);
break;
}
}
QPalette newPalette = compass->palette();
for ( c = 0; c < Palette::NColorRoles; c++ )
{
if ( colorGroup.color((Palette::ColorRole)c).isValid() )
{
for ( int cg = 0; cg < QPalette::NColorGroups; cg++ )
{
newPalette.setColor(
(QPalette::ColorGroup)cg,
(Palette::ColorRole)c,
colorGroup.color((Palette::ColorRole)c));
}
}
}
for ( int i = 0; i < QPalette::NColorGroups; i++ )
{
QPalette::ColorGroup cg = (QPalette::ColorGroup)i;
const QColor light =
newPalette.color(cg, Palette::Base).light(170);
const QColor dark = newPalette.color(cg, Palette::Base).dark(170);
const QColor mid = compass->frameShadow() == QwtDial::Raised
? newPalette.color(cg, Palette::Base).dark(110)
: newPalette.color(cg, Palette::Base).light(110);
newPalette.setColor(cg, Palette::Dark, dark);
newPalette.setColor(cg, Palette::Mid, mid);
newPalette.setColor(cg, Palette::Light, light);
}
compass->setPalette(newPalette);
//.........这里部分代码省略.........
示例14: remplirPalette_thread
////////////////////////////////////////////////////////////////// PUBLIC
//---------------------------------------------------- Fonctions publiques
//Méthode de thread
void remplirPalette_thread(void * argsUncasted)
{
unsigned int idpalette = 0;
ArgsRemplirPalette * args = (ArgsRemplirPalette *) argsUncasted;
ecriture_log_remplirPalette(args->gestionnaireLog,"Lancement de la tache remplir palette",EVENT);
Palette palette;
int countCarton = 0, countPalette = 0, countLot = 0;
while (1)
{
Carton carton = args->balPalette->Pull(); // appel bloquant
if (carton.fin)
{
ecriture_log_remplirPalette(args->gestionnaireLog,"Fin de la tache remplir palette",EVENT);
Palette p;
p.fin=true;
args->balStockage->Push(p,0);
pthread_exit(0);
}
ecriture_log_remplirPalette(args->gestionnaireLog,"La tache remplir palette a recu un carton de type "+args->shMemLots->content->lots[countLot].nom,EVENT);
// Message réseau carton empaletté :
Message msg = {carton.netstr_palette(), false};
args->balMessages->Push(msg, 1);
// passage au carton suivant :
countCarton++;
ecriture_log_remplirPalette(args->gestionnaireLog,"Le carton a été empilé par la tache remplir palette",EVENT);
if (countCarton == args->shMemLots->content->lots[countLot].cartons)
{ // next palette
// on emballe la palette qu'on vient de finir :
if ( (*args->capteurEmbalage)() )
{ // si erreur emballage :
ecriture_log_remplirPalette(args->gestionnaireLog,"La tache remplir palette a eu une erreur en emballant",EVENT);
args->eventBox->Push(Event(ABSPALETTE),0);
pthread_mutex_lock(args->mxcw);
pthread_cond_wait(args->cw,args->mxcw);
pthread_mutex_unlock(args->mxcw);
}
// On donne un id et un id_lot à la palette finie :
palette.id = idpalette++;
args->shMemLots->mutex.lock();
palette.lot = &args->shMemLots->content->lots[countLot];
args->shMemLots->mutex.unlock();
ecriture_log_remplirPalette(args->gestionnaireLog,"La tache remplir palette a empilé le carton",EVENT);
// on push la palette
args->balStockage->Push(palette,0);
// Message réseau palette finie :
Message msg = {palette.netstr(), false};
args->balMessages->Push(msg, 1);
countCarton = 0;
countPalette++;
if (countPalette == args->shMemLots->content->lots[countLot].palettes)
{ // next lot
countPalette = 0;
countLot++;
// test de fin de production :
if (countLot == args->shMemLots->content->lots.size())
break;
}
// la palette est elle bien présente ?
if ( (*args->capteurPalette)() )
{ // palette absente !
ecriture_log_remplirPalette(args->gestionnaireLog,"La tache remplir palette a detecté l'abscence d'une palette",EVENT);
args->eventBox->Push(Event(ERREMBALAGES),0);
pthread_mutex_lock(args->mxcw);
pthread_cond_wait(args->cw,args->mxcw);
pthread_mutex_unlock(args->mxcw);
}
}
}
}
示例15: frame
void DocumentApi::setPixelFormat(Sprite* sprite, PixelFormat newFormat, DitheringMethod dithering_method)
{
Image* old_image;
Image* new_image;
int c;
if (sprite->getPixelFormat() == newFormat)
return;
// Change pixel format of the stock of images.
DocumentUndo* undo = m_document->getUndo();
if (undo->isEnabled())
m_undoers->pushUndoer(new undoers::SetStockPixelFormat(getObjects(), sprite->getStock()));
sprite->getStock()->setPixelFormat(newFormat);
// TODO Review this, why we use the palette in frame 0?
FrameNumber frame(0);
// Use the rgbmap for the specified sprite
const RgbMap* rgbmap = sprite->getRgbMap(frame);
for (c=0; c<sprite->getStock()->size(); c++) {
old_image = sprite->getStock()->getImage(c);
if (!old_image)
continue;
new_image = quantization::convert_pixel_format
(old_image, newFormat, dithering_method, rgbmap,
sprite->getPalette(frame),
sprite->getBackgroundLayer() != NULL);
replaceStockImage(sprite, c, new_image);
}
// Change sprite's pixel format.
if (undo->isEnabled())
m_undoers->pushUndoer(new undoers::SetSpritePixelFormat(getObjects(), sprite));
sprite->setPixelFormat(newFormat);
// Regenerate extras
m_document->destroyExtraCel();
// When we are converting to grayscale color mode, we've to destroy
// all palettes and put only one grayscaled-palette at the first
// frame.
if (newFormat == IMAGE_GRAYSCALE) {
// Add undoers to revert all palette changes.
if (undo->isEnabled()) {
PalettesList palettes = sprite->getPalettes();
for (PalettesList::iterator it = palettes.begin(); it != palettes.end(); ++it) {
Palette* palette = *it;
m_undoers->pushUndoer(new undoers::RemovePalette(
getObjects(), sprite, palette->getFrame()));
}
m_undoers->pushUndoer(new undoers::AddPalette(
getObjects(), sprite, FrameNumber(0)));
}
// It's a UniquePtr because setPalette'll create a copy of "graypal".
UniquePtr<Palette> graypal(Palette::createGrayscale());
sprite->resetPalettes();
sprite->setPalette(graypal, true);
}
}