From d1bb9d093c925178e8fc05ce6d444941b2585251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cfred-dev=E2=80=9D?= Date: Tue, 3 Oct 2023 14:12:06 +1100 Subject: [PATCH] added colours file and better colours --- src/colours.h | 28 ++++++++++++++++++++++++++++ src/modes/ConversionMode.cpp | 7 ++++--- src/modes/ConversionMode.h | 2 +- src/modes/MidiInSetupMode.cpp | 17 ++++++++++------- src/modes/MidiInSetupMode.h | 2 +- src/modes/MidiOutSetupMode.cpp | 27 +++++++++++++++++++-------- src/modes/MidiOutSetupMode.h | 2 +- src/modes/Mode.cpp | 7 ++++--- src/modes/Mode.h | 6 ++++-- src/modes/OscInSetupMode.cpp | 7 ++++--- src/modes/OscInSetupMode.h | 2 +- src/modes/OscOutSetupMode.cpp | 8 ++++---- src/modes/OscOutSetupMode.h | 2 +- src/ofApp.cpp | 12 ++++++------ src/ofApp.h | 4 +++- src/simpleButton.h | 11 ++++++----- 16 files changed, 97 insertions(+), 47 deletions(-) create mode 100644 src/colours.h diff --git a/src/colours.h b/src/colours.h new file mode 100644 index 0000000..d63ca62 --- /dev/null +++ b/src/colours.h @@ -0,0 +1,28 @@ +// +// colours.h +// OSC_MIDI_OSC +// +// Created by Fred Rodrigues on 03/10/2023. +// + +#pragma once + +#include "ofMain.h" + +class Colours { +public: + + ofColor background = ofColor::fromHex(0xEBEDFF); + ofColor text = ofColor::fromHex(0x1B2CC1); + ofColor button = ofColor::fromHex(0x1B2CC1); + ofColor buttonActive = ofColor::fromHex(0xFF499E); + ofColor buttonHover = ofColor::fromHex(0xFF499E); + ofColor buttonOutline = ofColor::fromHex(0x1B2CC1); + ofColor buttonOutlineHover = ofColor::fromHex(0xFF499E); + ofColor buttonOutlineActive = ofColor::fromHex(0xFF499E); + +}; + + + + diff --git a/src/modes/ConversionMode.cpp b/src/modes/ConversionMode.cpp index 0ff51dd..f969709 100644 --- a/src/modes/ConversionMode.cpp +++ b/src/modes/ConversionMode.cpp @@ -8,8 +8,8 @@ #include "ConversionMode.h" -ConversionMode::ConversionMode(ofTrueTypeFont & fontRef, ofJson & settingsRef) - : Mode(fontRef, settingsRef) { +ConversionMode::ConversionMode(ofTrueTypeFont & fontRef, ofJson & settingsRef, Colours & coloursRef) + : Mode(fontRef, settingsRef, coloursRef) { goToMidiOutSetMode.setup("Midi out setup", "BTN_MSG_GOTOMODE_MODE_SETTING_MIDI_OUT"); goToMidiOutSetMode.set(30, 175, 140, 20); goToMidiOutSetMode.disableAllEvents(); @@ -43,7 +43,8 @@ void ConversionMode::setup() { } void ConversionMode::draw() { - ofSetColor(40,96,189); + + ofSetColor(colours.text); font.drawString("Conversion active", 10, 15); font.drawString(activityMessage, 10, 35); font.drawString("Midi input on port " + settings["inPortLabel"].get() + " Channel: " + ofToString(settings["midiInChannel"]), 10, 55); diff --git a/src/modes/ConversionMode.h b/src/modes/ConversionMode.h index 5aa3be5..3aaf6fc 100644 --- a/src/modes/ConversionMode.h +++ b/src/modes/ConversionMode.h @@ -16,7 +16,7 @@ class ConversionMode : public Mode { std::string activityMessage = "Waiting for input......"; public: - ConversionMode(ofTrueTypeFont & fontRef, ofJson & settingsRef); + ConversionMode(ofTrueTypeFont & fontRef, ofJson & settingsRef, Colours & coloursRef); ~ConversionMode(); void setup() override; diff --git a/src/modes/MidiInSetupMode.cpp b/src/modes/MidiInSetupMode.cpp index b3587b6..9bc3165 100644 --- a/src/modes/MidiInSetupMode.cpp +++ b/src/modes/MidiInSetupMode.cpp @@ -8,8 +8,8 @@ #include "MidiInSetupMode.h" -MidiInSetupMode::MidiInSetupMode(ofTrueTypeFont & fontRef, ofJson & settingsRef) - : Mode(fontRef, settingsRef) { +MidiInSetupMode::MidiInSetupMode(ofTrueTypeFont & fontRef, ofJson & settingsRef, Colours & coloursRef) + : Mode(fontRef, settingsRef, coloursRef) { saveMidiInPortSettings.setup("Set midi in port", "BTN_MSG_MIDI_IN_PORT_SET"); saveMidiInPortSettings.set(30, 175, 140, 20); saveMidiInPortSettings.disableAllEvents(); @@ -34,7 +34,7 @@ void MidiInSetupMode::setup() { } void MidiInSetupMode::draw() { - ofSetColor(40,96,189); + ofSetColor(colours.text); font.drawString(title, 10, 15); font.drawString("Use the up & down keys to set the port and the < and > to set the channel", 10, 35); @@ -44,9 +44,9 @@ void MidiInSetupMode::draw() { ofPushStyle(); if (settings["allInPorts"][i] == settings["inPortLabel"]) { - ofSetColor(189,89,40); + ofSetColor(colours.buttonActive); } else { - ofSetColor(40,96,189); + ofSetColor(colours.text); } font.drawString(settings["allInPorts"][i], 10, 55 + (i * 20)); @@ -54,8 +54,11 @@ void MidiInSetupMode::draw() { } // Draw the midi channel to the right of these messages - ofSetColor(40,96,189); - font.drawString("Midi channel set to: " + ofToString(settings["midiInChannel"]), 320, 55); + ofSetColor(colours.text); + font.drawString("Midi channel set to: ", 320, 55); + ofSetColor(colours.buttonActive); + int xPos = font.getStringBoundingBox("Midi channel set to: ", 320, 55).x + font.getStringBoundingBox("Midi channel set to: ", 320, 55).width; + font.drawString( ofToString(settings["midiInChannel"]), xPos, 55); } void MidiInSetupMode::update() { diff --git a/src/modes/MidiInSetupMode.h b/src/modes/MidiInSetupMode.h index f3d365b..dc38c95 100644 --- a/src/modes/MidiInSetupMode.h +++ b/src/modes/MidiInSetupMode.h @@ -17,7 +17,7 @@ class MidiInSetupMode : public Mode { public: - MidiInSetupMode(ofTrueTypeFont & fontRef, ofJson & settingsRef); + MidiInSetupMode(ofTrueTypeFont & fontRef, ofJson & settingsRef, Colours & coloursRef); ~MidiInSetupMode(); void setup() override; diff --git a/src/modes/MidiOutSetupMode.cpp b/src/modes/MidiOutSetupMode.cpp index d4b2eb4..c8c668f 100644 --- a/src/modes/MidiOutSetupMode.cpp +++ b/src/modes/MidiOutSetupMode.cpp @@ -8,8 +8,8 @@ #include "MidiOutSetupMode.h" -MidiOutSetupMode::MidiOutSetupMode(ofTrueTypeFont & fontRef, ofJson & settingsRef) - : Mode(fontRef, settingsRef) { +MidiOutSetupMode::MidiOutSetupMode(ofTrueTypeFont & fontRef, ofJson & settingsRef, Colours & coloursRef) + : Mode(fontRef, settingsRef, coloursRef) { saveMidiOutPortSettings.setup("Set midi out port", "BTN_MSG_MIDI_OUT_PORT_SET"); saveMidiOutPortSettings.set(30, 175, 140, 20); saveMidiOutPortSettings.disableAllEvents(); @@ -34,7 +34,7 @@ void MidiOutSetupMode::setup() { } void MidiOutSetupMode::draw() { - ofSetColor(40,96,189); + ofSetColor(colours.text); font.drawString(title, 10, 15); font.drawString("Use the up & down keys to set the port and the < and > to set the channel", 10, 35); @@ -44,19 +44,30 @@ void MidiOutSetupMode::draw() { ofPushStyle(); if (settings["allOutPorts"][i] == settings["outPortLabel"]) { - ofSetColor(189,89,40); + ofSetColor(colours.buttonActive); } else { - ofSetColor(40,96,189); + ofSetColor(colours.text); } - + font.drawString(settings["allOutPorts"][i], 10, 55 + (i * 15)); ofPopStyle(); } // Draw the midi channel to the right of these messages - ofSetColor(40,96,189); - font.drawString("Midi channel set to: " + ofToString(settings["midiOutChannel"]), 320, 55); + ofSetColor(colours.text); + // we want to draw this string font.drawString("Midi channel set to: " + ofToString(settings["midiOutChannel"]), 320, 55) but the ofToString(settings["midiOutChannel"]) part should be a different colour + font.drawString("Midi channel set to: ", 320, 55); + ofSetColor(colours.buttonActive); + int xPos = font.getStringBoundingBox("Midi channel set to: ", 320, 55).x + font.getStringBoundingBox("Midi channel set to: ", 320, 55).width; + font.drawString( ofToString(settings["midiOutChannel"]), xPos, 55); + + + + + + + //font.drawString("Midi channel set to: " + ofToString(settings["midiOutChannel"]), 320, 55); } void MidiOutSetupMode::update() { diff --git a/src/modes/MidiOutSetupMode.h b/src/modes/MidiOutSetupMode.h index 740b7b3..35a20a5 100644 --- a/src/modes/MidiOutSetupMode.h +++ b/src/modes/MidiOutSetupMode.h @@ -13,7 +13,7 @@ class MidiOutSetupMode : public Mode { std::string title = "MIDI out setup";; public: - MidiOutSetupMode(ofTrueTypeFont & fontRef, ofJson & settingsRef); + MidiOutSetupMode(ofTrueTypeFont & fontRef, ofJson & settingsRef, Colours & coloursRef); ~MidiOutSetupMode(); void setup() override; diff --git a/src/modes/Mode.cpp b/src/modes/Mode.cpp index 32efb5a..6938b60 100644 --- a/src/modes/Mode.cpp +++ b/src/modes/Mode.cpp @@ -7,11 +7,12 @@ #include "Mode.h" -Mode::Mode(ofTrueTypeFont & fontRef, ofJson & settingsRef) +Mode::Mode(ofTrueTypeFont & fontRef, ofJson & settingsRef, Colours & coloursRef) : font(fontRef) - , settings(settingsRef) { + , settings(settingsRef) + , colours(coloursRef) { } Mode::~Mode() { -} \ No newline at end of file +} diff --git a/src/modes/Mode.h b/src/modes/Mode.h index f9e982f..e914a54 100644 --- a/src/modes/Mode.h +++ b/src/modes/Mode.h @@ -10,16 +10,18 @@ #include "ofMain.h" #include "stdio.h" #include "simpleButton.h" - +#include "colours.h" class Mode { protected: ofTrueTypeFont & font; ofJson & settings; std::string title; + Colours & colours; + public: - Mode(ofTrueTypeFont & fontRef, ofJson & settingsRef); + Mode(ofTrueTypeFont & fontRef, ofJson & settingsRef, Colours & coloursRef); virtual ~Mode(); virtual void setup() = 0; diff --git a/src/modes/OscInSetupMode.cpp b/src/modes/OscInSetupMode.cpp index 6384190..06c4462 100644 --- a/src/modes/OscInSetupMode.cpp +++ b/src/modes/OscInSetupMode.cpp @@ -7,8 +7,8 @@ #include "OscInSetupMode.h" -OscInSetupMode::OscInSetupMode(ofTrueTypeFont & fontRef, ofJson & settingsRef) - : Mode(fontRef, settingsRef) { +OscInSetupMode::OscInSetupMode(ofTrueTypeFont & fontRef, ofJson & settingsRef, Colours & coloursRef) + : Mode(fontRef, settingsRef, coloursRef) { oscInPortField.setup(); oscInPortField.text = ofToString(settings["incomingPortOsc"]); oscInPortField.bounds.x = 10; @@ -38,9 +38,10 @@ void OscInSetupMode::setup() { } void OscInSetupMode::draw() { - ofSetColor(40,96,189); + ofSetColor(colours.text); font.drawString("OSC in settings", 10, 15); ofPushStyle(); + ofSetColor(colours.buttonActive); ofFill(); ofDrawRectRounded(oscInPortField.bounds.x, oscInPortField.bounds.y + 8, oscInPortField.bounds.width, oscInPortField.bounds.height, 3); ofPopStyle(); diff --git a/src/modes/OscInSetupMode.h b/src/modes/OscInSetupMode.h index 68c7761..881db34 100644 --- a/src/modes/OscInSetupMode.h +++ b/src/modes/OscInSetupMode.h @@ -18,7 +18,7 @@ class OscInSetupMode : public Mode { std::string title; public: - OscInSetupMode(ofTrueTypeFont & fontRef, ofJson & settingsRef); + OscInSetupMode(ofTrueTypeFont & fontRef, ofJson & settingsRef, Colours & coloursRef); ~OscInSetupMode(); void setup() override; diff --git a/src/modes/OscOutSetupMode.cpp b/src/modes/OscOutSetupMode.cpp index ff3ebf6..3bb9af3 100644 --- a/src/modes/OscOutSetupMode.cpp +++ b/src/modes/OscOutSetupMode.cpp @@ -7,8 +7,8 @@ #include "OscOutSetupMode.h" -OscOutSetupMode::OscOutSetupMode(ofTrueTypeFont & fontRef, ofJson & settingsRef) - : Mode(fontRef, settingsRef) { +OscOutSetupMode::OscOutSetupMode(ofTrueTypeFont & fontRef, ofJson & settingsRef, Colours & coloursRef) + : Mode(fontRef, settingsRef, coloursRef) { oscOutPortField.setup(); oscOutPortField.text = ofToString(settings["outGoingPortOsc"]); oscOutPortField.bounds.x = 10; @@ -52,11 +52,11 @@ void OscOutSetupMode::setup() { } void OscOutSetupMode::draw() { - ofSetColor(40,96,189); + ofSetColor(colours.text); font.drawString("OSC out settings", 10, 15); ofPushStyle(); ofFill(); - ofSetColor(255,216,139); + ofSetColor(colours.buttonActive); ofDrawRectRounded(oscOutPortField.bounds.x, oscOutPortField.bounds.y + 8, oscOutPortField.bounds.width, oscOutPortField.bounds.height, 3); ofDrawRectRounded(oscOutIPField.bounds.x, oscOutIPField.bounds.y + 8, oscOutIPField.bounds.width, oscOutIPField.bounds.height, 3); ofPopStyle(); diff --git a/src/modes/OscOutSetupMode.h b/src/modes/OscOutSetupMode.h index 4be85c3..f00ff2a 100644 --- a/src/modes/OscOutSetupMode.h +++ b/src/modes/OscOutSetupMode.h @@ -17,7 +17,7 @@ class OscOutSetupMode : public Mode { std::string title; public: - OscOutSetupMode(ofTrueTypeFont & fontRef, ofJson & settingsRef); + OscOutSetupMode(ofTrueTypeFont & fontRef, ofJson & settingsRef, Colours & coloursRef); ~OscOutSetupMode(); void setup() override; diff --git a/src/ofApp.cpp b/src/ofApp.cpp index 389daf9..27ca82f 100644 --- a/src/ofApp.cpp +++ b/src/ofApp.cpp @@ -12,11 +12,11 @@ void ofApp::setup() { activityMessage = "No messages received"; - midiInSetupMode = std::make_shared(font, appSettings); - midiOutSetupMode = std::make_shared(font, appSettings); - oscInSetupMode = std::make_shared(font, appSettings); - oscOutSetupMode = std::make_shared(font, appSettings); - conversionMode = std::make_shared(font, appSettings); + midiInSetupMode = std::make_shared(font, appSettings, colours); + midiOutSetupMode = std::make_shared(font, appSettings, colours); + oscInSetupMode = std::make_shared(font, appSettings, colours); + oscOutSetupMode = std::make_shared(font, appSettings, colours); + conversionMode = std::make_shared(font, appSettings, colours); modeManager.setMode(conversionMode); } @@ -29,7 +29,7 @@ void ofApp::update() { //-------------------------------------------------------------- void ofApp::draw() { - ofSetBackgroundColor(255,216,139); + ofSetBackgroundColor(colours.background); modeManager.draw(); } diff --git a/src/ofApp.h b/src/ofApp.h index 63c6cc9..4ae618b 100644 --- a/src/ofApp.h +++ b/src/ofApp.h @@ -13,6 +13,7 @@ #include "modes/OscInSetupMode.h" #include "modes/OscOutSetupMode.h" #include "modes/ConversionMode.h" +#include "colours.h" @@ -99,6 +100,7 @@ class ofApp : public ofBaseApp { {"BTN_MSG_GOTOMODE_MODE_CONVERSION", 11} }; - + Colours colours; + }; diff --git a/src/simpleButton.h b/src/simpleButton.h index 89f283f..6e9a402 100644 --- a/src/simpleButton.h +++ b/src/simpleButton.h @@ -7,6 +7,7 @@ #pragma once #include "ofxMSAInteractiveObject.h" +#include "colours.h" #define IDLE_COLOR 0x2860bd #define OVER_COLOR 0xbd5928 @@ -17,11 +18,11 @@ class simpleButton : public ofxMSAInteractiveObject { string buttonLabel; string buttonMessage; ofTrueTypeFont drawFont; - + Colours colours; void setup(string label, string message) { enableMouseEvents(); enableKeyEvents(); - + buttonLabel = label; buttonMessage = message; drawFont.load("frabk.ttf", 12); @@ -37,11 +38,11 @@ class simpleButton : public ofxMSAInteractiveObject { ofPushStyle(); if (isMousePressed()) { - ofSetHexColor(DOWN_COLOR); + ofSetColor(colours.buttonActive); } else if (isMouseOver()) { - ofSetHexColor(OVER_COLOR); + ofSetColor(colours.buttonActive); } else { - ofSetHexColor(IDLE_COLOR); + ofSetColor(colours.button); } ofNoFill();