Draw goal meters over bitmap background (Vivoactive 3m)

Former Member
Former Member

Is there a specific function which brings items to the front? I picked up the source code for a face from Github but when I've added my background the goal meters and date seem to be hidden, maybe "under" the background? Can they be pushed to the front?

For reference, I have my background in the Layout.xml file rather than loading and unloading it each time I look at the watch, could that also have something to do with it?

  • If you are using a layout along with direct dc calls to display things, make sure you do the view.onUpdate() before the dc calls.

    With a layout, you want to load it in onLayout() and not each time onUpdate() is called.  Each time you load it you are hitting the file system.

    if your layout is just used for the bitmap, you may what to just use dc.drawBitmap vs a layout.

  • Former Member
    Former Member over 5 years ago in reply to jim_m_58

    Thanks for getting back to me! The meters are called from the view.mc file as follows:

    View.onUpdate(dc);
    
    function updateGoalMeters()

    Similarly, towards the beginning the layout is loaded in onLayout:

    function onLayout(dc) {
    	setLayout(Rez.Layouts.Watch1(dc));

    Am I being silly and missing something?

  • post your onUpdate() function.  

  • Former Member
    Former Member over 5 years ago in reply to jim_m_58

    function onUpdate(dc) {
    //Sys.println("onUpdate()");

    // If burn-in protection has changed, set layout appropriate to new burn-in protection state.
    // If turning on burn-in protection, free memory for regular watch face drawables by clearing references. This means that
    // any use of mDrawables cache must only occur when burn in protection is NOT active.
    // If turning off burn-in protection, recache regular watch face drawables.
    if (mBurnInProtectionChangedSinceLastDraw) {
    mBurnInProtectionChangedSinceLastDraw = false;
    setLayout(Rez.Layouts.WatchFace(dc));
    cacheDrawables();
    }

    // Respond now to any settings change since last full draw, as we can now update the full screen.
    if (mSettingsChangedSinceLastDraw) {
    onSettingsChangedSinceLastDraw();
    }

    // Clear any partial update clipping.
    if (dc has :clearClip) {
    dc.clearClip();
    }

    // Call the parent onUpdate function to redraw the layout
    View.onUpdate(dc);
    }

    // Update each goal meter separately, then also pass types and values to data area to draw goal icons.
    function updateGoalMeters() {

    var leftType = App.getApp().getProperty("LeftGoalType");
    var leftValues = getValuesForGoalType(leftType);
    mDrawables[:LeftGoalMeter].setValues(leftValues[:current], leftValues[:max], /* isOff */ leftType == GOAL_TYPE_OFF);

    var rightType = App.getApp().getProperty("RightGoalType");
    var rightValues = getValuesForGoalType(rightType);
    mDrawables[:RightGoalMeter].setValues(rightValues[:current], rightValues[:max], /* isOff */ rightType == GOAL_TYPE_OFF);

    mDrawables[:DataArea].setGoalValues(leftType, leftValues, rightType, rightValues);

    This is the portion that references the meters

  • Where is updateGoalMeters() called?

  • Former Member
    Former Member over 5 years ago in reply to jim_m_58

    Myt bad - it's called just before function updateGoalMeters():

    // Clear any partial update clipping.
    		if (dc has :clearClip) {
    			dc.clearClip();
    		}
    
    		updateGoalMeters();
    
    		// Call the parent onUpdate function to redraw the layout
    		View.onUpdate(dc);
    	}
    
    	// Update each goal meter separately, then also pass types and values to data area to draw goal icons.
    	function updateGoalMeters() {