Skip to content

Commit 2e98704

Browse files
committed
frame delta, hand cursor on button hover
1 parent 559267f commit 2e98704

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

grey/widgets.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,9 @@ namespace grey::widgets {
885885
clicked = ImGui::Button(text.c_str(), ImVec2(width, 0));
886886
}
887887

888+
if(is_hovered())
889+
mouse_cursor(mouse_cursor_type::hand);
890+
888891
if (emp != emphasis::none) {
889892
ImGui::PopStyleColor(3);
890893
}
@@ -1178,6 +1181,10 @@ namespace grey::widgets {
11781181
return ImGui::IsItemFocused();
11791182
}
11801183

1184+
float frame_delta() {
1185+
return ImGui::GetIO().DeltaTime;
1186+
}
1187+
11811188
void mouse_cursor(mouse_cursor_type mct) {
11821189
ImGui::SetMouseCursor((ImGuiMouseCursor_)mct);
11831190
}

grey/widgets.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,12 @@ namespace grey::widgets {
523523

524524
bool hyperlink(const std::string& text, const std::string& url_to_open = "");
525525

526+
/**
527+
* @brief Colour picker
528+
* @param label
529+
* @param colour
530+
* @return
531+
*/
526532
bool colour(const std::string& label, unsigned int& colour);
527533

528534
/**
@@ -589,6 +595,11 @@ namespace grey::widgets {
589595

590596
bool is_focused();
591597

598+
/**
599+
* @brief Time passed since last frame in seconds, most likely fractional.
600+
*/
601+
float frame_delta();
602+
592603
enum class mouse_cursor_type {
593604
none = -1,
594605
arrow = 0,

0 commit comments

Comments
 (0)