Created
February 1, 2018 14:59
-
-
Save raulgrell/e955c215d435c6251b0a3260efbf965c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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