Skip to content

Instantly share code, notes, and snippets.

@raulgrell
Created February 1, 2018 15:00
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/097497bf298aaae08a68a8f42652c65a to your computer and use it in GitHub Desktop.
Save raulgrell/097497bf298aaae08a68a8f42652c65a to your computer and use it in GitHub Desktop.
´ pub fn Icon(self: &GUI, bounds: &const Rectangle, texture: &Texture) {
var clicked = false;
const state = if (isCursorColliding(self.input.cursor_position, bounds)) {
if (self.input.buttonDown[c.GLFW_MOUSE_BUTTON_LEFT]) {
ControlState.Pressed
} else if (self.input.prevButtonState[c.GLFW_MOUSE_BUTTON_LEFT]) {
clicked = true;
ControlState.Normal
} else {
ControlState.Focused
}
} else {
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