Commit 115d250d authored by Davis King's avatar Davis King

Made the button_style_toolbar1 look nicer and also gave the button_style

interface the ability to draw outside a button.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402595
parent c9553a50
......@@ -31,7 +31,7 @@ namespace dlib
{
rectangle old(rect);
rect = resize_rect(rect,width,height);
parent.invalidate_rectangle(rect+old);
parent.invalidate_rectangle(style->get_invalidation_rect(rect+old));
btn_tooltip.set_size(width,height);
}
}
......@@ -187,7 +187,7 @@ namespace dlib
rect = move_rect(style->get_min_size(name,*mfont),rect.left(),rect.top());
btn_tooltip.set_size(rect.width(),rect.height());
parent.invalidate_rectangle(rect+old);
parent.invalidate_rectangle(style->get_invalidation_rect(rect+old));
}
// ----------------------------------------------------------------------------------------
......
......@@ -710,7 +710,7 @@ namespace dlib
enable_events();
}
~button() { disable_events(); parent.invalidate_rectangle(rect); }
~button() { disable_events(); parent.invalidate_rectangle(style->get_invalidation_rect(rect)); }
void set_size (
unsigned long width,
......@@ -790,7 +790,7 @@ namespace dlib
auto_mutex M(m);
style.reset(new style_type(style_));
rect = move_rect(style->get_min_size(name_,*mfont), rect.left(), rect.top());
parent.invalidate_rectangle(rect);
parent.invalidate_rectangle(style->get_invalidation_rect(rect));
}
template <
......@@ -906,10 +906,10 @@ namespace dlib
);
void on_mouse_over (
){ if (style->redraw_on_mouse_over()) parent.invalidate_rectangle(rect); }
){ if (style->redraw_on_mouse_over()) parent.invalidate_rectangle(style->get_invalidation_rect(rect)); }
void on_mouse_not_over (
){ if (style->redraw_on_mouse_over()) parent.invalidate_rectangle(rect); }
){ if (style->redraw_on_mouse_over()) parent.invalidate_rectangle(style->get_invalidation_rect(rect)); }
};
// ----------------------------------------------------------------------------------------
......
......@@ -535,11 +535,6 @@ namespace dlib
for ( long y = c_top; y <= c_bottom;y++ )
{
if ( y < valid_area.top() )
continue;
if ( y > valid_area.bottom() )
break;
unsigned long c_s = y - c_top;
......
......@@ -118,7 +118,7 @@ namespace dlib
if (area.is_empty())
return;
const long radius = 7;
const long radius = 4;
unsigned char red, green, blue;
if (enabled)
......@@ -129,14 +129,23 @@ namespace dlib
long d = 0;
if (rect.contains(lastx,lasty))
d = -40;
d = -70;
if (is_depressed)
d = 50;
d = 20;
fill_gradient_rounded(c,rect,radius,rgb_alpha_pixel(180-d,180-d,200-d,150),
rgb_alpha_pixel(130-d,130-d,150-d,100));
draw_rounded_rectangle(c,rect,radius, rgb_alpha_pixel(80,80,100,190));
if (d != 0)
{
rectangle temp(rect);
temp.left()--; temp.top()--; temp.right()++; temp.bottom()++;
draw_rounded_rectangle(c, temp, radius, rgb_alpha_pixel(255,255,0,120));
temp.left()--; temp.top()--; temp.right()++; temp.bottom()++;
draw_rounded_rectangle(c, temp, radius, rgb_alpha_pixel(255,255,0,40));
}
fill_gradient_rounded(c,rect,radius,rgb_alpha_pixel(255, 255, 255,120-d),
rgb_alpha_pixel(255, 255, 255,0));
draw_rounded_rectangle(c,rect,radius, rgb_alpha_pixel(30,30,30,200));
}
else
{
......
......@@ -38,6 +38,10 @@ namespace dlib
virtual bool redraw_on_mouse_over (
) const { return false; }
virtual rectangle get_invalidation_rect (
const rectangle& rect
) const { return rect; }
virtual rectangle get_min_size (
const ustring& name,
const font& mfont
......@@ -106,6 +110,18 @@ namespace dlib
const bool is_depressed
) const;
virtual rectangle get_invalidation_rect (
const rectangle& rect
) const
{
rectangle temp(rect);
temp.left() -= 2;
temp.top() -= 2;
temp.right() += 2;
temp.bottom() += 2;
return temp;
}
virtual bool redraw_on_mouse_over (
) const { return true; }
......
......@@ -42,6 +42,19 @@ namespace dlib
- returns false
!*/
virtual rectangle get_invalidation_rect (
const rectangle& rect
) const { return rect; }
/*!
requires
- the mutex drawable::m is locked
- rect == the get_rect() that defines where the button is
ensures
- returns a rectangle that should be invalidated whenever a button
needs to redraw itself. (If you wanted your button style to
draw outside the button then you could return a larger rectangle)
!*/
virtual rectangle get_min_size (
const ustring& name,
const font& mfont
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment