(From issue #1027) The Adjuster's spin button is now frameless to solve (as a workaround) alignment inconsistency.

This commit is contained in:
Hombre
2011-10-22 14:17:35 +02:00
parent 9057cd34ff
commit ab343546ad
14 changed files with 152 additions and 9 deletions

View File

@@ -153,6 +153,13 @@ style "clearlooks-spinbutton" {
} }
} }
style "clearlooks-framelessspinbutton" {
# IMPORTANT!
# base[NORMAL] must have the same color than notebook bg[NORMAL]
base[NORMAL] = shade (1.02, @rt_bg_color)
}
style "clearlooks-scale" { style "clearlooks-scale" {
xthickness = 2 xthickness = 2
ythickness = 2 ythickness = 2
@@ -209,6 +216,8 @@ style "clearlooks-vscrollbar" {
style "clearlooks-notebook_bg" { style "clearlooks-notebook_bg" {
# IMPORTANT!
# If you modify bg[NORMAL] here under, you must set clearlooks-framelessspinbutton -> base[NORMAL] to the very same value
bg[NORMAL] = shade (1.02, @rt_bg_color) bg[NORMAL] = shade (1.02, @rt_bg_color)
bg[ACTIVE] = @rt_base_color bg[ACTIVE] = @rt_base_color
} }
@@ -454,6 +463,7 @@ widget_class "*.<GtkCList>.<GtkButton>" style "clearlooks-treeview_header"
widget "*.partialPasteHeader.*" style "clearlooks-frame_title" widget "*.partialPasteHeader.*" style "clearlooks-frame_title"
widget "*.partialPasteHeaderSep" style "clearlooks-partialPasteHeaderSep" widget "*.partialPasteHeaderSep" style "clearlooks-partialPasteHeaderSep"
widget "*.histButton" style "clearlooks-histButton" widget "*.histButton" style "clearlooks-histButton"
widget "*.FramelessSpinButton" style "clearlooks-framelessspinbutton"
# The window of the tooltip is called "gtk-tooltip" # The window of the tooltip is called "gtk-tooltip"
################################################################## ##################################################################

View File

@@ -153,6 +153,13 @@ style "clearlooks-spinbutton" {
} }
} }
style "clearlooks-framelessspinbutton" {
# IMPORTANT!
# base[NORMAL] must have the same color than notebook bg[NORMAL]
base[NORMAL] = shade (1.02, @rt_bg_color)
}
style "clearlooks-scale" { style "clearlooks-scale" {
xthickness = 2 xthickness = 2
ythickness = 2 ythickness = 2
@@ -209,6 +216,8 @@ style "clearlooks-vscrollbar" {
style "clearlooks-notebook_bg" { style "clearlooks-notebook_bg" {
# IMPORTANT!
# If you modify bg[NORMAL] here under, you must set clearlooks-framelessspinbutton -> base[NORMAL] to the very same value
bg[NORMAL] = shade (1.02, @rt_bg_color) bg[NORMAL] = shade (1.02, @rt_bg_color)
bg[ACTIVE] = shade (0.80, @rt_bg_color) bg[ACTIVE] = shade (0.80, @rt_bg_color)
} }
@@ -454,6 +463,7 @@ widget_class "*.<GtkCList>.<GtkButton>" style "clearlooks-treeview_header"
widget "*.partialPasteHeader.*" style "clearlooks-frame_title" widget "*.partialPasteHeader.*" style "clearlooks-frame_title"
widget "*.partialPasteHeaderSep" style "clearlooks-partialPasteHeaderSep" widget "*.partialPasteHeaderSep" style "clearlooks-partialPasteHeaderSep"
widget "*.histButton" style "clearlooks-histButton" widget "*.histButton" style "clearlooks-histButton"
widget "*.FramelessSpinButton" style "clearlooks-framelessspinbutton"
# The window of the tooltip is called "gtk-tooltip" # The window of the tooltip is called "gtk-tooltip"
################################################################## ##################################################################

View File

@@ -153,6 +153,13 @@ style "clearlooks-spinbutton" {
} }
} }
style "clearlooks-framelessspinbutton" {
# IMPORTANT!
# base[NORMAL] must have the same color than notebook bg[NORMAL]
base[NORMAL] = shade (1.02, @rt_bg_color)
}
style "clearlooks-scale" { style "clearlooks-scale" {
xthickness = 2 xthickness = 2
ythickness = 2 ythickness = 2
@@ -209,6 +216,8 @@ style "clearlooks-vscrollbar" {
style "clearlooks-notebook_bg" { style "clearlooks-notebook_bg" {
# IMPORTANT!
# If you modify bg[NORMAL] here under, you must set clearlooks-framelessspinbutton -> base[NORMAL] to the very same value
bg[NORMAL] = shade (1.02, @rt_bg_color) bg[NORMAL] = shade (1.02, @rt_bg_color)
bg[ACTIVE] = @rt_base_color bg[ACTIVE] = @rt_base_color
} }
@@ -465,6 +474,7 @@ widget_class "*.<GtkCList>.<GtkButton>" style "clearlooks-treeview_header"
widget "*.partialPasteHeader.*" style "clearlooks-frame_title" widget "*.partialPasteHeader.*" style "clearlooks-frame_title"
widget "*.partialPasteHeaderSep" style "clearlooks-partialPasteHeaderSep" widget "*.partialPasteHeaderSep" style "clearlooks-partialPasteHeaderSep"
widget "*.histButton" style "clearlooks-histButton" widget "*.histButton" style "clearlooks-histButton"
widget "*.FramelessSpinButton" style "clearlooks-framelessspinbutton"
# The window of the tooltip is called "gtk-tooltip" # The window of the tooltip is called "gtk-tooltip"
################################################################## ##################################################################

View File

@@ -153,6 +153,13 @@ style "clearlooks-spinbutton" {
} }
} }
style "clearlooks-framelessspinbutton" {
# IMPORTANT!
# base[NORMAL] must have the same color than notebook bg[NORMAL]
base[NORMAL] = shade (1.02, @rt_bg_color)
}
style "clearlooks-scale" { style "clearlooks-scale" {
xthickness = 2 xthickness = 2
ythickness = 2 ythickness = 2
@@ -209,6 +216,8 @@ style "clearlooks-vscrollbar" {
style "clearlooks-notebook_bg" { style "clearlooks-notebook_bg" {
# IMPORTANT!
# If you modify bg[NORMAL] here under, you must set clearlooks-framelessspinbutton -> base[NORMAL] to the very same value
bg[NORMAL] = shade (1.02, @rt_bg_color) bg[NORMAL] = shade (1.02, @rt_bg_color)
bg[ACTIVE] = shade (0.80, @rt_bg_color) bg[ACTIVE] = shade (0.80, @rt_bg_color)
} }
@@ -454,6 +463,7 @@ widget_class "*.<GtkCList>.<GtkButton>" style "clearlooks-treeview_header"
widget "*.partialPasteHeader.*" style "clearlooks-frame_title" widget "*.partialPasteHeader.*" style "clearlooks-frame_title"
widget "*.partialPasteHeaderSep" style "clearlooks-partialPasteHeaderSep" widget "*.partialPasteHeaderSep" style "clearlooks-partialPasteHeaderSep"
widget "*.histButton" style "clearlooks-histButton" widget "*.histButton" style "clearlooks-histButton"
widget "*.FramelessSpinButton" style "clearlooks-framelessspinbutton"
# The window of the tooltip is called "gtk-tooltip" # The window of the tooltip is called "gtk-tooltip"
################################################################## ##################################################################

View File

@@ -153,6 +153,13 @@ style "clearlooks-spinbutton" {
} }
} }
style "clearlooks-framelessspinbutton" {
# IMPORTANT!
# base[NORMAL] must have the same color than notebook bg[NORMAL]
base[NORMAL] = shade (1.02, @rt_bg_color)
}
style "clearlooks-scale" { style "clearlooks-scale" {
xthickness = 2 xthickness = 2
ythickness = 2 ythickness = 2
@@ -209,6 +216,8 @@ style "clearlooks-vscrollbar" {
style "clearlooks-notebook_bg" { style "clearlooks-notebook_bg" {
# IMPORTANT!
# If you modify bg[NORMAL] here under, you must set clearlooks-framelessspinbutton -> base[NORMAL] to the very same value
bg[NORMAL] = shade (1.02, @rt_bg_color) bg[NORMAL] = shade (1.02, @rt_bg_color)
bg[ACTIVE] = shade (0.80, @rt_bg_color) bg[ACTIVE] = shade (0.80, @rt_bg_color)
} }
@@ -454,6 +463,7 @@ widget_class "*.<GtkCList>.<GtkButton>" style "clearlooks-treeview_header"
widget "*.partialPasteHeader.*" style "clearlooks-frame_title" widget "*.partialPasteHeader.*" style "clearlooks-frame_title"
widget "*.partialPasteHeaderSep" style "clearlooks-partialPasteHeaderSep" widget "*.partialPasteHeaderSep" style "clearlooks-partialPasteHeaderSep"
widget "*.histButton" style "clearlooks-histButton" widget "*.histButton" style "clearlooks-histButton"
widget "*.FramelessSpinButton" style "clearlooks-framelessspinbutton"
# The window of the tooltip is called "gtk-tooltip" # The window of the tooltip is called "gtk-tooltip"
################################################################## ##################################################################

View File

@@ -153,6 +153,13 @@ style "clearlooks-spinbutton" {
} }
} }
style "clearlooks-framelessspinbutton" {
# IMPORTANT!
# base[NORMAL] must have the same color than notebook bg[NORMAL]
base[NORMAL] = shade (1.02, @rt_bg_color)
}
style "clearlooks-scale" { style "clearlooks-scale" {
xthickness = 2 xthickness = 2
ythickness = 2 ythickness = 2
@@ -209,6 +216,8 @@ style "clearlooks-vscrollbar" {
style "clearlooks-notebook_bg" { style "clearlooks-notebook_bg" {
# IMPORTANT!
# If you modify bg[NORMAL] here under, you must set clearlooks-framelessspinbutton -> base[NORMAL] to the very same value
bg[NORMAL] = shade (1.02, @rt_bg_color) bg[NORMAL] = shade (1.02, @rt_bg_color)
bg[ACTIVE] = shade (0.80, @rt_bg_color) bg[ACTIVE] = shade (0.80, @rt_bg_color)
} }
@@ -454,6 +463,7 @@ widget_class "*.<GtkCList>.<GtkButton>" style "clearlooks-treeview_header"
widget "*.partialPasteHeader.*" style "clearlooks-frame_title" widget "*.partialPasteHeader.*" style "clearlooks-frame_title"
widget "*.partialPasteHeaderSep" style "clearlooks-partialPasteHeaderSep" widget "*.partialPasteHeaderSep" style "clearlooks-partialPasteHeaderSep"
widget "*.histButton" style "clearlooks-histButton" widget "*.histButton" style "clearlooks-histButton"
widget "*.FramelessSpinButton" style "clearlooks-framelessspinbutton"
# The window of the tooltip is called "gtk-tooltip" # The window of the tooltip is called "gtk-tooltip"
################################################################## ##################################################################

View File

@@ -155,6 +155,13 @@ style "clearlooks-spinbutton" {
} }
} }
style "clearlooks-framelessspinbutton" {
# IMPORTANT!
# base[NORMAL] must have the same color than notebook bg[NORMAL]
base[NORMAL] = @rt_bg_color
}
style "clearlooks-scale" { style "clearlooks-scale" {
xthickness = 2 xthickness = 2
ythickness = 2 ythickness = 2
@@ -558,6 +565,8 @@ style "clearlooks-range" {
style "clearlooks-notebook_bg" { style "clearlooks-notebook_bg" {
# IMPORTANT!
# If you modify bg[NORMAL] here under, you must set clearlooks-framelessspinbutton -> base[NORMAL] to the very same value
bg[NORMAL] = @rt_bg_color bg[NORMAL] = @rt_bg_color
bg[ACTIVE] = shade (0.85, @rt_bg_color) bg[ACTIVE] = shade (0.85, @rt_bg_color)
} }
@@ -805,6 +814,7 @@ widget_class "*.<GtkCList>.<GtkButton>" style "clearlooks-treeview_header"
widget "*.partialPasteHeader.*" style "clearlooks-frame_title" widget "*.partialPasteHeader.*" style "clearlooks-frame_title"
widget "*.partialPasteHeaderSep" style "clearlooks-partialPasteHeaderSep" widget "*.partialPasteHeaderSep" style "clearlooks-partialPasteHeaderSep"
widget "*.histButton" style "clearlooks-histButton" widget "*.histButton" style "clearlooks-histButton"
widget "*.FramelessSpinButton" style "clearlooks-framelessspinbutton"
# The window of the tooltip is called "gtk-tooltip" # The window of the tooltip is called "gtk-tooltip"
################################################################## ##################################################################

View File

@@ -153,6 +153,13 @@ style "clearlooks-spinbutton" {
} }
} }
style "clearlooks-framelessspinbutton" {
# IMPORTANT!
# base[NORMAL] must have the same color than notebook bg[NORMAL]
base[NORMAL] = @rt_bg_color
}
style "clearlooks-scale" { style "clearlooks-scale" {
xthickness = 2 xthickness = 2
ythickness = 2 ythickness = 2
@@ -209,6 +216,8 @@ style "clearlooks-vscrollbar" {
style "clearlooks-notebook_bg" { style "clearlooks-notebook_bg" {
# IMPORTANT!
# If you modify bg[NORMAL] here under, you must set clearlooks-framelessspinbutton -> base[NORMAL] to the very same value
bg[NORMAL] = @rt_bg_color bg[NORMAL] = @rt_bg_color
bg[ACTIVE] = shade (0.85, @rt_bg_color) bg[ACTIVE] = shade (0.85, @rt_bg_color)
} }
@@ -455,6 +464,7 @@ widget_class "*.<GtkCList>.<GtkButton>" style "clearlooks-treeview_header"
widget "*.partialPasteHeader.*" style "clearlooks-frame_title" widget "*.partialPasteHeader.*" style "clearlooks-frame_title"
widget "*.partialPasteHeaderSep" style "clearlooks-partialPasteHeaderSep" widget "*.partialPasteHeaderSep" style "clearlooks-partialPasteHeaderSep"
widget "*.histButton" style "clearlooks-histButton" widget "*.histButton" style "clearlooks-histButton"
widget "*.FramelessSpinButton" style "clearlooks-framelessspinbutton"
# The window of the tooltip is called "gtk-tooltip" # The window of the tooltip is called "gtk-tooltip"
################################################################## ##################################################################

View File

@@ -153,6 +153,13 @@ style "clearlooks-spinbutton" {
} }
} }
style "clearlooks-framelessspinbutton" {
# IMPORTANT!
# base[NORMAL] must have the same color than notebook bg[NORMAL]
base[NORMAL] = shade (1.05, @rt_bg_color)
}
style "clearlooks-scale" { style "clearlooks-scale" {
xthickness = 2 xthickness = 2
ythickness = 2 ythickness = 2
@@ -209,6 +216,8 @@ style "clearlooks-vscrollbar" {
style "clearlooks-notebook_bg" { style "clearlooks-notebook_bg" {
# IMPORTANT!
# If you modify bg[NORMAL] here under, you must set clearlooks-framelessspinbutton -> base[NORMAL] to the very same value
bg[NORMAL] = shade (1.05, @rt_bg_color) bg[NORMAL] = shade (1.05, @rt_bg_color)
bg[ACTIVE] = shade (0.92, @rt_bg_color) bg[ACTIVE] = shade (0.92, @rt_bg_color)
} }
@@ -455,6 +464,7 @@ widget_class "*.<GtkCList>.<GtkButton>" style "clearlooks-treeview_header"
widget "*.partialPasteHeader.*" style "clearlooks-frame_title" widget "*.partialPasteHeader.*" style "clearlooks-frame_title"
widget "*.partialPasteHeaderSep" style "clearlooks-partialPasteHeaderSep" widget "*.partialPasteHeaderSep" style "clearlooks-partialPasteHeaderSep"
widget "*.histButton" style "clearlooks-histButton" widget "*.histButton" style "clearlooks-histButton"
widget "*.FramelessSpinButton" style "clearlooks-framelessspinbutton"
# The window of the tooltip is called "gtk-tooltip" # The window of the tooltip is called "gtk-tooltip"
################################################################## ##################################################################

View File

@@ -153,6 +153,13 @@ style "clearlooks-spinbutton" {
} }
} }
style "clearlooks-framelessspinbutton" {
# IMPORTANT!
# base[NORMAL] must have the same color than notebook bg[NORMAL]
base[NORMAL] = shade (1.02, @rt_bg_color)
}
style "clearlooks-scale" { style "clearlooks-scale" {
xthickness = 2 xthickness = 2
ythickness = 2 ythickness = 2
@@ -209,6 +216,8 @@ style "clearlooks-vscrollbar" {
style "clearlooks-notebook_bg" { style "clearlooks-notebook_bg" {
# IMPORTANT!
# If you modify bg[NORMAL] here under, you must set clearlooks-framelessspinbutton -> base[NORMAL] to the very same value
bg[NORMAL] = shade (1.02, @rt_bg_color) bg[NORMAL] = shade (1.02, @rt_bg_color)
} }
@@ -442,6 +451,7 @@ widget_class "*.<GtkCList>.<GtkButton>" style "clearlooks-treeview_header"
widget "*.partialPasteHeader.*" style "clearlooks-frame_title" widget "*.partialPasteHeader.*" style "clearlooks-frame_title"
widget "*.partialPasteHeaderSep" style "clearlooks-partialPasteHeaderSep" widget "*.partialPasteHeaderSep" style "clearlooks-partialPasteHeaderSep"
widget "*.histButton" style "clearlooks-histButton" widget "*.histButton" style "clearlooks-histButton"
widget "*.FramelessSpinButton" style "clearlooks-framelessspinbutton"
# The window of the tooltip is called "gtk-tooltip" # The window of the tooltip is called "gtk-tooltip"
################################################################## ##################################################################

View File

@@ -142,6 +142,13 @@ style "clearlooks-spinbutton" {
} }
} }
style "clearlooks-framelessspinbutton" {
# IMPORTANT!
# base[NORMAL] must have the same color than notebook bg[NORMAL]
base[NORMAL] = shade (1.02, @rt_bg_color)
}
style "clearlooks-scale" { style "clearlooks-scale" {
xthickness = 2 xthickness = 2
ythickness = 2 ythickness = 2
@@ -190,6 +197,8 @@ style "clearlooks-vscrollbar" {
style "clearlooks-notebook_bg" { style "clearlooks-notebook_bg" {
# IMPORTANT!
# If you modify bg[NORMAL] here under, you must set clearlooks-framelessspinbutton -> base[NORMAL] to the very same value
bg[NORMAL] = shade (1.02, @rt_bg_color) bg[NORMAL] = shade (1.02, @rt_bg_color)
} }
@@ -395,6 +404,7 @@ widget_class "*.<GtkCList>.<GtkButton>" style "clearlooks-treeview_header"
widget "*.partialPasteHeader.*" style "clearlooks-frame_title" widget "*.partialPasteHeader.*" style "clearlooks-frame_title"
widget "*.partialPasteHeaderSep" style "clearlooks-partialPasteHeaderSep" widget "*.partialPasteHeaderSep" style "clearlooks-partialPasteHeaderSep"
widget "*.histButton" style "clearlooks-histButton" widget "*.histButton" style "clearlooks-histButton"
widget "*.FramelessSpinButton" style "clearlooks-framelessspinbutton"
# The window of the tooltip is called "gtk-tooltip" # The window of the tooltip is called "gtk-tooltip"
################################################################## ##################################################################

View File

@@ -67,6 +67,8 @@ Adjuster::Adjuster (Glib::ustring vlabel, double vmin, double vmax, double vstep
hbox->pack_end (*reset, Gtk::PACK_SHRINK, 0); hbox->pack_end (*reset, Gtk::PACK_SHRINK, 0);
spin = Gtk::manage (new MySpinButton ()); spin = Gtk::manage (new MySpinButton ());
spin->set_has_frame(false);
spin->set_name("FramelessSpinButton");
hbox->pack_end (*spin, Gtk::PACK_SHRINK, 0); hbox->pack_end (*spin, Gtk::PACK_SHRINK, 0);
@@ -132,6 +134,8 @@ Adjuster::Adjuster (Gtk::Image *imgIcon, double vmin, double vmax, double vstep,
hbox->pack_end (*reset, Gtk::PACK_SHRINK, 0); hbox->pack_end (*reset, Gtk::PACK_SHRINK, 0);
spin = Gtk::manage (new MySpinButton ()); spin = Gtk::manage (new MySpinButton ());
spin->set_has_frame(false);
spin->set_name("FramelessSpinButton");
reset->set_size_request (-1, spin->get_height()); reset->set_size_request (-1, spin->get_height());
@@ -208,18 +212,13 @@ void Adjuster::setLimits (double vmin, double vmax, double vstep, double vdefaul
spin->set_digits (digits); spin->set_digits (digits);
spin->set_increments (vstep, 2.0*vstep); spin->set_increments (vstep, 2.0*vstep);
spin->set_range (vmin, vmax); spin->set_range (vmin, vmax);
spin->updateSize();
spin->set_value (shapeValue(vdefault)); spin->set_value (shapeValue(vdefault));
slider->set_digits (digits); slider->set_digits (digits);
slider->set_increments (vstep, 2.0*vstep); slider->set_increments (vstep, 2.0*vstep);
slider->set_range (vmin, vmax); slider->set_range (vmin, vmax);
slider->set_value (shapeValue(vdefault)); slider->set_value (shapeValue(vdefault));
//defaultVal = shapeValue (vdefault); //defaultVal = shapeValue (vdefault);
double maxAbs = fmax(fabs(vmin), fabs(vmax));
int digits2;
for (digits2=0; maxAbs/pow(double(10),digits2)>=1.0; digits2++);
spin->set_width_chars(digits+digits2+(vmin<0?1:0)+(digits>0?1:0));
sliderChange.block (false); sliderChange.block (false);
spinChange.block (false); spinChange.block (false);
} }

View File

@@ -309,13 +309,44 @@ MySpinButton::MySpinButton () {
Gtk::Border border; Gtk::Border border;
border.bottom = 0; border.bottom = 0;
border.top = 0; border.top = 0;
border.left = 0; border.left = 3;
border.right = 0; border.right = 3;
set_inner_border(border); set_inner_border(border);
set_numeric(true);
set_wrap(true);
set_alignment(Gtk::ALIGN_RIGHT);
}
void MySpinButton::updateSize() {
double vMin, vMax;
double step, page;
double maxAbs;
unsigned int digits, digits2;
unsigned int maxLen;
get_range(vMin, vMax);
get_increments (step, page);
maxAbs = fmax(fabs(vMin), fabs(vMax));
digits = get_digits();
for (digits2=0; maxAbs/pow(double(10),digits2)>=1.0; digits2++);
maxLen = digits+digits2+(vMin<0?1:0)+(digits>0?1:0);
set_max_length(maxLen);
set_width_chars(maxLen);
}
bool MySpinButton::on_key_press_event (GdkEventKey* event) {
bool rcode = Gtk::Widget::on_key_press_event(event);
if ( (event->string[0] >= 'a' && event->string[0] <= 'z')
||(event->string[0] >= 'A' && event->string[0] <= 'Z')
|| event->string[0] == '+'
)
return false;
return rcode;
} }
bool MySpinButton::on_scroll_event (GdkEventScroll* event) { bool MySpinButton::on_scroll_event (GdkEventScroll* event) {
// If Shift is pressed, the widget is modified // If Shift is pressed, the widget is modified
if (event->state & GDK_SHIFT_MASK) { if (event->state & GDK_SHIFT_MASK) {
Gtk::SpinButton::on_scroll_event(event); Gtk::SpinButton::on_scroll_event(event);

View File

@@ -109,10 +109,13 @@ public:
*/ */
class MySpinButton : public Gtk::SpinButton { class MySpinButton : public Gtk::SpinButton {
protected:
bool on_scroll_event (GdkEventScroll* event); bool on_scroll_event (GdkEventScroll* event);
bool on_key_press_event (GdkEventKey* event);
public: public:
MySpinButton (); MySpinButton ();
void updateSize();
}; };
/** /**