Skip to content

Commit

Permalink
STB library rework and update.
Browse files Browse the repository at this point in the history
Moved imgui STB dependencies to STB library.
Cleaned up leftover SystemUI namespaces.
  • Loading branch information
rokups committed Jun 15, 2017
1 parent ee41ed6 commit 67b94a8
Show file tree
Hide file tree
Showing 22 changed files with 13,398 additions and 12,764 deletions.
2 changes: 0 additions & 2 deletions Source/Atomic/Resource/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@

// ATOMIC END

#define STB_IMAGE_IMPLEMENTATION
#include <STB/stb_image.h>
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include <STB/stb_image_write.h>

#include "../DebugNew.h"
Expand Down
4 changes: 2 additions & 2 deletions Source/Atomic/UI/SystemUI/SystemUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#define STB_TEXTEDIT_IMPLEMENTATION 1
#include "../../Input/InputEvents.h"
#include "../../Input/Input.h"
#include "../../Core/CoreEvents.h"
Expand All @@ -32,7 +33,6 @@
#include "../../UI/SystemUI/Console.h"
#include "../../UI/SystemUI/DebugHud.h"
#include <SDL.h>
#include <imgui_internal.h>


using namespace std::placeholders;
Expand Down Expand Up @@ -171,7 +171,7 @@ void SystemUI::OnRawEvent(VariantMap& args)
case SDL_KEYUP:
case SDL_KEYDOWN:
case SDL_TEXTINPUT:
args[SDLRawInput::P_CONSUMED] = ImGui::GetCurrentContext()->FocusedWindow != 0;
args[SDLRawInput::P_CONSUMED] = ImGui::IsAnyWindowFocused();
break;
case SDL_MOUSEWHEEL:
case SDL_MOUSEBUTTONUP:
Expand Down
18 changes: 10 additions & 8 deletions Source/Atomic/UI/SystemUI/SystemUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,21 @@

#include <imgui.h>


namespace Atomic
{

class SystemUI : public Atomic::Object
class SystemUI
: public Atomic::Object
{
ATOMIC_OBJECT(SystemUI, Atomic::Object);
ATOMIC_OBJECT(SystemUI, Atomic::Object);
public:
SystemUI(Atomic::Context* context);
~SystemUI();

//! Get ui scale.
//! \return scale of ui.
float GetScale() const
{ return uiScale_; };
float GetScale() const { return uiScale_; };
//! Set ui scale.
//! \param scale of ui.
void SetScale(float scale);
Expand All @@ -58,8 +59,8 @@ class SystemUI : public Atomic::Object
\param merge set to true if new font should be merged to last active font.
\return ImFont instance that may be used for setting current font when drawing GUI.
*/
ImFont*
AddFont(const Atomic::String& font_path, float size = 0, const unsigned short* ranges = 0, bool merge = false);
ImFont* AddFont(const Atomic::String& font_path, float size = 0, const unsigned short* ranges = 0,
bool merge = false);
//! Add font to imgui subsystem.
/*!
\param font_path a string pointing to TTF font resource.
Expand All @@ -68,8 +69,9 @@ class SystemUI : public Atomic::Object
\param merge set to true if new font should be merged to last active font.
\return ImFont instance that may be used for setting current font when drawing GUI.
*/
ImFont* AddFont(const Atomic::String& font_path, float size = 0,
const std::initializer_list<unsigned short>& ranges = {}, bool merge = false);
ImFont* AddFont(
const Atomic::String& font_path, float size = 0,
const std::initializer_list<unsigned short>& ranges = {}, bool merge = false);

void CreateConsoleAndDebugHud();

Expand Down
2 changes: 1 addition & 1 deletion Source/AtomicApp/Player/IPCPlayerApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ namespace Atomic
brokerActive_ = true;

// If the parent application has a profile mode up, sync
SystemUI::DebugHud* debugHud = GetSubsystem<SystemUI::DebugHud>();
DebugHud* debugHud = GetSubsystem<DebugHud>();
if (debugHud)
{
unsigned mode = eventData["debugHudMode"].GetUInt();
Expand Down
6 changes: 3 additions & 3 deletions Source/AtomicEditor/EditorMode/AEEditorMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ EditorMode::~EditorMode()
void EditorMode::HandleIPCWorkerStarted(StringHash eventType, VariantMap& eventData)
{
VariantMap startupData;
SystemUI::DebugHud* debugHud = GetSubsystem<SystemUI::DebugHud>();
DebugHud* debugHud = GetSubsystem<DebugHud>();

startupData["debugHudMode"] = debugHud ? debugHud->GetMode() : (unsigned) 0;
startupData["debugHudProfilerMode"] = (unsigned) (debugHud ? debugHud->GetProfilerMode() : DEBUG_HUD_PROFILE_PERFORMANCE);
Expand Down Expand Up @@ -272,9 +272,9 @@ bool EditorMode::PlayProjectInternal(const String &addArgs, bool debug)
{
// enabled metrics at app start

SystemUI::DebugHud* debugHud = GetSubsystem<SystemUI::DebugHud>();
DebugHud* debugHud = GetSubsystem<DebugHud>();

if ( debugHud && ( debugHud->GetMode() & Atomic::SystemUI::DEBUGHUD_SHOW_PROFILER) && (debugHud->GetProfilerMode() == DEBUG_HUD_PROFILE_METRICS))
if ( debugHud && ( debugHud->GetMode() & Atomic::DEBUGHUD_SHOW_PROFILER) && (debugHud->GetProfilerMode() == DEBUG_HUD_PROFILE_METRICS))
{
vargs.Insert(0, "--playermetrics");
}
Expand Down
4 changes: 2 additions & 2 deletions Source/AtomicEditor/PlayerMode/AEPlayerMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void PlayerMode::HandleIPCInitialize(StringHash eventType, VariantMap& eventData

// END LICENSE MANAGEMENT

SystemUI::DebugHud* debugHud = GetSubsystem<SystemUI::DebugHud>();
DebugHud* debugHud = GetSubsystem<DebugHud>();
if (debugHud)
{
debugHud->SetMode(eventData["debugHudMode"].GetUInt());
Expand Down Expand Up @@ -243,7 +243,7 @@ void PlayerMode::HandleViewRender(StringHash eventType, VariantMap& eventData)
done = true;

messageBox_ = GetSubsystem<UI>()->ShowSystemMessageBox("3D Module License Required", "A 3D Module License is required to display 3D content.\n\nUpgrade to Atomic Pro for all features and platforms.");
SubscribeToEvent(messageBox_, SystemUI::E_MESSAGEACK, ATOMIC_HANDLER(PlayerMode, HandleMessageAck));
SubscribeToEvent(messageBox_, E_MESSAGEACK, ATOMIC_HANDLER(PlayerMode, HandleMessageAck));

if (brokerActive_)
{
Expand Down
2 changes: 1 addition & 1 deletion Source/AtomicEditor/PlayerMode/AEPlayerMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class PlayerMode : public Object
// BEGIN LICENSE MANAGEMENT
void HandleMessageAck(StringHash eventType, VariantMap& eventData);
bool licenseModule3D_;
SharedPtr<SystemUI::MessageBox> messageBox_;
SharedPtr<MessageBox> messageBox_;
// END LICENSE MANAGEMENT

IPCHandle fd_[2];
Expand Down
17 changes: 4 additions & 13 deletions Source/ThirdParty/STB/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2008-2016 the Urho3D project.
# Copyright (c) 2017 the Atomic project.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand All @@ -20,15 +20,6 @@
# THE SOFTWARE.
#

# Define target name
set (TARGET_NAME STB)

# Define source files
define_source_files (GLOB_CPP_PATTERNS *.c *.cpp *.h)

# ATOMIC BEGIN
set (INCLUDE_DIRS . ${CMAKE_CURRENT_SOURCE_DIR}/../..)
# ATOMIC END

# Setup target
setup_library ()
add_library(STB STATIC stb_impl.cpp)
target_compile_definitions(STB PUBLIC -DSTB_VORBIS_HEADER_ONLY=1)
target_include_directories(STB PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ../..)
Loading

0 comments on commit 67b94a8

Please sign in to comment.