}
}
-void Button::pointer_leave()
+void Button::pointer_motion(int x, int y)
{
- Widget::pointer_leave();
- state&=~ACTIVE;
+ if(pressed)
+ {
+ if(!geom.is_inside_relative(x, y))
+ state&=~ACTIVE;
+ else
+ state|=ACTIVE;
+ }
}
void Button::render_special(const Part &part) const
void set_text(const std::string &);
virtual void button_press(int, int, unsigned);
virtual void button_release(int, int, unsigned);
- virtual void pointer_leave();
+ virtual void pointer_motion(int, int);
private:
virtual const char *get_class() const { return "button"; }
virtual void render_special(const Part &) const;
geom.x+=margin.left;
geom.y+=margin.bottom;
- if(parent.w>geom.w)
+ if(pw>geom.w)
{
geom.w+=static_cast<unsigned>((pw-geom.w)*w);
geom.x+=static_cast<int>((pw-geom.w)*x);
}
- if(parent.h>geom.h)
+ if(ph>geom.h)
{
geom.h+=static_cast<unsigned>((ph-geom.h)*h);
geom.y+=static_cast<int>((ph-geom.h)*y);
void HSlider::button_press(int x, int y, unsigned btn)
{
- if(geom.is_inside_relative(x, y) && max>min)
+ if(btn==1 && geom.is_inside_relative(x, y) && max>min)
{
int sx=static_cast<int>((geom.w-slider_size)*(value-min)/(max-min));
- if(btn==1 && x>=sx && x<static_cast<int>(sx+slider_size))
+ if(x<sx)
+ set_value(value-step*10);
+ else if(x>=static_cast<int>(sx+slider_size))
+ set_value(value+step*10);
+ else
start_drag(x);
}
}
else if(btn==1)
{
const GL::Font *const font=style->get_font();
- const unsigned row_height=static_cast<unsigned>(font->get_default_size());
+ const unsigned row_height=static_cast<unsigned>((font->get_ascent()-font->get_descent())*font->get_default_size());
if(items_part)
y+=items_part->get_margin().top;
const GL::Font *const font=style->get_font();
const float font_size=font->get_default_size();
const GL::Color &color=style->get_font_color();
- const unsigned row_height=static_cast<unsigned>(font_size);
+ const unsigned row_height=static_cast<unsigned>((font->get_ascent()-font->get_descent())*font_size);
const Sides &margin=part.get_margin();
Geometry pgeom=geom;
{
const GL::Font *const font=style->get_font();
const float font_size=font->get_default_size();
- const unsigned row_height=static_cast<unsigned>(font_size);
+ const unsigned row_height=static_cast<unsigned>((font->get_ascent()-font->get_descent())*font_size);
const Sides &margin=part.get_margin();
Geometry pgeom=geom;
{
if(pressed && btn==1)
{
- if(geom.is_inside_relative(x, y))
+ if(geom.is_inside_relative(x, y) && (!value || !exclusive))
{
set_value(!value);
signal_toggled.emit(value);
void VSlider::button_press(int x, int y, unsigned btn)
{
- if(geom.is_inside_relative(x, y) && max>min)
+ if(btn==1 && geom.is_inside_relative(x, y) && max>min)
{
int sy=static_cast<int>((geom.h-slider_size)*(value-min)/(max-min));
- if(btn==1 && y>=sy && y<static_cast<int>(sy+slider_size))
+ if(y<sy)
+ set_value(value-step*10);
+ else if(y>=static_cast<int>(sy+slider_size))
+ set_value(value+step*10);
+ else
start_drag(y);
}
}