void ScrollView::setVScrollbarMode(ScrollbarMode newMode) { if (m_data->vScrollbarMode != newMode) { m_data->vScrollbarMode = newMode; adjustScrollbars(); } }
void ScrollView::resizeContents(int w,int h) { wxWindow* win = nativeWindow(); if (win) { win->SetVirtualSize(w, h); adjustScrollbars(); } }
void ScrollView::setScrollbarsMode(ScrollbarMode newMode) { bool needsAdjust = false; if (m_data->hScrollbarMode != newMode) { m_data->hScrollbarMode = newMode; needsAdjust = true; } if (m_data->vScrollbarMode != newMode) { m_data->vScrollbarMode = newMode; adjustScrollbars(); needsAdjust = true; } if (needsAdjust) adjustScrollbars(); }
void EnvelopeEditorControl::setScale(pp_int32 scale) { if (scale < 16 || scale > 1024) return; xScale = scale; adjustScrollbars(); }
void ScrollView::platformSetContentsSize() { wxWindow* win = platformWidget(); if (!win) return; win->SetVirtualSize(m_contentsSize.width(), m_contentsSize.height()); adjustScrollbars(); }
void ScrollView::platformSetScrollbarModes() { bool needsAdjust = false; if (m_data->hScrollbarMode != horizontalScrollbarMode() ) { m_data->hScrollbarMode = horizontalScrollbarMode(); needsAdjust = true; } if (m_data->vScrollbarMode != verticalScrollbarMode() ) { m_data->vScrollbarMode = verticalScrollbarMode(); needsAdjust = true; } if (needsAdjust) adjustScrollbars(); }
void ScrollView::scrollBy(int dx, int dy) { wxWindow* win = nativeWindow(); if (!win) return; wxPoint scrollOffset = m_data->viewStart; wxPoint orig(scrollOffset); wxPoint newScrollOffset = scrollOffset + wxPoint(dx, dy); wxRect vRect(win->GetVirtualSize()); wxRect cRect(win->GetClientSize()); // clamp to scroll area if (newScrollOffset.x < 0) newScrollOffset.x = 0; else if (newScrollOffset.x + cRect.width > vRect.width) newScrollOffset.x = max(0, vRect.width - cRect.width - 1); if (newScrollOffset.y < 0) newScrollOffset.y = 0; else if (newScrollOffset.y + cRect.height > vRect.height) newScrollOffset.y = max(0, vRect.height - cRect.height - 1); if (newScrollOffset == scrollOffset) return; m_data->viewStart = newScrollOffset; wxPoint delta(orig - newScrollOffset); if (m_data->hasStaticBackground) win->Refresh(); else win->ScrollWindow(delta.x, delta.y); adjustScrollbars(); }
void ScrollView::platformSetScrollPosition(const IntPoint& scrollPoint) { wxWindow* win = platformWidget(); wxPoint scrollOffset = m_data->viewStart; wxPoint orig(scrollOffset); wxPoint newScrollOffset(scrollPoint); wxRect vRect(win->GetVirtualSize()); wxRect cRect(win->GetClientSize()); // clamp to scroll area if (newScrollOffset.x < 0) newScrollOffset.x = 0; else if (newScrollOffset.x + cRect.width > vRect.width) newScrollOffset.x = max(0, vRect.width - cRect.width); if (newScrollOffset.y < 0) newScrollOffset.y = 0; else if (newScrollOffset.y + cRect.height > vRect.height) newScrollOffset.y = max(0, vRect.height - cRect.height); if (newScrollOffset == scrollOffset) return; m_data->viewStart = newScrollOffset; wxPoint delta(orig - newScrollOffset); if (canBlitOnScroll()) win->ScrollWindow(delta.x, delta.y); else win->Refresh(); adjustScrollbars(); }
SampleEditorControl::SampleEditorControl(pp_int32 id, PPScreen* parentScreen, EventListenerInterface* eventListener, const PPPoint& location, const PPSize& size, bool border/*= true*/) : PPControl(id, parentScreen, eventListener, location, size), border(border), borderColor(&ourOwnBorderColor), caughtControl(NULL), controlCaughtByLMouseButton(false), controlCaughtByRMouseButton(false), sampleEditor(NULL), xScale(1.0f), minScale(1.0f), selectionStartNew(-1), selectionEndNew(-1), selecting(-1), resizing(0), drawMode(false), selectionTicker(-1), relativeNote(0), offsetFormat(OffsetFormatHex) { // default color backgroundColor.set(0, 0, 0); ourOwnBorderColor.set(192, 192, 192); hScrollbar = new PPScrollbar(0, parentScreen, this, PPPoint(location.x, location.y + size.height - SCROLLBARWIDTH - 1), size.width - 1, true); currentPosition.x = currentPosition.y = -1; currentOffset = -1; startPos = 0; visibleWidth = size.width - 4; visibleHeight = size.height - SCROLLBARWIDTH - 4; scrollDist = (3298*visibleWidth) >> 16; adjustScrollbars(); showMarks = new ShowMark[TrackerConfig::maximumPlayerChannels]; for (pp_int32 i = 0; i < TrackerConfig::maximumPlayerChannels; i++) { showMarks[i].pos = -1; showMarks[i].intensity = 0; showMarks[i].panning = 128; } // build submenu static const char* seperatorStringLarge = "\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4"; static const char* seperatorStringMed = "\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4"; subMenuAdvanced = new PPContextMenu(5, parentScreen, this, PPPoint(0,0), TrackerConfig::colorThemeMain); subMenuAdvanced->setSubMenu(true); subMenuAdvanced->addEntry("Volume boost" PPSTR_PERIODS, MenuCommandIDVolumeBoost); subMenuAdvanced->addEntry("Volume fade" PPSTR_PERIODS, MenuCommandIDVolumeFade); subMenuAdvanced->addEntry("Normalize", MenuCommandIDNormalize); subMenuAdvanced->addEntry(seperatorStringLarge, -1); subMenuAdvanced->addEntry("Backwards", MenuCommandIDReverse); subMenuAdvanced->addEntry("Cross-fade", MenuCommandIDXFade); subMenuAdvanced->addEntry(seperatorStringLarge, -1); subMenuAdvanced->addEntry("Change sign", MenuCommandIDChangeSign); subMenuAdvanced->addEntry("Swap byte order", MenuCommandIDSwapByteOrder); subMenuAdvanced->addEntry(seperatorStringLarge, -1); subMenuAdvanced->addEntry("DC normalize", MenuCommandIDDCNormalize); subMenuAdvanced->addEntry("DC offset" PPSTR_PERIODS, MenuCommandIDDCOffset); subMenuAdvanced->addEntry(seperatorStringLarge, -1); subMenuAdvanced->addEntry("Smooth (rect.)", MenuCommandIDRectangularSmooth); subMenuAdvanced->addEntry("Smooth (tri.)", MenuCommandIDTriangularSmooth); subMenuAdvanced->addEntry("3 Band EQ" PPSTR_PERIODS, MenuCommandIDEQ3Band); subMenuAdvanced->addEntry("10 Band EQ" PPSTR_PERIODS, MenuCommandIDEQ10Band); subMenuAdvanced->addEntry(seperatorStringLarge, -1); subMenuAdvanced->addEntry("Resample" PPSTR_PERIODS, MenuCommandIDResample); subMenuPT = new PPContextMenu(6, parentScreen, this, PPPoint(0,0), TrackerConfig::colorThemeMain); subMenuPT->addEntry("Boost", MenuCommandIDPTBoost); subMenuGenerators = new PPContextMenu(7, parentScreen, this, PPPoint(0,0), TrackerConfig::colorThemeMain); subMenuGenerators->addEntry("Noise" PPSTR_PERIODS, MenuCommandIDGenerateNoise); subMenuGenerators->addEntry("Sine" PPSTR_PERIODS, MenuCommandIDGenerateSine); subMenuGenerators->addEntry("Square" PPSTR_PERIODS, MenuCommandIDGenerateSquare); subMenuGenerators->addEntry("Triangle" PPSTR_PERIODS, MenuCommandIDGenerateTriangle); subMenuGenerators->addEntry("Sawtooth" PPSTR_PERIODS, MenuCommandIDGenerateSawtooth); subMenuGenerators->addEntry("Silence" PPSTR_PERIODS, MenuCommandIDGenerateSilence); // build context menu editMenuControl = new PPContextMenu(4, parentScreen, this, PPPoint(0,0), TrackerConfig::colorThemeMain, true); editMenuControl->addEntry("New", MenuCommandIDNew); editMenuControl->addEntry(seperatorStringMed, -1); editMenuControl->addEntry("Undo", MenuCommandIDUndo); editMenuControl->addEntry("Redo", MenuCommandIDRedo); editMenuControl->addEntry(seperatorStringMed, -1); editMenuControl->addEntry("Cut", MenuCommandIDCut); editMenuControl->addEntry("Copy", MenuCommandIDCopy); editMenuControl->addEntry("Paste", MenuCommandIDPaste); editMenuControl->addEntry("Mix-Paste", MenuCommandIDMixPaste); editMenuControl->addEntry("Crop", MenuCommandIDCrop); editMenuControl->addEntry("Range all", MenuCommandIDSelectAll); editMenuControl->addEntry(seperatorStringMed, -1); editMenuControl->addEntry("Advanced \x10", 0xFFFF, subMenuAdvanced); editMenuControl->addEntry("Protracker \x10", 0xFFFF, subMenuPT); editMenuControl->addEntry("Generators \x10", 0xFFFF, subMenuGenerators); // Create tool handler responder toolHandlerResponder = new ToolHandlerResponder(*this); dialog = NULL; resetLastValues(); }
pp_int32 EnvelopeEditorControl::dispatchEvent(PPEvent* event) { if (eventListener == NULL) return -1; switch (event->getID()) { case eRMouseDown: { PPPoint* p = (PPPoint*)event->getDataPtr(); if (!hScrollbar->hit(*p)) invokeContextMenu(*p); else { if (controlCaughtByLMouseButton) break; controlCaughtByRMouseButton = true; caughtControl = hScrollbar; caughtControl->dispatchEvent(event); } break; } case eLMouseDown: { hasDragged = false; selectionTicker = 0; PPPoint* p = (PPPoint*)event->getDataPtr(); // Clicked on horizontal scrollbar -> route event to scrollbar and catch scrollbar control if (hScrollbar->hit(*p)) { if (controlCaughtByRMouseButton) break; controlCaughtByLMouseButton = true; caughtControl = hScrollbar; caughtControl->dispatchEvent(event); } // Clicked in client area else { PPPoint cp = *p; translateCoordinates(cp); if (cp.x > visibleWidth) break; if (cp.y > visibleHeight) break; pp_int32 rx = (pp_int32)(cp.x + startPos); pp_int32 ry = (pp_int32)((visibleHeight - cp.y)); pp_int32 i = selectEnvelopePoint(rx, ry); if (i != -1) { envelopeEditor->startSelectionDragging(i); } else { updateCurrentPosition(cp); } parentScreen->paintControl(this); } break; } case eMouseLeft: { currentPosition.x = currentPosition.y = -1; parentScreen->paintControl(this); break; } case eMouseMoved: { PPPoint* p = (PPPoint*)event->getDataPtr(); PPPoint cp = *p; translateCoordinates(cp); if (cp.y < 0 || cp.x > visibleWidth || cp.y < 0 || cp.y > visibleHeight) break; updateCurrentPosition(cp); parentScreen->paintControl(this); break; } case eRMouseUp: { controlCaughtByRMouseButton = false; if (caughtControl && !controlCaughtByLMouseButton && !controlCaughtByRMouseButton) { caughtControl->dispatchEvent(event); caughtControl = NULL; break; } break; } case eLMouseUp: if (envelopeEditor->isSelectionDragging()) envelopeEditor->endSelectionDragging(); controlCaughtByLMouseButton = false; if (caughtControl == NULL) break; if (!controlCaughtByLMouseButton && !controlCaughtByRMouseButton) { caughtControl->dispatchEvent(event); caughtControl = NULL; } break; case eLMouseDrag: { if (caughtControl && controlCaughtByLMouseButton) { caughtControl->dispatchEvent(event); break; } hasDragged = true; if (!envelopeEditor->isSelectionDragging()) break; PPPoint* p = (PPPoint*)event->getDataPtr(); PPPoint cp = *p; translateCoordinates(cp); setEnvelopePoint(envelopeEditor->getSelectionIndex(), cp.x + startPos, visibleHeight - cp.y); updateCurrentPosition(cp); adjustScrollbars(); parentScreen->paintControl(this); break; } case eLMouseRepeat: { if (caughtControl && controlCaughtByLMouseButton) { caughtControl->dispatchEvent(event); break; } // for slowing down mouse pressed events selectionTicker++; // no selection has been made or mouse hasn't been dragged if (!envelopeEditor->isSelectionDragging() || !hasDragged) { // mouse hasn't been dragged and selection ticker has reached threshold value if (!hasDragged && selectionTicker > 0) { PPPoint* p = (PPPoint*)event->getDataPtr(); if (!hScrollbar->hit(*p)) invokeContextMenu(*p); } } break; } case eRMouseDrag: { if (caughtControl && controlCaughtByRMouseButton) caughtControl->dispatchEvent(event); break; } case eRMouseRepeat: { if (caughtControl && controlCaughtByRMouseButton) caughtControl->dispatchEvent(event); break; } // mouse wheel case eMouseWheelMoved: { TMouseWheelEventParams* params = (TMouseWheelEventParams*)event->getDataPtr(); if (params->delta > 0) { setScale(xScale << 1); parentScreen->paintControl(this); } else if (params->delta < 0) { setScale(xScale >> 1); parentScreen->paintControl(this); } event->cancel(); break; } default: if (caughtControl == NULL) break; caughtControl->dispatchEvent(event); break; }
EnvelopeEditorControl::EnvelopeEditorControl(pp_int32 id, PPScreen* parentScreen, EventListenerInterface* eventListener, const PPPoint& location, const PPSize& size, bool border/*= true*/) : PPControl(id, parentScreen, eventListener, location, size), borderColor(&ourOwnBorderColor), envelopeEditor(NULL), envelope(NULL), showMarks(NULL) { this->border = border; ourOwnBorderColor.set(192, 192, 192); // default color backgroundColor.set(0, 0, 0); hScrollbar = new PPScrollbar(0, parentScreen, this, PPPoint(location.x, location.y + size.height - SCROLLBARWIDTH - 1), size.width - 1, true); xMax = XMAX; yMax = YMAX; currentPosition.x = currentPosition.y = -1; xScale = 256; showVCenter = false; startPos = 0; visibleWidth = size.width - 5; visibleHeight = size.height - SCROLLBARWIDTH - 5; adjustScrollbars(); caughtControl = NULL; controlCaughtByLMouseButton = controlCaughtByRMouseButton = false; showMarks = new ShowMark[TrackerConfig::maximumPlayerChannels]; clearShowMarks(); // build submenu subMenuAdvanced = new PPContextMenu(5, parentScreen, this, PPPoint(0,0), TrackerConfig::colorThemeMain); subMenuAdvanced->setSubMenu(true); subMenuAdvanced->addEntry("Scale X", MenuCommandIDXScale); subMenuAdvanced->addEntry("Scale Y", MenuCommandIDYScale); // Context PPMenu editMenuControl = new PPContextMenu(4, parentScreen, this, PPPoint(0,0), TrackerConfig::colorThemeMain, true); editMenuControl->addEntry("Undo", MenuCommandIDUndo); editMenuControl->addEntry("Redo", MenuCommandIDRedo); editMenuControl->addEntry("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4", -1); editMenuControl->addEntry("Copy", MenuCommandIDCopy); editMenuControl->addEntry("Paste", MenuCommandIDPaste); editMenuControl->addEntry("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4", -1); editMenuControl->addEntry("Advanced \x10", 0xFFFF, subMenuAdvanced); // Create tool handler responder toolHandlerResponder = new ToolHandlerResponder(*this); dialog = NULL; resetLastValues(); }