void selectBasedOnModifiers (TreeViewItem* const item, const ModifierKeys& modifiers) { TreeViewItem* firstSelected = 0; if (modifiers.isShiftDown() && ((firstSelected = owner.getSelectedItem (0)) != 0)) { TreeViewItem* const lastSelected = owner.getSelectedItem (owner.getNumSelectedItems() - 1); jassert (lastSelected != 0); int rowStart = firstSelected->getRowNumberInTree(); int rowEnd = lastSelected->getRowNumberInTree(); if (rowStart > rowEnd) swapVariables (rowStart, rowEnd); int ourRow = item->getRowNumberInTree(); int otherEnd = ourRow < rowEnd ? rowStart : rowEnd; if (ourRow > otherEnd) swapVariables (ourRow, otherEnd); for (int i = ourRow; i <= otherEnd; ++i) owner.getItemOnRow (i)->setSelected (true, false); } else { const bool cmd = modifiers.isCommandDown(); item->setSelected ((! cmd) || ! item->isSelected(), ! cmd); } }
void BPTree::delete_entry(_F_FileAddr L, pKey_Attr pPrimKey, _F_FileAddr pRec) { BPTreeNode NodeL; NodeL.readNodeFromFile(L); // delete the (V,P) entry if( 1 == NodeL.IsLeaf ) NodeL.deleteKeyInLeaf(pPrimKey); else NodeL.deleteKeyNotLeaf(pPrimKey); // L is root and has only one son and not a leaf if( isRoot(L) && ( 0 == NodeL.ItemOnNode ) && (0 == NodeL.IsLeaf) ) { grantRoot(NodeL.p[0]); // grant root to the son deleteNodeInFile(L); // delete node } else if( !isRoot(L) && NodeL.isNotEnoughPoints() ) {// isn't root and not enough points //set L_ neighbour of L bool IsLLeftOfL_; _F_FileAddr L_; pKey_Attr pPrimKey_; setNb(L, &L_, &pPrimKey_, &IsLLeftOfL_); BPTreeNode NodeL_; NodeL_.readNodeFromFile(L_); if( canCoalesce(&NodeL, &NodeL_)) { if(IsLLeftOfL_) swapVariables(L,L_); coalesce(&NodeL, &NodeL_, pPrimKey_, IsLLeftOfL_); if( NodeL.IsLeaf && IsLLeftOfL_ ) // differe from book swapVariables(L,L_); delete_entry(getParent(L), pPrimKey_, L); if( NodeL.IsLeaf && IsLLeftOfL_ ) // L is a leaf and L < L_. Different from the book deleteNodeInFile(L_); // delete the node pointed by L_ else deleteNodeInFile(L); // delete the node pointed by L } else reDistribute(&NodeL, &NodeL_, pPrimKey_, IsLLeftOfL_, L); NodeL_.writeNodeToFile(L_); } NodeL.writeNodeToFile(L); // if though the node is delete }
int main() { int a = 15; int b = 100; swapVariables(&a, &b); // Değişkenlerimizin adreslerini gönderiyoruz böylece ram üzerinde degişiklik yapabilelim. printf("A (15) > : %d\n",a); printf("B (100)> : %d\n",b); }
void OldSchoolLookAndFeel::positionDocumentWindowButtons (DocumentWindow&, int titleBarX, int titleBarY, int titleBarW, int titleBarH, Button* minimiseButton, Button* maximiseButton, Button* closeButton, bool positionTitleBarButtonsOnLeft) { titleBarY += titleBarH / 8; titleBarH -= titleBarH / 4; const int buttonW = titleBarH; int x = positionTitleBarButtonsOnLeft ? titleBarX + 4 : titleBarX + titleBarW - buttonW - 4; if (closeButton != 0) { closeButton->setBounds (x, titleBarY, buttonW, titleBarH); x += positionTitleBarButtonsOnLeft ? buttonW + buttonW / 5 : -(buttonW + buttonW / 5); } if (positionTitleBarButtonsOnLeft) swapVariables (minimiseButton, maximiseButton); if (maximiseButton != 0) { maximiseButton->setBounds (x, titleBarY - 2, buttonW, titleBarH); x += positionTitleBarButtonsOnLeft ? buttonW : -buttonW; } if (minimiseButton != 0) minimiseButton->setBounds (x, titleBarY - 2, buttonW, titleBarH); }
void drawCurrentImage (Graphics& g, int x, int y, int w, int h) { if (imageNeedsFlipping) { const ScopedLock sl (imageSwapLock); swapVariables (loadingImage, activeImage); imageNeedsFlipping = false; } RectanglePlacement rp (RectanglePlacement::centred); double dx = 0, dy = 0, dw = width, dh = height; rp.applyTo (dx, dy, dw, dh, x, y, w, h); const int rx = roundToInt (dx), ry = roundToInt (dy); const int rw = roundToInt (dw), rh = roundToInt (dh); { Graphics::ScopedSaveState ss (g); g.excludeClipRegion (Rectangle<int> (rx, ry, rw, rh)); g.fillAll (Colours::black); } g.drawImage (activeImage, rx, ry, rw, rh, 0, 0, width, height); }
//============================================================================== void var::swapWith (var& other) throw() { swapVariables (type, other.type); swapVariables (value, other.value); }
void TabbedButtonBar::resized() { int depth = getWidth(); int length = getHeight(); if (orientation == TabsAtTop || orientation == TabsAtBottom) swapVariables (depth, length); const int overlap = getLookAndFeel().getTabButtonOverlap (depth) + getLookAndFeel().getTabButtonSpaceAroundImage() * 2; int i, totalLength = overlap; int numVisibleButtons = tabs.size(); for (i = 0; i < tabs.size(); ++i) { TabBarButton* const tb = tabs.getUnchecked(i)->component; totalLength += tb->getBestTabLength (depth) - overlap; tb->overlapPixels = overlap / 2; } double scale = 1.0; if (totalLength > length) scale = jmax (minimumScale, length / (double) totalLength); const bool isTooBig = totalLength * scale > length; int tabsButtonPos = 0; if (isTooBig) { if (extraTabsButton == 0) { addAndMakeVisible (extraTabsButton = getLookAndFeel().createTabBarExtrasButton()); extraTabsButton->addListener (behindFrontTab); extraTabsButton->setAlwaysOnTop (true); extraTabsButton->setTriggeredOnMouseDown (true); } const int buttonSize = jmin (proportionOfWidth (0.7f), proportionOfHeight (0.7f)); extraTabsButton->setSize (buttonSize, buttonSize); if (orientation == TabsAtTop || orientation == TabsAtBottom) { tabsButtonPos = getWidth() - buttonSize / 2 - 1; extraTabsButton->setCentrePosition (tabsButtonPos, getHeight() / 2); } else { tabsButtonPos = getHeight() - buttonSize / 2 - 1; extraTabsButton->setCentrePosition (getWidth() / 2, tabsButtonPos); } totalLength = 0; for (i = 0; i < tabs.size(); ++i) { TabBarButton* const tb = tabs.getUnchecked(i)->component; const int newLength = totalLength + tb->getBestTabLength (depth); if (i > 0 && newLength * minimumScale > tabsButtonPos) { totalLength += overlap; break; } numVisibleButtons = i + 1; totalLength = newLength - overlap; } scale = jmax (minimumScale, tabsButtonPos / (double) totalLength); } else { extraTabsButton = 0; } int pos = 0; TabBarButton* frontTab = 0; for (i = 0; i < tabs.size(); ++i) { TabBarButton* const tb = getTabButton (i); if (tb != 0) { const int bestLength = roundToInt (scale * tb->getBestTabLength (depth)); if (i < numVisibleButtons) { if (orientation == TabsAtTop || orientation == TabsAtBottom) tb->setBounds (pos, 0, bestLength, getHeight()); else tb->setBounds (0, pos, getWidth(), bestLength); tb->toBack(); if (i == currentTabIndex) frontTab = tb; tb->setVisible (true); } else { tb->setVisible (false); } pos += bestLength - overlap; } } behindFrontTab->setBounds (getLocalBounds()); if (frontTab != 0) { frontTab->toFront (false); behindFrontTab->toBehind (frontTab); } }
void PianoRoll::mouseUp (const MouseEvent& e) { int highnote,lownote; if (lasso.getWidth()>0) { lownote = (int)((float)(getHeight()-lasso.getY())*128.f/(float)getHeight()); highnote = (int)((float)(getHeight()-(lasso.getY()+lasso.getHeight()))*128.f/(float)getHeight()); if (lownote>highnote) swapVariables(lownote,highnote); for (int index=0;index<(sequence->getNumEvents());index++) { MidiMessage m = sequence->getEventPointer(index)->message; DBG("eventtime=" + String(sequence->getEventTime(index))); if (m.isNoteOn()) {DBG("note=" + String(m.getNoteNumber()));} DBG("lassostart=" + String(pixelsToPpq((float)lasso.getX(),false))); DBG("lassoend=" + String(pixelsToPpq((float)(lasso.getX()+lasso.getWidth()),false))); if (m.isNoteOn() && sequence->getEventTime(index)>=pixelsToPpq((float)lasso.getX(),false) && sequence->getEventTime(index)<=pixelsToPpq((float)(lasso.getX()+lasso.getWidth()),false) && m.getNoteNumber()>=lownote && m.getNoteNumber()<=highnote) { addToSelection(sequence->getEventPointer(index)); } } lasso.setSize(0,0); repaint(); noteLayer->repaint(); } if (hoveringNoteIndex != No_Note) { if (hoveringNoteIndex<-2) hoveringNoteIndex+=9999; if (e.mods.isPopupMenu() && hoveringNoteIndex!=-2) { //right click, delete notes plugin->getCallbackLock().enter(); for (int i=selectedNotes.size();--i>=0;) sequence->deleteEvent(sequence->getIndexOf(selectedNotes.getUnchecked(i)),true); sequence->updateMatchedPairs(); plugin->getCallbackLock().exit(); clearSelection(); } else { if (draggingNoteTimeDelta!=0 || draggingNoteTransposition!=0) { plugin->getCallbackLock().enter(); if (draggingNoteTimeDelta!=0.0) { for (int i=0;i<selectedNotes.size();i++) { selectedNotes.getUnchecked(i)->message.addToTimeStamp(draggingNoteTimeDelta); selectedNotes.getUnchecked(i)->noteOffObject->message.addToTimeStamp(draggingNoteTimeDelta); //sequence->moveEvent(sequence->getIndexOf(selectedNotes.getUnchecked(i)),draggingNoteTimeDelta,true); } draggingNoteTimeDelta=0.0; } if (draggingNoteTransposition!=0) { for (int i=0;i<selectedNotes.size();i++) sequence->transposeEvent(sequence->getIndexOf(selectedNotes.getUnchecked(i)),draggingNoteTransposition); draggingNoteTransposition=0; } sequence->updateMatchedPairs(true); plugin->getCallbackLock().exit(); } else if (wasResizing || e.mods.isAltDown()) { //resize notes wasResizing=false; for (int i=selectedNoteLengths.size();--i>=0;) { if (selectedNotes.getUnchecked(i)!=0 && selectedNotes.getUnchecked(i)->noteOffObject!=0) { selectedNoteLengths.getReference(i).updateLength(); } else { selectedNotes.remove(i); selectedNoteLengths.remove(i); } } plugin->getCallbackLock().enter(); sequence->updateMatchedPairs(true); plugin->getCallbackLock().exit(); } } hoveringNoteIndex = No_Note; hoveringNote=0; sendChangeMessage(); noteLayer->repaint(); } }