Skip to content

Commit

Permalink
added and tested new auto-path load/save for patches and files, plus …
Browse files Browse the repository at this point in the history
…file extensions check on save
  • Loading branch information
d3cod3 committed Dec 3, 2019
1 parent 5b4f866 commit a9582c5
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 62 deletions.
3 changes: 2 additions & 1 deletion Mosaic.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Project{
"src/MosaicTheme.h",
"src/SplashScreen.cpp",
"src/SplashScreen.h",
"src/TextEditor.cpp",
"src/TextEditor.h",
"src/config.h",
"src/includes.h",
'src/main.cpp',
Expand All @@ -25,7 +27,6 @@ Project{

of.addons: [
'ofxImGui',
'ofxLoggerChannel',
'ofxModal',
'ofxSimpleHttp',
'ofxVisualProgramming'
Expand Down
12 changes: 2 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ Mosaic, ofxVisualProgramming, openframeworks, linux, macOS, windows, creative-co

#### [ofxGLEditor](https://github.com/d3cod3/ofxGLEditor) -- Fork

#### [ofxGLError](https://github.com/armadillu/ofxGLError)

#### [ofxHistoryPlot](https://github.com/armadillu/ofxHistoryPlot)

#### [ofxHttpForm](https://github.com/armadillu/ofxHttpForm)
Expand All @@ -96,12 +94,10 @@ Mosaic, ofxVisualProgramming, openframeworks, linux, macOS, windows, creative-co

#### [ofxJSON](https://github.com/jeffcrouse/ofxJSON)

#### [ofxImGui](https://github.com/jvcleave/ofxImGui)
#### [ofxImGui](https://github.com/d3cod3/ofxImGui) -- Fork

#### [ofxInfiniteCanvas](https://github.com/d3cod3/ofxInfiniteCanvas) -- Fork

#### [ofxLoggerChannel](https://github.com/d3cod3/ofxLoggerChannel) -- Fork

#### [ofxLua](https://github.com/d3cod3/ofxLua) -- Fork

#### [ofxMidi](https://github.com/d3cod3/ofxMidi) -- Fork
Expand All @@ -126,8 +122,6 @@ Mosaic, ofxVisualProgramming, openframeworks, linux, macOS, windows, creative-co

#### [ofxThreadedFileDialog](https://github.com/d3cod3/ofxThreadedFileDialog)

#### [ofxThreadedYouTubeVideo](http://github.com/pierrep/ofxThreadedYouTubeVideo)

#### [ofxTimeline](https://github.com/d3cod3/ofxTimeline) -- Fork

#### [ofxTimeMeasurements](https://github.com/armadillu/ofxTimeMeasurements)
Expand Down Expand Up @@ -195,9 +189,8 @@ git clone https://github.com/armadillu/ofxHistoryPlot
git clone https://github.com/armadillu/ofxHttpForm
git clone https://github.com/d3cod3/ofxJava
git clone https://github.com/jeffcrouse/ofxJSON
git clone https://github.com/jvcleave/ofxImGui
git clone https://github.com/d3cod3/ofxImGui
git clone https://github.com/d3cod3/ofxInfiniteCanvas
git clone https://github.com/d3cod3/ofxLoggerChannel
git clone --branch=of-0.10.0 https://github.com/d3cod3/ofxLua
git clone https://github.com/d3cod3/ofxMidi
git clone https://github.com/d3cod3/ofxModal
Expand All @@ -210,7 +203,6 @@ git clone https://github.com/d3cod3/ofxPdExternals
git clone https://github.com/npisanti/ofxPDSP
git clone https://github.com/armadillu/ofxSimpleHttp
git clone https://github.com/d3cod3/ofxThreadedFileDialog
git clone http://github.com/pierrep/ofxThreadedYouTubeVideo
git clone https://github.com/d3cod3/ofxTimeline
git clone https://github.com/armadillu/ofxTimeMeasurements
git clone https://github.com/d3cod3/ofxVisualProgramming
Expand Down
17 changes: 17 additions & 0 deletions src/MosaicTheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,20 @@ void MosaicTheme::drawDemoComboBox(){
MosaicTheme::TextInputComboBox("Objects", buffer, 20, items, IM_ARRAYSIZE(items));
ImGui::End();
}

//--------------------------------------------------------------
void MosaicTheme::drawMosaicLogDemo(){
static MosaicLoggerChannel log;

// Demo: add random items (unless Ctrl is held)
static double last_time = -1.0;
double time = ImGui::GetTime();
if (time - last_time >= 0.20f && !ImGui::GetIO().KeyCtrl)
{
const char* random_words[] = { "system", "info", "warning", "error", "fatal", "notice", "log" };
log.AddLog("[%s] Hello, time is %.1f, frame count is %d\n", random_words[rand() % IM_ARRAYSIZE(random_words)], time, ImGui::GetFrameCount());
last_time = time;
}

log.Draw("Example: Log");
}
107 changes: 107 additions & 0 deletions src/MosaicTheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,112 @@ class MosaicTheme : public ofxImGui::BaseTheme{
static bool TextInputComboBox(const char* id, char* buffer, size_t maxInputSize, const char* items[], size_t item_len);

static void drawDemoComboBox();
static void drawMosaicLogDemo();

};

class MosaicLoggerChannel : public ofBaseLoggerChannel
{
public:

ImVector<char*> Items;
bool scrollToBottom;

MosaicLoggerChannel() {
scrollToBottom = true;
}

void log( ofLogLevel level, const std::string & module, const std::string & message ){
std::ostringstream oss;
oss << ofGetTimestampString("%H:%M:%S:%i") << " ";
oss << "[" << ofGetLogLevelName(level, true) << "] ";
if (module != "") {
oss << module << ": ";
}
oss << message << endl;

AddLog("%s\n", oss.str().c_str());
}
void log( ofLogLevel level, const std::string & module, const char* format, ... ) OF_PRINTF_ATTR( 4, 5 ){
va_list args;
va_start(args, format);
log(level, module, format, args);
va_end(args);
}
void log( ofLogLevel level, const std::string & module, const char* format, va_list args ){
// Compose the message.
std::ostringstream oss;
oss << ofGetTimestampString("%H:%M:%S:%i") << " ";
oss << "[" << ofGetLogLevelName(level, true) << "] ";
if (module != "") {
oss << module << ": ";
}

oss << ofVAArgsToString(format, args) << endl;

AddLog("%s\n", oss.str().c_str());
}

void Clear() {
for (int i = 0; i < Items.Size; i++){
free(Items[i]);
}
Items.clear();
}

void AddLog(const char* fmt, ...) IM_FMTARGS(2){
char buf[1024];
va_list args;
va_start(args, fmt);
vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args);
buf[IM_ARRAYSIZE(buf)-1] = 0;
va_end(args);
Items.push_back(strdup(buf));
scrollToBottom = true;
}

void Draw(const char* title){

if (!ImGui::Begin(title))
{
ImGui::End();
return;
}
if (ImGui::Button("Clear")) Clear();

ImGui::Separator();
ImGui::BeginChild("scrolling", ImVec2(0,0), false, ImGuiWindowFlags_HorizontalScrollbar);

ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4,1)); // Tighten spacing

ImVec4 col_default_text = ImGui::GetStyleColorVec4(ImGuiCol_Text);
for (int i = 0; i < Items.Size; i++){
const char* item = Items[i];
ImVec4 col = col_default_text;
if (strstr(item, "[notice")) col = ImGui::GetStyleColorVec4(ImGuiCol_Text);
else if (strstr(item, "[warning")) col = ImColor(1.0f,0.5f,0.0f,1.0f);
else if (strstr(item, "[ error")) col = ImColor(1.0f,0.176f,0.176f,1.0f);
else if (strstr(item, "[silent")) col = ImColor(1.0f,0.78f,0.58f,1.0f);
else if (strncmp(item, "# ", 2) == 0) col = ImColor(1.0f,0.78f,0.58f,1.0f);

// force verbose
if(strstr(item, "[verbose]")){
col = ImColor(0.235f,1.0f,0.235f,1.0f);
}

ImGui::PushStyleColor(ImGuiCol_Text, col);
ImGui::TextUnformatted(item);
ImGui::PopStyleColor();
}

if(scrollToBottom){
scrollToBottom = false;
ImGui::SetScrollHere(1.0f);
}


ImGui::EndChild();
ImGui::End();
}

};
1 change: 0 additions & 1 deletion src/includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

#include "ofxVisualProgramming.h"
#include "ofxImGui.h"
#include "ofxScreenLoggerChannel.h"
#include "ofxModal.h"
#include "ofxSimpleHttp.h"

Expand Down
Loading

0 comments on commit a9582c5

Please sign in to comment.