示例#1
0
static void gui_button_cb_play (I, GuiButtonEvent event) {
	(void) event;
	iam (Manual);
	GuiObject_setSensitive (my recordButton, false);
	GuiObject_setSensitive (my playButton, false);
	GuiObject_setSensitive (my publishButton, false);
	#if motif
		XmUpdateDisplay (my d_windowShell);
	#endif
	Melder_play ();
	GuiObject_setSensitive (my recordButton, true);
	GuiObject_setSensitive (my playButton, true);
	GuiObject_setSensitive (my publishButton, true);
}
示例#2
0
static void gui_button_cb_record (I, GuiButtonEvent event) {
	(void) event;
	iam (Manual);
	ManPages manPages = (ManPages) my data;
	ManPage manPage = (ManPage) (my path < 1 ? NULL : manPages -> pages -> item [my path]);
	GuiObject_setSensitive (my recordButton, false);
	GuiObject_setSensitive (my playButton, false);
	GuiObject_setSensitive (my publishButton, false);
	#if motif
		XmUpdateDisplay (my d_windowShell);
	#endif
	if (! Melder_record (manPage == NULL ? 1.0 : manPage -> recordingTime)) Melder_flushError (NULL);
	GuiObject_setSensitive (my recordButton, true);
	GuiObject_setSensitive (my playButton, true);
	GuiObject_setSensitive (my publishButton, true);
}
示例#3
0
void SoundEditor::draw () {
	long first, last, selectedSamples;
	Graphics_Viewport viewport;
	int showAnalysis = _spectrogram.show || _pitch.show || _intensity.show || _formant.show;
	Melder_assert (_data != NULL);
	Melder_assert (_sound.data != NULL || _longSound.data != NULL);

	/*
	 * We check beforehand whether the window fits the LongSound buffer.
	 */
	if (_longSound.data && _endWindow - _startWindow > _longSound.data -> bufferLength) {
		Graphics_setColour (_graphics, Graphics_WHITE);
		Graphics_setWindow (_graphics, 0, 1, 0, 1);
		Graphics_fillRectangle (_graphics, 0, 1, 0, 1);
		Graphics_setColour (_graphics, Graphics_BLACK);
		Graphics_setTextAlignment (_graphics, Graphics_CENTRE, Graphics_BOTTOM);
		Graphics_text3 (_graphics, 0.5, 0.5, L"(window longer than ", Melder_float (Melder_single (_longSound.data -> bufferLength)), L" seconds)");
		Graphics_setTextAlignment (_graphics, Graphics_CENTRE, Graphics_TOP);
		Graphics_text1 (_graphics, 0.5, 0.5, L"(zoom in to see the samples)");
		return;
	}

	/* Draw sound. */

	if (showAnalysis)
		viewport = Graphics_insetViewport (_graphics, 0, 1, 0.5, 1);
	Graphics_setColour (_graphics, Graphics_WHITE);
	Graphics_setWindow (_graphics, 0, 1, 0, 1);
	Graphics_fillRectangle (_graphics, 0, 1, 0, 1);
	draw_sound (_sound.minimum, _sound.maximum);
	Graphics_flushWs (_graphics);
	if (showAnalysis)
		Graphics_resetViewport (_graphics, viewport);

	/* Draw analyses. */

	if (showAnalysis) {
		/* Draw spectrogram, pitch, formants. */
		viewport = Graphics_insetViewport (_graphics, 0, 1, 0, 0.5);
		draw_analysis ();
		Graphics_flushWs (_graphics);
		Graphics_resetViewport (_graphics, viewport);
	}

	/* Draw pulses. */

	if (_pulses.show) {
		if (showAnalysis)
			viewport = Graphics_insetViewport (_graphics, 0, 1, 0.5, 1);
		draw_analysis_pulses ();
		draw_sound (_sound.minimum, _sound.maximum);   /* Second time, partially across the pulses. */
		Graphics_flushWs (_graphics);
		if (showAnalysis)
			Graphics_resetViewport (_graphics, viewport);
	}

	/* Update buttons. */

	selectedSamples = Sampled_getWindowSamples (_data, _startSelection, _endSelection, & first, & last);
	updateMenuItems_file ();
	if (_sound.data) {
		GuiObject_setSensitive (_cutButton, selectedSamples != 0 && selectedSamples < _sound.data -> nx);
		GuiObject_setSensitive (_copyButton, selectedSamples != 0);
		GuiObject_setSensitive (_zeroButton, selectedSamples != 0);
		GuiObject_setSensitive (_reverseButton, selectedSamples != 0);
	}
}
示例#4
0
GuiObject GuiMenu_addItem (GuiObject menu, const wchar_t *title, long flags,
	void (*commandCallback) (GuiObject, XtPointer, XtPointer), const void *closure)
{
	Boolean toggle = flags & (GuiMenu_CHECKBUTTON | GuiMenu_RADIO_FIRST | GuiMenu_RADIO_NEXT | GuiMenu_TOGGLE_ON) ? True : False;
	GuiObject button;
	int accelerator = flags & 127;
	Melder_assert (title != NULL);
	if (toggle) {
		if (flags & (GuiMenu_RADIO_FIRST)) group = NULL;
		if (flags & (GuiMenu_RADIO_FIRST | GuiMenu_RADIO_NEXT)) {
			button = gtk_radio_menu_item_new_with_label (group, Melder_peekWcsToUtf8 (title));
			group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (button));
			//Melder_casual ("Created a radio menu item with title %ls, group %ld", title, group);
		} else {
			button = gtk_check_menu_item_new_with_label (Melder_peekWcsToUtf8 (title));
		}
	} else {
		button = gtk_menu_item_new_with_label (Melder_peekWcsToUtf8 (title));
	}
	gtk_menu_shell_append (GTK_MENU_SHELL (menu), button);
	Melder_assert (button != NULL);
	if (flags & GuiMenu_INSENSITIVE)
		GuiObject_setSensitive (button, false);
	if (flags & GuiMenu_TOGGLE_ON)
		gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (button), TRUE);
	if (accelerator) {
		/*
		 * For printable characters, the Command key is assumed.
		 */
		if (accelerator >= 32)
			flags |= GuiMenu_COMMAND;
		
		static const guint acceleratorKeys [] = { 0,
			GDK_Left, GDK_Right, GDK_Up, GDK_Down, GDK_Pause, GDK_Delete, GDK_Insert, GDK_BackSpace,
			GDK_Tab, GDK_Return, GDK_Home, GDK_End, GDK_Return, GDK_Page_Up, GDK_Page_Down, GDK_Escape,
			GDK_F1, GDK_F2, GDK_F3, GDK_F4, GDK_F5, GDK_F6, GDK_F7, GDK_F8, GDK_F9, GDK_F10, GDK_F11, GDK_F12,
			0, 0, 0 };

		int modifiers = 0;
		if (flags & GuiMenu_COMMAND) modifiers |= GDK_CONTROL_MASK;
		if (flags & GuiMenu_SHIFT)   modifiers |= GDK_SHIFT_MASK;
		if (flags & GuiMenu_OPTION)  modifiers |= GDK_MOD1_MASK;

		guint key;
		if (accelerator < 32) {
			key = acceleratorKeys [accelerator];
		} else {
			// gdk key symbols in the ASCII range are equal to ASCII
			key = accelerator;
		}

		GtkAccelGroup *ag = gtk_menu_get_accel_group (GTK_MENU (menu));

		if (key != 0)
			gtk_widget_add_accelerator (button, toggle ? "toggled" : "activate",
				ag, key, (GdkModifierType)modifiers, GTK_ACCEL_VISIBLE);
	}
	#if mac
		if (flags & GuiMenu_ATTRACTIVE) {
			//Melder_casual ("attractive!");
			SetItemStyle (button -> nat.entry.handle, button -> nat.entry.item, bold);
		}
	#endif
	if (commandCallback != NULL) {
		gulong handlerId = g_signal_connect (G_OBJECT (button),
			toggle ? "toggled" : "activate",
			G_CALLBACK (commandCallback), (gpointer) closure);
		g_object_set_data (G_OBJECT (button), "handlerId", (gpointer) handlerId);
		g_object_set_data (G_OBJECT (button), "commandCallback", (gpointer) commandCallback);
		g_object_set_data (G_OBJECT (button), "commandClosure", (gpointer) closure);
	} else {
		gtk_widget_set_sensitive (button, FALSE);
	}
	gtk_widget_show (button);

	return button;
}