예제 #1
0
void Console::render_private(rendering::Printer& printer)
{
	printer.set_texture(nullptr);
	printer.set_color(rendering::Color4(0.02f, 0.02f, 0.025f));

	// thing between messageviewer and inputline
	printer.set_position(get_absolute_position() + get_client_offset() + float2(0.f, message_viewer_.dimensions().y));
	printer.draw_quad(float2(get_client_size().x, 4.f));

	printer.flush(false);
}
예제 #2
0
void Button::update(const Gui_input& input)
{
	const float2& pos = input.cursor.coord();

	float2 apos = get_absolute_position();

	m_hovered_over = pos.x >= apos.x && pos.x <= apos.x + size_.x
		      && pos.y >= apos.y && pos.y <= apos.y + size_.y;

	if (m_enabled && m_hovered_over && input.mouse.is_key_click(0))
	{
		m_on_click.raise(this);
	}
}
예제 #3
0
void Radio_button_set::render(rendering::Printer& printer)
{
	printer.set_color(rendering::Color4(0.175f, 0.175f, 0.175f, 1.f));
	printer.set_font("segoeui", 12);
	printer.set_position(get_absolute_position());
	printer.print(m_caption);
	printer.flush();
	

	for (size_t i = 0; i < m_buttons.size(); ++i)
	{
		m_buttons[i].render(printer);
	}
}
예제 #4
0
static void message_insert_char(int c)
{
        char *ptr;
        int n;

        if (!edit_mode)
                return;

        memused_songchanged();
        if (c == '\t') {
                /* Find the number of characters until the next tab stop.
                 * (This is new behaviour; Impulse Tracker just inserts
                 * eight characters regardless of the cursor position.) */
                n = 8 - cursor_char % 8;
                if (cursor_char + n > LINE_WRAP) {
                        message_insert_char('\r');
                } else {
                        do {
                                if (!message_add_char(' ', cursor_pos))
                                        break;
                                cursor_char++;
                                cursor_pos++;
                                n--;
                        } while (n);
                }
        } else if (c < 32 && c != '\r') {
                return;
        } else {
                if (!message_add_char(c, cursor_pos))
                        return;
                cursor_pos++;
                if (c == '\r') {
                        cursor_char = 0;
                        cursor_line++;
                } else {
                        cursor_char++;
                }
        }
        if (get_nth_line(current_song->message, cursor_line, &ptr) >= LINE_WRAP) {
                message_wrap_line(ptr);
        }
        if (cursor_char >= LINE_WRAP) {
                cursor_char = get_nth_line(current_song->message, ++cursor_line, &ptr);
                cursor_pos = get_absolute_position(current_song->message, cursor_line, cursor_char);
        }

        message_reposition();
        status.flags |= NEED_UPDATE | SONG_NEEDS_SAVE;
}
예제 #5
0
static void message_delete_line(void)
{
        int len;
        int movelen;
        char *ptr;

        len = get_nth_line(current_song->message, cursor_line, &ptr);
        if (len < 0)
                return;
        if (ptr[len] == 13 && ptr[len + 1] == 10)
                len++;
        movelen = (current_song->message + strlen(current_song->message) - ptr);
        if (movelen == 0)
                return;
        memmove(ptr, ptr + len + 1, movelen);
        len = get_nth_line(current_song->message, cursor_line, &ptr);
        if (cursor_char > len) {
                cursor_char = len;
                cursor_pos = get_absolute_position(current_song->message, cursor_line, cursor_char);
        }
        message_reposition();
        status.flags |= NEED_UPDATE | SONG_NEEDS_SAVE;
}
예제 #6
0
void Border_button::render(rendering::Printer& printer)
{
	printer.set_position(get_absolute_position());

	if (Type::Minimize == type_)
	{
		printer.set_texture_coordinates(float2(0.5f, 0.f), float2(1.f, 0.5f));
	}
	else if (Type::Close == type_)
	{
		printer.set_texture_coordinates(float2(0.f, 0.f), float2(0.5f, 0.5f));
	}

	if (m_enabled)
	{
		printer.set_color(m_hovered_over ? rendering::Color4(1.f, 0.f, 0.f) : rendering::Color4(0.f, 0.3f, 0.6f));
	}
	else
	{
		printer.set_color(rendering::Color4(0.01f, 0.01f, 0.015f));
	}
		
	printer.draw_quad(size_);
}
예제 #7
0
static int message_handle_key_editmode(struct key_event * k)
{
        int line_len, num_lines = -1;
        int new_cursor_line = cursor_line;
        int new_cursor_char = cursor_char;
        char *ptr;
        int doing_drag = 0;
        int clipl, clipr, cp;

        if (k->mouse == MOUSE_SCROLL_UP) {
                if (k->state == KEY_RELEASE)
                        return 0;
                new_cursor_line -= MOUSE_SCROLL_LINES;
        } else if (k->mouse == MOUSE_SCROLL_DOWN) {
                if (k->state == KEY_RELEASE)
                        return 0;
                new_cursor_line += MOUSE_SCROLL_LINES;
        } else if (k->mouse == MOUSE_CLICK && k->mouse_button == 2) {
                if (k->state == KEY_RELEASE)
                        status.flags |= CLIPPY_PASTE_SELECTION;
                return 1;
        } else if (k->mouse == MOUSE_CLICK) {
                if (k->x >= 2 && k->x <= 77 && k->y >= 13 && k->y <= 47) {
                        new_cursor_line = (k->y - 13) + top_line;
                        new_cursor_char = (k->x - 2);
                        if (k->sx != k->x || k->sy != k->y) {
                                /* yay drag operation */
                                cp = get_absolute_position(current_song->message, (k->sy-13)+top_line,
                                                        (k->sx-2));
                                widgets_message[0].clip_start = cp;
                                doing_drag = 1;
                        }
                }
        }

        line_len = get_nth_line(current_song->message, cursor_line, &ptr);


        switch (k->sym) {
        case SDLK_UP:
                if (!NO_MODIFIER(k->mod))
                        return 0;
                if (k->state == KEY_RELEASE)
                        return 1;
                new_cursor_line--;
                break;
        case SDLK_DOWN:
                if (!NO_MODIFIER(k->mod))
                        return 0;
                if (k->state == KEY_RELEASE)
                        return 1;
                new_cursor_line++;
                break;
        case SDLK_LEFT:
                if (!NO_MODIFIER(k->mod))
                        return 0;
                if (k->state == KEY_RELEASE)
                        return 1;
                new_cursor_char--;
                break;
        case SDLK_RIGHT:
                if (!NO_MODIFIER(k->mod))
                        return 0;
                if (k->state == KEY_RELEASE)
                        return 1;
                new_cursor_char++;
                break;
        case SDLK_PAGEUP:
                if (!NO_MODIFIER(k->mod))
                        return 0;
                if (k->state == KEY_RELEASE)
                        return 1;
                new_cursor_line -= 35;
                break;
        case SDLK_PAGEDOWN:
                if (!NO_MODIFIER(k->mod))
                        return 0;
                if (k->state == KEY_RELEASE)
                        return 1;
                new_cursor_line += 35;
                break;
        case SDLK_HOME:
                if (k->state == KEY_RELEASE)
                        return 1;
                if (k->mod & KMOD_CTRL)
                        new_cursor_line = 0;
                else
                        new_cursor_char = 0;
                break;
        case SDLK_END:
                if (k->state == KEY_RELEASE)
                        return 1;
                if (k->mod & KMOD_CTRL) {
                        num_lines = get_num_lines(current_song->message);
                        new_cursor_line = num_lines;
                } else {
                        new_cursor_char = line_len;
                }
                break;
        case SDLK_ESCAPE:
                if (!NO_MODIFIER(k->mod))
                        return 0;
                if (k->state == KEY_RELEASE)
                        return 1;
                message_set_viewmode();
                memused_songchanged();
                return 1;
        case SDLK_BACKSPACE:
                if (!NO_MODIFIER(k->mod))
                        return 0;
                if (k->state == KEY_RELEASE)
                        return 1;
                if (k->sym && clippy_owner(CLIPPY_SELECT) == widgets_message) {
                        _delete_selection();
                } else {
                        message_delete_char();
                }
                return 1;
        case SDLK_DELETE:
                if (!NO_MODIFIER(k->mod))
                        return 0;
                if (k->state == KEY_RELEASE)
                        return 1;
                if (k->sym && clippy_owner(CLIPPY_SELECT) == widgets_message) {
                        _delete_selection();
                } else {
                        message_delete_next_char();
                }
                return 1;
        default:
                if (k->mod & KMOD_CTRL) {
                        if (k->state == KEY_RELEASE)
                                return 1;
                        if (k->sym == SDLK_t) {
                                message_extfont = !message_extfont;
                                break;
                        } else if (k->sym == SDLK_y) {
                                clippy_select(NULL, NULL, 0);
                                message_delete_line();
                                break;
                        }
                } else if (k->mod & KMOD_ALT) {
                        if (k->state == KEY_RELEASE)
                                return 1;
                        if (k->sym == SDLK_c) {
                                prompt_message_clear();
                                return 1;
                        }
                } else if (k->mouse == MOUSE_NONE) {
                        if (k->unicode == '\r' || k->unicode == '\t'
                        || k->unicode >= 32) {
                                if (k->state == KEY_RELEASE)
                                        return 1;
                                if (k->sym && clippy_owner(CLIPPY_SELECT) == widgets_message) {
                                        _delete_selection();
                                }
                                if (k->mod & (KMOD_SHIFT|KMOD_CAPS)) {
                                        message_insert_char(toupper((unsigned int)k->unicode));
                                } else {
                                        message_insert_char(k->unicode);
                                }
                                return 1;
                        }
                        return 0;
                }

                if (k->mouse != MOUSE_CLICK)
                        return 0;

                if (k->state == KEY_RELEASE)
                        return 1;
                if (!doing_drag) {
                        clippy_select(NULL, NULL, 0);
                }
        }

        if (new_cursor_line != cursor_line) {
                if (num_lines == -1)
                        num_lines = get_num_lines(current_song->message);

                if (new_cursor_line < 0)
                        new_cursor_line = 0;
                else if (new_cursor_line > num_lines)
                        new_cursor_line = num_lines;

                /* make sure the cursor doesn't go past the new eol */
                line_len = get_nth_line(current_song->message, new_cursor_line, &ptr);
                if (new_cursor_char > line_len)
                        new_cursor_char = line_len;

                cursor_char = new_cursor_char;
                cursor_line = new_cursor_line;
        } else if (new_cursor_char != cursor_char) {
        /* we say "else" here ESPECIALLY because the mouse can only come
        in the top section - not because it's some clever optimization */
                if (new_cursor_char < 0) {
                        if (cursor_line == 0) {
                                new_cursor_char = cursor_char;
                        } else {
                                cursor_line--;
                                new_cursor_char =
                                        get_nth_line(current_song->message, cursor_line, &ptr);
                        }

                } else if (new_cursor_char >
                           get_nth_line(current_song->message, cursor_line, &ptr)) {
                        if (cursor_line == get_num_lines(current_song->message)) {
                                new_cursor_char = cursor_char;
                        } else {
                                cursor_line++;
                                new_cursor_char = 0;
                        }
                }
                cursor_char = new_cursor_char;
        }

        message_reposition();
        cursor_pos = get_absolute_position(current_song->message, cursor_line, cursor_char);

        if (doing_drag) {
                widgets_message[0].clip_end = cursor_pos;

                clipl = widgets_message[0].clip_start;
                clipr = widgets_message[0].clip_end;
                if (clipl > clipr) {
                        cp = clipl;
                        clipl = clipr;
                        clipr = cp;
                }
                clippy_select(widgets_message, (current_song->message+clipl), clipr-clipl);
        }

        status.flags |= NEED_UPDATE;

        return 1;
}