mirror of
https://github.com/elementary/gala.git
synced 2024-12-11 09:52:29 +03:00
workspaceview: visual improvements, namely custom drawn plus sign, border and top stroke for thumbs and overlaid noise texture on the view
This commit is contained in:
commit
ee5c21f7b9
@ -99,3 +99,4 @@ add_executable(gala ${VALA_C})#src/main.c)
|
||||
install(TARGETS gala RUNTIME DESTINATION bin)
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/gala.desktop DESTINATION share/applications)
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/gala.css DESTINATION ${PKGDATADIR})
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/texture.png DESTINATION ${PKGDATADIR})
|
||||
|
BIN
data/texture.png
Normal file
BIN
data/texture.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
@ -31,6 +31,10 @@ namespace Gala
|
||||
static const float THUMBNAIL_HEIGHT = 80.0f;
|
||||
static const uint CLOSE_BUTTON_DELAY = 500;
|
||||
|
||||
static const int PLUS_SIZE = 8;
|
||||
static const int PLUS_WIDTH = 24;
|
||||
static const int PLUS_OFFSET = 8;
|
||||
|
||||
public signal void clicked ();
|
||||
public signal void closed ();
|
||||
public signal void window_on_last ();
|
||||
@ -39,7 +43,7 @@ namespace Gala
|
||||
|
||||
unowned Screen screen;
|
||||
|
||||
static GtkClutter.Texture? plus = null;
|
||||
static Actor? plus = null;
|
||||
|
||||
Gtk.StyleContext selector_style;
|
||||
Gtk.EventBox selector_style_widget;
|
||||
@ -132,22 +136,43 @@ namespace Gala
|
||||
close_click.clicked.connect (close_workspace);
|
||||
|
||||
if (plus == null) {
|
||||
var css = new Gtk.CssProvider ();
|
||||
var img = new Gtk.Image ();
|
||||
try {
|
||||
css.load_from_data ("*{text-shadow:0 1 #f00;color:alpha(#fff, 0.8);}", -1);
|
||||
} catch (Error e) { warning(e.message); }
|
||||
img.get_style_context ().add_provider (css, 20000);
|
||||
plus = new Actor ();
|
||||
var canvas = new Canvas ();
|
||||
plus.content = canvas;
|
||||
canvas.draw.connect ((cr) => {
|
||||
// putting the buffer inside here is not a problem performance-wise,
|
||||
// as the method will only be called once anyway
|
||||
var buffer = new Granite.Drawing.BufferSurface (canvas.width, canvas.height);
|
||||
|
||||
plus = new GtkClutter.Texture ();
|
||||
try {
|
||||
var pix = Gtk.IconTheme.get_default ().choose_icon ({"list-add-symbolic", "list-add"}, (int)THUMBNAIL_HEIGHT / 2, 0).
|
||||
load_symbolic_for_context (img.get_style_context ());
|
||||
plus.set_from_pixbuf (pix);
|
||||
} catch (Error e) { warning (e.message); }
|
||||
buffer.context.rectangle (PLUS_WIDTH / 2 - PLUS_SIZE / 2 + 0.5 + PLUS_OFFSET, 0.5 + PLUS_OFFSET, PLUS_SIZE - 1, PLUS_WIDTH - 1);
|
||||
buffer.context.rectangle (0.5 + PLUS_OFFSET, PLUS_WIDTH / 2 - PLUS_SIZE / 2 + 0.5 + PLUS_OFFSET, PLUS_WIDTH - 1, PLUS_SIZE - 1);
|
||||
|
||||
buffer.context.set_source_rgb (0, 0, 0);
|
||||
buffer.context.fill_preserve ();
|
||||
buffer.exponential_blur (5);
|
||||
|
||||
buffer.context.set_source_rgb (1, 1, 1);
|
||||
buffer.context.set_line_width (1);
|
||||
buffer.context.stroke_preserve ();
|
||||
|
||||
buffer.context.set_source_rgb (0.8, 0.8, 0.8);
|
||||
buffer.context.fill ();
|
||||
|
||||
cr.set_operator (Cairo.Operator.CLEAR);
|
||||
cr.paint ();
|
||||
cr.set_operator (Cairo.Operator.SOURCE);
|
||||
|
||||
cr.set_source_surface (buffer.surface, 0, 0);
|
||||
cr.paint ();
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
plus.width = PLUS_WIDTH + 2 * PLUS_OFFSET;
|
||||
plus.height = PLUS_WIDTH + 2 * PLUS_OFFSET;
|
||||
plus.x = wallpaper.x + wallpaper.width / 2 - plus.width / 2;
|
||||
plus.y = wallpaper.y + wallpaper.height / 2 - plus.height / 2;
|
||||
canvas.set_size ((int)plus.width, (int)plus.height);
|
||||
}
|
||||
|
||||
add_action_with_name ("drop", new DropAction ());
|
||||
@ -166,6 +191,22 @@ namespace Gala
|
||||
content = canvas;
|
||||
}
|
||||
|
||||
public override void paint ()
|
||||
{
|
||||
// black border
|
||||
Cogl.Path.rectangle (INDICATOR_BORDER, INDICATOR_BORDER, wallpaper.width + INDICATOR_BORDER + 1, wallpaper.height + INDICATOR_BORDER + 1);
|
||||
Cogl.set_source_color4f (0, 0, 0, 1);
|
||||
Cogl.Path.stroke ();
|
||||
|
||||
base.paint ();
|
||||
|
||||
// top stroke
|
||||
Cogl.Path.move_to (INDICATOR_BORDER + 1, INDICATOR_BORDER + 1);
|
||||
Cogl.Path.line_to (wallpaper.width + INDICATOR_BORDER, INDICATOR_BORDER + 1);
|
||||
Cogl.set_source_color4f (1, 1, 1, 0.3f);
|
||||
Cogl.Path.stroke ();
|
||||
}
|
||||
|
||||
void over_in (Actor actor)
|
||||
{
|
||||
if (indicator.opacity != 255)
|
||||
|
@ -172,6 +172,11 @@ namespace Gala
|
||||
background_style.render_background (cr, 0, 0, width, height);
|
||||
background_style.render_frame (cr, 0, 0, width, height);
|
||||
|
||||
var pat = new Cairo.Pattern.for_surface (new Cairo.ImageSurface.from_png (Config.PKGDATADIR + "/texture.png"));
|
||||
pat.set_extend (Cairo.Extend.REPEAT);
|
||||
cr.set_source (pat);
|
||||
cr.paint_with_alpha (0.6);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user