This commit is contained in:
Branimir Karadžić 2015-06-10 19:46:22 -07:00
commit 9cae56fb96
18 changed files with 124 additions and 76 deletions

View file

@ -265,7 +265,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
, mouseState.m_my
, (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0)
| (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0)
, 0
, mouseState.m_mz
, width
, height
);

View file

@ -132,7 +132,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
, mouseState.m_my
, (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0)
| (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0)
, 0
, mouseState.m_mz
, width
, height
);

View file

@ -119,7 +119,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
, mouseState.m_my
, (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0)
| (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0)
, 0
, mouseState.m_mz
, width
, height
);

View file

@ -945,7 +945,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
, mouseState.m_my
, (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0)
| (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0)
, 0
, mouseState.m_mz
, viewState.m_width
, viewState.m_height
);

View file

@ -2128,7 +2128,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
, mouseState.m_my
, (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0)
| (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0)
, 0
, mouseState.m_mz
, viewState.m_width
, viewState.m_height
);

View file

@ -1974,7 +1974,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
, mouseState.m_my
, (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0)
| (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0)
, 0
, mouseState.m_mz
, viewState.m_width
, viewState.m_height
);

View file

@ -141,7 +141,7 @@ BX_NO_INLINE bool mainloop()
, mouseState.m_my
, (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0)
| (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0)
, 0
, mouseState.m_mz
, width
, height
);

View file

@ -311,7 +311,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
, mouseState.m_my
, (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0)
| (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0)
, 0
, mouseState.m_mz
, width
, height
);

View file

@ -244,7 +244,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
, mouseState.m_my
, (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0)
| (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0)
, 0
, mouseState.m_mz
, width
, height
);

View file

@ -407,7 +407,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
, mouseState.m_my
, (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0)
| (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0)
, 0
, mouseState.m_mz
, width
, height
);

View file

@ -221,7 +221,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
, mouseState.m_my
, (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0)
| (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0)
, 0
, mouseState.m_mz
, width
, height
);

View file

@ -477,7 +477,7 @@ namespace entry
XUnmapWindow(m_display, m_window[0]);
XDestroyWindow(m_display, m_window[0]);
return m_thread.getExitCode();
return thread.getExitCode();
}
void setModifier(Modifier::Enum _modifier, bool _set)

View file

@ -29,7 +29,6 @@
#include <bx/fpumath.h>
#include <bx/handlealloc.h>
#include "../entry/dbg.h"
#include "imgui.h"
#include "ocornut_imgui.h"
#include "../nanovg/nanovg.h"
@ -824,7 +823,7 @@ struct Imgui
const int32_t mx = int32_t(float(_mx)*xscale);
const int32_t my = int32_t(float(_my)*yscale);
IMGUI_beginFrame(mx, my, _button, _width, _height, _inputChar, _view);
IMGUI_beginFrame(mx, my, _button, _scroll, _width, _height, _inputChar, _view);
nvgBeginFrameScaled(m_nvg, m_viewWidth, m_viewHeight, m_surfaceWidth, m_surfaceHeight, 1.0f);
nvgViewId(m_nvg, _view);

View file

@ -11,6 +11,10 @@
#include "ocornut_imgui.h"
#include <stb/stb_image.c>
#if defined(SCI_NAMESPACE)
# include "../entry/input.h"
#endif // defined(SCI_NAMESPACE)
#include "vs_ocornut_imgui.bin.h"
#include "fs_ocornut_imgui.bin.h"
@ -35,7 +39,6 @@ struct OcornutImguiContext
{
bgfx::TransientVertexBuffer tvb;
const ImDrawList* cmd_list = _lists[ii];
const ImDrawVert* vtx_buffer = cmd_list->vtx_buffer.begin();
uint32_t vtx_size = (uint32_t)cmd_list->vtx_buffer.size();
@ -56,6 +59,12 @@ struct OcornutImguiContext
const ImDrawCmd* pcmd_end = cmd_list->commands.end();
for (const ImDrawCmd* pcmd = pcmd_begin; pcmd != pcmd_end; pcmd++)
{
if (pcmd->user_callback)
{
pcmd->user_callback(cmd_list, pcmd);
vtx_offset += pcmd->vtx_count;
continue;
}
if (0 == pcmd->vtx_count)
{
continue;
@ -92,6 +101,7 @@ struct OcornutImguiContext
{
m_viewId = 255;
m_allocator = _allocator;
m_lastScroll = 0;
ImGuiIO& io = ImGui::GetIO();
io.RenderDrawListsFn = renderDrawLists;
@ -105,10 +115,25 @@ struct OcornutImguiContext
io.IniFilename = NULL;
io.PixelCenterOffset = bgfx::RendererType::Direct3D9 == bgfx::getRendererType() ? 0.0f : 0.5f;
for (uint32_t ii = 0; ii < ImGuiKey_COUNT; ++ii)
{
io.KeyMap[ii] = ImGuiKey_(ii);
}
#if defined(SCI_NAMESPACE)
io.KeyMap[ImGuiKey_Tab] = (int)entry::Key::Tab;
io.KeyMap[ImGuiKey_LeftArrow] = (int)entry::Key::Left;
io.KeyMap[ImGuiKey_RightArrow] = (int)entry::Key::Right;
io.KeyMap[ImGuiKey_UpArrow] = (int)entry::Key::Up;
io.KeyMap[ImGuiKey_DownArrow] = (int)entry::Key::Down;
io.KeyMap[ImGuiKey_Home] = (int)entry::Key::Home;
io.KeyMap[ImGuiKey_End] = (int)entry::Key::End;
io.KeyMap[ImGuiKey_Delete] = (int)entry::Key::Delete;
io.KeyMap[ImGuiKey_Backspace] = (int)entry::Key::Backspace;
io.KeyMap[ImGuiKey_Enter] = (int)entry::Key::Return;
io.KeyMap[ImGuiKey_Escape] = (int)entry::Key::Esc;
io.KeyMap[ImGuiKey_A] = (int)entry::Key::KeyA;
io.KeyMap[ImGuiKey_C] = (int)entry::Key::KeyC;
io.KeyMap[ImGuiKey_V] = (int)entry::Key::KeyV;
io.KeyMap[ImGuiKey_X] = (int)entry::Key::KeyX;
io.KeyMap[ImGuiKey_Y] = (int)entry::Key::KeyY;
io.KeyMap[ImGuiKey_Z] = (int)entry::Key::KeyZ;
#endif // defined(SCI_NAMESPACE)
const bgfx::Memory* vsmem;
const bgfx::Memory* fsmem;
@ -177,35 +202,33 @@ struct OcornutImguiContext
m_allocator = NULL;
}
void beginFrame(int32_t _mx, int32_t _my, uint8_t _button, int _width, int _height, char _inputChar, uint8_t _viewId)
void beginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, int _width, int _height, char _inputChar, uint8_t _viewId)
{
m_viewId = _viewId;
ImGuiIO& io = ImGui::GetIO();
io.AddInputCharacter(_inputChar & 0x7f); // ASCII or GTFO! :)
if (_inputChar < 0x7f)
{
io.AddInputCharacter(_inputChar); // ASCII or GTFO! :(
}
io.DisplaySize = ImVec2((float)_width, (float)_height);
io.DeltaTime = 1.0f / 60.0f;
io.MousePos = ImVec2((float)_mx, (float)_my);
io.MouseDown[0] = 0 != (_button & IMGUI_MBUT_LEFT);
io.MouseDown[1] = 0 != (_button & IMGUI_MBUT_RIGHT);
io.MouseWheel = (float)(_scroll - m_lastScroll);
m_lastScroll = _scroll;
#if 0
io.KeysDown[ImGuiKey_Tab] = inputGetKeyState(entry::Key::Tab);
io.KeysDown[ImGuiKey_LeftArrow] = inputGetKeyState(entry::Key::Left);
io.KeysDown[ImGuiKey_RightArrow] = inputGetKeyState(entry::Key::Right);
io.KeysDown[ImGuiKey_UpArrow] = inputGetKeyState(entry::Key::Up);
io.KeysDown[ImGuiKey_DownArrow] = inputGetKeyState(entry::Key::Down);
io.KeysDown[ImGuiKey_Home] = inputGetKeyState(entry::Key::Home);
io.KeysDown[ImGuiKey_End] = inputGetKeyState(entry::Key::End);
io.KeysDown[ImGuiKey_Delete] = inputGetKeyState(entry::Key::Delete);
io.KeysDown[ImGuiKey_Backspace] = inputGetKeyState(entry::Key::Backspace);
io.KeysDown[ImGuiKey_Enter] = inputGetKeyState(entry::Key::Return);
io.KeysDown[ImGuiKey_Escape] = inputGetKeyState(entry::Key::Esc);
io.KeysDown[ImGuiKey_A] = inputGetKeyState(entry::Key::KeyA);
io.KeysDown[ImGuiKey_C] = inputGetKeyState(entry::Key::KeyC);
io.KeysDown[ImGuiKey_V] = inputGetKeyState(entry::Key::KeyV);
io.KeysDown[ImGuiKey_X] = inputGetKeyState(entry::Key::KeyX);
io.KeysDown[ImGuiKey_Y] = inputGetKeyState(entry::Key::KeyY);
io.KeysDown[ImGuiKey_Z] = inputGetKeyState(entry::Key::KeyZ);
#endif // 0
#if defined(SCI_NAMESPACE)
uint8_t modifiers = inputGetModifiersState();
io.KeyShift = 0 != (modifiers & (entry::Modifier::LeftShift | entry::Modifier::RightShift) );
io.KeyCtrl = 0 != (modifiers & (entry::Modifier::LeftCtrl | entry::Modifier::RightCtrl ) );
io.KeyAlt = 0 != (modifiers & (entry::Modifier::LeftAlt | entry::Modifier::RightAlt ) );
for (int32_t ii = 0; ii < (int32_t)entry::Key::Count; ++ii)
{
io.KeysDown[ii] = inputGetKeyState(entry::Key::Enum(ii) );
}
#endif // defined(SCI_NAMESPACE)
ImGui::NewFrame();
@ -223,6 +246,7 @@ struct OcornutImguiContext
bgfx::TextureHandle m_texture;
bgfx::UniformHandle s_tex;
uint8_t m_viewId;
int32_t m_lastScroll;
};
static OcornutImguiContext s_ctx;
@ -252,9 +276,9 @@ void IMGUI_destroy()
s_ctx.destroy();
}
void IMGUI_beginFrame(int32_t _mx, int32_t _my, uint8_t _button, int _width, int _height, char _inputChar, uint8_t _viewId)
void IMGUI_beginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, int _width, int _height, char _inputChar, uint8_t _viewId)
{
s_ctx.beginFrame(_mx, _my, _button, _width, _height, _inputChar, _viewId);
s_ctx.beginFrame(_mx, _my, _button, _scroll, _width, _height, _inputChar, _viewId);
}
void IMGUI_endFrame()

View file

@ -12,7 +12,7 @@ namespace bx { struct AllocatorI; }
void IMGUI_create(const void* _data, uint32_t _size, float _fontSize, bx::AllocatorI* _allocator);
void IMGUI_destroy();
void IMGUI_beginFrame(int32_t _mx, int32_t _my, uint8_t _button, int _width, int _height, char _inputChar, uint8_t _viewId);
void IMGUI_beginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, int _width, int _height, char _inputChar, uint8_t _viewId);
void IMGUI_endFrame();
#endif // OCORNUT_IMGUI_H_HEADER_GUARD

View file

@ -8,6 +8,7 @@
#include <algorithm>
#include <map>
#include <vector>
#include <string.h>
#include "scintilla/include/Platform.h"
#include "scintilla/include/Scintilla.h"
@ -351,16 +352,16 @@ inline WindowInt* GetWindow(Scintilla::WindowID id)
class ListBoxInt : public Scintilla::ListBox
{
public:
ListBoxInt::ListBoxInt()
: m_lineHeight(10)
, m_unicodeMode(false)
ListBoxInt()
: m_maxStrWidth(0)
, m_lineHeight(10)
, m_desiredVisibleRows(5)
, m_aveCharWidth(8)
, m_maxStrWidth(0)
, m_unicodeMode(false)
{
}
ListBoxInt::~ListBoxInt()
~ListBoxInt()
{
}
@ -468,16 +469,14 @@ private:
bool m_unicodeMode;
};
struct ScEditor : public Scintilla::ScintillaBase
struct Editor : public Scintilla::ScintillaBase
{
public:
ScEditor()
Editor()
: m_width(0)
, m_height(0)
, m_wheelVRotation(0)
, m_wheelHRotation(0)
, m_foreground(0xffffffff)
, m_lineNumber(0xff00ffff)
, m_searchResultIndication(0xff5A5A5A)
, m_filteredSearchResultIndication(0xff5a5a5a)
, m_occurrenceIndication(0xff5a5a5a)
@ -508,10 +507,12 @@ public:
, m_staticField(0xff4b9ce9)
, m_staticFinalField(0xff4b9ce9)
, m_deprecatedMember(0xfff9f9f9)
, m_foreground(0xffffffff)
, m_lineNumber(0xff00ffff)
{
}
virtual ~ScEditor()
virtual ~Editor()
{
}
@ -668,71 +669,71 @@ public:
const bool ctrl = 0 != (modifiers & (entry::Modifier::LeftCtrl | entry::Modifier::RightCtrl ) );
const bool alt = 0 != (modifiers & (entry::Modifier::LeftAlt | entry::Modifier::RightAlt ) );
if (ImGui::IsKeyPressed(ImGuiKey_Tab) )
if (ImGui::IsKeyPressed(entry::Key::Tab) )
{
Editor::KeyDown(SCK_TAB, shift, ctrl, alt);
}
else if (ImGui::IsKeyPressed(ImGuiKey_LeftArrow) )
else if (ImGui::IsKeyPressed(entry::Key::Left) )
{
Editor::KeyDown(SCK_LEFT, shift, ctrl, alt);
}
else if (ImGui::IsKeyPressed(ImGuiKey_RightArrow) )
else if (ImGui::IsKeyPressed(entry::Key::Right) )
{
Editor::KeyDown(SCK_RIGHT, shift, ctrl, alt);
}
else if (ImGui::IsKeyPressed(ImGuiKey_UpArrow) )
else if (ImGui::IsKeyPressed(entry::Key::Up) )
{
Editor::KeyDown(SCK_UP, shift, ctrl, alt);
}
else if (ImGui::IsKeyPressed(ImGuiKey_DownArrow) )
else if (ImGui::IsKeyPressed(entry::Key::Down) )
{
Editor::KeyDown(SCK_DOWN, shift, ctrl, alt);
}
else if (ImGui::IsKeyPressed(ImGuiKey_Home) )
else if (ImGui::IsKeyPressed(entry::Key::Home) )
{
Editor::KeyDown(SCK_HOME, shift, ctrl, alt);
}
else if (ImGui::IsKeyPressed(ImGuiKey_End) )
else if (ImGui::IsKeyPressed(entry::Key::End) )
{
Editor::KeyDown(SCK_END, shift, ctrl, alt);
}
else if (ImGui::IsKeyPressed(ImGuiKey_Delete) )
else if (ImGui::IsKeyPressed(entry::Key::Delete) )
{
Editor::KeyDown(SCK_DELETE, shift, ctrl, alt);
}
else if (ImGui::IsKeyPressed(ImGuiKey_Backspace) )
else if (ImGui::IsKeyPressed(entry::Key::Backspace) )
{
Editor::KeyDown(SCK_BACK, shift, ctrl, alt); inputGetChar();
}
else if (ImGui::IsKeyPressed(ImGuiKey_Enter) )
else if (ImGui::IsKeyPressed(entry::Key::Return) )
{
Editor::KeyDown(SCK_RETURN, shift, ctrl, alt); inputGetChar();
}
else if (ImGui::IsKeyPressed(ImGuiKey_Escape) )
else if (ImGui::IsKeyPressed(entry::Key::Esc) )
{
Editor::KeyDown(SCK_ESCAPE, shift, ctrl, alt);
}
else if (ctrl && ImGui::IsKeyPressed(ImGuiKey_A) )
else if (ctrl && ImGui::IsKeyPressed(entry::Key::KeyA) )
{
Editor::KeyDown('A', shift, ctrl, alt); inputGetChar();
}
else if (ctrl && ImGui::IsKeyPressed(ImGuiKey_C) )
else if (ctrl && ImGui::IsKeyPressed(entry::Key::KeyC) )
{
Editor::KeyDown('C', shift, ctrl, alt); inputGetChar();
}
else if (ctrl && ImGui::IsKeyPressed(ImGuiKey_V) )
else if (ctrl && ImGui::IsKeyPressed(entry::Key::KeyV) )
{
Editor::KeyDown('V', shift, ctrl, alt); inputGetChar();
}
else if (ctrl && ImGui::IsKeyPressed(ImGuiKey_X) )
else if (ctrl && ImGui::IsKeyPressed(entry::Key::KeyX) )
{
Editor::KeyDown('X', shift, ctrl, alt); inputGetChar();
}
else if (ctrl && ImGui::IsKeyPressed(ImGuiKey_Y) )
else if (ctrl && ImGui::IsKeyPressed(entry::Key::KeyY) )
{
Editor::KeyDown('Y', shift, ctrl, alt); inputGetChar();
}
else if (ctrl && ImGui::IsKeyPressed(ImGuiKey_Z) )
else if (ctrl && ImGui::IsKeyPressed(entry::Key::KeyZ) )
{
Editor::KeyDown('Z', shift, ctrl, alt); inputGetChar();
}
@ -833,7 +834,7 @@ private:
ScintillaEditor* ScintillaEditor::create(int _width, int _height)
{
ScEditor* editor = IMGUI_NEW(ScEditor);
Editor* editor = IMGUI_NEW(Editor);
editor->Initialise();
editor->Resize(0, 0, _width, _height);
@ -843,18 +844,18 @@ ScintillaEditor* ScintillaEditor::create(int _width, int _height)
void ScintillaEditor::destroy(ScintillaEditor* _scintilla)
{
IMGUI_DELETE(ScEditor, _scintilla);
IMGUI_DELETE(Editor, _scintilla);
}
intptr_t ScintillaEditor::command(unsigned int _msg, uintptr_t _p0, intptr_t _p1)
{
ScEditor* editor = reinterpret_cast<ScEditor*>(this);
Editor* editor = reinterpret_cast<Editor*>(this);
return editor->command(_msg, _p0, _p1);
}
void ScintillaEditor::draw()
{
ScEditor* editor = reinterpret_cast<ScEditor*>(this);
Editor* editor = reinterpret_cast<Editor*>(this);
return editor->draw();
}
@ -1019,9 +1020,9 @@ namespace Scintilla
GetWindow(wid)->position = rc;
}
void Window::SetPositionRelative(PRectangle rc, Window w)
void Window::SetPositionRelative(PRectangle _rc, Window /*_w*/)
{
SetPosition(rc);
SetPosition(_rc);
}
PRectangle Window::GetClientPosition()

View file

@ -28,6 +28,10 @@ project ("example-common")
"SCI_LEXER",
}
buildoptions {
-- "-Wno-missing-field-initializers",
}
includedirs {
path.join(BGFX_DIR, "3rdparty/scintilla/include"),
path.join(BGFX_DIR, "3rdparty/scintilla/lexlib"),

View file

@ -15,8 +15,13 @@ namespace bgfx { namespace gl
# define GL_IMPORT(_optional, _proto, _func, _import) _proto _func = NULL
# include "glimports.h"
static void* s_opengles = NULL;
void GlContext::create(uint32_t _width, uint32_t _height)
{
s_opengles = bx::dlopen("/System/Library/Frameworks/OpenGLES.framework/OpenGLES");
BX_CHECK(NULL != s_opengles, "OpenGLES dynamic library is not found!");
BX_UNUSED(_width, _height);
CAEAGLLayer* layer = (CAEAGLLayer*)g_platformData.nwh;
layer.opaque = true;
@ -59,6 +64,8 @@ namespace bgfx { namespace gl
, "glCheckFramebufferStatus failed 0x%08x"
, glCheckFramebufferStatus(GL_FRAMEBUFFER)
);
import();
}
void GlContext::destroy()
@ -83,6 +90,8 @@ namespace bgfx { namespace gl
EAGLContext* context = (EAGLContext*)m_context;
[context release];
bx::dlclose(s_opengles);
}
void GlContext::resize(uint32_t _width, uint32_t _height, uint32_t _flags)
@ -121,6 +130,17 @@ namespace bgfx { namespace gl
void GlContext::import()
{
BX_TRACE("Import:");
# define GL_EXTENSION(_optional, _proto, _func, _import) \
{ \
if (_func == NULL) \
{ \
_func = (_proto)bx::dlsym(s_opengles, #_import); \
BX_TRACE("%p " #_func " (" #_import ")", _func); \
} \
BGFX_FATAL(_optional || NULL != _func, Fatal::UnableToInitialize, "Failed to create OpenGLES context. EAGLGetProcAddress(\"%s\")", #_import); \
}
# include "glimports.h"
}
} /* namespace gl */ } // namespace bgfx