Skip to content

Commit

Permalink
added colours file and better colours
Browse files Browse the repository at this point in the history
  • Loading branch information
fred-dev committed Oct 3, 2023
1 parent 4869b61 commit d1bb9d0
Show file tree
Hide file tree
Showing 16 changed files with 97 additions and 47 deletions.
28 changes: 28 additions & 0 deletions src/colours.h
Original file line number Diff line number Diff line change
@@ -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);

};




7 changes: 4 additions & 3 deletions src/modes/ConversionMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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<string>() + " Channel: " + ofToString(settings["midiInChannel"]), 10, 55);
Expand Down
2 changes: 1 addition & 1 deletion src/modes/ConversionMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 10 additions & 7 deletions src/modes/MidiInSetupMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand All @@ -44,18 +44,21 @@ 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));
ofPopStyle();
}

// 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() {
Expand Down
2 changes: 1 addition & 1 deletion src/modes/MidiInSetupMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
27 changes: 19 additions & 8 deletions src/modes/MidiOutSetupMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand All @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/modes/MidiOutSetupMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions src/modes/Mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

}
}
6 changes: 4 additions & 2 deletions src/modes/Mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions src/modes/OscInSetupMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/modes/OscInSetupMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/modes/OscOutSetupMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/modes/OscOutSetupMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ void ofApp::setup() {

activityMessage = "No messages received";

midiInSetupMode = std::make_shared<MidiInSetupMode>(font, appSettings);
midiOutSetupMode = std::make_shared<MidiOutSetupMode>(font, appSettings);
oscInSetupMode = std::make_shared<OscInSetupMode>(font, appSettings);
oscOutSetupMode = std::make_shared<OscOutSetupMode>(font, appSettings);
conversionMode = std::make_shared<ConversionMode>(font, appSettings);
midiInSetupMode = std::make_shared<MidiInSetupMode>(font, appSettings, colours);
midiOutSetupMode = std::make_shared<MidiOutSetupMode>(font, appSettings, colours);
oscInSetupMode = std::make_shared<OscInSetupMode>(font, appSettings, colours);
oscOutSetupMode = std::make_shared<OscOutSetupMode>(font, appSettings, colours);
conversionMode = std::make_shared<ConversionMode>(font, appSettings, colours);

modeManager.setMode(conversionMode);
}
Expand All @@ -29,7 +29,7 @@ void ofApp::update() {

//--------------------------------------------------------------
void ofApp::draw() {
ofSetBackgroundColor(255,216,139);
ofSetBackgroundColor(colours.background);
modeManager.draw();
}

Expand Down
4 changes: 3 additions & 1 deletion src/ofApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "modes/OscInSetupMode.h"
#include "modes/OscOutSetupMode.h"
#include "modes/ConversionMode.h"
#include "colours.h"



Expand Down Expand Up @@ -99,6 +100,7 @@ class ofApp : public ofBaseApp {
{"BTN_MSG_GOTOMODE_MODE_CONVERSION", 11}
};


Colours colours;

};

11 changes: 6 additions & 5 deletions src/simpleButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#pragma once
#include "ofxMSAInteractiveObject.h"
#include "colours.h"

#define IDLE_COLOR 0x2860bd
#define OVER_COLOR 0xbd5928
Expand All @@ -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);
Expand All @@ -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();
Expand Down

0 comments on commit d1bb9d0

Please sign in to comment.