summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOrcan Ogetbil <oget.fedora@gmail.com>2011-09-14 03:02:14 +0000
committerOrcan Ogetbil <oget.fedora@gmail.com>2011-09-14 03:02:14 +0000
commit42269af2e0cc7a8c7b70d89ffa270184acde3dec (patch)
tree724d299da6d46185decd87e25b830d1be740be0c
parent725b1d96a20557856fc1ceaf3d886bdd2f816826 (diff)
The sizeHint of Slider is respected, and the plugin window now has a reasonable width. Scale support commented out in Slider.
-rw-r--r--muse2/ChangeLog3
-rw-r--r--muse2/muse/plugin.cpp7
-rw-r--r--muse2/muse/widgets/meter.cpp6
-rw-r--r--muse2/muse/widgets/slider.cpp47
-rw-r--r--muse2/muse/widgets/slider.h8
-rw-r--r--muse2/muse/widgets/verticalmeter.cpp6
6 files changed, 56 insertions, 21 deletions
diff --git a/muse2/ChangeLog b/muse2/ChangeLog
index b798bdeb..e0d39301 100644
--- a/muse2/ChangeLog
+++ b/muse2/ChangeLog
@@ -1,3 +1,6 @@
+13.09.2011:
+ - Made Slider::sizeHint() a const function again, so that the plugin window respects its sizeHint. (Orcan)
+ - Explicitly disabled the scale support in Slider since it wasn't really in use for a while. (Orcan)
11.09.2011:
- Rewrote the rounding function for efficientcy. Moved the function into utils.cpp since it is written
for general purpose. (Orcan)
diff --git a/muse2/muse/plugin.cpp b/muse2/muse/plugin.cpp
index 00b75dce..e2170ebb 100644
--- a/muse2/muse/plugin.cpp
+++ b/muse2/muse/plugin.cpp
@@ -3611,7 +3611,7 @@ PluginGui::PluginGui(PluginIBase* p)
s->setCursorHoming(true);
s->setId(i);
- //s->setFixedHeight(h);
+ s->setSizeHint(200, 8);
s->setRange(dlower, dupper);
if(LADSPA_IS_HINT_INTEGER(range.HintDescriptor))
s->setStep(1.0);
@@ -3620,7 +3620,7 @@ PluginGui::PluginGui(PluginIBase* p)
params[i].label->setSlider((MusEWidget::Slider*)params[i].actuator);
}
//params[i].actuator->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum));
- params[i].actuator->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
+ params[i].actuator->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed));
if (params[i].type == GuiParam::GUI_SLIDER) {
//label->setFixedHeight(20);
//label->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum));
@@ -3696,9 +3696,6 @@ PluginGui::PluginGui(PluginIBase* p)
}
- // p3.3.43
- resize(280, height());
-
grid->setColumnStretch(2, 10);
mw->setLayout(grid);
view->setWidget(mw);
diff --git a/muse2/muse/widgets/meter.cpp b/muse2/muse/widgets/meter.cpp
index e316a52a..239f7655 100644
--- a/muse2/muse/widgets/meter.cpp
+++ b/muse2/muse/widgets/meter.cpp
@@ -182,7 +182,7 @@ void Meter::setRange(double min, double max)
// paintEvent
//---------------------------------------------------------
-void Meter::paintEvent(QPaintEvent* ev)
+void Meter::paintEvent(QPaintEvent* /*ev*/)
{
// TODO: Could make better use of event rectangle, for speed.
@@ -192,14 +192,14 @@ void Meter::paintEvent(QPaintEvent* ev)
double range = maxScale - minScale;
int fw = frameWidth();
- /*
int w = width() - 2*fw;
int h = height() - 2*fw;
- */
+ /*
QRect rect = ev->rect();
int w = rect.width() - 2*fw;
int h = rect.height() - 2*fw;
+ */
int yv;
if(mtype == DBMeter)
diff --git a/muse2/muse/widgets/slider.cpp b/muse2/muse/widgets/slider.cpp
index b9803fca..593b3df6 100644
--- a/muse2/muse/widgets/slider.cpp
+++ b/muse2/muse/widgets/slider.cpp
@@ -57,7 +57,7 @@ namespace MusEWidget {
// Defaults to Horizontal.
// ScalePos scalePos -- Position of the scale. Can be Slider::None,
// Slider::Left, Slider::Right, Slider::Top,
-// or Slider::Bottom. Defaults to Slider::None.
+// or Slider::Bottom. Defaults to Slider::None. !!! CURRENTLY only Slider::None supported - oget 20110913
// QColor fillcolor -- the color used to fill in the full side
// of the Slider
//------------------------------------------------------------
@@ -85,6 +85,16 @@ Slider::Slider(QWidget *parent, const char *name,
}
//------------------------------------------------------------
+//.F Slider::setSizeHint
+//------------------------------------------------------------
+
+void Slider::setSizeHint(uint w, uint h)
+ {
+ horizontal_hint = w;
+ vertical_hint = h;
+ }
+
+//------------------------------------------------------------
//.F Slider::~Slider
// Destructor
//.u Syntax
@@ -540,10 +550,11 @@ void Slider::getScrollMode( QPoint &p, const Qt::MouseButton &button, int &scrol
//.f void Slider::paintEvent(QPaintEvent *e)
//------------------------------------------------------------
-void Slider::paintEvent(QPaintEvent* /*e*/)
+void Slider::paintEvent(QPaintEvent* /*ev*/)
{
- QPainter p;
+ QPainter p(this);
+ /* Scale is not supported
if (p.begin(this)) {
if (d_scalePos != None) {
p.fillRect(rect(), palette().window());
@@ -552,6 +563,8 @@ void Slider::paintEvent(QPaintEvent* /*e*/)
drawSlider(&p, d_sliderRect);
}
p.end();
+ */
+ drawSlider(&p, d_sliderRect);
}
//------------------------------------------------------------
@@ -570,6 +583,7 @@ void Slider::resizeEvent(QResizeEvent *e)
d_resized = TRUE;
QSize s = e->size();
+ /* Scale is not supported
int sliderWidth = d_thumbWidth;
// reposition slider
@@ -642,8 +656,10 @@ void Slider::resizeEvent(QResizeEvent *e)
s.width(), s.height());
break;
}
-
}
+ */
+ d_sliderRect.setRect(this->rect().x(), this->rect().y(),
+ s.width(), s.height());
}
//------------------------------------------------------------
@@ -714,13 +730,14 @@ void Slider::setMargins(int hor, int vert)
// scale.
//------------------------------------------------------------
-QSize Slider::sizeHint() //const ddskrjo
+QSize Slider::sizeHint() const
{
+ /* Scale is not supported
+ int w = 40;
+ int h = 40;
QPainter p;
int msWidth = 0, msHeight = 0;
- int w = 40;
- int h = 40;
if (d_scalePos != None) {
if (p.begin(this)) {
msWidth = d_scale.maxWidth(&p, FALSE);
@@ -747,7 +764,8 @@ QSize Slider::sizeHint() //const ddskrjo
break;
}
}
- return QSize(w, h);
+ */
+ return QSize(horizontal_hint, vertical_hint);
}
//---------------------------------------------------------
@@ -757,6 +775,7 @@ QSize Slider::sizeHint() //const ddskrjo
void Slider::setOrientation(Qt::Orientation o)
{
d_orient = o;
+ /* Scale is not supported
ScaleDraw::OrientationX so = ScaleDraw::Bottom;
switch(d_orient) {
case Qt::Vertical:
@@ -781,6 +800,18 @@ void Slider::setOrientation(Qt::Orientation o)
QRect r = geometry();
setGeometry(r.x(), r.y(), r.height(), r.width());
update();
+ */
+
+ switch(d_orient) {
+ case Qt::Vertical:
+ horizontal_hint = 16;
+ vertical_hint = 64;
+ break;
+ case Qt::Horizontal:
+ horizontal_hint = 64;
+ vertical_hint = 16;
+ break;
+ }
}
Qt::Orientation Slider::orientation() const
diff --git a/muse2/muse/widgets/slider.h b/muse2/muse/widgets/slider.h
index 861d8f4b..5a2bff71 100644
--- a/muse2/muse/widgets/slider.h
+++ b/muse2/muse/widgets/slider.h
@@ -69,6 +69,9 @@ class Slider : public SliderBase, public ScaleIf
int d_bgStyle;
int markerPos;
+ uint vertical_hint;
+ uint horizontal_hint;
+
void drawHsBgSlot(QPainter *, const QRect&, const QRect&,const QBrush&);
void drawVsBgSlot(QPainter *, const QRect&, const QRect&,const QBrush&);
@@ -102,8 +105,9 @@ class Slider : public SliderBase, public ScaleIf
void setLineStep(double);
void setPageStep(double);
- void setMargins(int x, int y);
- QSize sizeHint(); // const;
+ void setMargins(int x, int y);
+ virtual QSize sizeHint() const;
+ void setSizeHint(uint w, uint h);
};
} // namespace MusEWidget
diff --git a/muse2/muse/widgets/verticalmeter.cpp b/muse2/muse/widgets/verticalmeter.cpp
index 83baa83b..74b4b695 100644
--- a/muse2/muse/widgets/verticalmeter.cpp
+++ b/muse2/muse/widgets/verticalmeter.cpp
@@ -130,7 +130,7 @@ void VerticalMeter::setRange(double min, double max)
// paintEvent
//---------------------------------------------------------
-void VerticalMeter::paintEvent(QPaintEvent* ev)
+void VerticalMeter::paintEvent(QPaintEvent* /*ev*/)
{
// TODO: Could make better use of event rectangle, for speed.
@@ -140,14 +140,14 @@ void VerticalMeter::paintEvent(QPaintEvent* ev)
double range = maxScale - minScale;
int fw = frameWidth();
- /*
int w = width() - 2*fw;
int h = height() - 2*fw;
- */
+ /*
QRect rect = ev->rect();
int w = rect.width() - 2*fw;
int h = rect.height() - 2*fw;
+ */
int xv;