void W_BUTTON::clicked(W_CONTEXT *, WIDGET_KEY key) { dirty = true; /* Can't click a button if it is disabled or locked down */ if ((state & (WBUT_DISABLE | WBUT_LOCK)) == 0) { // Check this is the correct key if ((!(style & WBUT_NOPRIMARY) && key == WKEY_PRIMARY) || ((style & WBUT_SECONDARY) && key == WKEY_SECONDARY)) { if (AudioCallback) { AudioCallback(ClickedAudioID); } state &= ~WBUT_FLASH; // Stop it flashing state |= WBUT_DOWN; } } /* Kill the tip if there is one */ if (!pTip.empty()) { tipStop(this); } }
/* Respond to a mouse click */ void W_EDITBOX::clicked(W_CONTEXT *psContext, WIDGET_KEY) { if (state & WEDBS_DISABLE) // disabled button. { return; } // Set cursor position to the click location. iV_SetFont(FontID); setCursorPosPixels(psContext->mx - x); // Cursor should be visible instantly. blinkOffset = wzGetTicks(); if ((state & WEDBS_MASK) == WEDBS_FIXED) { if (AudioCallback) { AudioCallback(ClickedAudioID); } /* Set up the widget state */ state = (state & ~WEDBS_MASK) | WEDBS_INSERT; /* Calculate how much of the string can appear in the box */ fitStringEnd(); /* Clear the input buffer */ inputClearBuffer(); /* Tell the form that the edit box has focus */ screenSetFocus(psContext->psScreen, this); } }
/* Insert a character into a text buffer */ bool W_EDITBOX::insertChar(QChar ch) { if (ch == QChar('\0')) { return false; } ASSERT(insPos <= aText.length(), "Invalid insertion point"); if (aText.length() >= maxStringSize) { if (AudioCallback) { AudioCallback(ErrorAudioID); } return false; // string too big, just return } /* Move the end of the string up by one (including terminating \0) */ /* Insert the character */ aText.insert(insPos, ch); /* Update the insertion point */ ++insPos; return true; }
/* Respond to a mouse moving over a button */ void W_BUTTON::highlight(W_CONTEXT *psContext) { if ((state & WBUT_HIGHLIGHT) == 0) { state |= WBUT_HIGHLIGHT; dirty = true; } if (AudioCallback) { AudioCallback(HilightAudioID); } /* If there is a tip string start the tool tip */ if (!pTip.empty()) { tipStart(this, pTip, screenPointer->TipFontID, x() + psContext->xOffset, y() + psContext->yOffset, width(), height()); } }
u32 AudioPluginOSX::AudioThread(void * arg) { AudioPluginOSX * plugin = static_cast<AudioPluginOSX *>(arg); AudioStreamBasicDescription format; format.mSampleRate = kOutputFrequency; format.mFormatID = kAudioFormatLinearPCM; format.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked; format.mBitsPerChannel = 8 * sizeof(s16); format.mChannelsPerFrame = kNumChannels; format.mBytesPerFrame = sizeof(s16) * kNumChannels; format.mFramesPerPacket = 1; format.mBytesPerPacket = format.mBytesPerFrame * format.mFramesPerPacket; format.mReserved = 0; AudioQueueRef queue; AudioQueueBufferRef buffers[kNumBuffers]; AudioQueueNewOutput(&format, &AudioCallback, plugin, CFRunLoopGetCurrent(), kCFRunLoopCommonModes, 0, &queue); for (u32 i = 0; i < kNumBuffers; ++i) { AudioQueueAllocateBuffer(queue, kAudioQueueBufferLength, &buffers[i]); buffers[i]->mAudioDataByteSize = kAudioQueueBufferLength; AudioCallback(plugin, queue, buffers[i]); } AudioQueueStart(queue, NULL); CFRunLoopRun(); AudioQueueStop(queue, false); AudioQueueDispose(queue, false); for (u32 i = 0; i < kNumBuffers; ++i) { AudioQueueFreeBuffer(queue, buffers[i]); buffers[i] = NULL; } return 0; }