Skip to content

Instantly share code, notes, and snippets.

@raulgrell
Created February 1, 2018 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raulgrell/e955c215d435c6251b0a3260efbf965c to your computer and use it in GitHub Desktop.
Save raulgrell/e955c215d435c6251b0a3260efbf965c to your computer and use it in GitHub Desktop.
pub fn Icon(self: &GUI, bounds: &const Rectangle, texture: &Texture) {
var clicked = false;
const state = blk: { if (isCursorColliding(self.input.cursor_position, bounds)) {
if (self.input.buttonDown[c.GLFW_MOUSE_BUTTON_LEFT]) {
break :blk ControlState.Pressed;
} else if (self.input.prevButtonState[c.GLFW_MOUSE_BUTTON_LEFT]) {
clicked = true;
break :blk ControlState.Normal;
} else {
break :blk ControlState.Focused;
}
} else {
break :blk ControlState.Normal;
}};
const style = getStyle(state);
self.draw_outer(bounds, getColor(style.lines));
self.draw_inner(bounds, getColor(style.base ), Theme.BORDER_WIDTH);
self.draw_texture(texture, bounds, Theme.PADDING);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment