Make emigui fill entire web page
This commit is contained in:
parent
1affa10dee
commit
7459aa60a4
4 changed files with 9 additions and 6 deletions
Binary file not shown.
|
@ -16,12 +16,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
background: #000000;
|
background: #101010;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Allow canvas to fill entire web page: */
|
||||||
html,
|
html,
|
||||||
body {
|
body {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
margin: 0 !important;
|
||||||
|
padding: 0 !important;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
@ -80,12 +83,11 @@
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
var g_mouse_pos = null;
|
var g_mouse_pos = null;
|
||||||
var g_mouse_down = false;
|
var g_mouse_down = false;
|
||||||
var g_is_touch = false;
|
var g_is_touch = false; // we don't know yet
|
||||||
var g_scroll_delta_x = 0;
|
var g_scroll_delta_x = 0;
|
||||||
var g_scroll_delta_y = 0;
|
var g_scroll_delta_y = 0;
|
||||||
|
|
||||||
function pixels_per_point() {
|
function pixels_per_point() {
|
||||||
// return 1.0;
|
|
||||||
return window.devicePixelRatio || 1.0;
|
return window.devicePixelRatio || 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +220,7 @@
|
||||||
paint_and_schedule();
|
paint_and_schedule();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<!-- TODO: make this cover the entire screen, with resize and all -->
|
<!-- We later make this cover the entire screen even when resized -->
|
||||||
<canvas id="canvas" width="1024" height="1024"></canvas>
|
<canvas id="canvas" width="1024" height="1024"></canvas>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ pub struct GuiInput {
|
||||||
pub mouse_released: bool,
|
pub mouse_released: bool,
|
||||||
|
|
||||||
/// Current position of the mouse in points.
|
/// Current position of the mouse in points.
|
||||||
|
/// None for touch screens when finger is not down.
|
||||||
pub mouse_pos: Option<Pos2>,
|
pub mouse_pos: Option<Pos2>,
|
||||||
|
|
||||||
/// How much the mouse moved compared to last frame, in points.
|
/// How much the mouse moved compared to last frame, in points.
|
||||||
|
@ -71,7 +72,7 @@ impl GuiInput {
|
||||||
.and_then(|new| last.mouse_pos.map(|last| new - last))
|
.and_then(|new| last.mouse_pos.map(|last| new - last))
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
GuiInput {
|
GuiInput {
|
||||||
mouse_down: new.mouse_down,
|
mouse_down: new.mouse_down && new.mouse_pos.is_some(),
|
||||||
mouse_pressed: !last.mouse_down && new.mouse_down,
|
mouse_pressed: !last.mouse_down && new.mouse_down,
|
||||||
mouse_released: last.mouse_down && !new.mouse_down,
|
mouse_released: last.mouse_down && !new.mouse_down,
|
||||||
mouse_pos: new.mouse_pos,
|
mouse_pos: new.mouse_pos,
|
||||||
|
|
|
@ -91,7 +91,7 @@ impl State {
|
||||||
self.emigui.ui(region);
|
self.emigui.ui(region);
|
||||||
});
|
});
|
||||||
|
|
||||||
let bg_color = srgba(16, 16, 16, 255);
|
let bg_color = srgba(0, 0, 0, 0); // Use background css color.
|
||||||
let (output, batches) = self.emigui.end_frame();
|
let (output, batches) = self.emigui.end_frame();
|
||||||
self.webgl_painter.paint_batches(
|
self.webgl_painter.paint_batches(
|
||||||
bg_color,
|
bg_color,
|
||||||
|
|
Loading…
Reference in a new issue