Skip to content

Commit 822c8a8

Browse files
committed
Fixed some small bugs, version bump
1 parent 0630ac9 commit 822c8a8

File tree

8 files changed

+48
-32
lines changed

8 files changed

+48
-32
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ endif()
1111
set(JUCE_ENABLE_MODULE_SOURCE_GROUPS ON CACHE BOOL "" FORCE)
1212
set_property(GLOBAL PROPERTY USE_FOLDERS YES)
1313

14-
project(PlugData VERSION 0.3 LANGUAGES C CXX)
14+
project(PlugData VERSION 0.3.1 LANGUAGES C CXX)
1515

1616
if("${CMAKE_SYSTEM}" MATCHES "Linux")
1717
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-Bsymbolic")

Source/Box.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,11 @@ void Box::setType(const String& newType, bool exists)
182182
// Create graphics for the object if necessary
183183
graphics.reset(GUIComponent::createGui(type, this));
184184

185-
if (graphics) graphics->lock(locked);
185+
if (graphics) {
186+
graphics->lock(locked);
187+
graphics->updateValue();
188+
}
189+
186190

187191
if (graphics && graphics->getGui().getType() == pd::Type::Comment)
188192
{
@@ -265,6 +269,11 @@ void Box::paint(Graphics& g)
265269
outlineColour = MainLook::highlightColour;
266270
}
267271

272+
if(!graphics || (graphics && graphics->fakeGui() && graphics->getGui().getType() != pd::Type::Comment)) {
273+
g.setColour(MainLook::firstBackground);
274+
g.fillRect(getLocalBounds().reduced(5));
275+
}
276+
268277
// Draw comment style
269278
if (graphics && graphics->getGui().getType() == pd::Type::Comment)
270279
{
@@ -278,9 +287,6 @@ void Box::paint(Graphics& g)
278287
// Draw for all other objects
279288
else
280289
{
281-
g.setColour(MainLook::firstBackground);
282-
g.fillRect(getLocalBounds().reduced(5));
283-
284290
g.setColour(outlineColour);
285291
g.drawRoundedRectangle(rect.toFloat(), 2.0f, 1.5f);
286292
}
@@ -336,7 +342,7 @@ void Box::resized()
336342
index++;
337343
}
338344

339-
resizer.toBack();
345+
resizer.toFront(false);
340346
}
341347

342348
void Box::updatePorts()

Source/Canvas.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ struct GraphArea : public Component, public ComponentDragger
168168
// Lock first?
169169
if (cnv)
170170
{
171-
cnv->gl_pixwidth = getWidth();
172-
cnv->gl_pixheight = getHeight();
171+
cnv->gl_pixwidth = getWidth() / pd::Patch::zoom;
172+
cnv->gl_pixheight = getHeight() / pd::Patch::zoom;
173173
cnv->gl_xmargin = (getX() - 4) / pd::Patch::zoom;
174174
cnv->gl_ymargin = (getY() - 4) / pd::Patch::zoom;
175175
}

Source/GUIObjects.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ BangComponent::BangComponent(const pd::Gui& pdGui, Box* parent) : GUIComponent(p
329329
};
330330

331331
initParameters(); // !! FIXME: virtual call from constructor!!
332-
box->restrainer.setSizeLimits(38, 38, 200, 200);
332+
box->restrainer.setSizeLimits(38, 38, 1200, 1200);
333333
box->restrainer.checkComponentBounds(box);
334334
}
335335

@@ -366,7 +366,7 @@ ToggleComponent::ToggleComponent(const pd::Gui& pdGui, Box* parent) : GUICompone
366366

367367
initParameters();
368368

369-
box->restrainer.setSizeLimits(38, 38, 200, 200);
369+
box->restrainer.setSizeLimits(38, 38, 1200, 1200);
370370
box->restrainer.checkComponentBounds(box);
371371
}
372372

@@ -1088,10 +1088,7 @@ void GraphOnParent::updateCanvas()
10881088
canvas->setBounds(-x, -y, w + x, h + y);
10891089

10901090
auto parentBounds = box->getBounds();
1091-
if (parentBounds.getWidth() != w - 8 || parentBounds.getHeight() != h - 29)
1092-
{
1093-
box->setSize(w + 8, h + 29);
1094-
}
1091+
box->setSize(w, h);
10951092
}
10961093
}
10971094

@@ -1131,9 +1128,6 @@ void Subpatch::updateValue()
11311128
if (static_cast<t_canvas*>(gui.getPointer())->gl_isgraph)
11321129
{
11331130
box->setType(box->textLabel.getText(), true);
1134-
1135-
// Makes sure it has the correct size
1136-
box->graphics->updateValue();
11371131
}
11381132
};
11391133

@@ -1157,10 +1151,13 @@ MousePad::MousePad(const pd::Gui& gui, Box* box) : GUIComponent(gui, box)
11571151
{
11581152
Desktop::getInstance().addGlobalMouseListener(this);
11591153
// setInterceptsMouseClicks(false, true);
1154+
1155+
box->textLabel.setVisible(false);
11601156
}
11611157

11621158
MousePad::~MousePad()
11631159
{
1160+
box->textLabel.setVisible(true);
11641161
Desktop::getInstance().removeGlobalMouseListener(this);
11651162
}
11661163

@@ -1174,7 +1171,7 @@ void MousePad::updateValue(){
11741171

11751172
void MousePad::mouseDown(const MouseEvent& e)
11761173
{
1177-
if (!getScreenBounds().contains(e.getScreenPosition())) return;
1174+
if (!getScreenBounds().contains(e.getScreenPosition()) || !isLocked) return;
11781175

11791176
auto* x = static_cast<t_pad*>(gui.getPointer());
11801177
t_atom at[3];
@@ -1200,7 +1197,7 @@ void MousePad::mouseDrag(const MouseEvent& e)
12001197

12011198
void MousePad::mouseMove(const MouseEvent& e)
12021199
{
1203-
if (!getScreenBounds().contains(e.getScreenPosition())) return;
1200+
if (!getScreenBounds().contains(e.getScreenPosition()) || !isLocked) return;
12041201

12051202
auto* x = static_cast<t_pad*>(gui.getPointer());
12061203
t_atom at[3];
@@ -1229,6 +1226,10 @@ void MousePad::mouseUp(const MouseEvent& e)
12291226
outlet_anything(x->x_obj.ob_outlet, gensym("click"), 1, at);
12301227
}
12311228

1229+
void MousePad::lock(bool locked) {
1230+
isLocked = locked;
1231+
}
1232+
12321233
MouseComponent::MouseComponent(const pd::Gui& gui, Box* box) : GUIComponent(gui, box)
12331234
{
12341235
Desktop::getInstance().addGlobalMouseListener(this);
@@ -1286,6 +1287,8 @@ KeyboardComponent::KeyboardComponent(const pd::Gui& gui, Box* box) : GUIComponen
12861287

12871288
state.addListener(this);
12881289
addAndMakeVisible(keyboard);
1290+
1291+
box->restrainer.setSizeLimits(50, 150, 1200, 1200);
12891292
}
12901293

12911294
void KeyboardComponent::resized()

Source/GUIObjects.h

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,30 +125,32 @@ struct GUIComponent : public Component, public ComponentListener
125125
{
126126
auto& [parameters, cb] = params;
127127

128-
parameters.insert(parameters.begin(), {"Width", tInt, static_cast<void*>(&width)});
129-
parameters.insert(parameters.begin() + 1, {"Send Symbol", tString, static_cast<void*>(&sendSymbol)});
130-
parameters.insert(parameters.begin() + 2, {"Receive Symbol", tString, static_cast<void*>(&receiveSymbol)});
128+
//parameters.insert(parameters.begin(), {"Width", tInt, static_cast<void*>(&width)});
129+
130+
parameters.insert(parameters.begin(), {"Send Symbol", tString, static_cast<void*>(&sendSymbol)});
131+
parameters.insert(parameters.begin() + 1, {"Receive Symbol", tString, static_cast<void*>(&receiveSymbol)});
131132

132133
auto oldCallback = cb;
133134
cb = [this, oldCallback](int changedParameter)
134135
{
136+
/*
135137
if (changedParameter == 0)
136138
{
137139
// Width
138-
}
139-
else if (changedParameter == 1)
140+
} */
141+
if (changedParameter == 0)
140142
{
141143
gui.setSendSymbol(sendSymbol.toStdString());
142144
repaint();
143145
}
144-
else if (changedParameter == 2)
146+
else if (changedParameter == 1)
145147
{
146148
gui.setReceiveSymbol(receiveSymbol.toStdString());
147149
repaint();
148150
}
149151
else
150152
{
151-
oldCallback(changedParameter - 3);
153+
oldCallback(changedParameter - 2);
152154
}
153155
};
154156
}
@@ -854,6 +856,9 @@ struct PanelComponent : public GUIComponent
854856
// ELSE mousepad
855857
struct MousePad : public GUIComponent
856858
{
859+
860+
bool isLocked = false;
861+
857862
typedef struct _pad
858863
{
859864
t_object x_obj;
@@ -875,6 +880,8 @@ struct MousePad : public GUIComponent
875880
~MousePad() override;
876881

877882
void paint(Graphics& g) override;
883+
884+
void lock(bool isLocked) override;
878885

879886
void updateValue() override;
880887

Source/Pd/PdObject.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ Patch Object::getHelp() const
131131
if (File(usedir).getChildFile(realname).existsAsFile())
132132
{
133133
sys_lock();
134-
auto p = Patch(glob_evalfile(nullptr, gensym(realname), gensym(usedir)), instance);
134+
auto* pdPatch = glob_evalfile(nullptr, gensym(realname), gensym(usedir));
135135
sys_unlock();
136-
return p;
136+
return {pdPatch, instance};
137137
}
138138

139139
/* 2. "help-objectname.pd" */
@@ -144,9 +144,9 @@ Patch Object::getHelp() const
144144
if (File(dir).getChildFile(realname).existsAsFile())
145145
{
146146
sys_lock();
147-
auto p = Patch(glob_evalfile(nullptr, gensym(realname), gensym(usedir)), instance);
147+
auto* pdPatch = glob_evalfile(nullptr, gensym(realname), gensym(usedir));
148148
sys_unlock();
149-
return p;
149+
return {pdPatch, instance};
150150
}
151151

152152
return {};

Source/Pd/PdPatch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ std::array<int, 4> Patch::getBounds() const noexcept
9393

9494
if (cnv->gl_isgraph)
9595
{
96-
return {int(cnv->gl_xmargin * Patch::zoom) + 4, int(cnv->gl_ymargin * Patch::zoom) + 4, cnv->gl_pixwidth, cnv->gl_pixheight};
96+
return {int(cnv->gl_xmargin * Patch::zoom) + 4, int(cnv->gl_ymargin * Patch::zoom) + 4, int(cnv->gl_pixwidth * Patch::zoom), int(cnv->gl_pixheight * Patch::zoom)};
9797
}
9898
}
9999
return {0, 0, 0, 0};

Source/PluginConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
namespace ProjectInfo
1414
{
1515
const char* const companyName = "Octagon";
16-
const char* const versionString = "0.3";
16+
const char* const versionString = "0.3.1";
1717
} // namespace ProjectInfo

0 commit comments

Comments
 (0)