I can easily make it so, that if whole parent object is scaled, child cube would be scaled as well, but I totally cannot figure out how to scale this inner cube only when selected faces are scaled. I have tried bunch of methods like vertex groups, copy scale/transformation constraints, hook modifiers, but nothing really worked, most probably I was doing something wrong.
In this particular case, to keep things simple, for a constant offset, you could assign a Shrinkwrap modifier to the cube, target the frame, set to 'Nearest Vertex', and with the Offset in the modifier adjusted to give the desired gap. Here, the frame is being animated using shape-keys.
Perhaps more generally. this time giving a true scale, so the gap scales as well as the cube and inner rim:
- Create vertex groups of the inner surfaces of the frame and all of the cube
- Create a single-bone armature at the scaling origin
- Name the vertex groups the same as the bone
- Assign an Armature modifier to the frame and the cube, both targeted on the armature, and both set to 'Vertex Group' using the named vertex groups.
Now scaling the bone will scale all the associated vertices.