-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
209 additions
and
7 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#ifndef DIGITIZER_TOOLBAR_H | ||
#define DIGITIZER_TOOLBAR_H | ||
|
||
#ifndef IMGUI_DEFINE_MATH_OPERATORS | ||
#define IMGUI_DEFINE_MATH_OPERATORS true | ||
#endif | ||
|
||
#include <imgui.h> | ||
|
||
#include "dashboard.h" | ||
#include "flowgraph.h" | ||
|
||
#include "app.h" | ||
#include "toolbar_block.h" | ||
|
||
namespace DigitizerUi { | ||
namespace detail { | ||
inline bool beginToolbar(const char *id) { | ||
const ImVec2 size = ImGui::GetContentRegionAvail(); | ||
const auto width = size.x; | ||
constexpr auto height = 36; | ||
auto ret = ImGui::BeginChild(id, ImVec2(width, height)); | ||
auto currentX = ImGui::GetCursorPosX(); | ||
ImGui::SetCursorPosX(currentX + 16); | ||
|
||
return ret; | ||
} | ||
|
||
inline void endToolbar() { | ||
const float width = ImGui::GetWindowWidth(); | ||
const float y = (ImGui::GetWindowPos().y + ImGui::GetWindowHeight()) - 1; | ||
const float x = ImGui::GetWindowPos().x; | ||
const uint32_t lineColor = DigitizerUi::App::instance().style() == DigitizerUi::Style::Light ? 0x40000000 : 0x40ffffff; | ||
ImGui::GetWindowDrawList()->AddLine(ImVec2(x, y), ImVec2(width, y), lineColor); | ||
|
||
ImGui::EndChild(); | ||
} | ||
|
||
} // namespace detail | ||
|
||
inline void drawToolbar() { | ||
detail::beginToolbar("##Toolbar"); | ||
|
||
const auto &blocks = App::instance().dashboard->localFlowGraph.blocks(); | ||
for (const auto &b : blocks) { | ||
if (b->isToolbarBlock()) { | ||
b->draw(); | ||
ImGui::SameLine(); | ||
} | ||
} | ||
|
||
detail::endToolbar(); | ||
} | ||
|
||
} // namespace DigitizerUi | ||
|
||
#endif |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
#ifndef OPENDIGITIZER_TOOLBAR_BLOCK_H | ||
#define OPENDIGITIZER_TOOLBAR_BLOCK_H | ||
|
||
#ifndef IMGUI_DEFINE_MATH_OPERATORS | ||
#define IMGUI_DEFINE_MATH_OPERATORS true | ||
#endif | ||
|
||
#include "app.h" | ||
#include "imgui.h" | ||
|
||
#include <gnuradio-4.0/Block.hpp> | ||
|
||
namespace DigitizerUi { | ||
|
||
inline bool toolbarButton(const char *label, bool disabled) { | ||
ImGui::BeginDisabled(disabled); | ||
ImGui::PushFont(DigitizerUi::App::instance().fontIconsSolid); | ||
const bool clicked = ImGui::Button(label, ImVec2(28, 28)); | ||
ImGui::PopFont(); | ||
ImGui::SameLine(); | ||
ImGui::EndDisabled(); | ||
return clicked; | ||
} | ||
|
||
template<typename T> | ||
struct GRPlayStopToolbarBlock : public gr::Block<GRPlayStopToolbarBlock<T>, gr::BlockingIO<false>, gr::Drawable<gr::UICategory::Toolbar, "Dear ImGui">> { | ||
using super_t = gr::Block<GRPlayStopToolbarBlock<T>, gr::BlockingIO<false>, gr::Drawable<gr::UICategory::Toolbar, "Dear ImGui">>; | ||
|
||
enum State { | ||
Initial, | ||
PlayStop, | ||
Play, | ||
Stream, | ||
Pause | ||
}; | ||
|
||
State m_state = Initial; | ||
|
||
GRPlayStopToolbarBlock() {} | ||
|
||
void playStop() { | ||
// TODO: needs proper impl | ||
m_state = PlayStop; | ||
} | ||
|
||
void play() { | ||
// TODO: needs proper impl | ||
m_state = Play; | ||
} | ||
|
||
void stream() { | ||
// TODO: needs proper impl | ||
m_state = Stream; | ||
} | ||
|
||
void stop() { | ||
// TODO: needs proper impl | ||
m_state = Initial; | ||
} | ||
|
||
void pause() { | ||
// TODO: needs proper impl | ||
m_state == Pause; | ||
} | ||
|
||
gr::work::Status | ||
draw() noexcept { | ||
if (DigitizerUi::toolbarButton("\uf051", m_state != Initial)) { // play-stop | ||
playStop(); | ||
} | ||
|
||
if (DigitizerUi::toolbarButton("\uf04b", isPlayDisabled())) { // play | ||
play(); | ||
} | ||
|
||
if (DigitizerUi::toolbarButton("\uf04e", isStreamDisabled())) { // forward | ||
stream(); | ||
} | ||
|
||
if (DigitizerUi::toolbarButton("\uf04c", isPauseDisabled())) { // pause | ||
pause(); | ||
} | ||
|
||
if (DigitizerUi::toolbarButton("\uf04d", isStopDisabled())) { // stop | ||
stop(); | ||
} | ||
|
||
return gr::work::Status::DONE; | ||
} | ||
|
||
bool isStreamDisabled() const { return m_state != Initial && m_state != Pause; } | ||
bool isPlayDisabled() const { return m_state != Initial && m_state != Pause; } | ||
bool isStopDisabled() const { return m_state == Initial || m_state == PlayStop; } | ||
bool isPauseDisabled() const { return m_state == Initial || m_state == PlayStop; } | ||
}; | ||
|
||
template<typename T> | ||
struct GRLabelToolbarBlock : public gr::Block<GRLabelToolbarBlock<T>, gr::BlockingIO<false>, gr::Drawable<gr::UICategory::Toolbar, "Dear ImGui">> { | ||
GRLabelToolbarBlock() {} | ||
|
||
void | ||
processMessages(auto &, std::span<const gr::Message>) { | ||
// | ||
} | ||
|
||
gr::work::Status | ||
draw() noexcept { | ||
ImGui::Text("Text block"); | ||
return gr::work::Status::DONE; | ||
} | ||
}; | ||
|
||
} // namespace DigitizerUi | ||
|
||
ENABLE_REFLECTION_FOR_TEMPLATE(DigitizerUi::GRPlayStopToolbarBlock, msgOut) | ||
ENABLE_REFLECTION_FOR_TEMPLATE(DigitizerUi::GRLabelToolbarBlock, msgIn) | ||
|
||
#endif |