From c1d7287a18a4678a42d600c2714a2d73b5217fb1 Mon Sep 17 00:00:00 2001 From: kavikhalique Date: Tue, 20 Aug 2024 18:07:31 +0530 Subject: [PATCH] Track editing fix Signed-off-by: kavikhalique --- .../main/cpp/app/organicmaps/Framework.cpp | 5 ++ .../main/cpp/app/organicmaps/Framework.hpp | 1 + .../bookmarks/data/BookmarkManager.cpp | 22 ++++-- .../bookmarks/BookmarkListAdapter.java | 13 +++- .../bookmarks/BookmarksListFragment.java | 38 +++++++++++ .../app/organicmaps/bookmarks/Holders.java | 13 ++++ .../bookmarks/data/BookmarkManager.java | 10 ++- .../app/organicmaps/bookmarks/data/Icon.java | 10 +++ .../bookmarks/data/IconClickListener.java | 8 +++ .../BookmarkColorDialogFragment.java | 4 +- .../placepage/EditBookmarkFragment.java | 67 +++++++++---------- .../app/src/main/res/layout/item_track.xml | 14 ++++ android/app/src/main/res/values/strings.xml | 2 + map/bookmark_manager.cpp | 18 +++-- map/bookmark_manager.hpp | 6 +- map/track.cpp | 6 ++ map/track.hpp | 1 + 17 files changed, 183 insertions(+), 55 deletions(-) create mode 100644 android/app/src/main/java/app/organicmaps/bookmarks/data/IconClickListener.java diff --git a/android/app/src/main/cpp/app/organicmaps/Framework.cpp b/android/app/src/main/cpp/app/organicmaps/Framework.cpp index 3180a2e208..0154d6f923 100644 --- a/android/app/src/main/cpp/app/organicmaps/Framework.cpp +++ b/android/app/src/main/cpp/app/organicmaps/Framework.cpp @@ -588,6 +588,11 @@ void Framework::ReplaceTrack(kml::TrackId trackId, kml::TrackData & trackData) m_work.GetBookmarkManager().GetEditSession().UpdateTrack(trackId, trackData); } +void Framework::ChangeTrackColor(kml::TrackId trackId, uint32_t color) +{ + m_work.GetBookmarkManager().GetEditSession().ChangeTrackColor(trackId, color); +} + void Framework::MoveBookmark(kml::MarkId markId, kml::MarkGroupId curCat, kml::MarkGroupId newCat) { m_work.GetBookmarkManager().GetEditSession().MoveBookmark(markId, curCat, newCat); diff --git a/android/app/src/main/cpp/app/organicmaps/Framework.hpp b/android/app/src/main/cpp/app/organicmaps/Framework.hpp index 4da7be85e3..36096efb25 100644 --- a/android/app/src/main/cpp/app/organicmaps/Framework.hpp +++ b/android/app/src/main/cpp/app/organicmaps/Framework.hpp @@ -158,6 +158,7 @@ namespace android void Scale(::Framework::EScaleMode mode); void Scale(m2::PointD const & centerPt, int targetZoom, bool animate); + void ChangeTrackColor(kml::TrackId trackId, uint32_t color); void ReplaceBookmark(kml::MarkId markId, kml::BookmarkData & bm); void ReplaceTrack(kml::TrackId trackId, kml::TrackData & trackData); void MoveBookmark(kml::MarkId markId, kml::MarkGroupId curCat, kml::MarkGroupId newCat); diff --git a/android/app/src/main/cpp/app/organicmaps/bookmarks/data/BookmarkManager.cpp b/android/app/src/main/cpp/app/organicmaps/bookmarks/data/BookmarkManager.cpp index 908cc08c64..167bc7f247 100644 --- a/android/app/src/main/cpp/app/organicmaps/bookmarks/data/BookmarkManager.cpp +++ b/android/app/src/main/cpp/app/organicmaps/bookmarks/data/BookmarkManager.cpp @@ -790,21 +790,23 @@ Java_app_organicmaps_bookmarks_data_BookmarkManager_nativeSetBookmarkParams( g_framework->ReplaceBookmark(static_cast(bmk), bmData); } +constexpr static uint8_t ExtractByte(uint32_t number, uint8_t byteIdx) { return (number >> (8 * byteIdx)) & 0xFF; } + JNIEXPORT void JNICALL Java_app_organicmaps_bookmarks_data_BookmarkManager_nativeSetTrackParams( JNIEnv * env, jclass, jlong trackId, jstring name, jint color, jstring descr) { auto const * nTrack = frm()->GetBookmarkManager().GetTrack(static_cast(trackId)); - ASSERT(nTrack, ("Track must not be null with id:", trackId)); + CHECK(nTrack, ("Track must not be null with id:", trackId)); kml::TrackData trackData(nTrack->GetData()); auto const trkName = jni::ToNativeString(env, name); - if (nTrack->GetName() != trkName) - kml::SetDefaultStr(trackData.m_name, trkName); - if (descr) - kml::SetDefaultStr(trackData.m_description, jni::ToNativeString(env, descr)); - trackData.m_layers[0].m_color.m_rgba = static_cast((color << 8) + 255); + kml::SetDefaultStr(trackData.m_name, trkName); + kml::SetDefaultStr(trackData.m_description, jni::ToNativeString(env, descr)); + + uint8_t alpha = ExtractByte(color, 3); + trackData.m_layers[0].m_color.m_rgba = static_cast(shift(color,8) + alpha); g_framework->ReplaceTrack(static_cast(trackId), trackData); } @@ -832,6 +834,14 @@ Java_app_organicmaps_bookmarks_data_BookmarkManager_nativeChangeTrackCategory( static_cast(newCat)); } +JNIEXPORT void JNICALL +Java_app_organicmaps_bookmarks_data_BookmarkManager_nativeChangeTrackColor( + JNIEnv *, jclass, jlong trackId, jint color) +{ + uint8_t alpha = ExtractByte(color, 3); + g_framework->ChangeTrackColor(static_cast(trackId), static_cast(shift(color,8) + alpha)); +} + JNIEXPORT jobject JNICALL Java_app_organicmaps_bookmarks_data_BookmarkManager_nativeGetBookmarkXY( JNIEnv * env, jclass, jlong bmk) diff --git a/android/app/src/main/java/app/organicmaps/bookmarks/BookmarkListAdapter.java b/android/app/src/main/java/app/organicmaps/bookmarks/BookmarkListAdapter.java index 0ae957371d..7d85f6cf85 100644 --- a/android/app/src/main/java/app/organicmaps/bookmarks/BookmarkListAdapter.java +++ b/android/app/src/main/java/app/organicmaps/bookmarks/BookmarkListAdapter.java @@ -14,6 +14,7 @@ import app.organicmaps.R; import app.organicmaps.bookmarks.data.BookmarkCategory; import app.organicmaps.bookmarks.data.BookmarkInfo; import app.organicmaps.bookmarks.data.BookmarkManager; +import app.organicmaps.bookmarks.data.IconClickListener; import app.organicmaps.bookmarks.data.SortedBlock; import app.organicmaps.content.DataSource; import app.organicmaps.widget.recycler.RecyclerClickListener; @@ -47,6 +48,8 @@ public class BookmarkListAdapter extends RecyclerView.Adapter onItemClick(position)); adapter.setOnLongClickListener((v, position) -> onItemMore(position)); adapter.setMoreListener((v, position) -> onItemMore(position)); + adapter.setIconClickListener(this::showColorDialog); } private void configureFab(@NonNull View view) @@ -579,6 +587,36 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment { + int from = mTrack.getColor(); + int to = BookmarkManager.ICONS.get(colorPos).argb(); + if (from == to) + return; + BookmarkManager.INSTANCE.changeTrackColor(mTrack.getTrackId(), to); + Drawable circle = Graphics.drawCircle(to, + R.dimen.track_circle_size, + requireContext().getResources()); + v.setImageDrawable(circle); + }); + + dialogFragment.show(requireActivity().getSupportFragmentManager(), null); + } + public void onItemMore(int position) { BookmarkListAdapter adapter = getBookmarkListAdapter(); diff --git a/android/app/src/main/java/app/organicmaps/bookmarks/Holders.java b/android/app/src/main/java/app/organicmaps/bookmarks/Holders.java index 602f291e63..a5c0495189 100644 --- a/android/app/src/main/java/app/organicmaps/bookmarks/Holders.java +++ b/android/app/src/main/java/app/organicmaps/bookmarks/Holders.java @@ -20,6 +20,7 @@ import app.organicmaps.adapter.OnItemClickListener; import app.organicmaps.bookmarks.data.BookmarkCategory; import app.organicmaps.bookmarks.data.BookmarkInfo; import app.organicmaps.bookmarks.data.BookmarkManager; +import app.organicmaps.bookmarks.data.IconClickListener; import app.organicmaps.bookmarks.data.Track; import app.organicmaps.location.LocationHelper; import app.organicmaps.util.Utils; @@ -388,6 +389,7 @@ public class Holders private final TextView mName; @NonNull private final TextView mDistance; + private final ImageView mMoreButton; TrackViewHolder(@NonNull View itemView) { @@ -395,6 +397,7 @@ public class Holders mIcon = itemView.findViewById(R.id.iv__bookmark_color); mName = itemView.findViewById(R.id.tv__bookmark_name); mDistance = itemView.findViewById(R.id.tv__bookmark_distance); + mMoreButton = itemView.findViewById(R.id.more); } @Override @@ -413,6 +416,16 @@ public class Holders mIcon.getContext().getResources()); mIcon.setImageDrawable(circle); } + + public void setMoreButtonClickListener(RecyclerClickListener listener) + { + mMoreButton.setOnClickListener(v -> listener.onItemClick(v, getBindingAdapterPosition())); + } + + public void setTrackIconClickListener(IconClickListener listener) + { + mIcon.setOnClickListener(v -> listener.onItemClick((ImageView) v, getBindingAdapterPosition())); + } } public static class SectionViewHolder extends BaseBookmarkHolder diff --git a/android/app/src/main/java/app/organicmaps/bookmarks/data/BookmarkManager.java b/android/app/src/main/java/app/organicmaps/bookmarks/data/BookmarkManager.java index dc82737f49..0664f13306 100644 --- a/android/app/src/main/java/app/organicmaps/bookmarks/data/BookmarkManager.java +++ b/android/app/src/main/java/app/organicmaps/bookmarks/data/BookmarkManager.java @@ -631,11 +631,16 @@ public enum BookmarkManager } public void setTrackParams(@IntRange(from = 0) long trackId, @NonNull String name, - @Icon.PredefinedColor int color, @NonNull String descr) + int color, @NonNull String descr) { nativeSetTrackParams(trackId, name, color, descr); } + public void changeTrackColor(@IntRange(from = 0) long trackId, int color) + { + nativeChangeTrackColor(trackId, color); + } + public void changeBookmarkCategory(@IntRange(from = 0) long oldCatId, @IntRange(from = 0) long newCatId, @IntRange(from = 0) long bookmarkId) @@ -867,6 +872,9 @@ public enum BookmarkManager @Icon.PredefinedColor int color, @NonNull String descr); + private static native void nativeChangeTrackColor(@IntRange(from = 0) long trackId, + @Icon.PredefinedColor int color); + private static native void nativeSetTrackParams(@IntRange(from = 0) long trackId, @NonNull String name, @Icon.PredefinedColor int color, diff --git a/android/app/src/main/java/app/organicmaps/bookmarks/data/Icon.java b/android/app/src/main/java/app/organicmaps/bookmarks/data/Icon.java index 2a6b01d7e0..b842636754 100644 --- a/android/app/src/main/java/app/organicmaps/bookmarks/data/Icon.java +++ b/android/app/src/main/java/app/organicmaps/bookmarks/data/Icon.java @@ -219,6 +219,16 @@ public class Icon implements Parcelable return ARGB_COLORS[mColor]; } + public static int getColorPosition(int color) + { + for (int index = 1; index < ARGB_COLORS.length; index++) + { + if (ARGB_COLORS[index] == color) + return index; + } + return -1; + } + @BookmarkIconType public int getType() { diff --git a/android/app/src/main/java/app/organicmaps/bookmarks/data/IconClickListener.java b/android/app/src/main/java/app/organicmaps/bookmarks/data/IconClickListener.java new file mode 100644 index 0000000000..b1ebbe44f3 --- /dev/null +++ b/android/app/src/main/java/app/organicmaps/bookmarks/data/IconClickListener.java @@ -0,0 +1,8 @@ +package app.organicmaps.bookmarks.data; + +import android.widget.ImageView; + +public interface IconClickListener +{ + void onItemClick(ImageView v, int position); +} diff --git a/android/app/src/main/java/app/organicmaps/widget/placepage/BookmarkColorDialogFragment.java b/android/app/src/main/java/app/organicmaps/widget/placepage/BookmarkColorDialogFragment.java index ade983c797..f9e1c0028e 100644 --- a/android/app/src/main/java/app/organicmaps/widget/placepage/BookmarkColorDialogFragment.java +++ b/android/app/src/main/java/app/organicmaps/widget/placepage/BookmarkColorDialogFragment.java @@ -24,7 +24,7 @@ public class BookmarkColorDialogFragment extends BaseMwmDialogFragment private int mIconColor; - interface OnBookmarkColorChangeListener + public interface OnBookmarkColorChangeListener { void onBookmarkColorSet(int colorPos); } @@ -42,7 +42,7 @@ public class BookmarkColorDialogFragment extends BaseMwmDialogFragment return new MaterialAlertDialogBuilder(requireActivity(), R.style.MwmTheme_AlertDialog) .setView(buildView()) - .setTitle(R.string.bookmark_color) + .setTitle(R.string.choose_color) .setNegativeButton(R.string.cancel, null) .create(); } diff --git a/android/app/src/main/java/app/organicmaps/widget/placepage/EditBookmarkFragment.java b/android/app/src/main/java/app/organicmaps/widget/placepage/EditBookmarkFragment.java index 76243603c4..44bea078cb 100644 --- a/android/app/src/main/java/app/organicmaps/widget/placepage/EditBookmarkFragment.java +++ b/android/app/src/main/java/app/organicmaps/widget/placepage/EditBookmarkFragment.java @@ -41,9 +41,10 @@ import java.util.List; public class EditBookmarkFragment extends BaseMwmDialogFragment implements View.OnClickListener, Listener { public static final String EXTRA_CATEGORY_ID = "CategoryId"; - public static final String EXTRA_BOOKMARK_ID = "BookmarkId"; + public static final String EXTRA_ID = "BookmarkTrackId"; public static final String EXTRA_BOOKMARK_TYPE = "BookmarkType"; - public static final String EXTRA_TRACK_ID = "TrackId"; + public static final int TYPE_BOOKMARK = 1; + public static final int TYPE_TRACK = 2; private TextInputEditText mEtDescription; private TextInputEditText mEtName; @@ -72,9 +73,9 @@ public class EditBookmarkFragment extends BaseMwmDialogFragment implements View. @Nullable EditBookmarkListener listener) { final Bundle args = new Bundle(); - args.putInt(EXTRA_BOOKMARK_TYPE, 1); + args.putInt(EXTRA_BOOKMARK_TYPE, TYPE_BOOKMARK); args.putLong(EXTRA_CATEGORY_ID, categoryId); - args.putLong(EXTRA_BOOKMARK_ID, bookmarkId); + args.putLong(EXTRA_ID, bookmarkId); String name = EditBookmarkFragment.class.getName(); final FragmentFactory factory = manager.getFragmentFactory(); final EditBookmarkFragment fragment = (EditBookmarkFragment) factory.instantiate(context.getClassLoader(), name); @@ -86,9 +87,9 @@ public class EditBookmarkFragment extends BaseMwmDialogFragment implements View. public static void editTrack(long categoryId, long trackId, Context context, FragmentManager manager, @Nullable EditBookmarkListener listener) { final Bundle args = new Bundle(); - args.putInt(EXTRA_BOOKMARK_TYPE, 2); + args.putInt(EXTRA_BOOKMARK_TYPE, TYPE_TRACK); args.putLong(EXTRA_CATEGORY_ID, categoryId); - args.putLong(EXTRA_TRACK_ID, trackId); + args.putLong(EXTRA_ID, trackId); String name = EditBookmarkFragment.class.getName(); final FragmentFactory factory = manager.getFragmentFactory(); final EditBookmarkFragment fragment = (EditBookmarkFragment) factory.instantiate(context.getClassLoader(), name); @@ -140,34 +141,28 @@ public class EditBookmarkFragment extends BaseMwmDialogFragment implements View. mIvColor = view.findViewById(R.id.iv__bookmark_color); mIvColor.setOnClickListener(this); + //For tracks an bookmarks same category is used so this portion is common for both + long categoryId = args.getLong(EXTRA_CATEGORY_ID); + mBookmarkCategory = BookmarkManager.INSTANCE.getCategoryById(categoryId); + long id = args.getLong(EXTRA_ID); + switch (mType) { - case 1: + case TYPE_BOOKMARK -> { - long categoryId = args.getLong(EXTRA_CATEGORY_ID); - mBookmarkCategory = BookmarkManager.INSTANCE.getCategoryById(categoryId); - long bookmarkId = args.getLong(EXTRA_BOOKMARK_ID); - mBookmark = BookmarkManager.INSTANCE.getBookmarkInfo(bookmarkId); + mBookmark = BookmarkManager.INSTANCE.getBookmarkInfo(id); if (mBookmark != null) mIcon = mBookmark.getIcon(); refreshBookmark(); - initToolbar(view); - break; } - case 2: + case TYPE_TRACK -> { - long categoryId = args.getLong(EXTRA_CATEGORY_ID); - mBookmarkCategory = BookmarkManager.INSTANCE.getCategoryById(categoryId); - long trackId = args.getLong(EXTRA_TRACK_ID); - mTrack = BookmarkManager.INSTANCE.getTrack(trackId); + mTrack = BookmarkManager.INSTANCE.getTrack(id); mColor = mTrack.getColor(); refreshTrack(); - initToolbar(view); - break; } } - - + initToolbar(view); } @Override @@ -195,13 +190,18 @@ public class EditBookmarkFragment extends BaseMwmDialogFragment implements View. final ImageView imageView = toolbar.findViewById(R.id.save); switch (mType) { - case 1: + case TYPE_BOOKMARK -> + { imageView.setOnClickListener(v -> saveBookmark()); - case 2: + toolbar.setTitle(R.string.placepage_edit_bookmark_button); + } + case TYPE_TRACK -> + { imageView.setOnClickListener(v -> saveTrack()); + toolbar.setTitle(R.string.edit_track); + } } UiUtils.showHomeUpButton(toolbar); - toolbar.setTitle(R.string.placepage_edit_bookmark_button); toolbar.setNavigationOnClickListener(v -> dismiss()); } @@ -233,10 +233,8 @@ public class EditBookmarkFragment extends BaseMwmDialogFragment implements View. boolean movedFromCategory = mTrack.getCategoryId() != mBookmarkCategory.getId(); if (movedFromCategory) BookmarkManager.INSTANCE.notifyCategoryChanging(mTrack, mBookmarkCategory.getId()); - BookmarkManager.INSTANCE.notifyParametersUpdating(mTrack, mEtName.getText() - .toString(), mColor, mEtDescription.getText() - .toString()); - + BookmarkManager.INSTANCE.notifyParametersUpdating(mTrack, mEtName.getText().toString(), + mColor, mEtDescription.getText().toString()); if (mListener != null) mListener.onBookmarkSaved(mTrack.getTrackId(), movedFromCategory); dismiss(); @@ -289,11 +287,10 @@ public class EditBookmarkFragment extends BaseMwmDialogFragment implements View. dialogFragment.setArguments(args); switch (mType) { - case 1: - { + case TYPE_BOOKMARK -> dialogFragment.setOnColorSetListener(colorPos -> { final Icon newIcon = BookmarkManager.ICONS.get(colorPos); - final String from = mTrack.getName(); + final String from = mIcon.getName(); final String to = newIcon.getName(); if (TextUtils.equals(from, to)) return; @@ -301,9 +298,7 @@ public class EditBookmarkFragment extends BaseMwmDialogFragment implements View. mIcon = newIcon; refreshColorMarker(); }); - } - case 2: - { + case TYPE_TRACK -> dialogFragment.setOnColorSetListener(colorPos -> { int from = mTrack.getColor(); int to = BookmarkManager.ICONS.get(colorPos).argb(); @@ -312,8 +307,6 @@ public class EditBookmarkFragment extends BaseMwmDialogFragment implements View. mColor = to; refreshTrackColor(); }); - break; - } } dialogFragment.show(requireActivity().getSupportFragmentManager(), null); diff --git a/android/app/src/main/res/layout/item_track.xml b/android/app/src/main/res/layout/item_track.xml index 0e6bfee4e6..5c1a88b069 100644 --- a/android/app/src/main/res/layout/item_track.xml +++ b/android/app/src/main/res/layout/item_track.xml @@ -2,6 +2,7 @@ @@ -9,13 +10,16 @@ android:id="@+id/iv__bookmark_color" android:layout_width="wrap_content" android:layout_height="wrap_content" + style="@style/MwmWidget.Editor.MetadataBlock.Clickable" android:layout_alignParentStart="true" android:layout_centerVertical="true" + android:paddingHorizontal="8dp" android:layout_marginStart="@dimen/margin_base" android:layout_marginEnd="@dimen/margin_base" /> + diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index 786256a1c0..6633f074af 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -2262,4 +2262,6 @@ Dojo Sports hall + Choose Color + Edit Track diff --git a/map/bookmark_manager.cpp b/map/bookmark_manager.cpp index 15f0ce0e54..c59b2c999e 100644 --- a/map/bookmark_manager.cpp +++ b/map/bookmark_manager.cpp @@ -2316,17 +2316,18 @@ void BookmarkManager::UpdateBookmark(kml::MarkId bmID, kml::BookmarkData const & SetLastEditedBmColor(bookmark->GetColor()); } +void BookmarkManager::ChangeTrackColor(kml::TrackId trackId, uint32_t color) +{ + CHECK_THREAD_CHECKER(m_threadChecker, ()); + auto * track = GetTrackForEdit(trackId); + track->SetColor(color); +} + void BookmarkManager::UpdateTrack(kml::TrackId trackId, kml::TrackData const & trackData) { CHECK_THREAD_CHECKER(m_threadChecker, ()); auto * track = GetTrackForEdit(trackId); - -// auto const prevColor = track->GetColor(0); track->setData(trackData); - ASSERT(track->GetGroupId() != kml::kInvalidTrackId, ()); - -// if (prevColor != track->GetColor()) -// SetLastEditedBmColor(track->GetColor()); } kml::MarkGroupId BookmarkManager::LastEditedBMCategory() @@ -3654,6 +3655,11 @@ void BookmarkManager::EditSession::UpdateTrack(kml::TrackId trackId, kml::TrackD return m_bmManager.UpdateTrack(trackId,trackData); } +void BookmarkManager::EditSession::ChangeTrackColor(kml::TrackId trackId, uint32_t color) +{ + m_bmManager.ChangeTrackColor(trackId, color); +} + void BookmarkManager::EditSession::AttachBookmark(kml::MarkId bmId, kml::MarkGroupId groupId) { m_bmManager.AttachBookmark(bmId, groupId); diff --git a/map/bookmark_manager.hpp b/map/bookmark_manager.hpp index e3f219b726..ea2637693d 100644 --- a/map/bookmark_manager.hpp +++ b/map/bookmark_manager.hpp @@ -145,7 +145,6 @@ public: void MoveBookmark(kml::MarkId bmID, kml::MarkGroupId curGroupID, kml::MarkGroupId newGroupID); void UpdateBookmark(kml::MarkId bmId, kml::BookmarkData const & bm); - void UpdateTrack(kml::TrackId trackId, kml::TrackData const & trackData); void AttachBookmark(kml::MarkId bmId, kml::MarkGroupId groupId); void DetachBookmark(kml::MarkId bmId, kml::MarkGroupId groupId); @@ -155,6 +154,8 @@ public: void MoveTrack(kml::TrackId trackID, kml::MarkGroupId curGroupID, kml::MarkGroupId newGroupID); void AttachTrack(kml::TrackId trackId, kml::MarkGroupId groupId); void DetachTrack(kml::TrackId trackId, kml::MarkGroupId groupId); + void ChangeTrackColor(kml::TrackId trackId, uint32_t color); + void UpdateTrack(kml::TrackId trackId, kml::TrackData const & trackData); void SetCategoryName(kml::MarkGroupId categoryId, std::string const & name); void SetCategoryDescription(kml::MarkGroupId categoryId, std::string const & desc); @@ -586,6 +587,8 @@ private: void DetachTrack(kml::TrackId trackId, kml::MarkGroupId groupId); void DeleteTrack(kml::TrackId trackId); void MoveTrack(kml::TrackId trackID, kml::MarkGroupId curGroupID, kml::MarkGroupId newGroupID); + void ChangeTrackColor(kml::TrackId trackId, uint32_t color); + void UpdateTrack(kml::TrackId trackId, kml::TrackData const & trackData); void ClearGroup(kml::MarkGroupId groupId); void SetIsVisible(kml::MarkGroupId groupId, bool visible); @@ -600,7 +603,6 @@ private: void MoveBookmark(kml::MarkId bmID, kml::MarkGroupId curGroupID, kml::MarkGroupId newGroupID); void UpdateBookmark(kml::MarkId bmId, kml::BookmarkData const & bm); - void UpdateTrack(kml::TrackId trackId, kml::TrackData const & trackData); UserMark const * GetMark(kml::MarkId markId) const; diff --git a/map/track.cpp b/map/track.cpp index b44153c1d4..881f4360af 100644 --- a/map/track.cpp +++ b/map/track.cpp @@ -237,6 +237,12 @@ void Track::SetColor(dp::Color color) m_data.m_layers[0].m_color.m_rgba = color.GetRGBA(); } +void Track::SetColor(uint32_t color) +{ + m_isDirty = true; + m_data.m_layers[0].m_color.m_rgba = color; +} + float Track::GetWidth(size_t layerIndex) const { CHECK_LESS(layerIndex, m_data.m_layers.size(), ()); diff --git a/map/track.hpp b/map/track.hpp index 32b9c43c9e..865bf2921c 100644 --- a/map/track.hpp +++ b/map/track.hpp @@ -55,6 +55,7 @@ public: size_t GetLayerCount() const override; dp::Color GetColor(size_t layerIndex) const override; void SetColor(dp::Color color); + void SetColor(uint32_t color); float GetWidth(size_t layerIndex) const override; float GetDepth(size_t layerIndex) const override; void ForEachGeometry(GeometryFnT && fn) const override;