| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
#if !defined( INCLUDED_TEXTUREENTRY_H ) |
| 23 |
#define INCLUDED_TEXTUREENTRY_H |
| 24 |
|
| 25 |
#include "gtkutil/idledraw.h" |
| 26 |
|
| 27 |
#include "generic/static.h" |
| 28 |
#include "signal/isignal.h" |
| 29 |
#include "shaderlib.h" |
| 30 |
|
| 31 |
#include "texwindow.h" |
| 32 |
|
| 33 |
template<typename StringList> |
| 34 |
class EntryCompletion { |
| 35 |
ui::ListStore m_store; |
| 36 |
IdleDraw m_idleUpdate; |
| 37 |
public: |
| 38 |
EntryCompletion() : m_store(ui::null), m_idleUpdate(UpdateCaller(*this)) |
| 39 |
{ |
| 40 |
} |
| 41 |
|
| 42 |
void connect(ui::Entry entry); |
| 43 |
|
| 44 |
void append(const char *string); |
| 45 |
|
| 46 |
using AppendCaller = MemberCaller<EntryCompletion, void(const char *), &EntryCompletion::append>; |
| 47 |
|
| 48 |
void fill(); |
| 49 |
|
| 50 |
void clear(); |
| 51 |
|
| 52 |
void update(); |
| 53 |
|
| 54 |
using UpdateCaller = MemberCaller<EntryCompletion, void(), &EntryCompletion::update>; |
| 55 |
}; |
| 56 |
|
| 57 |
class TextureNameList { |
| 58 |
public: |
| 59 |
void forEach(const ShaderNameCallback &callback) const |
| 60 |
{ |
| 61 |
for (QERApp_ActiveShaders_IteratorBegin(); !QERApp_ActiveShaders_IteratorAtEnd(); QERApp_ActiveShaders_IteratorIncrement()) { |
| 62 |
IShader *shader = QERApp_ActiveShaders_IteratorCurrent(); |
| 63 |
|
| 64 |
if (shader_equal_prefix(shader->getName(), "textures/")) { |
| 65 |
callback(shader->getName() + 9); |
| 66 |
} |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
void connect(const SignalHandler &update) const |
| 71 |
{ |
| 72 |
TextureBrowser_addActiveShadersChangedCallback(update); |
| 73 |
} |
| 74 |
}; |
| 75 |
|
| 76 |
typedef Static<EntryCompletion<TextureNameList> > GlobalTextureEntryCompletion; |
| 77 |
|
| 78 |
|
| 79 |
class ShaderList { |
| 80 |
public: |
| 81 |
void forEach(const ShaderNameCallback &callback) const |
| 82 |
{ |
| 83 |
GlobalShaderSystem().foreachShaderName(callback); |
| 84 |
} |
| 85 |
|
| 86 |
void connect(const SignalHandler &update) const |
| 87 |
{ |
| 88 |
TextureBrowser_addShadersRealiseCallback(update); |
| 89 |
} |
| 90 |
}; |
| 91 |
|
| 92 |
typedef Static<EntryCompletion<ShaderList> > GlobalShaderEntryCompletion; |
| 93 |
|
| 94 |
|
| 95 |
#endif |