src/window.c

changeset 155
b598b4eb4b44
parent 154
4dff9cc488fe
equal deleted inserted replaced
154:4dff9cc488fe 155:b598b4eb4b44
192 if (asc_context.windows[i].id == id) break; 192 if (asc_context.windows[i].id == id) break;
193 } 193 }
194 return i; 194 return i;
195 } 195 }
196 196
197 void asc_add_ui_node(AscSceneNode *node) {
198 asc_scene_add_node(&asc_active_window->ui, node);
199 }
200
201 AscScene *asc_window_scene(unsigned int index) { 197 AscScene *asc_window_scene(unsigned int index) {
202 return &asc_active_window->scenes[index]; 198 return &asc_active_window->scenes[index];
203 } 199 }
204 200
205 asc_vec2u asc_window_display_resolution(void) { 201 asc_vec2u asc_window_display_resolution(void) {
210 asc_error("Failed to get display mode for window %u on display %d: %s", 206 asc_error("Failed to get display mode for window %u on display %d: %s",
211 window->id, display, SDL_GetError()); 207 window->id, display, SDL_GetError());
212 } 208 }
213 return asc_vec2u_new(dm.w, dm.h); 209 return asc_vec2u_new(dm.w, dm.h);
214 } 210 }
215
216 void asc_ui_scale(float scale) {
217 asc_active_window->ui_scale = scale;
218 }
219
220 float asc_ui_get_scale(void) {
221 return asc_active_window->ui_scale;
222 }
223
224 void asc_ui_scale_auto(void) {
225 asc_vec2u res = asc_window_display_resolution();
226 // TODO: debug why this is wrong under GNOME or just throw GNOME away
227 if (res.width > 3000) {
228 asc_ui_scale(1.5f);
229 } else if (res.width > 2000) {
230 asc_ui_scale(1.2f);
231 } else {
232 return asc_ui_scale(1.f);
233 }
234 }

mercurial