1 #include "ui_exhibit.h"
6 static void draw_titlebar();
7 static void draw_tabs();
8 static void layout_text(const char *text);
12 static float text_padding;
16 static std::vector<const char*> text_lines;
17 static AudioStream *voice;
24 text_padding = size.x * 0.01;
33 void exui_change_tab(int dir)
37 void exui_scroll(float delta)
41 bool exui_raycast(const Ray &ray)
46 void exui_update(float dt)
48 if(exsel_active.ex != ex) {
53 if(voice) voice->stop();
56 int num_data = ex->data.size();
57 for(int i=0; i<num_data; i++) {
58 if(ex->data[i].type == EXDATA_INFO) {
59 layout_text(ex->data[i].text.c_str());
60 voice = ex->data[i].voice;
65 voice->play(AUDIO_PLAYMODE_ONCE);
75 if(!exsel_active) return;
81 static void draw_titlebar()
85 static void draw_tabs()
89 static void layout_text(const char *text)
95 dtx_use_font(ui_font, ui_font_size);
97 float pos = text_padding;
98 text_lines.push_back(text);
99 const char *last_break = 0;
102 if(*text == '\n') { // paragraph break
103 text_lines.push_back(text);
104 text_lines.push_back(++text);
110 int code = dtx_utf8_char_code(text);
111 const char *next = dtx_utf8_next_char((char*)text);
112 pos += dtx_glyph_width(code);
114 if(pos >= size.x - text_padding) {
115 if(text == text_lines.back()) {
116 // not even a single character fits on a line... abort
117 warning_log("text layout failed. glyph %d doesn't fit in line (%g)\n", code, size.x - 2.0 * text_padding);
122 text_lines.push_back(last_break + 1);
125 // no good point to break, just break here
126 text_lines.push_back(text);