CTrackData::Draw() Key Position
-
On 29/06/2016 at 08:50, xxxxxxxx wrote:
User Information:
Cinema 4D Version:
Platform:
Language(s) :---------
How do I find the position of a key in pixels (and its width) in CTrackData::Draw()? Or how else can I
find the necessary information in order to properly draw custom information in correct relationship
with the keys?Bool Draw(CTrack* track, GeClipMap* map, const BaseTime& clip_left, const BaseTime& clip_right) override { map->BeginDraw(); CCurve* const curve = track->GetCurve(); for (Int32 i = 0; i < curve->GetKeyCount(); ++i) { CKey* const key = curve->GetKey(i); // How do I find out what the X-position and width of the key is? } map->EndDraw(); return true; }
Thanks in advance,
Niklas -
On 29/06/2016 at 11:43, xxxxxxxx wrote:
clip_left and clip_right seem to be the min and max times that are visible in the timeline
-
On 30/06/2016 at 02:11, xxxxxxxx wrote:
Hello,
yes, the clip_left and clip_right parameters define the frame range of the currently displayed timeline (see CTrackData::Draw()). So using that information and the width of the given GeClipMap it should be easy to calculate the keyframe position.
Best wishes,
Sebastian -
On 30/06/2016 at 05:15, xxxxxxxx wrote:
Indeed it is, thanks Sebastian.
Bool Draw(CTrack* track, GeClipMap* map, const BaseTime& clip_left, const BaseTime& clip_right) override { this->keyGuiInfo.Flush(); BaseDocument* doc = track->GetDocument(); CCurve* curve = track->GetCurve(); if (!doc || !curve) return false; BaseTime const delta = (clip_right - clip_left); Int32 const bw = map->GetBw(); Int32 const bh = map->GetBh(); map->BeginDraw(); for (Int32 i = 0; i < curve->GetKeyCount(); ++i) { CKey* const key = curve->GetKey(i); GeListNode* preset = GetParam(key, CKSTAGECUE_PRESETLINK).GetLink(doc); BaseTime fade = GetParam(key, CKSTAGECUE_FADEIN).GetTime(); if (preset) SetColor(map, gParams.activeFade); else SetColor(map, gParams.inactiveFade); Int32 x2 = ((key->GetTime() - clip_left) / delta).Get() * bw; Int32 x1 = x2 - (fade / delta).Get() * bw; map->FillRect(x1, 0, x2, bh - 1); this->keyGuiInfo.Append({key, x1, x2}); } map->EndDraw(); return true; }
I have another important related question: How can I convert the screen X/Y position in
TrackData::GuiMessage() sent with BFM_DRAGRECEIVE to local X/Y coordinates? Or do
I have to do that in Draw() and remember the layout information? But there is no Screen2Local()
or alike in the GeClipMap class either.TIA,
Niklas -
On 30/06/2016 at 23:51, xxxxxxxx wrote:
Hello,
only a GeDialog or GeUserArea could perform this transformation. So I'm afraid that it is not possible to transform the coordinates into local coordinates.
Best wishes,
Sebastian -
On 01/07/2016 at 03:56, xxxxxxxx wrote:
Hello Sebastian,
hm.. may I ask, if not too rude, if you could dig any deeper or ask the developers?
From my viewpoint, it must somehow be possible. Otherwise, the GuiMessage() method would be
pretty much completely useless (if I get Gui events but can't process them correctly, well you get
the idea).The "standard" tracks can act on user interaction as well (eg. you can modify the tangents and
value of the keys).Thanks,
Niklas -
On 01/07/2016 at 07:36, xxxxxxxx wrote:
Hello,
the standard tracks are no plugins. They are build-in elements of the timeline window and have nothing to do with the CTrackData class. Only special tracks like Sound or Doodle tracks are based on CTrackData.
If you want to edit a track with tangents etc. a default float parameter track should be sufficient.
Best wishes,
Sebastian -
On 01/07/2016 at 07:44, xxxxxxxx wrote:
Hey,
unfortunately that won't suffice. It should be a new interface. You should be able to drag&drop objects
onto the gray fields you can see in under the "Stage Cue" tracks to assign a key parameter link field and
you should be able to drag the size of the grays fields (also a parameter on the key).There is no way to make this possible? May I ask, what is the GuiMessage() method for then? I can't
see any other application other than to process input events.Thanks,
Niklas -
On 05/07/2016 at 01:59, xxxxxxxx wrote:
Hi Niklas,
we are terribly sorry, but it is the way Sebastian said.
The GuiMessage() is used internally in a special way and it was probably not a good idea (and not completely thought through) to expose it. Sorry! -
On 05/07/2016 at 08:00, xxxxxxxx wrote:
Well, that's utterly unfortunate. My client is very said that I can not make the drag thing work.
Anyway, thanks for confirming. And for bearing with my impatience. :')Cheers,
Niklas