summaryrefslogtreecommitdiff
path: root/plugingui
diff options
context:
space:
mode:
authorAndré Nusser <andre.nusser@googlemail.com>2017-04-01 19:01:25 +0200
committerAndré Nusser <andre.nusser@googlemail.com>2017-04-01 19:01:25 +0200
commit1f41de14a04240dfd993b030306ac251d962a843 (patch)
tree08d5ef8b74793909a15cb8f3c0b7732819a41f8a /plugingui
parent4739f0bed6e6332fcf2c6ed2b04c4ae161c41060 (diff)
Fix a lot of style issues in the code for the new GUI.
Diffstat (limited to 'plugingui')
-rw-r--r--plugingui/checkbox.cc11
-rw-r--r--plugingui/diskstreamingframecontent.cc8
-rw-r--r--plugingui/diskstreamingframecontent.h9
-rw-r--r--plugingui/drumkitframecontent.cc6
-rw-r--r--plugingui/drumkitframecontent.h27
-rw-r--r--plugingui/frame.cc24
-rw-r--r--plugingui/frame.h13
-rw-r--r--plugingui/humanizerframecontent.cc10
-rw-r--r--plugingui/humanizerframecontent.h11
-rw-r--r--plugingui/maintab.cc6
-rw-r--r--plugingui/powerbutton.cc21
-rw-r--r--plugingui/powerbutton.h7
-rw-r--r--plugingui/slider.cc23
-rw-r--r--plugingui/slider.h9
-rw-r--r--plugingui/statusframecontent.cc6
-rw-r--r--plugingui/statusframecontent.h5
-rw-r--r--plugingui/testmain.cc6
-rw-r--r--plugingui/tests/framewidgettest.cc32
-rw-r--r--plugingui/textedit.cc31
-rw-r--r--plugingui/toggle.cc3
-rw-r--r--plugingui/toggle.h8
21 files changed, 147 insertions, 129 deletions
diff --git a/plugingui/checkbox.cc b/plugingui/checkbox.cc
index 0f101ec..a6d52a1 100644
--- a/plugingui/checkbox.cc
+++ b/plugingui/checkbox.cc
@@ -32,10 +32,10 @@ namespace GUI
{
CheckBox::CheckBox(Widget* parent)
- : Toggle(parent)
- , bg_on(getImageCache(), ":switch_back_on.png")
- , bg_off(getImageCache(), ":switch_back_off.png")
- , knob(getImageCache(), ":switch_front.png")
+ : Toggle(parent)
+ , bg_on(getImageCache(), ":switch_back_on.png")
+ , bg_off(getImageCache(), ":switch_back_off.png")
+ , knob(getImageCache(), ":switch_front.png")
{
}
@@ -44,7 +44,8 @@ void CheckBox::repaintEvent(RepaintEvent* repaintEvent)
Painter p(*this);
p.clear();
- p.drawImage(0, (knob.height() - bg_on.height()) / 2, state ? bg_on : bg_off);
+ p.drawImage(
+ 0, (knob.height() - bg_on.height()) / 2, state ? bg_on : bg_off);
if(clicked)
{
diff --git a/plugingui/diskstreamingframecontent.cc b/plugingui/diskstreamingframecontent.cc
index 0d17aaf..bb4cfc3 100644
--- a/plugingui/diskstreamingframecontent.cc
+++ b/plugingui/diskstreamingframecontent.cc
@@ -26,11 +26,11 @@
*/
#include "diskstreamingframecontent.h"
-namespace GUI {
+namespace GUI
+{
DiskstreamingframeContent::DiskstreamingframeContent(Widget* parent)
- : Widget(parent)
- , slider_width{250}
+ : Widget(parent), slider_width{250}
{
label_text.setText("Cache limit (max memory usage):");
label_text.setAlignment(TextAlignment::center);
@@ -48,7 +48,7 @@ void DiskstreamingframeContent::resize(std::size_t width, std::size_t height)
slider_width = 0.8 * width;
button_width = width - slider_width;
- label_text.move(0,0);
+ label_text.move(0, 0);
slider.move(0, 20);
button.move(slider_width, 10);
label_size.move(0, 40);
diff --git a/plugingui/diskstreamingframecontent.h b/plugingui/diskstreamingframecontent.h
index 33afcf8..5c1fad0 100644
--- a/plugingui/diskstreamingframecontent.h
+++ b/plugingui/diskstreamingframecontent.h
@@ -26,12 +26,13 @@
*/
#pragma once
-#include "widget.h"
-#include "slider.h"
-#include "label.h"
#include "button.h"
+#include "label.h"
+#include "slider.h"
+#include "widget.h"
-namespace GUI {
+namespace GUI
+{
class DiskstreamingframeContent : public Widget
{
diff --git a/plugingui/drumkitframecontent.cc b/plugingui/drumkitframecontent.cc
index 8b2b828..3a87fbe 100644
--- a/plugingui/drumkitframecontent.cc
+++ b/plugingui/drumkitframecontent.cc
@@ -28,10 +28,10 @@
#include "label.h"
-namespace GUI {
+namespace GUI
+{
-DrumkitframeContent::DrumkitframeContent(Widget* parent)
- : Widget(parent)
+DrumkitframeContent::DrumkitframeContent(Widget* parent) : Widget(parent)
{
layout.setHAlignment(HAlignment::left);
diff --git a/plugingui/drumkitframecontent.h b/plugingui/drumkitframecontent.h
index b5b929c..9533bd2 100644
--- a/plugingui/drumkitframecontent.h
+++ b/plugingui/drumkitframecontent.h
@@ -26,22 +26,20 @@
*/
#pragma once
-#include "widget.h"
-#include "lineedit.h"
-#include "progressbar.h"
#include "button.h"
#include "label.h"
+#include "lineedit.h"
+#include "progressbar.h"
+#include "widget.h"
namespace GUI
{
// TODO: move to own class?
-class File
- : public Widget
+class File : public Widget
{
public:
- File(Widget* parent)
- : Widget(parent)
+ File(Widget* parent) : Widget(parent)
{
layout.setResizeChildren(false);
layout.setVAlignment(VAlignment::center);
@@ -66,8 +64,14 @@ public:
layout.layout();
}
- std::size_t getLineEditWidth() { return lineedit_width; }
- std::size_t getButtonWidth() { return button_width; }
+ std::size_t getLineEditWidth()
+ {
+ return lineedit_width;
+ }
+ std::size_t getButtonWidth()
+ {
+ return button_width;
+ }
private:
HBoxLayout layout{this};
@@ -78,7 +82,10 @@ private:
std::size_t lineedit_width;
std::size_t button_width;
- LineEdit& getLineEdit() { return lineedit; }
+ LineEdit& getLineEdit()
+ {
+ return lineedit;
+ }
};
class DrumkitframeContent : public Widget
diff --git a/plugingui/frame.cc b/plugingui/frame.cc
index df468dd..ea2bfe3 100644
--- a/plugingui/frame.cc
+++ b/plugingui/frame.cc
@@ -31,24 +31,24 @@
namespace GUI
{
-FrameWidget::FrameWidget(Widget *parent, bool has_switch)
- : Widget(parent)
- , is_switched_on(!has_switch)
- , bar_height(24)
+FrameWidget::FrameWidget(Widget* parent, bool has_switch)
+ : Widget(parent), is_switched_on(!has_switch), bar_height(24)
{
- if (has_switch) {
+ if(has_switch)
+ {
// We only have to set this once as nothing happens on a resize
power_button.move(4, 4);
power_button.resize(16, 16);
- CONNECT(&power_button, stateChangedNotifier, this, &FrameWidget::powerButtonClicked);
+ CONNECT(&power_button, stateChangedNotifier, this,
+ &FrameWidget::powerButtonClicked);
}
power_button.setVisible(has_switch);
CONNECT(this, sizeChangeNotifier, this, &FrameWidget::sizeChanged);
}
-void FrameWidget::repaintEvent(RepaintEvent* repaintEvent)
+void FrameWidget::repaintEvent(RepaintEvent* repaintEvent)
{
Painter p(*this);
p.clear();
@@ -77,7 +77,8 @@ void FrameWidget::powerButtonClicked(bool clicked)
{
is_switched_on = !is_switched_on;
- if (content) {
+ if(content)
+ {
content->setVisible(true);
}
}
@@ -97,11 +98,12 @@ void FrameWidget::setContent(Widget* content)
void FrameWidget::sizeChanged(int width, int height)
{
- if (content) {
+ if(content)
+ {
content_start_x = content_margin;
content_start_y = bar_height + content_margin;
- content_width = width - 2*content_margin;
- content_height = height - (bar_height + 2*content_margin);
+ content_width = width - 2 * content_margin;
+ content_height = height - (bar_height + 2 * content_margin);
content->move(content_start_x, content_start_y);
content->resize(content_width, content_height);
diff --git a/plugingui/frame.h b/plugingui/frame.h
index c891b59..e8c8778 100644
--- a/plugingui/frame.h
+++ b/plugingui/frame.h
@@ -26,13 +26,15 @@
*/
#pragma once
-#include "widget.h"
#include "font.h"
#include "powerbutton.h"
+#include "widget.h"
-namespace GUI {
+namespace GUI
+{
-class FrameWidget : public Widget {
+class FrameWidget : public Widget
+{
public:
FrameWidget(Widget* parent, bool has_switch = false);
virtual ~FrameWidget() = default;
@@ -42,6 +44,7 @@ public:
virtual bool catchMouse() override { return false; }
bool isSwitchedOn() { return is_switched_on; }
+
void setTitle(std::string const& title);
void setContent(Widget* content);
@@ -73,14 +76,14 @@ private:
std::size_t bar_height;
GUI::Colour grey_box_colour{0.7};
GUI::Colour background_colour{0.85, 0.8};
-
+
//
// content
//
// content frame
GUI::Colour frame_colour{0};
-
+
// content box
Widget* content{nullptr};
std::size_t content_margin{5};
diff --git a/plugingui/humanizerframecontent.cc b/plugingui/humanizerframecontent.cc
index aaa1167..6a01b7b 100644
--- a/plugingui/humanizerframecontent.cc
+++ b/plugingui/humanizerframecontent.cc
@@ -28,10 +28,10 @@
#include "painter.h"
-namespace GUI {
+namespace GUI
+{
-HumanizerframeContent::HumanizerframeContent(Widget* parent)
- : Widget(parent)
+HumanizerframeContent::HumanizerframeContent(Widget* parent) : Widget(parent)
{
// FIXME, is resizeChildren broken?
layout.setResizeChildren(true);
@@ -50,10 +50,10 @@ HumanizerframeContent::HumanizerframeContent(Widget* parent)
// TODO: connect the knobs to the right functions
// CONNECT(&humanizeControls->velocityCheck, stateChangedNotifier,
// this, &DGWindow::velocityCheckClick);
- //
+ //
// CONNECT(&humanizeControls->attackKnob, valueChangedNotifier,
// this, &DGWindow::attackValueChanged);
- //
+ //
// CONNECT(&humanizeControls->falloffKnob, valueChangedNotifier,
// this, &DGWindow::falloffValueChanged);
}
diff --git a/plugingui/humanizerframecontent.h b/plugingui/humanizerframecontent.h
index 29f76ab..ddbcf6a 100644
--- a/plugingui/humanizerframecontent.h
+++ b/plugingui/humanizerframecontent.h
@@ -26,19 +26,18 @@
*/
#pragma once
-#include "widget.h"
#include "knob.h"
#include "label.h"
+#include "widget.h"
-namespace GUI {
+namespace GUI
+{
// TODO move this to an own file?
-class LabeledControl
- : public Widget
+class LabeledControl : public Widget
{
public:
- LabeledControl(Widget* parent, const std::string& name)
- : Widget(parent)
+ LabeledControl(Widget* parent, const std::string& name) : Widget(parent)
{
layout.setResizeChildren(false);
layout.setHAlignment(HAlignment::center);
diff --git a/plugingui/maintab.cc b/plugingui/maintab.cc
index b6dc448..f450bc0 100644
--- a/plugingui/maintab.cc
+++ b/plugingui/maintab.cc
@@ -26,10 +26,10 @@
*/
#include "maintab.h"
-namespace GUI {
+namespace GUI
+{
-MainTab::MainTab(Widget* parent)
- : Widget(parent)
+MainTab::MainTab(Widget* parent) : Widget(parent)
{
layout.setSpacing(10);
layout.setResizeChildren(true);
diff --git a/plugingui/powerbutton.cc b/plugingui/powerbutton.cc
index aee7bd6..85ef0a3 100644
--- a/plugingui/powerbutton.cc
+++ b/plugingui/powerbutton.cc
@@ -31,8 +31,7 @@
namespace GUI
{
-PowerButton::PowerButton(Widget* parent)
- : Toggle(parent)
+PowerButton::PowerButton(Widget* parent) : Toggle(parent)
{
}
@@ -41,19 +40,25 @@ void PowerButton::repaintEvent(RepaintEvent* repaintEvent)
Painter p(*this);
p.clear();
- if (state) {
- if (clicked) {
+ if(state)
+ {
+ if(clicked)
+ {
p.drawImage(0, 0, on_clicked);
}
- else {
+ else
+ {
p.drawImage(0, 0, on);
}
}
- else {
- if (clicked) {
+ else
+ {
+ if(clicked)
+ {
p.drawImage(0, 0, off_clicked);
}
- else {
+ else
+ {
p.drawImage(0, 0, off);
}
}
diff --git a/plugingui/powerbutton.h b/plugingui/powerbutton.h
index 978fab4..47b3ca1 100644
--- a/plugingui/powerbutton.h
+++ b/plugingui/powerbutton.h
@@ -26,15 +26,16 @@
*/
#pragma once
-#include "toggle.h"
#include "texture.h"
+#include "toggle.h"
namespace GUI
{
-class PowerButton : public Toggle {
+class PowerButton : public Toggle
+{
public:
- PowerButton(Widget *parent);
+ PowerButton(Widget* parent);
virtual ~PowerButton() = default;
protected:
diff --git a/plugingui/slider.cc b/plugingui/slider.cc
index c657eb1..16808bb 100644
--- a/plugingui/slider.cc
+++ b/plugingui/slider.cc
@@ -31,10 +31,10 @@
#include <hugin.hpp>
#include <stdio.h>
-namespace GUI {
+namespace GUI
+{
-Slider::Slider(Widget *parent)
- : Widget(parent)
+Slider::Slider(Widget* parent) : Widget(parent)
{
state = State::up;
@@ -72,21 +72,21 @@ void Slider::repaintEvent(RepaintEvent* repaintEvent)
p.setColour(Colour(0.5, alpha));
}
- p.drawFilledRectangle(0,0,width(),height());
+ p.drawFilledRectangle(0, 0, width(), height());
- //p.setColour(Colour(0.1, alpha));
- //p.drawRectangle(0,0,width()-1,height() - 1);
+ // p.setColour(Colour(0.1, alpha));
+ // p.drawRectangle(0,0,width()-1,height() - 1);
p.setColour(Colour(1, 0, 0, alpha));
p.drawLine(xpos, 0, xpos, height() - 1);
- //p.setColour(Colour(0.8, alpha));
- //switch(state) {
- //case State::up:
+ // p.setColour(Colour(0.8, alpha));
+ // switch(state) {
+ // case State::up:
// p.drawLine(0, 0, 0, height() - 1);
// p.drawLine(0, 0, width() - 1, 0);
// break;
- //case State::down:
+ // case State::down:
// p.drawLine(width() - 1, 0, width() - 1, height() - 1);
// p.drawLine(width() - 1, height() - 1, 0, height() - 1);
// break;
@@ -94,7 +94,8 @@ void Slider::repaintEvent(RepaintEvent* repaintEvent)
p.setColour(Colour(0.3, alpha));
- if (height() > 0 && width() > 0) {
+ if(height() > 0 && width() > 0)
+ {
p.drawPoint(0, height() - 1);
p.drawPoint(width() - 1, 0);
}
diff --git a/plugingui/slider.h b/plugingui/slider.h
index 98d10f1..f11efba 100644
--- a/plugingui/slider.h
+++ b/plugingui/slider.h
@@ -28,9 +28,11 @@
#include "widget.h"
-namespace GUI {
+namespace GUI
+{
-class Slider : public Widget {
+class Slider : public Widget
+{
public:
Slider(Widget* parent);
virtual ~Slider() = default;
@@ -50,7 +52,8 @@ protected:
virtual void mouseMoveEvent(MouseMoveEvent* mouseMoveEvent) override;
private:
- enum class State {
+ enum class State
+ {
up,
down
};
diff --git a/plugingui/statusframecontent.cc b/plugingui/statusframecontent.cc
index 2f87dec..33a1367 100644
--- a/plugingui/statusframecontent.cc
+++ b/plugingui/statusframecontent.cc
@@ -26,10 +26,10 @@
*/
#include "statusframecontent.h"
-namespace GUI {
+namespace GUI
+{
-StatusframeContent::StatusframeContent(Widget* parent)
- : Widget(parent)
+StatusframeContent::StatusframeContent(Widget* parent) : Widget(parent)
{
text_field.move(0, 0);
text_field.setText("This is a status message.");
diff --git a/plugingui/statusframecontent.h b/plugingui/statusframecontent.h
index c61f716..020855c 100644
--- a/plugingui/statusframecontent.h
+++ b/plugingui/statusframecontent.h
@@ -26,10 +26,11 @@
*/
#pragma once
-#include "widget.h"
#include "textedit.h"
+#include "widget.h"
-namespace GUI {
+namespace GUI
+{
class StatusframeContent : public Widget
{
diff --git a/plugingui/testmain.cc b/plugingui/testmain.cc
index 79356e2..0e948c0 100644
--- a/plugingui/testmain.cc
+++ b/plugingui/testmain.cc
@@ -35,8 +35,8 @@
#include <hugin.hpp>
#include <settings.h>
-#include "window.h"
#include "mainwindow.h"
+#include "window.h"
int main()
{
@@ -47,8 +47,8 @@ int main()
Settings settings;
GUI::MainWindow main_window(settings, parent.getNativeWindowHandle());
- CONNECT(&parent, eventHandler()->closeNotifier,
- &main_window, &GUI::MainWindow::closeEventHandler);
+ CONNECT(&parent, eventHandler()->closeNotifier, &main_window,
+ &GUI::MainWindow::closeEventHandler);
parent.show();
main_window.show();
diff --git a/plugingui/tests/framewidgettest.cc b/plugingui/tests/framewidgettest.cc
index 5dff73c..5a22c51 100644
--- a/plugingui/tests/framewidgettest.cc
+++ b/plugingui/tests/framewidgettest.cc
@@ -34,22 +34,20 @@
#endif
#include <unistd.h>
-#include <hugin.hpp>
-#include <window.h>
+#include <button.h>
+#include <checkbox.h>
#include <frame.h>
+#include <hugin.hpp>
#include <label.h>
#include <layout.h>
-#include <button.h>
-#include <checkbox.h>
+#include <window.h>
// TODO: fix segfault on close
-class Widget1
- : public GUI::Widget
+class Widget1 : public GUI::Widget
{
public:
- Widget1(GUI::Widget* parent)
- : GUI::Widget(parent)
+ Widget1(GUI::Widget* parent) : GUI::Widget(parent)
{
layout.setResizeChildren(true);
layout.setHAlignment(GUI::HAlignment::center);
@@ -74,12 +72,10 @@ private:
GUI::Label label3{this};
};
-class Widget2
- : public GUI::Widget
+class Widget2 : public GUI::Widget
{
public:
- Widget2(GUI::Widget* parent)
- : GUI::Widget(parent)
+ Widget2(GUI::Widget* parent) : GUI::Widget(parent)
{
layout.setSpacing(10);
layout.setResizeChildren(true);
@@ -103,16 +99,14 @@ private:
GUI::CheckBox checkbox{this};
};
-class TestWindow
- : public GUI::Window
+class TestWindow : public GUI::Window
{
public:
- TestWindow()
- : GUI::Window(nullptr)
+ TestWindow() : GUI::Window(nullptr)
{
setCaption("FrameWidgetTest Window");
- CONNECT(eventHandler(), closeNotifier,
- this, &TestWindow::closeEventHandler);
+ CONNECT(eventHandler(), closeNotifier, this,
+ &TestWindow::closeEventHandler);
CONNECT(this, sizeChangeNotifier, this, &TestWindow::sizeChanged);
layout.setSpacing(10);
@@ -181,7 +175,7 @@ int main()
TestWindow test_window;
test_window.show();
- test_window.resize(300,300);
+ test_window.resize(300, 300);
while(test_window.processEvents())
{
diff --git a/plugingui/textedit.cc b/plugingui/textedit.cc
index e8661d7..9ef21ec 100644
--- a/plugingui/textedit.cc
+++ b/plugingui/textedit.cc
@@ -29,17 +29,16 @@
#include "window.h"
#include <assert.h>
-#include <list>
#include <hugin.hpp>
+#include <list>
#include <stdio.h>
#define BORDER 10
-namespace GUI {
+namespace GUI
+{
-TextEdit::TextEdit(Widget *parent)
- : Widget(parent)
- , scroll(this)
+TextEdit::TextEdit(Widget* parent) : Widget(parent), scroll(this)
{
setReadOnly(true);
@@ -55,8 +54,8 @@ TextEdit::~TextEdit()
void TextEdit::resize(std::size_t width, std::size_t height)
{
Widget::resize(width, height);
- scroll.resize(scroll.width(), height-14);
- scroll.move(width-30,7);
+ scroll.resize(scroll.width(), height - 14);
+ scroll.move(width - 30, 7);
}
void TextEdit::setReadOnly(bool readonly)
@@ -78,7 +77,7 @@ void TextEdit::setText(const std::string& text)
int ran = height() / font.textHeight();
DEBUG(textedit, "Setting range and max of scrollbar to '%d' and '%d'\n",
- ran, (int)preprocessedtext.size());
+ ran, (int)preprocessedtext.size());
scroll.setRange(ran);
scroll.setMaximum(preprocessedtext.size());
@@ -117,9 +116,8 @@ void TextEdit::preprocessText()
{
pos = text.find("\n");
lines.push_back(text.substr(0, pos));
- text = text.substr(pos+1);
- }
- while(pos != std::string::npos);
+ text = text.substr(pos + 1);
+ } while(pos != std::string::npos);
}
{ // Wrap long lines
@@ -131,7 +129,8 @@ void TextEdit::preprocessText()
for(size_t i = 0; i < line.length(); ++i)
{
size_t linewidth = font.textWidth(line.substr(0, i));
- if(linewidth >= width() - BORDER - 4 + 3 - 10 - scroll.width()) {
+ if(linewidth >= width() - BORDER - 4 + 3 - 10 - scroll.width())
+ {
preprocessedtext.push_back(line.substr(0, i));
line = line.substr(i);
i = 0;
@@ -156,9 +155,9 @@ void TextEdit::repaintEvent(RepaintEvent* repaintEvent)
}
box.setSize(w, h);
- p.drawImage(0,0, box);
+ p.drawImage(0, 0, box);
- p.setColour(Colour(183.0 / 255.0, 219.0 / 255.0 , 255.0 / 255.0, 1));
+ p.setColour(Colour(183.0 / 255.0, 219.0 / 255.0, 255.0 / 255.0, 1));
int skip = scroll.value();
@@ -167,13 +166,13 @@ void TextEdit::repaintEvent(RepaintEvent* repaintEvent)
it = preprocessedtext.begin();
int c = 0;
- for( ; c < skip; c++)
+ for(; c < skip; c++)
{
++it;
}
c = 0;
- for( ; it != preprocessedtext.end(); it++)
+ for(; it != preprocessedtext.end(); it++)
{
if((c * font.textHeight()) >= (height() - 8 - font.textHeight()))
{
diff --git a/plugingui/toggle.cc b/plugingui/toggle.cc
index 8168534..6fdb6bc 100644
--- a/plugingui/toggle.cc
+++ b/plugingui/toggle.cc
@@ -29,8 +29,7 @@
namespace GUI
{
-Toggle::Toggle(Widget* parent)
- : Widget(parent)
+Toggle::Toggle(Widget* parent) : Widget(parent)
{
}
diff --git a/plugingui/toggle.h b/plugingui/toggle.h
index b11db33..b599ced 100644
--- a/plugingui/toggle.h
+++ b/plugingui/toggle.h
@@ -30,11 +30,13 @@
#include <notifier.h>
-namespace GUI {
+namespace GUI
+{
-class Toggle : public Widget {
+class Toggle : public Widget
+{
public:
- Toggle(Widget *parent);
+ Toggle(Widget* parent);
virtual ~Toggle() = default;
void setText(std::string text);