waver: add indicators for new messages and capture data

This commit is contained in:
Georgi Gerganov
2021-01-06 19:38:44 +02:00
parent 4aaf7c594f
commit 635106f425
2 changed files with 29 additions and 7 deletions

View File

@@ -664,6 +664,8 @@ void renderMain() {
static bool lastMouseButtonLeft = 0;
static bool isTextInput = false;
static bool scrollMessagesToBottom = true;
static bool hasAudioCaptureData = false;
static bool hasNewMessages = false;
static double tStartInput = 0.0f;
static double tEndInput = -100.0f;
@@ -679,9 +681,11 @@ void renderMain() {
if (stateCurrent.flags.newMessage) {
scrollMessagesToBottom = true;
messageHistory.push_back(std::move(stateCurrent.message));
hasNewMessages = true;
}
if (stateCurrent.flags.newSpectrum) {
spectrumCurrent = std::move(stateCurrent.spectrum);
hasAudioCaptureData = !spectrumCurrent.empty();
}
if (stateCurrent.flags.newTxAmplitudeData) {
txAmplitudeDataCurrent = std::move(stateCurrent.txAmplitudeData);
@@ -750,8 +754,17 @@ void renderMain() {
}
ImGui::SameLine();
if (ImGui::ButtonSelectable(ICON_FA_COMMENT_ALT " Messages", { 0.35f*ImGui::GetContentRegionAvailWidth(), menuButtonHeight }, windowId == WindowId::Messages)) {
windowId = WindowId::Messages;
{
auto posSave = ImGui::GetCursorScreenPos();
if (ImGui::ButtonSelectable(ICON_FA_COMMENT_ALT " Messages", { 0.35f*ImGui::GetContentRegionAvailWidth(), menuButtonHeight }, windowId == WindowId::Messages)) {
windowId = WindowId::Messages;
}
auto radius = 0.3f*ImGui::GetTextLineHeight();
posSave.x += 2.0f*radius;
posSave.y += 2.0f*radius;
if (hasNewMessages) {
ImGui::GetWindowDrawList()->AddCircleFilled(posSave, radius, ImGui::ColorConvertFloat4ToU32({ 1.0f, 0.0f, 0.0f, 1.0f }), 16);
}
}
ImGui::SameLine();
@@ -760,8 +773,15 @@ void renderMain() {
}
ImGui::SameLine();
if (ImGui::ButtonSelectable(ICON_FA_SIGNAL " Spectrum", { 1.0f*ImGui::GetContentRegionAvailWidth(), menuButtonHeight }, windowId == WindowId::Spectrum)) {
windowId = WindowId::Spectrum;
{
auto posSave = ImGui::GetCursorScreenPos();
if (ImGui::ButtonSelectable(ICON_FA_SIGNAL " Spectrum", { 1.0f*ImGui::GetContentRegionAvailWidth(), menuButtonHeight }, windowId == WindowId::Spectrum)) {
windowId = WindowId::Spectrum;
}
auto radius = 0.3f*ImGui::GetTextLineHeight();
posSave.x += 2.0f*radius;
posSave.y += 2.0f*radius;
ImGui::GetWindowDrawList()->AddCircleFilled(posSave, radius, hasAudioCaptureData ? ImGui::ColorConvertFloat4ToU32({ 0.0f, 1.0f, 0.0f, 1.0f }) : ImGui::ColorConvertFloat4ToU32({ 1.0f, 0.0f, 0.0f, 1.0f }), 16);
}
if (windowId == WindowId::Settings) {
@@ -865,6 +885,8 @@ void renderMain() {
const float messagesHistoryHeigthMax = ImGui::GetContentRegionAvail().y - messagesInputHeight - 2.0f*style.ItemSpacing.x;
float messagesHistoryHeigth = messagesHistoryHeigthMax;
hasNewMessages = false;
// no automatic screen resize support for iOS
#if defined(IOS) || defined(ANDROID)
if (displaySize.x < displaySize.y) {
@@ -1444,7 +1466,7 @@ void renderMain() {
ImGui::Text("FPS: %4.2f\n", ImGui::GetIO().Framerate);
ImGui::SetCursorScreenPos(posSave);
}
if (spectrumCurrent.empty() == false) {
if (hasAudioCaptureData) {
auto wSize = ImGui::GetContentRegionAvail();
ImGui::PushStyleColor(ImGuiCol_FrameBg, { 0.3f, 0.3f, 0.3f, 0.3f });
if (statsCurrent.isReceiving) {

View File

@@ -116,8 +116,8 @@ bool ImGui_EndFrame(SDL_Window * window) {
bool ImGui_SetStyle() {
ImGuiStyle & style = ImGui::GetStyle();
style.AntiAliasedFill = false;
style.AntiAliasedLines = false;
style.AntiAliasedFill = true;
style.AntiAliasedLines = true;
style.WindowRounding = 0.0f;
style.WindowPadding = ImVec2(8, 8);