void CL_GUIWindowManagerProvider_System::destroy_window(CL_GUITopLevelWindow *handle)
{
	capture_mouse(handle, false);	// Ensure the destroyed window has not captured the mouse

	std::map<CL_GUITopLevelWindow *, CL_GUITopLevelWindowSystem *>::iterator it = window_map.find(handle);
	if (it == window_map.end())
		throw CL_Exception("destroy window called on non-existing window.");

	bool cached = false;
#ifdef WIN32	// Cached windows do not work on Linux
	for (std::vector<CL_GUITopLevelWindowSystem *>::size_type i = 0; i < cached_windows.size(); i++)
	{
		if ((*it).second == cached_windows[i])
		{
			cached = true;
			(*it).second->window.hide();
			used_cached_windows--;
			break;
		}
	}
#endif
	if (cached == false)
		delete window_map[handle];

	window_map.erase(it);
}
void GUIWindowManagerProvider_Direct::destroy_window(GUITopLevelWindow *handle)
{
	capture_mouse(handle, false);	// Ensure the destroyed window has not captured the mouse

	GUITopLevelWindowDirect *toplevel_window = get_direct_window(handle);

	if (toplevel_window->owner_window)
	{
		// Detach from owner
		toplevel_window->owner_window->child_windows_zorder.erase(std::find(toplevel_window->owner_window->child_windows_zorder.begin(), toplevel_window->owner_window->child_windows_zorder.end(), toplevel_window));
	}
	else
	{
		// Detach from root
		root_window_z_order.erase(std::find(root_window_z_order.begin(), root_window_z_order.end(), toplevel_window));
	}

	if (handle == activated_window)	// Ensure that the destroyed window is not in focus
	{
		activated_window = NULL;
	}

	delete toplevel_window;
	window_map.erase(window_map.find(handle));
}
void RadialMenu::on_mouse_lbutton_up(CL_InputEvent &input_event)
{
	if (!func_selected.is_null())
		func_selected.invoke(selected_index);

	set_visible(false);	
	capture_mouse(false);
}
Beispiel #4
0
void
WPiano::playStarted()
{
	if (playing()) {
		capture_mouse(false);
		update_timer_.start(update_freq, this);
	}
}
// ------------------------------------------------------------------------
// window to display an adventure map
// ------------------------------------------------------------------------
void t_adventure_map_window::left_button_down( t_mouse_event const& event )
{
	if (capture_mouse())
	{
		m_dragging = true;
		m_drag_start = event.screen_point;
	}
}
void
Slider::on_mouse_down(const CL_InputEvent& event)
{
  if (event.id == CL_MOUSE_LEFT)
  {
    pressed = true;
    capture_mouse();
    update_mouse(event);
  }
}
void UI_DOT_SLIDER::process(int focus)
{
	if (disabled_flag)
		return;

	// check focus and derived focus with one variable
	if (my_wnd->selected_gadget == this)
		focus = 1;

	// first check the dot area
	button.process(focus);
	if (button.button_down() || button.pressed() || mouse_captured()) {
		capture_mouse();  // while we are changing level, ignore all other buttons

		if ( has_end_buttons ) {
			pos = (ui_mouse.x - x + 17) / 19;
		} else {
			pos = (ui_mouse.x - x) / 19;
		}

		if (pos < 0){
			pos = 0;
		}

		if ( pos > num_pos ){
			pos = num_pos;
		}

		return;
	}

	if ( has_end_buttons ) {
		up_button.process(focus);
		if (up_button.pressed()) {
			if (pos < num_pos){
				pos++;
			} else {
				gamesnd_play_iface(SND_GENERAL_FAIL);
			}
		}

		down_button.process(focus);
		if (down_button.pressed()) {
			if (pos){
				pos--;
			} else {
				gamesnd_play_iface(SND_GENERAL_FAIL);
			}
		}
	}
}
Beispiel #8
0
void
WPiano::mousePressEvent(QMouseEvent *ev)
{
	switch (ev->button()) {
	case Qt::LeftButton:
		if (!mouse_captured_) {
			capture_mouse();
			mouseMoveEvent(ev);
		} else
			toggle_note();
		break;
	default:
		;
	}
}
Beispiel #9
0
void RedScreen::resize(int width, int height)
{
    RecurciveLock lock(_update_lock);
    _size.x = width;
    _size.y = height;
    create_composit_area();
    if (_full_screen) {
        bool cuptur = _owner.rearrange_monitors(*this);
        __show_full_screen();
        if (cuptur) {
            capture_mouse();
        }
    } else {
        bool cuptur = is_mouse_captured();
        if (cuptur) {
            relase_mouse();
        }
        _window.resize(_size.x, _size.y);
        if (_active && cuptur) {
            capture_mouse();
        }
    }
    notify_new_size();
}
Beispiel #10
0
// process() is called to process the button, which amounts to:
//   If mouse is over button, hilight it
//   If highlighted and mouse button down, flag button as down
//   If hotkey pressed, flag button as down
//   If hotkey_if_focus pressed, and button has focus, flag button as down
//   Set various BF_JUST_* flags if events changed from last frame
//
void UI_BUTTON::process(int focus)
{
	int mouse_on_me, old_flags;

	old_flags = m_flags;
	frame_reset();

	// check mouse over control and handle hilighting state
	mouse_on_me = is_mouse_on();

	// if gadget is disabled, force button up and return
	if (disabled_flag) {
		if (old_flags & BF_DOWN){
			m_flags |= BF_JUST_RELEASED;
		}

		if (!hidden && !my_wnd->use_hack_to_get_around_stupid_problem_flag) {
			if (mouse_on_me && B1_JUST_PRESSED){
				gamesnd_play_iface(SND_GENERAL_FAIL);
			}

			if ( (hotkey >= 0) && (my_wnd->keypress == hotkey) ){
				gamesnd_play_iface(SND_GENERAL_FAIL);
			}
		}

		// do callback if the button is disabled
		if (mouse_on_me && B1_JUST_PRESSED){
			if (m_disabled_function != NULL) {
				m_disabled_function();
			}
		}

		return;
	}

	// check focus and derived focus with one variable
	if (my_wnd->selected_gadget == this) {
		focus = 1;
	}

	// show alternate cursor, perhaps?
	maybe_show_custom_cursor();

	if ( !mouse_on_me ) {
		next_repeat = 0;
	} else {
		m_flags |= BF_HIGHLIGHTED;
		if ( !(old_flags & BF_HIGHLIGHTED) ) {
			int do_callback = 1;
			m_flags |= BF_JUST_HIGHLIGHTED;
			// if a callback exists, call it
			if (m_just_highlighted_function) {

				if ( m_flags & BF_SKIP_FIRST_HIGHLIGHT_CALLBACK ) {
					if ( first_callback ) {
						do_callback = 0;
					}
				}

				first_callback = 0;						
				if ( do_callback ) {
					m_just_highlighted_function();
				}
			}
		}
	}

	// check if mouse is pressed
	if ( B1_PRESSED && mouse_on_me )	{
		m_flags |= BF_DOWN;
		capture_mouse();
	}

	// check if hotkey is down or not
	if ( (hotkey >= 0) && (my_wnd->keypress == hotkey) ) {
		m_flags |= BF_DOWN | BF_CLICKED;
	}

	// only check for space/enter keystrokes if we are not ignoring the focus (this is the
	// default behavior)
	if ( !(m_flags & BF_IGNORE_FOCUS) ) {
		if ( focus && (hotkey_if_focus >= 0) ) {
			if (my_wnd->keypress == hotkey_if_focus)
				m_flags |= BF_DOWN | BF_CLICKED;

			if ( (hotkey_if_focus == KEY_SPACEBAR) && (my_wnd->keypress == KEY_ENTER) )
				m_flags |= BF_DOWN | BF_CLICKED;
		}
	}

	// handler for button not down
	if ( !(m_flags & BF_DOWN) ) {
		next_repeat = 0;
		if ( (old_flags & BF_DOWN) && !(old_flags & BF_CLICKED) )  // check for release of mouse, not hotkey
			m_flags |= BF_JUST_RELEASED;

		// non-repeating buttons behave sort of uniquely..  They activate when released over button
		if (!(m_flags & BF_REPEATS)) {
			if ( (m_flags & BF_JUST_RELEASED) && (m_flags & BF_HIGHLIGHTED) )
				m_flags |= BF_CLICKED;
		}

		return;
	}

	// check if button just went down this frame
	if ( !(old_flags & BF_DOWN) ) {
		m_flags |= BF_JUST_PRESSED;
		m_press_linger = timestamp(100);
		if (user_function)
			user_function();

		if (m_flags & BF_REPEATS) {
			next_repeat = timestamp(B_REPEAT_TIME * 3);
			m_flags |= BF_CLICKED;
		}
	}

	// check if a repeat event should occur
	if ( timestamp_elapsed(next_repeat) && (m_flags & BF_REPEATS) ) {
		next_repeat = timestamp(B_REPEAT_TIME);
		m_flags |= BF_CLICKED;
		m_press_linger = timestamp(100);
	}

	// check for double click occurance
	if (B1_DOUBLE_CLICKED && mouse_on_me) {
		m_flags |= BF_DOUBLE_CLICKED;
		m_press_linger = timestamp(100);
	}
}
void UI_DOT_SLIDER_NEW::process(int focus)
{
	if (disabled_flag) {
		if (!hidden && !my_wnd->use_hack_to_get_around_stupid_problem_flag) {
			if (button.is_mouse_on() && B1_JUST_PRESSED) {
				gamesnd_play_iface(SND_GENERAL_FAIL);
			} else if (has_end_buttons && (up_button.is_mouse_on() || down_button.is_mouse_on())) {
				gamesnd_play_iface(SND_GENERAL_FAIL);
			}
			

			if ( (hotkey >= 0) && (my_wnd->keypress == hotkey) ){
				gamesnd_play_iface(SND_GENERAL_FAIL);
			}
		}

		return;
	}

	// check focus and derived focus with one variable
	if (my_wnd->selected_gadget == this){
		focus = 1;
	}

	// first check the dot area
	button.process(focus);
	if (button.button_down() || button.pressed() || mouse_captured()) {
		capture_mouse();  // while we are changing level, ignore all other buttons
		
		pos = (ui_mouse.x - x) / dot_width;		

		if (pos < 0){
			pos = 0;
		}

		// if we have 10 positions, 0 - 9 are valid
		if ( pos >= num_pos ) {
			pos = num_pos - 1;
		}

		return;
	}

	if ( has_end_buttons ) {
		up_button.process(focus);
		if (up_button.pressed()) {
			if (pos < num_pos-1){
				pos++;
			} else {
				gamesnd_play_iface(SND_GENERAL_FAIL);
			}
		}

		down_button.process(focus);
		if (down_button.pressed()) {
			if(pos){
				pos--;
			} else {
				gamesnd_play_iface(SND_GENERAL_FAIL);
			}
		}
	}
}
Beispiel #12
0
void RadialMenu::show(CL_Point &position)
{
	set_geometry(CL_Rect(position.x - 120, position.y - 120, position.x + 120, position.y + 120));
	set_visible(true);
	capture_mouse(true);
}
Beispiel #13
0
void
WPiano::keyPressEvent(QKeyEvent *ev)
{
	int key = ev->key();
	int mod = ev->modifiers() & (Qt::CTRL | Qt::SHIFT);

#define SHIFT_SELECTS \
	do { \
		if (mod & Qt::SHIFT) { \
			capture_mouse(false); \
			set_pivot(); \
		} else \
			drop_pivot(); \
	} while(0)

	switch (key) {
	case Qt::Key_Escape:
		drop_pivot();
		capture_mouse(false);
		break;
	case Qt::Key_Home:
		SHIFT_SELECTS;
		setCursorTime(0);
		break;
	case Qt::Key_End:
		SHIFT_SELECTS;
		setCursorTime(grid_snap_right(this, vmd_track_length(track_)));
		break;
	case Qt::Key_Left:
		SHIFT_SELECTS;
		setCursorTime(grid_snap_left(this, cursor_time_ - 1));
		break;
	case Qt::Key_Right:
		SHIFT_SELECTS;
		setCursorTime(grid_snap_right(this, cursor_time_ + 1));
		break;
	case Qt::Key_Up:
		SHIFT_SELECTS;
		if (cursor_level_ < levels(track()))
			setCursorLevel(cursor_level_ + 1);
		break;
	case Qt::Key_Down:
		SHIFT_SELECTS;
		if (cursor_level_ > 0)
			setCursorLevel(cursor_level_ - 1);
		break;
	case Qt::Key_Space:
		drop_pivot();
		if (playing())
			player_->stop();
		else
			player_->play(file(), cursor_time_);
		break;
	case Qt::Key_QuoteLeft:
		{
			QString s = QInputDialog::getText(
				this,
				"vomid",
				mod & Qt::CTRL ? QString("Enter grid size:") : QString("Enter cursor size:")
			);
			QStringList sl = s.split("/");
			if (sl.size() != 2)
				break;
			int n = sl[0].toInt();
			int m = sl[1].toInt();
			if (n <= 0 && m <= 0)
				break;
			vmd_time_t size = file()->division * 4 * n / m;
			if (mod & Qt::CTRL)
				grid_size_ = size;
			else
				cursor_size_ = size;
		}
		break;
	case Qt::Key_1: case Qt::Key_2: case Qt::Key_3: case Qt::Key_4:
	case Qt::Key_5: case Qt::Key_6: case Qt::Key_7:
		{
			vmd_time_t size = file()->division * 4;
			for (int i = 0; i < key - Qt::Key_1; i++)
				size /= 2;
			if (mod & Qt::CTRL)
				grid_size_ = size;
			else
				cursor_size_ = size;
		}
		break;
	case Qt::Key_Enter:
	case Qt::Key_Return:
		drop_pivot();
		toggle_note();
		break;
	case Qt::Key_I:
		if (mod == Qt::CTRL) {
			vmd_note_t *note = noteAtCursor();
			if (note == NULL)
				break;
			QPoint pos(time2x(cursor_time_), level2y(cursor_level_));
			QString text = "Note: ";
			text += "channel = "; text += QString::number(note->channel->number);
			QToolTip::hideText();
			QToolTip::showText(mapToGlobal(pos), text);
		}
		break;
	case Qt::Key_C:
		if (mod == Qt::CTRL) {
			if (clipboard == NULL)
				clipboard = vmd_track_create(&clipboard_file, VMD_CHANMASK_ALL);

			Rect s = selectionRect();
			vmd_time_t base_time = s.time_beg;
			int base_pitch = level2pitch(track(), s.level_beg, true);

			clipboard_time_relative = s.time_end != VMD_MAX_TIME;
			clipboard_pitch_relative = s.level_end <= levels(track());
			vmd_track_clear(clipboard);
			for (vmd_note_t *i = selection(); i != NULL; i = i->next)
				vmd_copy_note(i, clipboard, -base_time, -base_pitch);
		}
		break;
	case Qt::Key_V:
		if (mod == Qt::CTRL) {
			vmd_time_t t = clipboard_time_relative ? cursorTime() : 0;
			vmd_pitch_t p = clipboard_pitch_relative ? cursorPitch() : 0;
			if (clipboard == NULL || p < 0)
				break;

			VMD_BST_FOREACH(vmd_bst_node_t *i, &clipboard->notes)
				vmd_copy_note(vmd_track_note(i), track(), t, p);
			file()->commit("Paste Notes");
			drop_pivot();
		}
		break;
	case Qt::Key_Delete:
		for (vmd_note_t *i = selection(); i != NULL; i = i->next)
			vmd_erase_note(i);
		file()->commit("Erase Notes");
		drop_pivot();
	case Qt::Key_T:
		if (mod == Qt::CTRL) {
			int dPitch = QInputDialog::getInt(
				this,
				"vomid",
				QString("Transpose (in semi-tones):")
			);
			if (dPitch == 0)
				break;
			for (vmd_note_t *i = selection(), *next; i != NULL; i = next) {
				next = i->next;
				vmd_copy_note(i, track(), 0, dPitch);
				vmd_erase_note(i);
			}
			file()->commit("Transpose");
		}
	default:
		return QWidget::keyPressEvent(ev);
	}
	look_at_cursor();
	update();
}
Beispiel #14
0
void
WPiano::focusOutEvent(QFocusEvent *)
{
	capture_mouse(false);
}