Mir

Merge lp:~vanvugt/mir/render-focus into lp:mir

Proposed by Daniel van Vugt
Status: Work in progress
Proposed branch: lp:~vanvugt/mir/render-focus
Merge into: lp:mir
Prerequisite: lp:~vanvugt/mir/renderable-id
Diff against target: 114 lines (+34/-8)
2 files modified
examples/demo-shell/demo_renderer.cpp (+29/-6)
examples/demo-shell/demo_renderer.h (+5/-2)
To merge this branch: bzr merge lp:~vanvugt/mir/render-focus
Reviewer Review Type Date Requested Status
Mir development team Pending
Review via email: mp+214169@code.launchpad.net

Commit message

demo-shell: Visibly highlight the focussed surface

Description of the change

There's a TODO around how to accurately get the focus information. This started out as an activity to enable and enrich Renderable with that kind of state, but now I realize focus is not a piece of state stored in any Renderable/Surface. So it's turned into more of a hack than expected. But it's one worth building upon...

To post a comment you must log in.
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

On second thoughts, leave this work in progress. A nicer solution would be to simply augment each surface with an "int stacking_depth" which the render could use for other things too.

lp:~vanvugt/mir/render-focus updated
1533. By Daniel van Vugt

Merge latest development-branch, resolve conflicts and port to the new
interfaces.

1534. By Daniel van Vugt

Tweak focussed/unfocussed colour differences to be less dramatic

Unmerged revisions

1534. By Daniel van Vugt

Tweak focussed/unfocussed colour differences to be less dramatic

1533. By Daniel van Vugt

Merge latest development-branch, resolve conflicts and port to the new
interfaces.

1532. By Daniel van Vugt

Make use of Renderable::ID

1531. By Daniel van Vugt

Merge branch renderable-id

1530. By Daniel van Vugt

Merge latest development-branch and fix a conflict

1529. By Daniel van Vugt

Merge branch "renderable-id"

1528. By Daniel van Vugt

And vary the titlebar itself based on focus

1527. By Daniel van Vugt

Initial prototype of varying shadow size based on focus

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'examples/demo-shell/demo_renderer.cpp'
2--- examples/demo-shell/demo_renderer.cpp 2014-05-02 03:56:16 +0000
3+++ examples/demo-shell/demo_renderer.cpp 2014-05-05 07:49:30 +0000
4@@ -139,17 +139,20 @@
5 geometry::Rectangle const& display_area)
6 : GLRenderer(program_factory, display_area)
7 , corner_radius(0.5f)
8+ , focus(0)
9 {
10 shadow_corner_tex = generate_shadow_corner_texture(0.4f);
11- titlebar_corner_tex = generate_frame_corner_texture(corner_radius,
12- {128,128,128,255},
13- 255);
14+ normal_titlebar_corner_tex =
15+ generate_frame_corner_texture(corner_radius, {160,160,160,255}, 220);
16+ focussed_titlebar_corner_tex =
17+ generate_frame_corner_texture(corner_radius, {180,180,180,255}, 255);
18 }
19
20 DemoRenderer::~DemoRenderer()
21 {
22 glDeleteTextures(1, &shadow_corner_tex);
23- glDeleteTextures(1, &titlebar_corner_tex);
24+ glDeleteTextures(1, &normal_titlebar_corner_tex);
25+ glDeleteTextures(1, &focussed_titlebar_corner_tex);
26 }
27
28 void DemoRenderer::begin() const
29@@ -162,19 +165,33 @@
30 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
31 }
32
33+void DemoRenderer::render(graphics::RenderableList const& renderables) const
34+{
35+ // At the moment, top-of-the-stack and focus are the same thing in Mir.
36+ // But maybe in future they won't be...
37+
38+ focus = 0;
39+ if (!renderables.empty())
40+ focus = renderables.back()->id();
41+
42+ GLRenderer::render(renderables);
43+}
44+
45 void DemoRenderer::tessellate(std::vector<Primitive>& primitives,
46 graphics::Renderable const& renderable,
47 geometry::Size const& buf_size) const
48 {
49 GLRenderer::tessellate(primitives, renderable, buf_size);
50- tessellate_shadow(primitives, renderable, 80.0f);
51+ tessellate_shadow(primitives, renderable, 30.0f, 80.0f);
52 tessellate_frame(primitives, renderable, 30.0f);
53 }
54
55 void DemoRenderer::tessellate_shadow(std::vector<Primitive>& primitives,
56 graphics::Renderable const& renderable,
57- float radius) const
58+ float normal_radius,
59+ float focussed_radius) const
60 {
61+
62 auto const& rect = renderable.screen_position();
63 GLfloat left = rect.top_left.x.as_int();
64 GLfloat right = left + rect.size.width.as_int();
65@@ -184,6 +201,8 @@
66 auto n = primitives.size();
67 primitives.resize(n + 8);
68
69+ GLfloat radius = renderable.id() == focus ? focussed_radius :
70+ normal_radius;
71 GLfloat rightr = right + radius;
72 GLfloat leftr = left - radius;
73 GLfloat topr = top - radius;
74@@ -287,6 +306,10 @@
75 if (inleft > mid) inleft = mid;
76 if (inright < mid) inright = mid;
77
78+ GLuint titlebar_corner_tex = renderable.id() == focus ?
79+ focussed_titlebar_corner_tex :
80+ normal_titlebar_corner_tex;
81+
82 auto& top_left_corner = primitives[n++];
83 top_left_corner.tex_id = titlebar_corner_tex;
84 top_left_corner.type = GL_TRIANGLE_FAN;
85
86=== modified file 'examples/demo-shell/demo_renderer.h'
87--- examples/demo-shell/demo_renderer.h 2014-04-24 08:42:12 +0000
88+++ examples/demo-shell/demo_renderer.h 2014-05-05 07:49:30 +0000
89@@ -33,12 +33,13 @@
90 ~DemoRenderer();
91
92 void begin() const override;
93+ void render(graphics::RenderableList const&) const override;
94 void tessellate(std::vector<Primitive>& primitives,
95 graphics::Renderable const& renderable,
96 geometry::Size const& buf_size) const override;
97 void tessellate_shadow(std::vector<Primitive>& primitives,
98 graphics::Renderable const& renderable,
99- float radius) const;
100+ float normal_radius, float focussed_radius) const;
101 void tessellate_frame(std::vector<Primitive>& primitives,
102 graphics::Renderable const& renderable,
103 float titlebar_height) const;
104@@ -46,7 +47,9 @@
105 private:
106 float const corner_radius;
107 GLuint shadow_corner_tex;
108- GLuint titlebar_corner_tex;
109+ GLuint normal_titlebar_corner_tex;
110+ GLuint focussed_titlebar_corner_tex;
111+ mutable graphics::Renderable::ID focus;
112 };
113
114 } // namespace examples

Subscribers

People subscribed via source and target branches